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.
Paul, > Thanks for the help. I do not have a reproduce case at this time - I am > working on incorporating NetCDF 4.0.1 into IDL and it will take me a > little bit of time to put together a pure "C" reproduce case. > > As far as NC_check_id is concerned, I have yet to see NC_check_id return > anything other than the value NC_EBADID. This happens even if you just > create a new file, and then immediately use NC_check_id. In fact, I have > been seeing NC_check_id failing on all platforms on which I have tested > (both Windows and UNIX - 32 and 64 bit.) NC_check_id is an internal function that is not part of the public netCDF API, and it is not intended to be called by netCDF client programs. It's declaration only appears in libsrc/nc.h, which has a comment near the to that says: /* * netcdf library 'private' data structures, objects and interfaces */ That's why NC_check_id is not documented for user use. It works as an internal library function, when the private data structures it uses are initialized and changed through the publicly documented netCDF interfaces. Is there some reason you need to use NC_check_id rather than the public API declared in netcdf.h? > I was, however, wondering if there is anything wrong with the following > (updated) code for nvdims: > > static size_t > nvdims(int ncid, int varid) > { > int ndims, vardims, nvars, ngatts, unlimdimid; > > if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid) != NC_NOERR) > return 0; > > if (nc_inq_varndims(ncid, varid, &vardims) != NC_NOERR) > return 0; > return (size_t) vardims; > } > > This just follows the same logic used in the original nvdims function, > but uses different API. This at least appears to do a better job of > alleviating the problem. That code looks OK, but there should be no need to rewrite this function. If it is not returning the right value because of a failure of the NC_check_id call in the original version of this function, that is the problem to investigate and correct rather than coding around that problem, because NC_check_id is used in every netCDF-3 function that has a netCDF id as its first argument, which is most netCDF-3 functions. In fact both of the functions you call in the replacementt code, nc_inq and nc_inq_varndims, have as their first executable statements status = NC_check_id(ncid, &ncp); if(status != NC_NOERR) return status; so NC_check_id appears to be working OK if your new version of nvdims works. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: WXE-224025 Department: Support netCDF Priority: Normal Status: Closed