Andrew,
I am not sure about your "in a module" statement. I believe that the module
would require some sort of MAXSIZE parameter.
>Is it possible to pass an allocatable array from a main program to a
>subroutine in a module? The array has been allocated in the main program.
>I have done this before with 'non-allocatable' arrays, but not with
>allocated arrays. I have also acheived this with allocatable vectors using
>the * symbol, but the two dimensional version of this method requires
>declaration of the first dimension.
If you have ALLOCATABLE X(:,:) and you allocate as X(:N,:N), pass N as the
argument of the first size
CALL WORK(A,N)
SUBROUTINE WORK(A,N)
REAL A(N,:)
should work correctly. It seems to for me (Compaq Fortran on various
platforms), but perhaps RM will tell me that it is not portable :-((((.
I have re-written several programs/applications to be automatically dynamic.
I read sizing values and then ALLOCATE in the main routine, but use automatic
sizing in lower level routines for local arrays. This does mean passing the
allocated arrays (and dimensions if they are more than 1-D) as arguments.
I hope I have understood your question.
Regards, Paddy
Paddy O'Brien,
Transmission Development,
TransGrid,
PO Box A1000, Sydney South,
NSW 2000, Australia
Tel: +61 2 9284-3063
Fax: +61 2 9284-3050
Email: [log in to unmask]
Either "\'" or "\s" (to escape the apostrophe) seems to work for most people,
but that little whizz-bang apostrophe gives me little spam.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|