[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #MLP-485355]: How to read a NetCDF data set with Fortran 77...
- Subject: [netCDF #MLP-485355]: How to read a NetCDF data set with Fortran 77...
- Date: Mon, 08 Jan 2007 13:48:40 -0700
Hi Miguel,
If you look at the Fortran-77 netCDF documentation:
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77.html
you can find a description of the arguments for the nf_get_vara_real function
in the "Variables" chapter:
INTEGER FUNCTION NF_GET_VARA_REAL(INTEGER NCID, INTEGER VARID,
INTEGER START(*), INTEGER COUNT(*),
REAL rvals(*))
It says that the START vector tells what index of the variable in the file is
where to start accessing data. The COUNT vector tells how far along each axis
of the variable to access data. So START and COUNT together define a sub-array
(or "slice") of the whole variable on disk. In particular, both START and
COUNT must have as many vlaues as the variable's rank, in this case 4. You
haven't provided any value for start(4), so it's probably zero, since it has
not been initialized. Therefor, you are asking to start access at the (1, 1,
1, 0) element of the variable, hence the error message. If you set start(4)=1,
your program may get farther.
If you really want to read all the values of the variable vosaline with one
read, you could use the simpler call
retval = nf_get_var_real(ncid, sal_varid, sal_in)
using the documented
INTEGER FUNCTION NF_GET_VAR_REAL(INTEGER NCID, INTEGER VARID,
REAL rvals(*))
which has no START or COUNT arguments, but just gets all the values. The only
reason to use the START and COUNT arguments in the more complicated
nf_get_vara_real() function is if you need to read in only part of the array on
disk, perhaps because it won't all fit into memory, or because you only want to
process one slice at a time.
--Russ
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77.html#NF_005fGET_005fVARA_005f-type
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: MLP-485355
Department: Support netCDF
Priority: Normal
Status: Closed