multidimensional arrays

D Gary Grady dgary at ecsvax.UUCP
Tue Jan 8 03:58:43 AEST 1985


<>
A couple of posters (and a few correspondents) have questioned whether
FORTRAN permits variably-dimensioned array parameters.  That is, does
this always work in FORTRAN:

SUBROUTINE FOO(ARRAY, R, C)
DIMENSION ARRAY(R, C)

The answer is yes, it works in all correct FORTRAN compilers.  It is a
standard feature of the language.  It is true that the UCSD p-System
FORTRAN doesn't allow that, even though its documentation used to say
otherwise.  This is because the UCSD p-System FORTRAN compiler stinks.
What can I say?

BTW, this also works in virtually all FORTRANs with array bounds
checking turned off:

SUBROUTINE FOO(ARRAY, R)
DIMENSION ARRAY(R, 1)

Because FORTRAN stores column-major and hence does not need to know the
last dimension to perform a subscript calculation.  Many, many FORTRAN
programs do this, even though its "legality" is open to question.

Best,

-- 

D Gary Grady
Duke University Computation Center, Durham, NC  27706
(919) 684-4146
USENET:  {decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary



More information about the Comp.lang.c mailing list