Next: , Previous: Compound Types, Up: Compound Types


5.6.1 Creating a Compound Type: NF_DEF_COMPOUND

Create a compound type. Provide an ncid, a name, and a total size (in bytes) of one element of the completed compound type.

After calling this function, fill out the type with repeated calls to NF_INSERT_COMPOUND (see NF_INSERT_COMPOUND). Call NF_INSERT_COMPOUND once for each field you wish to insert into the compound type.

Note that there does not seem to be a way to read such types into structures in Fortran 90 (and there are no structures in Fortran 77).

Fortran users may use character buffers to read and write compound types.

Usage

     INTEGER FUNCTION NF_DEF_COMPOUND(INTEGER NCID, INTEGER SIZE,
             CHARACTER*(*) NAME, INTEGER TYPEIDP)
NCID
The groupid where this compound type will be created.
SIZE
The size, in bytes, of the compound type.
NAME
The name of the new compound type.
TYPEIDP
The typeid of the new type will be placed here.

Errors

NF_NOERR
No error.
NF_EBADID
Bad group id.
NF_ENAMEINUSE
That name is in use. Compound type names must be unique in the data file.
NF_EMAXNAME
Name exceeds 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_EPERM
Attempt to write to a read-only file.
NF_ENOTINDEFINE
Not in define mode.

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)