The function nc_open opens an existing netCDF dataset for access.
int nc_open (const char *path, int omode, int *ncidp);
path
omode
Otherwise, the creation mode is NC_WRITE, NC_SHARE, or
NC_WRITE|NC_SHARE. Setting the NC_WRITE flag opens the dataset with
read-write access. ("Writing" means any kind of change to the dataset,
including appending or changing data, adding or renaming dimensions,
variables, and attributes, or deleting attributes.) The NC_SHARE flag
is appropriate when one process may be writing the dataset and one or
more other processes reading the dataset concurrently; it means that
dataset accesses are not buffered and caching is limited. Since the
buffering scheme is optimized for sequential access, programs that do
not access data sequentially may see some performance improvement by
setting the NC_SHARE flag.
ncidp
nc_open returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using nc_open to open an existing netCDF dataset named foo.nc for read-only, non-shared access:
#include <netcdf.h> ... int status; int ncid; ... status = nc_open("foo.nc", 0, &ncid); if (status != NC_NOERR) handle_error(status);