Next: NF90_REDEF, Previous: NF90_CREATE, Up: Datasets
The function NF90_OPEN opens an existing netCDF dataset for access.
function nf90_open(path, mode, ncid, chunksize) character (len = *), intent(in ) :: path integer, intent(in ) :: mode integer, intent( out) :: ncid integer, optional, intent(inout) :: chunksize integer :: nf90_open
path
mode
Otherwise, the creation mode is NF90_WRITE, NF90_SHARE, or
NF90_WRITE|NF90_SHARE. Setting the NF90_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 NF90_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 NF90_SHARE flag.
ncid
The following optional argument allows additional performance tuning.
chunksize
The library chooses a system-dependent default value if NF90_SIZEHINT_DEFAULT is supplied as input. If the "preferred I/O block size" is available from the stat() system call as member st_blksize this value is used. Lacking that, twice the system pagesize is used. Lacking a call to discover the system pagesize, the default chunksize is set to 8192 bytes.
The chunksize is a property of a given open netcdf descriptor ncid, it is not a persistent property of the netcdf dataset.
NF90_OPEN returns the value NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using NF90_OPEN to open an existing netCDF dataset named foo.nc for read-only, non-shared access:
use netcdf implicit none integer :: ncid, status ... status = nf90_open(path = "foo.nc", cmode = nf90_nowrite, ncid = ncid) if (status /= nf90_noerr) call handle_err(status)