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.
Hi Paul, > I encountered a problem on 64-bit Window XP that I wanted to tell you > about. I was having problems using nc_put_vara_, as I would get an > error that either the file id or the var id were bad, even though I > knew that both id's were indeed valid. The problem turned out to be in > the nvdims function in the file "v2i.c", where NC_check_id was not > working properly. I changed nvdims to the following and that appears to > have fixed the problem: > > static size_t > nvdims(int ncid, int varid) > { > int ndims; > > if (nc_inq_ndims(ncid, &ndims) != NC_NOERR) > return 0; > > return (size_t) ndims; > } > > This was a problem only on 64-bit Windows, and not on any other > platforms. This may have appeared to fix the problem, but it will cause other problems if you use this function on a file in which the number of dimensions is not the same for all variables. The original function, nvdims, is supposed to return the number of dimensions used to specify the shape of the variable that has the handle varid. The function nc_inq_ndims instead returns the total number of dimensions in the file, which is typically larger than the number of dimensions used to specify the shape of any particular variable. It would be better to identify the cause of the problem you encountered with NC_check_id and fix that. If you can provide a self-contained test program that demonstrates that problem on a 64-bit platform, we could try to reproduce the problem here and diagnose the cause. Thanks. --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