Next: , Previous: NF90_CREATE, Up: Datasets


2.6 NF90_OPEN

The function NF90_OPEN opens an existing netCDF dataset for access.

Usage

      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
File name for netCDF dataset to be opened.
mode
A zero value (or NF90_NOWRITE) specifies the default behavior: open the dataset with read-only access, buffering and caching accesses for efficiency

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
Returned netCDF ID.

The following optional argument allows additional performance tuning.

chunksize
Controls a space versus time trade-off, memory allocated in the netcdf library versus number of system calls. Because of internal requirements, the value may not be set to exactly the value requested. The actual value chosen is returned.

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.

Errors

NF90_OPEN returns the value NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:

Example

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)