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.
>Organization: Air Force >Keywords: 199509201853.AA19442 netCDF ncdiminq Hi Stan, > ncdiminq returns the correct size for all axes other than the > unlimited axis, but returns 1 + correct size for the unlimited axis. > That is, a file that ncdump reports as having "currently 144" entries > on the time axis returns 145 to ncdiminq. I can't duplicate this problem here, and it sounds puzzling since ncdump just uses ncdiminq to get the size of the unlimited dimension that it reports. I just used "ncgen -b x.cdl" on the following small CDL file to generate a netCDF file named "x.nc", then I ran ncdump on "x.nc" to verify that the size of the unlimited dimension was 3, and finally I ran a small C program to print the results of calling ncdiminq on this file. The output indicates that ncdiminq is in agreement that the size of the unlimited dimension is 3. I'd appreciate it if you could compile and link this C program and let me know if it reports the size as something other than 3. ------------- x.cdl ----------------------------------------------------- netcdf x { dimensions: t = unlimited ; variables: float x(t); data: x = 5, 10, 15; } ------------- diminq.c -------------------------------------------------- #include <stdio.h> #include <netcdf.h> int main() { int ncid, ndims, nvars, natts, uid; long usize; ncid = ncopen("x.nc", NC_NOWRITE); ncinquire(ncid, &ndims, &nvars, &natts, &uid); /* get id of unlim dim */ ncdiminq(ncid, uid, (char *)0, &usize); /* get size of unlim dim */ printf("usize = %ld\n", usize); return 0; } ------------------------------------------------------------------------- Just for completeness, I ran the above test with the released version 2.3.2 of netCDF on a Sun SPARCstation10 under Solaris 2.4 using cc version SC3.0.1, but I don't expect any of those details to be relevant to this test. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu