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: "Larisa Kalacheva" <address@hidden> >Subject: NetCDF Question. Please help me >Organization: . >Keywords: 199706181611.KAA25412 Hi Larisa, > I need to write program for direct access to data stored in netCDF format, > not using any standard Library for netCDF. This may not be wise. In the future, if the format for netCDF data changes, programs that use the library interfaces will continue to work, but programs that depend on details of the format will break. There is no speed advantage to avoiding the library interfaces, since they have been carefully optimized. If you want to provide your own implementation of netCDF (for example, in another computer language than C), it is an ambitious project. Our user documentation is probably not adequate for that purpose. > ... I read documentation available > from Unidata home page and still have some question about format > specification. > 1) If variable contains more than one dimension how I separate data written > starting with variable offset till offset + variable size? The order of the data is the same as for C, with the last dimension varying fastest. All the data is contiguous, except for record variables. For a record variable, all the data is contiguous for each record. > 2) What is record variable and how can i work with it? A record variable has as its first dimension the "unlimited" dimension, which can grow. Each record contains all the data for record variables for a specific value of the record dimension. For example, here is a netCDF file that uses record variables, followed by the order in which the data appears in the file (using C notation for multidimensional indices): netcdf md { dimensions: m = 3 ; n = 2 ; r = UNLIMITED ; // (2 currently) variables: float w(m) ; float x(m, n) ; float y(r) ; float z(r, n) ; data: w = 1, 2, 3 ; x = 11, 12, 21, 22, 31, 32 ; y = -1, -2 ; z = -11, -12, -21, -22 ; } Order of data in file (after header containing dimensions, names, etc): 1.0000000e+00 w[0] // start of non-record data 2.0000000e+00 w[1] 3.0000000e+00 w[2] 1.1000000e+01 x[0][0] 1.2000000e+01 x[0][1] 2.1000000e+01 x[1][0] 2.2000000e+01 x[1][1] 3.1000000e+01 x[2][0] 3.2000000e+01 x[2][1] // end of non-record data -1.0000000e+00 y[0] // start of record data -1.1000000e+01 z[0][0] -1.2000000e+01 z[0][1] -2.0000000e+00 y[1] -2.1000000e+01 z[1][0] -2.2000000e+01 z[1][1] On a Unix system, you can look at netCDF files with "od -f" and see the floating point values after the header information. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu