This should work fine in Fortran 77. Should MATRIX be an integer
matrix however? Apart from that, this is fine so long as N and M
are passed set to 10 (in this example) by the calling routine.
Your message was unclear to me about what was failing. Perhaps if
you put a complete test program out so we could try it ourselves
it would be clearer. Good luck!
John Prentice
jo...@unmfys.unm.edu
To make it working:
> >PROGRAM MAIN
> >DIMENSION MATRIX(10,10),RMATRIX(10,10)
> >.
> >CALL TESTSUB(MATRIX,RMATRIX,N,M)
--->CALL TESTSUB(MATRIX,RMATRIX,10,N,M)
> >.
> >.
> >SUBROUTINE TESTSUB(MATRIX,RMATRIX,N,M)
--->SUBROUTINE TESTSUB(MATRIX,RMATRIX,LD,N,M)
> >DIMENSION MATRIX(N,M),RMATRIX(N,M)
--->DIMENSION MATRIX(LD,M),RMATRIX(LD,M)
And now you can use the N*M sections of MATRIX and RMATRIX. As all Fortran
old-timers know: *Always pass the leading dimension of a two-dimensional
array to a subroutine*. Array's are not first-class citizens in Fortran.
An array is a piece of storage and a mapping function from indices to
address. When passing an array in Fortran only the piece of storage is
passed, not the mapping function; the mapping function is locally constructed
in the subroutine based on information available. (Fodder for flamage: Of
the languages I have used extensively C, Fortran and Pascal do not have
array's as first class citizens for various reasons; Algol 60, Algol 68 and
Ada do.)
--
dik t. winter, cwi, amsterdam, nederland
d...@cwi.nl