Go to the previous, next section.
The function ncopen
(or NCOPN
for FORTRAN)
opens an existing netCDF file for access.
In case of an error, ncopen
returns -1; NCOPN
returns a
nonzero value in rcode
. Possible causes of errors include::
NC_WRITE
or
NC_NOWRITE
.
int ncopen(const char* path,int mode);
path
mode
NC_WRITE
, to open the file for writing, or NC_NOWRITE
, to
open the file read-only. "Writing" means any kind of change to the
file, including appending or changing data, adding or renaming dimensions,
variables, and attributes, or deleting attributes.
Here is an example using ncopen
to open an existing netCDF file
named `foo.nc' for reading:
#include "netcdf.h" ... int ncid; ... ncid = ncopen("foo.nc", NC_NOWRITE);
INTEGER FUNCTION NCOPN(CHARACTER*(*) PATH, + INTEGER RWMODE, + INTEGER RCODE)
PATH
RWMODE
NCWRITE
, to open the file for writing, or NCNOWRIT
, to
open the file read-only. "Writing" means any kind of change to the
file, including appending or changing data, adding or renaming dimensions,
variables, and attributes, or deleting attributes.
RCODE
Here is an example of using NCOPN
to open an existing netCDF file
named `foo.nc' for reading:
INCLUDE 'netcdf.inc' ... INTEGER NCID ... NCID = NCOPN('foo.nc', NCNOWRIT, RCODE)
Go to the previous, next section.