Re: suggestion for new intrinsic function: CONFORM
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Tue, 27 Feb 2007 23:05:45 GMT
Beliavsky wrote:
On Feb 27, 4:33 pm, "Beliavsky" <beliav...@xxxxxxx> wrote:Alternatively, you could write a module function that has 2 or 3When 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.
required arguments and a ton of optional arguments. The three
argument form could have an error message. Something like
call Do_what_I_want("message", shape(imat), shape(x), shape(z))
Have it print out a nice error message if the sizes aren't correct.
With optional shape-like arguments the routine can compare a (ton + 2)
arrays for conformance in one call. You can fool around and make the
error message also optional, add a status return, allow different
ranks (and just require that the first dimensions match or maybe the
last, whichever is appropriate) or whatever. You should be able to
kill a few days adding alternatives!
*** Hendrickson
.
- 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: Matlab -> Fortran
- Next by Date: Re: Matlab -> Fortran
- Previous by thread: Re: suggestion for new intrinsic function: CONFORM
- Next by thread: Re: suggestion for new intrinsic function: CONFORM
- Index(es):