(j3.2006) Should this work?

Bill Long longb
Fri May 9 12:05:08 EDT 2008

Van Snyder wrote:
> I tried this little program using three compilers on Linux:
> subroutine foo ( a )
>   real :: a ( :, : )
>   integer, parameter :: b = size(shape(a))
> end subroutine foo
> Two were happy, one wasn't.
> It seems the value given for B is not an initialization expression.
> So this shouldn't work, right?

If the two that were happy excluded Cray's, then you can bump the happy 
list to 3.  Size and shape are both specification inquiry functions, so 
the relevant text is list item (8) at [127:10-15] in 04-007.  The 
reference shape(a) fails (8)(b)(i) since the property inquired about 
(the shape) is assumed.   The argument to size() does not depend on any 
of the conditions in (8)(b).  However, the argument to size() is not a 
"variable", so (8)(b) does not apply, and (8)(a) fails because shape(a) 
is not an initialization expression. Thus, it seems the whole expression 
fails to be an initialization expression, if only by the narrowest of 
margins. I suspect we intended for this case to be conforming since it 
is clear what the result should be.  Possible interp candidate.

Whether the expression involved a dummy argument is not relevant. 
Certainly b = kind(a) would be acceptable, for example.


Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120


More information about the J3 mailing list