[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #JXM-635268]: valid range for ncid


> I have a question about the C interface (probably also applies to
> fortran):
> What is the valid range of the (group or dataset) ncid's returned by
> calls to nc_create, nc_open, or nc_inq_ncid?  Can I assume that a
> valid ncid will always be strictly > 0?  Or >= 0?

It's always > 0, though it's intended to just be used as an opaque handle,
so there's no reason to assume that if you just want to use it for the
public interface.

Currently ncids astart at 2**16 (65536) and increment by 65536, so they
appear as if incrfementing by 1 in the top 16 bits of the 32-bit ncid
integer. The vottom 16 bits are used for group id for open netCDF-4
files, and not used for netCDF-3 files. But again, those are implementation
details that may change, which is why we don't document them.

> I have the same question for varids and dimids.  It seems that these
> are numbered incrementally, starting at 0.  Can I assume they will not
> be negative, or is such a guarantee deliberately left out of the
> interface?

For varids and dimids, the situation is different, because they are actually
documented as starting at 0 and incrementing by 1. You have to know that
to iterate through them, if (as is the case in generic netCDF utilities) you
don't know the names of any of the variables or dimensions. But they also
always non-negative.


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: JXM-635268
Department: Support netCDF
Priority: Normal
Status: Closed

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.