[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #AQT-176214]: UNLIMITED dimension for F90/95



Hi John,

Yes, you can get the current length of the frtime dimension by first
finding out the dimension ID of the unlimited dimension (using an
NF90_INQUIRE function call), then using NF90_INQUIRE_DIMENSION to
get the length.

You should not have to allocate enough memory to read all of a
variable into memory at once.  If you dimension your program
variables large enough to hold just one time slice of data, then
you can just read one time slice (also called a "record") at a
time, using the NF90_GET_VAR function, specifying a START argument
and a COUNT argument.

There is an example that uses the unlimited dimension and reads a
record at a time in the file examples/F90/pres_temp_4D_rd.f90 in the
netCDF distribution.  You can also see it online here:

 
http://www.unidata.ucar.edu/software/netcdf/examples/programs/pres_temp_4D_rd.f90

For a 1D variable, to read the Nth record you would specify

 START = (/ N /)
 COUNT = (/ 1 /)

For a 2D variable dimensioned in the netCDF file as

  float var(frtime, gates);

if you want to read the Nth record into a Fortran-90 variable declared

  REAL VAR(GATES)

for example, use:

 START = (/ 1, N /)      ! start at the first gate of the Nth record
 COUNT = (/ GATES, 1 /)  ! get GATES values along the gates dimension,
                         ! but only 1 frtime (record) value
--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: AQT-176214
Department: Support netCDF
Priority: Normal
Status: Closed