Next: , Previous: NF_PUT_VARA_ type, Up: Variables


4.9 NF_PUT_VARS_ type

Each member of the family of functions NF_PUT_VARS_ type writes a subsampled (strided) array section of values into a netCDF variable of an open netCDF dataset. The subsampled array section is specified by giving a corner, a vector of counts, and a stride vector. The netCDF dataset must be in data mode.

Usage

     INTEGER FUNCTION NF_PUT_VARS_TEXT  (INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*),CHARACTER*(*) TEXT)
     INTEGER FUNCTION NF_PUT_VARS_INT1  (INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*),INTEGER*1 I1VALS(*))
     INTEGER FUNCTION NF_PUT_VARS_INT2  (INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*),INTEGER*2 I2VALS(*))
     INTEGER FUNCTION NF_PUT_VARS_INT   (INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*), INTEGER IVALS(*))
     INTEGER FUNCTION NF_PUT_VARS_REAL  (INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*),  REAL RVALS(*))
     INTEGER FUNCTION NF_PUT_VARS_DOUBLE(INTEGER NCID, INTEGER VARID,
                                 INTEGER START(*), INTEGER COUNT(*),
                                 INTEGER STRIDE(*),  DOUBLE DVALS(*))
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.
VARID
Variable ID.
START
A vector of integers specifying the index in the variable where the first of the data values will be written. The indices are relative to 1, so for example, the first data value of a variable would have index (1, 1, ..., 1). The elements of START correspond, in order, to the variable's dimensions. Hence, if the variable is a record variable, the last index would correspond to the starting record number for writing the data values.
COUNT
A vector of integers specifying the number of indices selected along each dimension. To write a single value, for example, specify COUNT as (1, 1, ..., 1). The elements of COUNT correspond, in order, to the variable's dimensions. Hence, if the variable is a record variable, the last element of COUNT corresponds to a count of the number of records to write.
STRIDE
A vector of integers that specifies the sampling interval along each dimension of the netCDF variable. The elements of the stride vector correspond, in order, to the netCDF variable's dimensions (STRIDE(1) gives the sampling interval along the most rapidly varying dimension of the netCDF variable). Sampling intervals are specified in type-independent units of elements (a value of 1 selects consecutive elements of the netCDF variable along the corresponding dimension, a value of 2 selects every other element, etc.).
TEXT
I1VALS
I2VALS
IVALS
RVALS
DVALS
The block of data values to be written. The data should be of the type appropriate for the function called. You cannot put CHARACTER data into a numeric variable or numeric data into a text variable. For numeric data, if the type of data differs from the netCDF variable type, type conversion will occur (see Type Conversion).

Errors

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

Example

Here is an example of using NF_PUT_VARS_REAL to write – from an internal array – every other point of a netCDF variable named rh which is described by the FORTRAN declaration REAL RH(6,4) (note the size of the dimensions):

     INCLUDE 'netcdf.inc'
        ...
     PARAMETER (NDIM=2)   ! rank of netCDF variable
     INTEGER NCID         ! netCDF dataset ID
     INTEGER STATUS       ! return code
     INTEGER RHID         ! variable ID
     INTEGER START(NDIM)  ! netCDF variable start point
     INTEGER COUNT(NDIM)  ! size of internal array
     INTEGER STRIDE(NDIM) ! netCDF variable subsampling intervals
     REAL RH(3,2)         ! note subsampled sizes for netCDF variable
                          ! dimensions
     DATA START   /1, 1/  ! start at first netCDF variable value
     DATA COUNT   /3, 2/  ! size of internal array: entire (subsampled)
                          ! netCDF variable
     DATA STRIDE /2, 2/   ! access every other netCDF element
        ...
     STATUS = NF_OPEN('foo.nc', NF_WRITE, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_INQ_VARID(NCID, 'rh', RHID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_PUT_VARS_REAL(NCID, RHID, START, COUNT, STRIDE, RH)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)