Re: Allocating arrays inside a subroutine.



Tim: A couple years ago Mike Metcalf posted an example of allocating
a global array, the actual allocation being done via a subprogram.
See the code at: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/dyng.f90

Skip Knoble


On Tue, 29 Aug 2006 16:39:48 +1000, Timothy Hume <T.Hume@xxxxxxxxxx> wrote:

-|Hi,
-|
-|I'm wondering if someone could point me in the right direction with this
-|problem. I'm a new Fortran 90/95 user, but am familiar with 77.
-|
-|I want to create a Fortran 90 subroutine that reads data from a file, and
-|returns it in an array, which is one of the arguments to the subroutine.
-|Something like this:
-|
-|SUBROUTINE READ_DATA(FILENAME, DATA_ARRAY)
-|CHARACTER(LEN=128), INTENT(IN) :: FILENAME
-|REAL, DIMENSION(:), INTENT(OUT) :: DATA_ARRAY
-|.
-|.
-|.
-|END SUBROUTINE READ_DATA
-|
-|I don't know in advance how big DATA_ARRAY needs to be ... I can only tell
-|once I've opened up FILENAME and read some header records. At first I
-|thought I could do this by passing an unallocated array to the subroutine,
-|and then allocate the array inside the subroutine once the appropriate
-|header records that inform me how much data there are have been read.
-|However, I have found that you can't pass unallocated arrays to subroutines.
-|
-|I'm sure this must be a common problem?
-|
-|Any tips would be appreciated.
-|
-|Tim Hume
-|Bureau of Meteorology Research Centre
-|Melbourne
-|Australia

.



Relevant Pages

  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)
  • Re: memory leak help!
    ... a loop from the main program. ... REPLACE THE NEW COMPLEX INTO ORIGINAL ARRAY x ... END OF SUBROUTINE SCEUA ... IMPLICIT NONE ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)