Re: suggestion for new intrinsic function: CONFORM
- From: Dan Nagle <dannagle@xxxxxxxxxxx>
- Date: Tue, 27 Feb 2007 22:39:07 GMT
Hello,
Beliavsky wrote:
On Feb 27, 4:33 pm, "Beliavsky" <beliav...@xxxxxxx> wrote:When passing assumed shape arrays to procedures, typically the first
thing I do is check that the dimension are what I expect, in
particular that certain pairs of arguments conform, for example
subroutine foo(imat,y,z)
integer, intent(in) :: imat(:,:) ! (n1,n2)
real, intent(in) :: x(:,:) ! (n1,n2)
real, intent(out) :: z(:,:) ! (n1,n2)
if (size(imat,1) /= size(x,1) .or. size(imat,2) /= size(x,2) .or.
size(x,1) /= size(z,1) .or. size(x,2) /= size(z,2)) then
It occurs to me using the SHAPE function to check that arrays conform
is shorter, especially for high-rank arrays. So the question is
whether providing
conform(x,y)
as a shorter alternative to
all(shape(x) == shape(y))
is woth providing.
I agree. A proposal to have a BOUND( array) declaration
in place of the dimension attribute was defeated
during the feature selection process for f08. It lost
on the grounds that it was too much- compilers can always check
for themselves, and it was too little- what if an more or fewer
dimension are needed on the second array?
Personally, I think these are very weak reasons, but the above is
the view that prevailed.
Also, some argue, very wrongly IMNSHO, that these sorts of features
don't add much to the language. I think that's ignoring the conveyance
of programmer's intentions, and the extra error checking that
may be done during compilation. Maybe that's just me. :-(
--
Cheers!
Dan Nagle
Purple Sage Computing Solutions, Inc.
.
- References:
- suggestion for new intrinsic function: CONFORM
- From: Beliavsky
- Re: suggestion for new intrinsic function: CONFORM
- From: Beliavsky
- suggestion for new intrinsic function: CONFORM
- Prev by Date: Re: suggestion for new intrinsic function: CONFORM
- Next by Date: Matlab -> Fortran
- Previous by thread: Re: suggestion for new intrinsic function: CONFORM
- Next by thread: Re: suggestion for new intrinsic function: CONFORM
- Index(es):
Relevant Pages
|