Re: suggestion for new intrinsic function: CONFORM



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.
.



Relevant Pages

  • Re: linpack/zgeco, matrices
    ... there are still codes around from before F77. ... bound of the last dimension. ... There do exist compilers that will refuse to compile some cases of this ...
    (comp.lang.fortran)
  • Re: g95 wish list
    ... > time bounds checking. ... Before dimension xwas introduced into fortran, ... since it was accepted by f77 compilers as well. ...
    (comp.lang.fortran)
  • Re: Size of Largest Array?
    ... > Can anybody tell me the size of the largest array I can dimension? ... That's a typical limitation for 32-bit Fortran compilers. ...
    (comp.lang.fortran)
  • Re: REAL x(1)?
    ... compilers that didn't special case it. ... the N in the dimension statement. ... Many routines with dimension expect two dimensional array as arguments, ...
    (comp.lang.fortran)