Re: Allocating arrays inside a subroutine.
- From: Herman D. Knoble <SkipKnobleLESS@xxxxxxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 07:48:43 -0400
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
.
- References:
- Allocating arrays inside a subroutine.
- From: Timothy Hume
- Allocating arrays inside a subroutine.
- Prev by Date: Re: Is there any good nemerical methods to do Indefinite Integrals with fortran?
- Next by Date: Re: How to USE modules in a different directory?
- Previous by thread: Re: Allocating arrays inside a subroutine.
- Next by thread: Re: Allocating arrays inside a subroutine.
- Index(es):
Relevant Pages
|