This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: Pavel Ivanov <address@hidden> >Subject: NetCDF question >Organization: ACD >Keywords: 199707041126.FAA02754 Hi Pavel, > I have two questions about netCDF format. If netCDF file contain more > than one record variable how can I know length of each variable if from > header I read only number of records of all variables. All record variables have the same number of records, because when a netCDF file is extended by writing one or more additional records, all record variables are extended using "fill values", if necessary. There is only one record dimension per netCDF file, so its value is shared by all record variables. > And one more question about variable shape. Each variable have only one > dimention index. And if variable have more than two dimentions how can I > know witch dimention shall i use for this variable? If variable is two > dimension I can calculate second dimention lendth using variable size > and if dimensions number greater than 2 it is a problem. > > P.S I write my own direct data acsess to netCDF not using any c/c++ or > fortran librarys. No, I think you have misunderstood the format. Each variable has a single rank, which specifies the number of dimensions. This is followed by a list of that many dimension IDs, each identifying a dimension. For example, consider a simple netCDF file with a three dimensional variable and two one-dimensional variables: netcdf example { dimensions: lat = 5; lon = 10; time = unlimited; variables: float rh(time, lat, lon); float lat(lat); float lon(lon); } The variable section of the file contains rh a string naming the variable 3 the rank of rh, because it has 3 dimensions 2 ID of first dimension, "time" 0 ID of second dimension, "lat" 1 ID of third dimension, "lon" and similarly for the variables lat and lon: lat 1 the rank of the lat variable 0 the ID of its first (and only) dimension, "lat" lon 1 the rank of the lon variable 1 the ID of its first (and only) dimension, "lon" For more details, see appendix B of the netCDF User's Guide at http://www.unidata.ucar.edu/staff/russ/netcdf/guidec/guidec-18.html --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu