Next: , Previous: NF_INSERT_COMPOUND, Up: Compound Types


5.6.3 Inserting an Array Field into a Compound Type: NF_INSERT_ARRAY_COMPOUND

Insert a named array field into a compound type.

Usage

     INTEGER FUNCTION NF_INSERT_ARRAY_COMPOUND(INTEGER NCID, INTEGER XTYPE,
             CHARACTER*(*) NAME, INTEGER OFFSET, INTEGER FIELD_TYPEID,
             INTEGER NDIMS, INTEGER DIM_SIZES)
NCID
The ID of the file that contains the array type and the compound type.
XTYPE
The typeid for this compound type, as returned by nf_def_compound, or nf_inq_var.
NAME
The name of the new field.
OFFSET
Offset in byte from the beginning of the compound type for this field.
FIELD_TYPEID
The base type of the array to be inserted.
NDIMS
The number of dimensions for the array to be inserted.
DIM_SIZES
An array containing the sizes of each dimension.

Errors

NF_NOERR
No error.
NF_EBADID
Bad group id.
NF_ENAMEINUSE
That name is in use. Field names must be unique within a compound type.
NF_EMAXNAME
Name exceed max length NF_MAX_NAME.
NF_EBADNAME
Name contains illegal characters.
NF_ENOTNC4
Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4 operations can only be performed on files defined with a create mode which includes flag NF_NETCDF4. (see NF_OPEN).
NF_ESTRICTNC3
This file was created with the strict netcdf-3 flag, therefore netcdf-4 operations are not allowed. (see NF_OPEN).
NF_EHDFERR
An error was reported by the HDF5 layer.
NF_ENOTINDEFINE
Not in define mode.
NF_ETYPEDEFINED
Attempt to change type that has already been committed. The first time the file leaves define mode, all defined types are committed, and can't be changed. If you wish to add an array to a compound type, you must do so before the compound type is committed.

Example

This example is from nf_test/ftst_types2.F.

     C     Define a compound type.
           retval = nf_def_compound(ncid, cmp_size, type_name,
          &     cmp_typeid)
           if (retval .ne. nf_noerr) call handle_err(retval)
     
     C     Include an array.
           dim_sizes(1) = NX
           dim_sizes(2) = NY
           retval = nf_insert_array_compound(ncid, cmp_typeid, ary_name, 0,
          &     NF_INT, NDIMS, dim_sizes)
           if (retval .ne. nf_noerr) call handle_err(retval)