This document describes version 3 of Unidata netCDF data-access interface for the Fortran-90 programming language.
Returns a string identifying the version of the netCDF library, and when it was built, like: "3.1a of Aug 22 1996 12:57:47 $".
The RCS ident(1) command will find a string like "$Id: @(#) netcdf library version 3.1a of Sep 6 1996 15:56:26 $" in the library. The SCCS what(1) command will find a string like "netcdf library version 3.1a of Aug 23 1996 16:07:40 $".
All netCDF functions (except nf90_inq_libvers() and nf90_strerror()) return an integer status. This behavior replaces the rcode argument used in previous versions of the library. If this returned status value is not equal to nf90_noerr (zero), it indicates that an error occurred. The possible status values are defined in the module netcdf.
Returns a string textual translation of the ncerr value, like "Attribute or variable name contains illegal characters" or "No such file or directory".
(Corresponds to nccre() in version 2)
Creates a new netCDF dataset at path, returning a netCDF ID in ncid. The argument cmode may include the bitwise-or of the following flags: nf90_noclobber to protect existing datasets (default silently blows them away), nf90_share for synchronous dataset updates (default is to buffer accesses), and nf90_lock (not yet implemented). When a netCDF dataset is created, is is opened nf90_write. The new netCDF dataset is in define mode.
The optional argument initialsize sets the initial size of the file at creation time.
See nf__open() below for an explanation of the optional chunksize argument.
(Corresponds to ncopn() in version 2)
Opens a existing netCDF dataset at path returning a netCDF ID in ncid. As of NetCDF version 4.1, and if DAP support was enabled when the library was built, the path may instead specify a DAP URL (refer to the NetCDF user's manual for details).
The type of access is described by the mode parameter, which may include the bitwise-or of the following flags: nf90_write for read-write access (default read-only), nf90_share for synchronous dataset updates (default is to buffer accesses), and nf90_lock (not yet implemented).
The optional argument referenced by chunksize controls a space versus time tradeoff, 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 by reference. Using the value nf90_sizehint_default causes the library to choose a default. How the system choses the default depends on the system. On many systems, the "preferred I/O block size" is available from the stat() system call, struct stat member st_blksize. If this is available it is used. Lacking that, twice the system pagesize is used. Lacking a call to discover the system pagesize, we just set default chunksize to 8192.
The chunksize is a property of a given open netcdf descriptor ncid: it is not a persistent property of the netcdf dataset.
Sets the fill-mode for a netCDF dataset to optimize writes under some circumstances. The fill-mode argument, fillmode, can be either nf90_fill or nf90_nofill. nf90_fill causes fill-values to be written into non-record variables and into skipped-over records when writing beyond the last valid record. nf90_nofill suspends this behavior. The default behavior corresponds to nf90_fill.
The previous fill-mode value is return in old_mode.
The fill-mode is a property of a given open netcdf descriptor ncid: it is not a persistent property of the netcdf dataset.
(Corresponds to ncredf() in version 2)
Puts an open netCDF dataset into define mode, so dimensions, variables, and attributes can be added or renamed and attributes can be deleted.
(Corresponds to ncendf() in version 2)
Takes an open netCDF dataset out of define mode. The changes made to the netCDF dataset while it was in define mode are checked and committed to disk if no problems occurred. Some data values may be written as well, see "VARIABLE PREFILLING" below. After a successful call, variable data can be read or written to the dataset.
The optional arguments are performance tuning parameters. They exposes internals of the netcdf version 1 file format and may not be available on future netcdf implementations.
The current netcdf file format has three sections, the "header" section, the data section for fixed size variables, and the data section for variables which have an unlimited dimension (record variables). The header begins at the beginning of the file. The index (offset) of the beginning of the other two sections is contained in the header. Typically, there is no space between the sections. This causes copying overhead to accrue if one wishes to change the size of the sections, as may happen when changing names of things, text attribute values, adding attributes or adding variables. Also, for buffered i/o, there may be advantages to aligning sections in certain ways.
The minfree parameters allow one to control costs of future calls to nf90_redef(), nf90_enddef() by requesting that minfree bytes be available at the end of the section. The h_minfree parameter sets the pad at the end of the "header" section. The v_minfree parameter sets the pad at the end of the data section for fixed size variables.
The align parameters allow one to set the alignment of the beginning of the corresponding sections. The beginning of the section is rounded up to an index which is a multiple of the align parameter. The flag value nf90_align_chunk tells the library to use the chunksize (see above) as the align parameter. The v_align parameter controls the alignment of the beginning of the data section for fixed size variables. The r_align parameter controls the alignment of the beginning of the data section for variables which have an unlimited dimension (record variables).
The file format requires mod 4 alignment, so the align parameters are silently rounded up to multiples of 4. The usual call, nf90_enddef(ncid) is equivalent to nf__enddef(ncid, 0, 4, 0, 4).
The file format does not contain a "record size" value, this is calculated from the sizes of the record variables. This unfortunate fact prevents us from providing minfree and alignment control of the "records" in a netcdf file. If you add a variable which has an unlimited dimension, the third section will always be copied with the new variable added.
(Corresponds to ncsnc() in version 2)
Unless the nf90_share bit is set in nf90_open() or nf90_create(), accesses to the underlying netCDF dataset are buffered by the library. This function synchronizes the state of the underlying dataset and the library. This is done automatically by nf90_close() and nf90_enddef().
(Corresponds to ncabor() in version 2)
You don't need to call this function. This function is called automatically by nf90_close() if the netCDF dataset was in define mode and something goes wrong with the commit. If the netCDF dataset isn't in define mode, then this function is equivalent to nf90_close(). If it is called after nf90_redef(), but before nf90_enddef(), the new definitions are not committed and the dataset is closed. If it is called after nf90_create() but before nf90_enddef(), the dataset disappears.
(Corresponds to ncclos() in version 2)
Closes an open netCDF dataset. If the dataset is in define mode, nf90_enddef() will be called before closing. After a dataset is closed, its ID may be reassigned to another dataset.
Inquire about an open netCDF dataset. ncid is the netCDF ID of the open dataset. Upon successful return, ndims will contain the number of dimensions defined for this netCDF dataset, nvars will contain the number of variables, natts will contain the number of attributes, and unlimdimid will contain the dimension ID of the unlimited dimension if one exists, or 0 otherwise. nformat will contain the format version number, rarely needed because the library detects the format version and behaves appropriately.
(Corresponds to ncddef() in version 2)
Adds a new dimension to an open netCDF dataset, which must be in define mode. name is the dimension name. len is the size of the new dimension or nf90_unlimited to define the unlimited dimension. On return, dimid will contain the dimension ID of the newly created dimension.
(Corresponds to ncdid() in version 2)
Given an open netCDF dataset and dimension name, returns the dimension ID of the netCDF dimension in dimid.
Inquire about a dimension. name should be big enough (nf90_max_name) to hold the dimension name as the name will be copied into your storage. The length return parameter, len will contain the size of the dimension. For the unlimited dimension, the returned length is the current maximum value used for writing into any of the variables which use the dimension.
(Corresponds to ncdren() in version 2)
Renames an existing dimension in an open netCDF dataset. If the new name is longer than the old name, the netCDF dataset must be in define mode. You cannot rename a dimension to have the same name as another dimension.
(Corresponds to ncvdef() in version 2)
Adds a new variable to a netCDF dataset. The netCDF must be in define mode. name will be the name of the netCDF variable. xtype is the external, netCDF type of the variable and should be one of nf90_byte, nf90_char, nf90_short, nf90_int, nf90_float, or nf90_double, The optional dimids argument contains the dimension ID-s of the domain of the netCDF variable and, consequently, determines the rank of the created variable: if dimids is omitted, then the netCDF variable will be a scalar; if dimids is a scalar, then the netCDF variable will be 1 dimensional; and if dimids is a vector, then the netCDF variable will have rank equal to the number of elements in dimids. varid will be set to the netCDF variable ID.
(Corresponds to ncvid() in version 2)
Returns the ID of a netCDF variable in varid given an open netCDF dataset and the name of the variable.
Inquire about a netCDF variable in an open netCDF dataset, given its variable ID. On return, name will contain the name of the variable and should be capacious enough (nf90_max_name). xtype will contain the external, netCDF type of the variable. ndims will contain the dimensionality of the netCDF variable: if the variable is a scalar, then size(ndims) will be zero; otherwise, size(ndims) will be the rank of the variable and ndims will contain the dimension ID-s of the netCDF dimensions that constitute the domain of the variable. natts will contain the number of attributes associated with the netCDF variable.
(Corresponds to ncvren() in version 2)
Changes the name of a netCDF variable. If the new name is longer than the old name, the netCDF must be in define mode. You cannot rename a variable to have the name of any existing variable.
(Replaces ncvpt() in version 2)
Writes a value or values to a netCDF variable. The netCDF dataset must be open and in data mode. values contains the value(s) what will be written to the netCDF variable identified by ncid and varid; it may be a scalar or an array and must be of type character, integer(kind=OneByteInt), integer(kind=TwoByteInt), integer(kind=FourByteInt), integer(kind=EightByteInt), real(kind=FourByteReal), or real(kind=EightByteReal). All values are converted to the external type of the netCDF variable, if possible; otherwise, an nf90_erange error is returned. The optional argument start specifies the starting index in the netCDF variable for writing for each dimension of the netCDF variable. The optional argument stride specifies the sampling stride (the interval between accessed values in the netCDF variable) for each dimension of the netCDF variable (see COMMON ARGUMENT DESCRIPTIONS below). The optional argument imap specifies the in-memory arrangement of the data values (see COMMON ARGUMENT DESCRIPTIONS below).
(Replaces ncvgt() in version 2)
Reads a value or values from a netCDF variable.
The netCDF dataset must be open and in data mode.
values will receive the value(s) what will be read from the netCDF
variable
identified by ncid and varid; it may be a scalar or an array and
must be of type
character,
integer(kind=OneByteInt),
integer(kind=TwoByteInt),
integer(kind=FourByteInt),
integer(kind=EightByteInt),
real(kind=FourByteReal), or
real(kind=EightByteReal).
All values are converted from the external type
of the netCDF variable, if possible; otherwise, an
nf90_erange error is returned.
The optional argument start specifies
the starting index in the netCDF variable for reading for each
dimension of the netCDF variable.
The optional argument stride specifies the sampling stride
(the interval between accessed values in the netCDF variable)
for each dimension of the netCDF variable (see COMMON ARGUMENT DESCRIPTIONS
below).
The optional argument imap specifies the in-memory arrangement of the data
values (see COMMON ARGUMENT DESCRIPTIONS below).
Inquires about the netCDF attribute named name, of variable varid, in the open netCDF dataset ncid. xtype will contain the external, netCDF type of the variable. len will contain the number of elements in the attribute. attnum will contain the attribute number.
(Corresponds to ncanam() in version 2)
Gets the name of an attribute, given its variable ID and attribute number. This function is useful in generic applications that need to get the names of all the attributes associated with a variable because attributes are accessed by name rather than number in all other attribute functions (the number of an attribute is more volatile than the name because it can change when other attributes of the same variable are deleted). The attributes for each variable are numbered from 1 (the first attribute) to natts, where natts is the number of attributes for the variable, as returned from a call to nf90_inquire_variable().
Unlike variables, attributes do not have separate functions for defining and writing values. This function defines a new attribute with a value or changes the value of an existing attribute. If the attribute is new, or if the space required to store the attribute value is greater than before, the netCDF dataset must be in define mode. values contains the attribute values to be written; it may be a scalar or a vector and must be of type character, integer(kind=OneByteInt), integer(kind=TwoByteInt), integer(kind=FourByteInt), integer(kind=EightByteInt), real(kind=FourByteReal), or real(kind=EightByteReal).
integer, intent(in) :: ncid, varid character(len=*), intent(in) :: name <<whatever>>, intent(out) :: values integer :: nf90_get_att
(Replaces ncagt() in version 2)
Gets the value(s) of a netCDF attribute, given its variable ID and name. The values are returned in values, which must be of type character, integer(kind=OneByteInt), integer(kind=TwoByteInt), integer(kind=FourByteInt), integer(kind=EightByteInt), real(kind=FourByteReal), or real(kind=EightByteReal). Converts from the external type to the type of the receiving variable, if possible; otherwise returns an nf90_erange error. All values of the attribute are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nf90_inquire_attribute() first to find out the length of the attribute.
(Corresponds to ncacpy() in version 2)
Copies an attribute from one netCDF dataset to another. It can also be used to copy an attribute from one variable to another within the same netCDF dataset. ncid_in is the netCDF ID of an input netCDF dataset from which the attribute will be copied. varid_in is the ID of the variable in the input netCDF dataset from which the attribute will be copied, or nf90_global for a global attribute. name is the name of the attribute in the input netCDF dataset to be copied. ncid_out is the netCDF ID of the output netCDF dataset to which the attribute will be copied. It is permissible for the input and output netCDF ID's to be the same. The output netCDF dataset should be in define mode if the attribute to be copied does not already exist for the target variable, or if it would cause an existing target attribute to grow. varid_out is the ID of the variable in the output netCDF dataset to which the attribute will be copied, or nf90_global to copy to a global attribute.
(Corresponds to ncaren()
Changes the name of an attribute. If the new name is longer than the original name, the netCDF must be in define mode. You cannot rename an attribute to have the same name as another attribute of the same variable. name is the original attribute name. newname is the new name to be assigned to the specified attribute. If the new name is longer than the old name, the netCDF dataset must be in define mode.
(Corresponds to ncadel() in version 2)
Deletes an attribute from a netCDF dataset. The dataset must be in define mode.
In this section we define some common arguments which are used in the "FUNCTION DESCRIPTIONS" section.
By default, the netCDF interface sets the values of all newly-defined variables of finite length (i.e. those that do not have an unlimited, dimension) to the type-dependent fill-value associated with each variable. This is done when nf90_enddef() is called. The fill-value for a variable may be changed from the default value by defining the attribute `_FillValue' for the variable. This attribute must have the same type as the variable and be of length one.
Variables with an unlimited dimension are also prefilled, but on an `as needed' basis. For example, if the first write of such a variable is to position 5, then positions 1 through 4 (and no others) would be set to the fill-value at the same time.
This default prefilling of data values may be disabled by or'ing the nf90_nofill flag into the mode parameter of nf90_open() or nf90_create(), or, by calling the function nf90_set_fill() with the argument nf90_nofill. For variables that do not use the unlimited dimension, this call must be made before nf90_enddef(). For variables that use the unlimited dimension, this call may be made at any time.
One can obtain increased performance of the netCDF interface by using this feature, but only at the expense of requiring the application to set every single data value. The performance enhancing behavior of this function is dependent on the particulars of the implementation and dataset format. The flag value controlled by nf90_set_fill() is per netCDF ID, not per variable or per write. Allowing this to change affects the degree to which a program can be effectively parallelized. Given all of this, we state that the use of this feature may not be available (or even needed) in future releases. Programmers are cautioned against heavy reliance upon this feature.
Additional functions for use on SGI/Cray MPP machines (_CRAYMPP). These are used to set and inquire which PE is the base for MPP for a particular netCDF. These are only relevant when using the SGI/Cray ``global'' Flexible File I/O layer and desire to have only a subset of PEs to open the specific netCDF file. For technical reasons, these functions are available on all platforms. On a platform other than SGI/Cray MPP, it is as if only processor available were processor 0.
To use this feature, you need to specify a communicator group and call glio_group_mpi() or glio_group_shmem() prior to the netCDF nf90_open() and nf90_create() calls.
Note that the routines described below are Fortran-77 routines rather than Fortran-90 routines (they have an "nf_" prefix rather than an "nf90_" prefix).
The argument pe sets the base PE at creation time. In the MPP environment, nf__create() and nf90_create() set the base PE to processor zero by default.
Both a mailing list and a digest are available for discussion of the netCDF interface and announcements about netCDF bugs, fixes, and enhancements. To begin or change your subscription to either the mailing-list or the digest, send one of the following in the body (not the subject line) of an email message to "majordomo@unidata.ucar.edu". Use your email address in place of jdoe@host.inst.domain.
To subscribe to the netCDF mailing list:
ncdump(1), ncgen(1), netcdf(3f).
netCDF User's Guide, published by the Unidata Program Center, University Corporation for Atmospheric Research, located in Boulder, Colorado.