1 5 User Defined Data Types {#f90-user-defined-data-types}
2 =========================
4 5.1 User Defined Types Introduction {#f90-user-defined-types-introduction}
5 =========================
9 NetCDF-4 has added support
for four different user defined data types.
13 : Like a C
struct, a compound type is a collection of types, including
14 other user defined types, in one package.
16 `variable length array type`
18 : The variable length array may be used to store ragged arrays.
22 : This type has only a size per element, and no other
27 : Like an enumeration in C,
this type lets you assign text values to
28 integer values, and store the integer values.
30 Users may construct user defined type with the various
NF90\_DEF\_\*
31 functions described in
this section. They may learn about user defined
32 types by
using the
NF90\_INQ\_ functions defined in
this section.
34 Once types are constructed, define variables of the
new type with
35 NF90\_DEF\_VAR (see section [Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)). Write to them with
36 NF90\_PUT\_VAR (see section [Writing Data Values: `NF90_PUT_VAR`](#NF90_005fPUT_005fVAR)). Read data of user-defined type
37 with NF90\_GET\_VAR (see section [Reading Data Values: `NF90_GET_VAR`](#NF90_005fGET_005fVAR)).
39 Create attributes of the
new type with NF90\_PUT\_ATT (see section
40 [Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)). Read
41 attributes of the
new type with NF90\_GET\_ATT (see section [Get
42 Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)).
45 5.2 Learn the IDs of All Types in Group: NF90_INQ_TYPEIDS {#f90-learn-the-ids-of-all-types-in-group-
nf90_inq_typeids}
46 =========================
50 Learn the number of types defined in a group, and their IDs.
61 integer, intent(in) :: ncid
62 integer, intent(out) :: ntypes
63 integer, intent(out) :: typeids
76 : A pointer to
int which will get the number of types defined in
77 the group. If NULL, ignored.
81 : A pointer to an
int array which will get the typeids. If
102 =========================
106 Given a group ID and a type name, find the ID of the type. If the type
107 is not found in the group, then the parents are searched. If still not
108 found, the entire file is searched.
130 : The name of a type.
134 : The
typeid,
if found.
157 5.4 Learn About a User Defined Type: NF90_INQ_TYPE {#f90-learn-about-a-user-defined-type-
nf90_inq_type}
158 =========================
161 Given an ncid and a
typeid,
get the information about a type. This
162 function will work on any type, including atomic and any user defined
163 type, whether compound, opaque, enumeration, or variable length array.
165 For even more information about a user defined type [Learn About a User
166 Defined Type: NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE).
177 integer, intent(in) :: ncid
178 integer, intent(in) :: xtype
179 character (len = *), intent(out) :: name
180 integer, intent(out) :: size
189 : The ncid for the group containing the type (ignored for
194 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
195 NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN, or
196 NF90\_INQ\_VAR, or as found in
netcdf.inc in the list of atomic
197 types (NF90\_CHAR, NF90\_INT, etc.).
201 : The name of the user defined type will be copied here. It will be
202 NF90\_MAX\_NAME bytes or less. For atomic types, the type name from
207 : The (in-memory) size of the type (in bytes) will be copied here.
208 VLEN type size is the size of one element of the VLEN. String size
209 is returned as the size of one
char.
226 : Seeking a user-defined type in a netCDF-3 file.
230 : Seeking a user-defined type in a netCDF-4 file
for which classic
231 model has been turned on.
235 : Bad group ID in ncid.
243 : An error was reported by the HDF5 layer.
250 5.5 Learn About a User Defined Type: NF90_INQ_USER_TYPE {#f90-learn-about-a-user-defined-type-
nf90_inq_user_type}
251 =========================
253 Given an ncid and a
typeid,
get the information about a user defined
254 type. This
function will work on any user defined type, whether
255 compound, opaque, enumeration, or variable length array.
266 integer, intent(in) :: ncid
267 integer, intent(in) :: xtype
268 character (len = *), intent(out) :: name
269 integer, intent(out) :: size
270 integer, intent(out) :: base_typeid
271 integer, intent(out) :: nfields
272 integer, intent(out) :: class
278 : The ncid for the group containing the user defined type.
282 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
283 NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN,
288 : The name of the user defined type will be copied here. It will be
289 NF90\_MAX\_NAME bytes or less.
293 : The (in-memory) size of the user defined type will be copied here.
297 : The base typeid will be copied here for vlen and enum types.
301 : The number of fields will be copied here for enum and
306 : The class of the user defined type, NF90\_VLEN, NF90\_OPAQUE,
307 NF90\_ENUM, or NF90\_COMPOUND, will be copied here.
327 : An error was reported by the HDF5 layer.
333 ## 5.5.1 Set a Variable Length Array with NF90_PUT_VLEN_ELEMENT {#f90-set-a-variable-length-array-with-nf90_put_vlen_element}
337 Use
this to set the element of the (potentially) n-dimensional array of
338 VLEN. That is, this sets the data in one variable length array.
348 INTEGER FUNCTION NF90_PUT_VLEN_ELEMENT(INTEGER NCID, INTEGER XTYPE,
349 CHARACTER*(*) VLEN_ELEMENT, INTEGER LEN, DATA)
357 : The ncid of the file that contains the VLEN type.
361 : The type of the VLEN.
365 : The VLEN element to be set.
369 : The number of entries in
this array.
373 : The data to be stored. Must match the base type of
this VLEN.
385 : Can’t find the
typeid.
393 : Group ID part of ncid was invalid.
399 This example is from nf90\_test/ftst\_vars4.F.
405 C Set up the vlen with
this helper
function, since F90 can
't deal
407 retval = nf90_put_vlen_element(ncid, vlen_typeid, vlen,
409 if (retval .ne. nf90_noerr) call handle_err(retval)
416 ## 5.5.2 Set a Variable Length Array with NF90_GET_VLEN_ELEMENT {#f90-set-a-variable-length-array-with-nf90_get_vlen_element}
420 Use this to set the element of the (potentially) n-dimensional array of
421 VLEN. That is, this sets the data in one variable length array.
431 INTEGER FUNCTION NF90_GET_VLEN_ELEMENT(INTEGER NCID, INTEGER XTYPE,
432 CHARACTER*(*) VLEN_ELEMENT, INTEGER LEN, DATA)
440 : The ncid of the file that contains the VLEN type.
444 : The type of the VLEN.
448 : The VLEN element to be set.
452 : This will be set to the number of entries in this array.
456 : The data will be copied here. Sufficient storage must be available
457 or bad things will happen to you.
469 : Can’t find the typeid.
477 : Group ID part of ncid was invalid.
484 5.6 Compound Types Introduction {#f90-compound-types-introduction}
485 =========================
489 NetCDF-4 added support for compound types, which allow users to
490 construct a new type - a combination of other types, like a C struct.
492 Compound types are not supported in classic or 64-bit offset format
495 To write data in a compound type, first use nf90\_def\_compound to
496 create the type, multiple calls to nf90\_insert\_compound to add to the
497 compound type, and then write data with the appropriate nf90\_put\_var1,
498 nf90\_put\_vara, nf90\_put\_vars, or nf90\_put\_varm call.
500 To read data written in a compound type, you must know its structure.
501 Use the NF90\_INQ\_COMPOUND functions to learn about the compound type.
503 In Fortran a character buffer must be used for the compound data. The
504 user must read the data from within that buffer in the same way that the
505 C compiler which compiled netCDF would store the structure.
507 The use of compound types introduces challenges and portability issues
510 ## 5.6.1 Creating a Compound Type: NF90_DEF_COMPOUND {#f90-creating-a-compound-type-nf90_def_compound}
514 Create a compound type. Provide an ncid, a name, and a total size (in
515 bytes) of one element of the completed compound type.
517 After calling this function, fill out the type with repeated calls to
518 NF90\_INSERT\_COMPOUND (see section [Inserting a Field into a Compound
519 Type: NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)). Call
520 NF90\_INSERT\_COMPOUND once for each field you wish to insert into the
523 Note that there does not seem to be a fully portable way to read such
524 types into structures in Fortran 90 (and there are no structures in
525 Fortran 77). Dozens of top-notch programmers are swarming over this
526 problem in a sub-basement of Unidata’s giant underground bunker in
529 Fortran users may use character buffers to read and write compound
530 types. User are invited to try classic Fortran features such as the
531 equivilence and the common block statment.
539 function nf90_def_compound(ncid, size, name, typeid)
540 integer, intent(in) :: ncid
541 integer, intent(in) :: size
542 character (len = *), intent(in) :: name
543 integer, intent(out) :: typeid
544 integer :: nf90_def_compound
552 : The groupid where this compound type will be created.
556 : The size, in bytes, of the compound type.
560 : The name of the new compound type.
564 : The typeid of the new type will be placed here.
580 : That name is in use. Compound type names must be unique in the
585 : Name exceeds max length NF90\_MAX\_NAME.
589 : Name contains illegal characters.
593 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
594 operations can only be performed on files defined with a create mode
595 which includes flag NF90\_NETCDF4. (see section
596 [NF90\_OPEN](#NF90_005fOPEN)).
600 : This file was created with the strict netcdf-3 flag, therefore
601 netcdf-4 operations are not allowed. (see section
602 [NF90\_OPEN](#NF90_005fOPEN)).
606 : An error was reported by the HDF5 layer.
610 : Attempt to write to a read-only file.
614 : Not in define mode.
620 ## 5.6.2 Inserting a Field into a Compound Type: NF90_INSERT_COMPOUND {#f90-inserting-a-field-into-a-compound-type-nf90_insert_compound}
624 Insert a named field into a compound type.
634 function nf90_insert_compound(ncid, xtype, name, offset, field_typeid)
635 integer, intent(in) :: ncid
636 integer, intent(in) :: xtype
637 character (len = *), intent(in) :: name
638 integer, intent(in) :: offset
639 integer, intent(in) :: field_typeid
640 integer :: nf90_insert_compound
648 : The typeid for this compound type, as returned by
649 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
653 : The name of the new field.
657 : Offset in byte from the beginning of the compound type for
662 : The type of the field to be inserted.
678 : That name is in use. Field names must be unique within a
683 : Name exceed max length NF90\_MAX\_NAME.
687 : Name contains illegal characters.
691 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
692 operations can only be performed on files defined with a create mode
693 which includes flag NF90\_NETCDF4. (see section
694 [NF90\_OPEN](#NF90_005fOPEN)).
698 : This file was created with the strict netcdf-3 flag, therefore
699 netcdf-4 operations are not allowed. (see section
700 [NF90\_OPEN](#NF90_005fOPEN)).
704 : An error was reported by the HDF5 layer.
708 : Not in define mode.
718 ## 5.6.3 Inserting an Array Field into a Compound Type: NF90_INSERT_ARRAY_COMPOUND {#f90-inserting-an-array-field-into-a-compound-type-nf90_insert_array_compound}
722 Insert a named array field into a compound type.
732 function nf90_insert_array_compound(ncid, xtype, name, offset, field_typeid, &
734 integer, intent(in) :: ncid
735 integer, intent(in) :: xtype
736 character (len = *), intent(in) :: name
737 integer, intent(in) :: offset
738 integer, intent(in) :: field_typeid
739 integer, intent(in) :: ndims
740 integer, intent(in) :: dim_sizes
741 integer :: nf90_insert_array_compound
749 : The ID of the file that contains the array type and the
754 : The typeid for this compound type, as returned by
755 nf90\_def\_compound, or nf90\_inq\_var.
759 : The name of the new field.
763 : Offset in byte from the beginning of the compound type for
768 : The base type of the array to be inserted.
772 : The number of dimensions for the array to be inserted.
776 : An array containing the sizes of each dimension.
792 : That name is in use. Field names must be unique within a
797 : Name exceed max length NF90\_MAX\_NAME.
801 : Name contains illegal characters.
805 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
806 operations can only be performed on files defined with a create mode
807 which includes flag NF90\_NETCDF4. (see section
808 [NF90\_OPEN](#NF90_005fOPEN)).
812 : This file was created with the strict netcdf-3 flag, therefore
813 netcdf-4 operations are not allowed. (see section
814 [NF90\_OPEN](#NF90_005fOPEN)).
818 : An error was reported by the HDF5 layer.
822 : Not in define mode.
826 : Attempt to change type that has already been committed. The first
827 time the file leaves define mode, all defined types are committed,
828 and can’t be changed. If you wish to add an array to a compound
829 type, you must do so before the compound type is committed.
835 ## 5.6.4 Learn About a Compound Type: NF90_INQ_COMPOUND {#f90-learn-about-a-compound-type-nf90_inq_compound}
839 Get the number of fields, length in bytes, and name of a compound type.
841 In addtion to the NF90\_INQ\_COMPOUND function, three additional
842 functions are provided which get only the name, size, and number of
853 function nf90_inq_compound(ncid, xtype, name, size, nfields)
854 integer, intent(in) :: ncid
855 integer, intent(in) :: xtype
856 character (len = *), intent(out) :: name
857 integer, intent(out) :: size
858 integer, intent(out) :: nfields
859 integer :: nf90_inq_compound
861 function nf90_inq_compound_name(ncid, xtype, name)
862 integer, intent(in) :: ncid
863 integer, intent(in) :: xtype
864 character (len = *), intent(out) :: name
865 integer :: nf90_inq_compound_name
867 function nf90_inq_compound_size(ncid, xtype, size)
868 integer, intent(in) :: ncid
869 integer, intent(in) :: xtype
870 integer, intent(out) :: size
871 integer :: nf90_inq_compound_size
873 function nf90_inq_compound_nfields(ncid, xtype, nfields)
874 integer, intent(in) :: ncid
875 integer, intent(in) :: xtype
876 integer, intent(out) :: nfields
877 integer :: nf90_inq_compound_nfields
885 : The ID of any group in the file that contains the compound type.
889 : The typeid for this compound type, as returned by
890 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
894 : Character array which will get the name of the compound type. It
895 will have a maximum length of NF90\_MAX\_NAME.
899 : The size of the compound type in bytes will be put here.
903 : The number of fields in the compound type will be placed here.
915 : Couldn’t find this ncid.
919 : Not a netCDF-4/HDF5 file.
923 : A netCDF-4/HDF5 file, but with CLASSIC\_MODEL. No user defined types
924 are allowed in the classic model.
928 : This type not a compound type.
936 : An error was reported by the HDF5 layer.
942 ## 5.6.5 Learn About a Field of a Compound Type: NF90_INQ_COMPOUND_FIELD {#f90-learn-about-a-field-of-a-compound-type-nf90_inq_compound_field}
946 Get information about one of the fields of a compound type.
956 function nf90_inq_compound_field(ncid, xtype, fieldid, name, offset, &
957 field_typeid, ndims, dim_sizes)
958 integer, intent(in) :: ncid
959 integer, intent(in) :: xtype
960 integer, intent(in) :: fieldid
961 character (len = *), intent(out) :: name
962 integer, intent(out) :: offset
963 integer, intent(out) :: field_typeid
964 integer, intent(out) :: ndims
965 integer, intent(out) :: dim_sizes
966 integer :: nf90_inq_compound_field
968 function nf90_inq_compound_fieldname(ncid, xtype, fieldid, name)
969 integer, intent(in) :: ncid
970 integer, intent(in) :: xtype
971 integer, intent(in) :: fieldid
972 character (len = *), intent(out) :: name
973 integer :: nf90_inq_compound_fieldname
975 function nf90_inq_compound_fieldindex(ncid, xtype, name, fieldid)
976 integer, intent(in) :: ncid
977 integer, intent(in) :: xtype
978 character (len = *), intent(in) :: name
979 integer, intent(out) :: fieldid
980 integer :: nf90_inq_compound_fieldindex
982 function nf90_inq_compound_fieldoffset(ncid, xtype, fieldid, offset)
983 integer, intent(in) :: ncid
984 integer, intent(in) :: xtype
985 integer, intent(in) :: fieldid
986 integer, intent(out) :: offset
987 integer :: nf90_inq_compound_fieldoffset
989 function nf90_inq_compound_fieldtype(ncid, xtype, fieldid, field_typeid)
990 integer, intent(in) :: ncid
991 integer, intent(in) :: xtype
992 integer, intent(in) :: fieldid
993 integer, intent(out) :: field_typeid
994 integer :: nf90_inq_compound_fieldtype
996 function nf90_inq_compound_fieldndims(ncid, xtype, fieldid, ndims)
997 integer, intent(in) :: ncid
998 integer, intent(in) :: xtype
999 integer, intent(in) :: fieldid
1000 integer, intent(out) :: ndims
1001 integer :: nf90_inq_compound_fieldndims
1003 function nf90_inq_cmp_fielddim_sizes(ncid, xtype, fieldid, dim_sizes)
1004 integer, intent(in) :: ncid
1005 integer, intent(in) :: xtype
1006 integer, intent(in) :: fieldid
1007 integer, intent(out) :: dim_sizes
1008 integer :: nf90_inq_cmp_fielddim_sizes
1016 : The groupid where this compound type exists.
1020 : The typeid for this compound type, as returned by
1021 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
1025 : A one-based index number specifying a field in the compound type.
1029 : A character array which will get the name of the field. The name
1030 will be NF90\_MAX\_NAME characters, at most.
1034 : An integer which will get the offset of the field.
1038 : An integer which will get the typeid of the field.
1042 : An integer which will get the number of dimensions of the field.
1046 : An integer array which will get the dimension sizes of the field.
1062 : An error was reported by the HDF5 layer.
1068 5.7 Variable Length Array Introduction {#f90-variable-length-array-introduction}
1069 =========================
1073 NetCDF-4 added support for a variable length array type. This is not
1074 supported in classic or 64-bit offset files, or in netCDF-4 files which
1075 were created with the NF90\_CLASSIC\_MODEL flag.
1077 A variable length array is represented in C as a structure from HDF5,
1078 the nf90\_vlen\_t structure. It contains a len member, which contains
1079 the length of that array, and a pointer to the array.
1081 So an array of VLEN in C is an array of nc\_vlen\_t structures. The only
1082 way to handle this in Fortran is with a character buffer sized correctly
1085 VLEN arrays are handled differently with respect to allocation of
1086 memory. Generally, when reading data, it is up to the user to malloc
1087 (and subsequently free) the memory needed to hold the data. It is up to
1088 the user to ensure that enough memory is allocated.
1090 With VLENs, this is impossible. The user cannot know the size of an
1091 array of VLEN until after reading the array. Therefore when reading VLEN
1092 arrays, the netCDF library will allocate the memory for the data within
1095 It is up to the user, however, to eventually free this memory. This is
1096 not just a matter of one call to free, with the pointer to the array of
1097 VLENs; each VLEN contains a pointer which must be freed.
1099 Compression is permitted but may not be effective for VLEN data, because
1100 the compression is applied to the nc\_vlen\_t structures, rather than
1103 ## 5.7.1 Define a Variable Length Array (VLEN): NF90_DEF_VLEN {#f90-define-a-variable-length-array-vlen-nf90_def_vlen}
1107 Use this function to define a variable length array type.
1117 function nf90_def_vlen(ncid, name, base_typeid, xtypeid)
1118 integer, intent(in) :: ncid
1119 character (len = *), intent(in) :: name
1120 integer, intent(in) :: base_typeid
1121 integer, intent(out) :: xtypeid
1122 integer :: nf90_def_vlen
1130 : The ncid of the file to create the VLEN type in.
1134 : A name for the VLEN type.
1138 : The typeid of the base type of the VLEN. For example, for a VLEN of
1139 shorts, the base type is NF90\_SHORT. This can be a user
1144 : The typeid of the new VLEN type will be set here.
1156 : NF90\_MAX\_NAME exceeded.
1160 : Name is already in use.
1164 : Attribute or variable name contains illegal characters.
1172 : Group ID part of ncid was invalid.
1186 ## 5.7.2 Learning about a Variable Length Array (VLEN) Type: NF90_INQ_VLEN {#f90-learning-about-a-variable-length-array-vlen-type-nf90_inq_vlen}
1190 Use this type to learn about a vlen.
1200 function nf90_inq_vlen(ncid, xtype, name, datum_size, base_nc_type)
1201 integer, intent(in) :: ncid
1202 integer, intent(in) :: xtype
1203 character (len = *), intent(out) :: name
1204 integer, intent(out) :: datum_size
1205 integer, intent(out) :: base_nc_type
1206 integer :: nf90_inq_vlen
1214 : The ncid of the file that contains the VLEN type.
1218 : The type of the VLEN to inquire about.
1222 : The name of the VLEN type. The name will be NF90\_MAX\_NAME
1227 : A pointer to a size\_t, this will get the size of one element of
1232 : An integer that will get the type of the VLEN base type. (In other
1233 words, what type is this a VLEN of?)
1245 : Can’t find the typeid.
1253 : Group ID part of ncid was invalid.
1260 ## 5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type: NF90_FREE_VLEN {#f90-releasing-memory-for-a-variable-length-array-vlen-type-nf90_free_vlen}
1264 When a VLEN is read into user memory from the file, the HDF5 library
1265 performs memory allocations for each of the variable length arrays
1266 contained within the VLEN structure. This memory must be freed by the
1267 user to avoid memory leaks.
1269 This violates the normal netCDF expectation that the user is responsible
1270 for all memory allocation. But, with VLEN arrays, the underlying HDF5
1271 library allocates the memory for the user, and the user is responsible
1272 for deallocating that memory.
1282 function nf90_free_vlen(vl)
1283 character (len = *), intent(in) :: vlen
1284 integer :: nf90_free_vlen
1285 end function nf90_free_vlen
1293 : The variable length array structure which is to be freed.
1305 : Can’t find the typeid.
1312 5.8 Opaque Type Introduction {#f90-opaque-type-introduction}
1313 =========================
1317 NetCDF-4 added support for the opaque type. This is not supported in
1318 classic or 64-bit offset files.
1320 The opaque type is a type which is a collection of objects of a known
1321 size. (And each object is the same size). Nothing is known to netCDF
1322 about the contents of these blobs of data, except their size in bytes,
1323 and the name of the type.
1325 To use an opaque type, first define it with [Creating Opaque Types:
1326 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE). If encountering an enum
1327 type in a new data file, use [Learn About an Opaque Type:
1328 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE) to learn its name and size.
1330 ## 5.8.1 Creating Opaque Types: NF90_DEF_OPAQUE {#f90-creating-opaque-types-nf90_def_opaque}
1334 Create an opaque type. Provide a size and a name.
1344 function nf90_def_opaque(ncid, size, name, xtype)
1345 integer, intent(in) :: ncid
1346 integer, intent(in) :: size
1347 character (len = *), intent(in) :: name
1348 integer, intent(out) :: xtype
1349 integer :: nf90_def_opaque
1357 : The groupid where the type will be created. The type may be used
1358 anywhere in the file, no matter what group it is in.
1362 : The name for this type. Must be shorter than NF90\_MAX\_NAME.
1366 : The size of each opaque object.
1370 : Pointer where the new typeid for this type is returned. Use this
1371 typeid when defining variables of this type with [Create a Variable:
1372 `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR).
1392 : An error was reported by the HDF5 layer.
1398 ## 5.8.2 Learn About an Opaque Type: NF90_INQ_OPAQUE {#f90-learn-about-an-opaque-type-nf90_inq_opaque}
1402 Given a typeid, get the information about an opaque type.
1412 function nf90_inq_opaque(ncid, xtype, name, size)
1413 integer, intent(in) :: ncid
1414 integer, intent(in) :: xtype
1415 character (len = *), intent(out) :: name
1416 integer, intent(out) :: size
1417 integer :: nf90_inq_opaque
1425 : The ncid for the group containing the opaque type.
1429 : The typeid for this opaque type, as returned by NF90\_DEF\_COMPOUND,
1434 : The name of the opaque type will be copied here. It will be
1435 NF90\_MAX\_NAME bytes or less.
1439 : The size of the opaque type will be copied here.
1459 : An error was reported by the HDF5 layer.
1465 5.9 Enum Type Introduction {#f90-enum-type-introduction}
1466 =========================
1470 NetCDF-4 added support for the enum type. This is not supported in
1471 classic or 64-bit offset files.
1474 ## 5.9.1 Creating a Enum Type: NF90_DEF_ENUM {#f90-creating-a-enum-type-nf90_def_enum}
1478 Create an enum type. Provide an ncid, a name, and a base integer type.
1480 After calling this function, fill out the type with repeated calls to
1481 NF90\_INSERT\_ENUM (see section [Inserting a Field into a Enum Type:
1482 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)). Call NF90\_INSERT\_ENUM
1483 once for each value you wish to make part of the enumeration.
1493 function nf90_def_enum(ncid, base_typeid, name, typeid)
1494 integer, intent(in) :: ncid
1495 integer, intent(in) :: base_typeid
1496 character (len = *), intent(in) :: name
1497 integer, intent(out) :: typeid
1498 integer :: nf90_def_enum
1506 : The groupid where this compound type will be created.
1510 : The base integer type for this enum. Must be one of: NF90\_BYTE,
1511 NF90\_UBYTE, NF90\_SHORT, NF90\_USHORT, NF90\_INT, NF90\_UINT,
1512 NF90\_INT64, NF90\_UINT64.
1516 : The name of the new enum type.
1520 : The typeid of the new type will be placed here.
1536 : That name is in use. Compound type names must be unique in the
1541 : Name exceeds max length NF90\_MAX\_NAME.
1545 : Name contains illegal characters.
1549 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
1550 operations can only be performed on files defined with a create mode
1551 which includes flag NF90\_NETCDF4. (see section
1552 [NF90\_OPEN](#NF90_005fOPEN)).
1556 : This file was created with the strict netcdf-3 flag, therefore
1557 netcdf-4 operations are not allowed. (see section
1558 [NF90\_OPEN](#NF90_005fOPEN)).
1562 : An error was reported by the HDF5 layer.
1566 : Attempt to write to a read-only file.
1570 : Not in define mode.
1578 ## 5.9.2 Inserting a Field into a Enum Type: NF90_INSERT_ENUM {#f90-inserting-a-field-into-a-enum-type-nf90_insert_enum}
1582 Insert a named member into a enum type.
1592 function nf90_insert_enum(ncid, xtype, name, value)
1593 integer, intent(in) :: ncid
1594 integer, intent(in) :: xtype
1595 character (len = *), intent(in) :: name
1596 integer, intent(in) :: value
1597 integer :: nf90_insert_enum
1605 : The ncid of the group which contains the type.
1609 : The typeid for this enum type, as returned by nf90\_def\_enum,
1614 : The identifier of the new member.
1618 : The value that is to be associated with this member.
1634 : That name is in use. Field names must be unique within a enum type.
1638 : Name exceed max length NF90\_MAX\_NAME.
1642 : Name contains illegal characters.
1646 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
1647 operations can only be performed on files defined with a create mode
1648 which includes flag NF90\_NETCDF4. (see section
1649 [NF90\_OPEN](#NF90_005fOPEN)).
1653 : This file was created with the strict netcdf-3 flag, therefore
1654 netcdf-4 operations are not allowed. (see section
1655 [NF90\_OPEN](#NF90_005fOPEN)).
1659 : An error was reported by the HDF5 layer.
1663 : Not in define mode.
1669 ## 5.9.3 Learn About a Enum Type: NF90_INQ_ENUM {#f90-learn-about-a-enum-type-nf90_inq_enum}
1673 Get information about a user-defined enumeration type.
1683 function nf90_inq_enum(ncid, xtype, name, base_nc_type, base_size, num_members)
1684 integer, intent(in) :: ncid
1685 integer, intent(in) :: xtype
1686 character (len = *), intent(out) :: name
1687 integer, intent(out) :: base_nc_type
1688 integer, intent(out) :: base_size
1689 integer, intent(out) :: num_members
1690 integer :: nf90_inq_enum
1698 : The group ID of the group which holds the enum type.
1702 : The typeid for this enum type, as returned by NF90\_DEF\_ENUM,
1707 : Character array which will get the name. It will have a maximum
1708 length of NF90\_MAX\_NAME.
1712 : An integer which will get the base integer type of this enum.
1716 : An integer which will get the size (in bytes) of the base integer
1721 : An integer which will get the number of members defined for this
1738 : An error was reported by the HDF5 layer.
1745 ## 5.9.4 Learn the Name of a Enum Type: nf90_inq_enum_member {#f90-learn-the-name-of-a-enum-type-nf90_inq_enum_member}
1749 Get information about a member of an enum type.
1759 function nf90_inq_enum_member(ncid, xtype, idx, name, value)
1760 integer, intent(in) :: ncid
1761 integer, intent(in) :: xtype
1762 integer, intent(in) :: idx
1763 character (len = *), intent(out) :: name
1764 integer, intent(in) :: value
1765 integer :: nf90_inq_enum_member
1773 : The groupid where this enum type exists.
1777 : The typeid for this enum type.
1781 : The one-based index number for the member of interest.
1785 : A character array which will get the name of the member. It will
1786 have a maximum length of NF90\_MAX\_NAME.
1790 : An integer that will get the value associated with this member.
1806 : An error was reported by the HDF5 layer.
1814 ## 5.9.5 Learn the Name of a Enum Type: NF90_INQ_ENUM_IDENT {#f90-learn-the-name-of-a-enum-type-nf90_inq_enum_ident}
1818 Get the name which is associated with an enum member value.
1820 This is similar to NF90\_INQ\_ENUM\_MEMBER, but instead of using the
1821 index of the member, you use the value of the member.
1831 function nf90_inq_enum_ident(ncid, xtype, value, idx)
1832 integer, intent(in) :: ncid
1833 integer, intent(in) :: xtype
1834 integer, intent(in) :: value
1835 integer, intent(out) :: idx
1836 integer :: nf90_inq_enum_ident
1844 : The groupid where this enum type exists.
1848 : The typeid for this enum type.
1852 : The value for which an identifier is sought.
1856 : A character array that will get the identifier. It will have a
1857 maximum length of NF90\_MAX\_NAME.
1870 : Bad type id, or not an enum type.
1874 : An error was reported by the HDF5 layer.
1878 : The value was not found in the enum.
integer function nf90_inq_user_type(ncid, xtype, name, size, base_typeid, nfields, class)
integer function nf90_inq_typeids(ncid, ntypes, typeids)
integer function nf90_inq_type(ncid, xtype, name, size)
integer function nf90_inq_typeid(ncid, name, typeid)