![]() | |||
| |||
help@iri | |||
---|---|---|---|
Search |
We also have a library ODB, which is a greatly simplified interface to the netCDF library.
For example, consider a random-access file that contains a three dimensional dataset: 360 by 180 by 12. To read the data as a single chunk from a file called 'evap',
program rea parameter(NX=360,NY=180,NT=12) real evap(NX,NY,NT) open(1,file='evap',form='unformatted', * status='unknown',access='random',RECL=NX*NY*NT) read(1,REC=1)evap stop endOR (just to give you practice in reading data in pieces)
program rea parameter(NX=360,NY=180,NT=12) real evap(NX,NY,NT) open(1,file='evap',form='unformatted', * status='unknown',access='random',RECL=NX*NY) do IT=1,NT read(1,REC=IT)((evap(i,j),i=1,nx),j=1,ny) enddo stop endThe point being that, for random access files in fortran, you need to specify the record length in the open statement, and the record number in the read (or write) statement. Some machines give the RECL in words (my machine and my example), others have the RECL in bytes, in which case you would have in the second example
open(1,file='evap',form='unformatted', * status='unknown',access='random',RECL=4*NX*NY)Some machines call it access='direct', instead.
read(5,*) evapThis reads blank-delimited data, and will keep reading new lines of text until the array is filled.