NetCDF-Fortran  4.4.4
netcdf-f90-sec5-user_defined_types.md
Go to the documentation of this file.
1 5 User Defined Data Types {#f90-user-defined-data-types}
2 =========================
3 
4 5.1 User Defined Types Introduction {#f90-user-defined-types-introduction}
5 =========================
6 
7 [TOC]
8 
9 NetCDF-4 has added support for four different user defined data types.
10 
11 `compound type`
12 
13 : Like a C struct, a compound type is a collection of types, including
14  other user defined types, in one package.
15 
16 `variable length array type`
17 
18 : The variable length array may be used to store ragged arrays.
19 
20 `opaque type`
21 
22 : This type has only a size per element, and no other
23  type information.
24 
25 `enum type`
26 
27 : Like an enumeration in C, this type lets you assign text values to
28  integer values, and store the integer values.
29 
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.
33 
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)).
38 
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)).
43 
44 
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 =========================
47 
48 
49 
50 Learn the number of types defined in a group, and their IDs.
51 
52 
53 
54 ## Usage
55 
56 
57 
58 ~~~~.fortran
59 
60  function nf90_inq_typeids(ncid, ntypes, typeids)
61  integer, intent(in) :: ncid
62  integer, intent(out) :: ntypes
63  integer, intent(out) :: typeids
64  integer :: nf90_inq_typeids
65 
66 
67 
68 ~~~~
69 
70 `NCID`
71 
72 : The group id.
73 
74 `NTYPES`
75 
76 : A pointer to int which will get the number of types defined in
77  the group. If NULL, ignored.
78 
79 `TYPEIDS`
80 
81 : A pointer to an int array which will get the typeids. If
82  NULL, ignored.
83 
84 
85 
86 ## Errors
87 
88 `NF90_NOERR`
89 
90 : No error.
91 
92 `NF90_BADID`
93 
94 : Bad ncid.
95 
96 
97 
98 ## Example
99 
100 
101 5.3 Find a Typeid from Group and Name: nf90_inq_typeid {#f90-find-a-typeid-from-group-and-name-nf90_inq_typeid}
102 =========================
103 
104 
105 
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.
109 
110 
111 
112 ## Usage
113 
114 
115 
116 
117 ~~~~.fortran
118 int nf90_inq_typeid(int ncid, char *name, nf90_type *typeidp);
119 
120 
121 ~~~~
122 
123 
124 `ncid`
125 
126 : The group id.
127 
128 `name`
129 
130 : The name of a type.
131 
132 `typeidp`
133 
134 : The typeid, if found.
135 
136 
137 
138 ### Errors
139 
140 `NF90_NOERR`
141 
142 : No error.
143 
144 `NF90_EBADID`
145 
146 : Bad ncid.
147 
148 `NF90_EBADTYPE`
149 
150 : Can’t find type.
151 
152 
153 
154 ## Example
155 
156 
157 5.4 Learn About a User Defined Type: NF90_INQ_TYPE {#f90-learn-about-a-user-defined-type-nf90_inq_type}
158 =========================
159 
160 
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.
164 
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).
167 
168 
169 
170 ## Usage
171 
172 ~~~~.fortran
173 
174 
175 
176  function nf90_inq_type(ncid, xtype, name, size)
177  integer, intent(in) :: ncid
178  integer, intent(in) :: xtype
179  character (len = *), intent(out) :: name
180  integer, intent(out) :: size
181  integer :: nf90_inq_type
182 
183 
184 
185 ~~~~
186 
187 `NCID`
188 
189 : The ncid for the group containing the type (ignored for
190  atomic types).
191 
192 `XTYPE`
193 
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.).
198 
199 `NAME`
200 
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
203  CDL will be given.
204 
205 `SIZEP`
206 
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.
210 
211 
212 
213 ## Return Codes
214 
215 
216 `NF90_NOERR`
217 
218 : No error.
219 
220 `NF90_EBADTYPEID`
221 
222 : Bad typeid.
223 
224 `NF90_ENOTNC4`
225 
226 : Seeking a user-defined type in a netCDF-3 file.
227 
228 `NF90_ESTRICTNC3`
229 
230 : Seeking a user-defined type in a netCDF-4 file for which classic
231  model has been turned on.
232 
233 `NF90_EBADGRPID`
234 
235 : Bad group ID in ncid.
236 
237 `NF90_EBADID`
238 
239 : Type ID not found.
240 
241 `NF90_EHDFERR`
242 
243 : An error was reported by the HDF5 layer.
244 
245 
246 
247 ## Example
248 
249 
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 =========================
252 
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.
256 
257 
258 
259 ## Usage
260 
261 
262 
263 ~~~~.fortran
264 
265  function nf90_inq_user_type(ncid, xtype, name, size, base_typeid, nfields, class)
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
273  integer :: nf90_inq_user_type
274 ~~~~
275 
276 `NCID`
277 
278 : The ncid for the group containing the user defined type.
279 
280 `XTYPE`
281 
282 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
283  NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN,
284  or NF90\_INQ\_VAR.
285 
286 `NAME`
287 
288 : The name of the user defined type will be copied here. It will be
289  NF90\_MAX\_NAME bytes or less.
290 
291 `SIZE`
292 
293 : The (in-memory) size of the user defined type will be copied here.
294 
295 `BASE_NF90_TYPE`
296 
297 : The base typeid will be copied here for vlen and enum types.
298 
299 `NFIELDS`
300 
301 : The number of fields will be copied here for enum and
302  compound types.
303 
304 `CLASS`
305 
306 : The class of the user defined type, NF90\_VLEN, NF90\_OPAQUE,
307  NF90\_ENUM, or NF90\_COMPOUND, will be copied here.
308 
309 
310 
311 ## Errors
312 
313 `NF90_NOERR`
314 
315 : No error.
316 
317 `NF90_EBADTYPEID`
318 
319 : Bad typeid.
320 
321 `NF90_EBADFIELDID`
322 
323 : Bad fieldid.
324 
325 `NF90_EHDFERR`
326 
327 : An error was reported by the HDF5 layer.
328 
329 
330 
331 ## Example
332 
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}
334 
335 
336 
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.
339 
340 
341 
342 ### Usage
343 
344 
345 ~~~~.fortran
346 
347 
348 INTEGER FUNCTION NF90_PUT_VLEN_ELEMENT(INTEGER NCID, INTEGER XTYPE,
349  CHARACTER*(*) VLEN_ELEMENT, INTEGER LEN, DATA)
350 
351 
352 
353 ~~~~
354 
355 `NCID`
356 
357 : The ncid of the file that contains the VLEN type.
358 
359 `XTYPE`
360 
361 : The type of the VLEN.
362 
363 `VLEN_ELEMENT`
364 
365 : The VLEN element to be set.
366 
367 `LEN`
368 
369 : The number of entries in this array.
370 
371 `DATA`
372 
373 : The data to be stored. Must match the base type of this VLEN.
374 
375 
376 
377 ### Errors
378 
379 `NF90_NOERR`
380 
381 : No error.
382 
383 `NF90_EBADTYPE`
384 
385 : Can’t find the typeid.
386 
387 `NF90_EBADID`
388 
389 : ncid invalid.
390 
391 `NF90_EBADGRPID`
392 
393 : Group ID part of ncid was invalid.
394 
395 
396 
397 ### Example
398 
399 This example is from nf90\_test/ftst\_vars4.F.
400 
401 
402 
403 ~~~~.fortran
404 
405 C Set up the vlen with this helper function, since F90 can't deal
406 C with pointers.
407  retval = nf90_put_vlen_element(ncid, vlen_typeid, vlen,
408  & vlen_len, data1)
409  if (retval .ne. nf90_noerr) call handle_err(retval)
410 
411 
412 
413 ~~~~
414 
415 
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}
417 
418 
419 
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.
422 
423 
424 
425 ### Usage
426 
427 
428 
429 ~~~~.fortran
430 
431 INTEGER FUNCTION NF90_GET_VLEN_ELEMENT(INTEGER NCID, INTEGER XTYPE,
432  CHARACTER*(*) VLEN_ELEMENT, INTEGER LEN, DATA)
433 
434 
435 ~~~~
436 
437 
438 `NCID`
439 
440 : The ncid of the file that contains the VLEN type.
441 
442 `XTYPE`
443 
444 : The type of the VLEN.
445 
446 `VLEN_ELEMENT`
447 
448 : The VLEN element to be set.
449 
450 `LEN`
451 
452 : This will be set to the number of entries in this array.
453 
454 `DATA`
455 
456 : The data will be copied here. Sufficient storage must be available
457  or bad things will happen to you.
458 
459 
460 
461 ### Errors
462 
463 `NF90_NOERR`
464 
465 : No error.
466 
467 `NF90_EBADTYPE`
468 
469 : Can’t find the typeid.
470 
471 `NF90_EBADID`
472 
473 : ncid invalid.
474 
475 `NF90_EBADGRPID`
476 
477 : Group ID part of ncid was invalid.
478 
479 
480 
481 ### Example
482 
483 
484 5.6 Compound Types Introduction {#f90-compound-types-introduction}
485 =========================
486 
487 
488 
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.
491 
492 Compound types are not supported in classic or 64-bit offset format
493 files.
494 
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.
499 
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.
502 
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.
506 
507 The use of compound types introduces challenges and portability issues
508 for Fortran users.
509 
510 ## 5.6.1 Creating a Compound Type: NF90_DEF_COMPOUND {#f90-creating-a-compound-type-nf90_def_compound}
511 
512 
513 
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.
516 
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
521 compound type.
522 
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
527 Wyoming.
528 
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.
532 
533 ### Usage
534 
535 
536 
537 ~~~~.fortran
538 
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
545 
546 ~~~~
547 
548 
549 
550 `NCID`
551 
552 : The groupid where this compound type will be created.
553 
554 `SIZE`
555 
556 : The size, in bytes, of the compound type.
557 
558 `NAME`
559 
560 : The name of the new compound type.
561 
562 `TYPEIDP`
563 
564 : The typeid of the new type will be placed here.
565 
566 
567 
568 ### Errors
569 
570 `NF90_NOERR`
571 
572 : No error.
573 
574 `NF90_EBADID`
575 
576 : Bad group id.
577 
578 `NF90_ENAMEINUSE`
579 
580 : That name is in use. Compound type names must be unique in the
581  data file.
582 
583 `NF90_EMAXNAME`
584 
585 : Name exceeds max length NF90\_MAX\_NAME.
586 
587 `NF90_EBADNAME`
588 
589 : Name contains illegal characters.
590 
591 `NF90_ENOTNC4`
592 
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)).
597 
598 `NF90_ESTRICTNC3`
599 
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)).
603 
604 `NF90_EHDFERR`
605 
606 : An error was reported by the HDF5 layer.
607 
608 `NF90_EPERM`
609 
610 : Attempt to write to a read-only file.
611 
612 `NF90_ENOTINDEFINE`
613 
614 : Not in define mode.
615 
616 
617 
618 ### Example
619 
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}
621 
622 
623 
624 Insert a named field into a compound type.
625 
626 
627 
628 ### Usage
629 
630 
631 
632 ~~~~.fortran
633 
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
641 
642 
643 ~~~~
644 
645 
646 `TYPEID`
647 
648 : The typeid for this compound type, as returned by
649  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
650 
651 `NAME`
652 
653 : The name of the new field.
654 
655 `OFFSET`
656 
657 : Offset in byte from the beginning of the compound type for
658  this field.
659 
660 `FIELD_TYPEID`
661 
662 : The type of the field to be inserted.
663 
664 
665 
666 ### Errors
667 
668 `NF90_NOERR`
669 
670 : No error.
671 
672 `NF90_EBADID`
673 
674 : Bad group id.
675 
676 `NF90_ENAMEINUSE`
677 
678 : That name is in use. Field names must be unique within a
679  compound type.
680 
681 `NF90_EMAXNAME`
682 
683 : Name exceed max length NF90\_MAX\_NAME.
684 
685 `NF90_EBADNAME`
686 
687 : Name contains illegal characters.
688 
689 `NF90_ENOTNC4`
690 
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)).
695 
696 `NF90_ESTRICTNC3`
697 
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)).
701 
702 `NF90_EHDFERR`
703 
704 : An error was reported by the HDF5 layer.
705 
706 `NF90_ENOTINDEFINE`
707 
708 : Not in define mode.
709 
710 
711 
712 ### Example
713 
714 
715 
716 
717 
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}
719 
720 
721 
722 Insert a named array field into a compound type.
723 
724 
725 
726 ### Usage
727 
728 
729 
730 ~~~~.fortran
731 
732  function nf90_insert_array_compound(ncid, xtype, name, offset, field_typeid, &
733  ndims, dim_sizes)
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
742 
743 
744 
745 ~~~~
746 
747 `NCID`
748 
749 : The ID of the file that contains the array type and the
750  compound type.
751 
752 `XTYPE`
753 
754 : The typeid for this compound type, as returned by
755  nf90\_def\_compound, or nf90\_inq\_var.
756 
757 `NAME`
758 
759 : The name of the new field.
760 
761 `OFFSET`
762 
763 : Offset in byte from the beginning of the compound type for
764  this field.
765 
766 `FIELD_TYPEID`
767 
768 : The base type of the array to be inserted.
769 
770 `NDIMS`
771 
772 : The number of dimensions for the array to be inserted.
773 
774 `DIM_SIZES`
775 
776 : An array containing the sizes of each dimension.
777 
778 
779 
780 ### Errors
781 
782 `NF90_NOERR`
783 
784 : No error.
785 
786 `NF90_EBADID`
787 
788 : Bad group id.
789 
790 `NF90_ENAMEINUSE`
791 
792 : That name is in use. Field names must be unique within a
793  compound type.
794 
795 `NF90_EMAXNAME`
796 
797 : Name exceed max length NF90\_MAX\_NAME.
798 
799 `NF90_EBADNAME`
800 
801 : Name contains illegal characters.
802 
803 `NF90_ENOTNC4`
804 
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)).
809 
810 `NF90_ESTRICTNC3`
811 
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)).
815 
816 `NF90_EHDFERR`
817 
818 : An error was reported by the HDF5 layer.
819 
820 `NF90_ENOTINDEFINE`
821 
822 : Not in define mode.
823 
824 `NF90_ETYPEDEFINED`
825 
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.
830 
831 
832 
833 ### Example
834 
835 ## 5.6.4 Learn About a Compound Type: NF90_INQ_COMPOUND {#f90-learn-about-a-compound-type-nf90_inq_compound}
836 
837 
838 
839 Get the number of fields, length in bytes, and name of a compound type.
840 
841 In addtion to the NF90\_INQ\_COMPOUND function, three additional
842 functions are provided which get only the name, size, and number of
843 fields.
844 
845 
846 
847 ### Usage
848 
849 
850 ~~~~.fortran
851 
852 
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
860 
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
866 
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
872 
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
878 
879 
880 
881 ~~~~
882 
883 `NCID`
884 
885 : The ID of any group in the file that contains the compound type.
886 
887 `XTYPE`
888 
889 : The typeid for this compound type, as returned by
890  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
891 
892 `NAME`
893 
894 : Character array which will get the name of the compound type. It
895  will have a maximum length of NF90\_MAX\_NAME.
896 
897 `SIZEP`
898 
899 : The size of the compound type in bytes will be put here.
900 
901 `NFIELDSP`
902 
903 : The number of fields in the compound type will be placed here.
904 
905 
906 
907 ### Return Codes
908 
909 `NF90_NOERR`
910 
911 : No error.
912 
913 `NF90_EBADID`
914 
915 : Couldn’t find this ncid.
916 
917 `NF90_ENOTNC4`
918 
919 : Not a netCDF-4/HDF5 file.
920 
921 `NF90_ESTRICTNC3`
922 
923 : A netCDF-4/HDF5 file, but with CLASSIC\_MODEL. No user defined types
924  are allowed in the classic model.
925 
926 `NF90_EBADTYPE`
927 
928 : This type not a compound type.
929 
930 `NF90_EBADTYPEID`
931 
932 : Bad type id.
933 
934 `NF90_EHDFERR`
935 
936 : An error was reported by the HDF5 layer.
937 
938 
939 
940 ### Example
941 
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}
943 
944 
945 
946 Get information about one of the fields of a compound type.
947 
948 
949 
950 ### Usage
951 
952 
953 ~~~~.fortran
954 
955 
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
967 
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
974 
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
981 
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
988 
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
995 
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
1002 
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
1009 
1010 
1011 ~~~~
1012 
1013 
1014 `NCID`
1015 
1016 : The groupid where this compound type exists.
1017 
1018 `XTYPE`
1019 
1020 : The typeid for this compound type, as returned by
1021  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
1022 
1023 `FIELDID`
1024 
1025 : A one-based index number specifying a field in the compound type.
1026 
1027 `NAME`
1028 
1029 : A character array which will get the name of the field. The name
1030  will be NF90\_MAX\_NAME characters, at most.
1031 
1032 `OFFSETP`
1033 
1034 : An integer which will get the offset of the field.
1035 
1036 `FIELD_TYPEID`
1037 
1038 : An integer which will get the typeid of the field.
1039 
1040 `NDIMSP`
1041 
1042 : An integer which will get the number of dimensions of the field.
1043 
1044 `DIM_SIZESP`
1045 
1046 : An integer array which will get the dimension sizes of the field.
1047 
1048 
1049 
1050 ### Errors
1051 
1052 `NF90_NOERR`
1053 
1054 : No error.
1055 
1056 `NF90_EBADTYPEID`
1057 
1058 : Bad type id.
1059 
1060 `NF90_EHDFERR`
1061 
1062 : An error was reported by the HDF5 layer.
1063 
1064 
1065 
1066 ### Example
1067 
1068 5.7 Variable Length Array Introduction {#f90-variable-length-array-introduction}
1069 =========================
1070 
1071 
1072 
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.
1076 
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.
1080 
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
1083 for the platform.
1084 
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.
1089 
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
1093 each VLEN.
1094 
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.
1098 
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
1101 the actual data.
1102 
1103 ## 5.7.1 Define a Variable Length Array (VLEN): NF90_DEF_VLEN {#f90-define-a-variable-length-array-vlen-nf90_def_vlen}
1104 
1105 
1106 
1107 Use this function to define a variable length array type.
1108 
1109 
1110 
1111 ### Usage
1112 
1113 
1114 ~~~~.fortran
1115 
1116 
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
1123 
1124 
1125 ~~~~
1126 
1127 
1128 `NCID`
1129 
1130 : The ncid of the file to create the VLEN type in.
1131 
1132 `NAME`
1133 
1134 : A name for the VLEN type.
1135 
1136 `BASE_TYPEID`
1137 
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
1140  defined type.
1141 
1142 `XTYPEP`
1143 
1144 : The typeid of the new VLEN type will be set here.
1145 
1146 
1147 
1148 ### Errors
1149 
1150 `NF90_NOERR`
1151 
1152 : No error.
1153 
1154 `NF90_EMAXNAME`
1155 
1156 : NF90\_MAX\_NAME exceeded.
1157 
1158 `NF90_ENAMEINUSE`
1159 
1160 : Name is already in use.
1161 
1162 `NF90_EBADNAME`
1163 
1164 : Attribute or variable name contains illegal characters.
1165 
1166 `NF90_EBADID`
1167 
1168 : ncid invalid.
1169 
1170 `NF90_EBADGRPID`
1171 
1172 : Group ID part of ncid was invalid.
1173 
1174 `NF90_EINVAL`
1175 
1176 : Size is invalid.
1177 
1178 `NF90_ENOMEM`
1179 
1180 : Out of memory.
1181 
1182 
1183 
1184 ### Example
1185 
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}
1187 
1188 
1189 
1190 Use this type to learn about a vlen.
1191 
1192 
1193 
1194 ### Usage
1195 
1196 
1197 ~~~~.fortran
1198 
1199 
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
1207 
1208 
1209 ~~~~
1210 
1211 
1212 `NCID`
1213 
1214 : The ncid of the file that contains the VLEN type.
1215 
1216 `XTYPE`
1217 
1218 : The type of the VLEN to inquire about.
1219 
1220 `NAME`
1221 
1222 : The name of the VLEN type. The name will be NF90\_MAX\_NAME
1223  characters or less.
1224 
1225 `DATUM_SIZEP`
1226 
1227 : A pointer to a size\_t, this will get the size of one element of
1228  this vlen.
1229 
1230 `BASE_NF90_TYPEP`
1231 
1232 : An integer that will get the type of the VLEN base type. (In other
1233  words, what type is this a VLEN of?)
1234 
1235 
1236 
1237 #### Errors
1238 
1239 `NF90_NOERR`
1240 
1241 : No error.
1242 
1243 `NF90_EBADTYPE`
1244 
1245 : Can’t find the typeid.
1246 
1247 `NF90_EBADID`
1248 
1249 : ncid invalid.
1250 
1251 `NF90_EBADGRPID`
1252 
1253 : Group ID part of ncid was invalid.
1254 
1255 
1256 
1257 ### Example
1258 
1259 
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}
1261 
1262 
1263 
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.
1268 
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.
1273 
1274 
1275 
1276 ### Usage
1277 
1278 
1279 ~~~~.fortran
1280 
1281 
1282  function nf90_free_vlen(vl)
1283  character (len = *), intent(in) :: vlen
1284  integer :: nf90_free_vlen
1285  end function nf90_free_vlen
1286 
1287 
1288 ~~~~
1289 
1290 
1291 `VL`
1292 
1293 : The variable length array structure which is to be freed.
1294 
1295 
1296 
1297 ### Errors
1298 
1299 `NF90_NOERR`
1300 
1301 : No error.
1302 
1303 `NF90_EBADTYPE`
1304 
1305 : Can’t find the typeid.
1306 
1307 
1308 
1309 ### Example
1310 
1311 
1312 5.8 Opaque Type Introduction {#f90-opaque-type-introduction}
1313 =========================
1314 
1315 
1316 
1317 NetCDF-4 added support for the opaque type. This is not supported in
1318 classic or 64-bit offset files.
1319 
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.
1324 
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.
1329 
1330 ## 5.8.1 Creating Opaque Types: NF90_DEF_OPAQUE {#f90-creating-opaque-types-nf90_def_opaque}
1331 
1332 
1333 
1334 Create an opaque type. Provide a size and a name.
1335 
1336 
1337 
1338 ### Usage
1339 
1340 
1341 
1342 ~~~~.fortran
1343 
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
1350 
1351 
1352 ~~~~
1353 
1354 
1355 `NCID`
1356 
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.
1359 
1360 `NAME`
1361 
1362 : The name for this type. Must be shorter than NF90\_MAX\_NAME.
1363 
1364 `SIZE`
1365 
1366 : The size of each opaque object.
1367 
1368 `TYPEIDP`
1369 
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).
1373 
1374 
1375 
1376 ### Errors
1377 
1378 `NF90_NOERR`
1379 
1380 : No error.
1381 
1382 `NF90_EBADTYPEID`
1383 
1384 : Bad typeid.
1385 
1386 `NF90_EBADFIELDID`
1387 
1388 : Bad fieldid.
1389 
1390 `NF90_EHDFERR`
1391 
1392 : An error was reported by the HDF5 layer.
1393 
1394 
1395 
1396 ### Example
1397 
1398 ## 5.8.2 Learn About an Opaque Type: NF90_INQ_OPAQUE {#f90-learn-about-an-opaque-type-nf90_inq_opaque}
1399 
1400 
1401 
1402 Given a typeid, get the information about an opaque type.
1403 
1404 
1405 
1406 ### Usage
1407 
1408 
1409 
1410 ~~~~.fortran
1411 
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
1418 
1419 
1420 
1421 ~~~~
1422 
1423 `NCID`
1424 
1425 : The ncid for the group containing the opaque type.
1426 
1427 `XTYPE`
1428 
1429 : The typeid for this opaque type, as returned by NF90\_DEF\_COMPOUND,
1430  or NF90\_INQ\_VAR.
1431 
1432 `NAME`
1433 
1434 : The name of the opaque type will be copied here. It will be
1435  NF90\_MAX\_NAME bytes or less.
1436 
1437 `SIZEP`
1438 
1439 : The size of the opaque type will be copied here.
1440 
1441 
1442 
1443 ### Errors
1444 
1445 `NF90_NOERR`
1446 
1447 : No error.
1448 
1449 `NF90_EBADTYPEID`
1450 
1451 : Bad typeid.
1452 
1453 `NF90_EBADFIELDID`
1454 
1455 : Bad fieldid.
1456 
1457 `NF90_EHDFERR`
1458 
1459 : An error was reported by the HDF5 layer.
1460 
1461 
1462 
1463 ### Example
1464 
1465 5.9 Enum Type Introduction {#f90-enum-type-introduction}
1466 =========================
1467 
1468 
1469 
1470 NetCDF-4 added support for the enum type. This is not supported in
1471 classic or 64-bit offset files.
1472 
1473 
1474 ## 5.9.1 Creating a Enum Type: NF90_DEF_ENUM {#f90-creating-a-enum-type-nf90_def_enum}
1475 
1476 
1477 
1478 Create an enum type. Provide an ncid, a name, and a base integer type.
1479 
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.
1484 
1485 
1486 
1487 ### Usage
1488 
1489 
1490 
1491 ~~~~.fortran
1492 
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
1499 
1500 
1501 ~~~~
1502 
1503 
1504 `NCID`
1505 
1506 : The groupid where this compound type will be created.
1507 
1508 `BASE_TYPEID`
1509 
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.
1513 
1514 `NAME`
1515 
1516 : The name of the new enum type.
1517 
1518 `TYPEIDP`
1519 
1520 : The typeid of the new type will be placed here.
1521 
1522 
1523 
1524 ### Errors
1525 
1526 `NF90_NOERR`
1527 
1528 : No error.
1529 
1530 `NF90_EBADID`
1531 
1532 : Bad group id.
1533 
1534 `NF90_ENAMEINUSE`
1535 
1536 : That name is in use. Compound type names must be unique in the
1537  data file.
1538 
1539 `NF90_EMAXNAME`
1540 
1541 : Name exceeds max length NF90\_MAX\_NAME.
1542 
1543 `NF90_EBADNAME`
1544 
1545 : Name contains illegal characters.
1546 
1547 `NF90_ENOTNC4`
1548 
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)).
1553 
1554 `NF90_ESTRICTNC3`
1555 
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)).
1559 
1560 `NF90_EHDFERR`
1561 
1562 : An error was reported by the HDF5 layer.
1563 
1564 `NF90_EPERM`
1565 
1566 : Attempt to write to a read-only file.
1567 
1568 `NF90_ENOTINDEFINE`
1569 
1570 : Not in define mode.
1571 
1572 
1573 
1574 ### Example
1575 
1576 
1577 
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}
1579 
1580 
1581 
1582 Insert a named member into a enum type.
1583 
1584 
1585 
1586 ### Usage
1587 
1588 
1589 
1590 ~~~~.fortran
1591 
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
1598 
1599 
1600 ~~~~
1601 
1602 
1603 `NCID`
1604 
1605 : The ncid of the group which contains the type.
1606 
1607 `TYPEID`
1608 
1609 : The typeid for this enum type, as returned by nf90\_def\_enum,
1610  or nf90\_inq\_var.
1611 
1612 `IDENTIFIER`
1613 
1614 : The identifier of the new member.
1615 
1616 `VALUE`
1617 
1618 : The value that is to be associated with this member.
1619 
1620 
1621 
1622 ### Errors
1623 
1624 `NF90_NOERR`
1625 
1626 : No error.
1627 
1628 `NF90_EBADID`
1629 
1630 : Bad group id.
1631 
1632 `NF90_ENAMEINUSE`
1633 
1634 : That name is in use. Field names must be unique within a enum type.
1635 
1636 `NF90_EMAXNAME`
1637 
1638 : Name exceed max length NF90\_MAX\_NAME.
1639 
1640 `NF90_EBADNAME`
1641 
1642 : Name contains illegal characters.
1643 
1644 `NF90_ENOTNC4`
1645 
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)).
1650 
1651 `NF90_ESTRICTNC3`
1652 
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)).
1656 
1657 `NF90_EHDFERR`
1658 
1659 : An error was reported by the HDF5 layer.
1660 
1661 `NF90_ENOTINDEFINE`
1662 
1663 : Not in define mode.
1664 
1665 
1666 
1667 ### Example
1668 
1669 ## 5.9.3 Learn About a Enum Type: NF90_INQ_ENUM {#f90-learn-about-a-enum-type-nf90_inq_enum}
1670 
1671 
1672 
1673 Get information about a user-defined enumeration type.
1674 
1675 
1676 
1677 ### Usage
1678 
1679 
1680 ~~~~.fortran
1681 
1682 
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
1691 
1692 
1693 
1694 ~~~~
1695 
1696 `NCID`
1697 
1698 : The group ID of the group which holds the enum type.
1699 
1700 `XTYPE`
1701 
1702 : The typeid for this enum type, as returned by NF90\_DEF\_ENUM,
1703  or NF90\_INQ\_VAR.
1704 
1705 `NAME`
1706 
1707 : Character array which will get the name. It will have a maximum
1708  length of NF90\_MAX\_NAME.
1709 
1710 `BASE_NF90_TYPE`
1711 
1712 : An integer which will get the base integer type of this enum.
1713 
1714 `BASE_SIZE`
1715 
1716 : An integer which will get the size (in bytes) of the base integer
1717  type of this enum.
1718 
1719 `NUM_MEMBERS`
1720 
1721 : An integer which will get the number of members defined for this
1722  enumeration type.
1723 
1724 
1725 
1726 ### Errors
1727 
1728 `NF90_NOERR`
1729 
1730 : No error.
1731 
1732 `NF90_EBADTYPEID`
1733 
1734 : Bad type id.
1735 
1736 `NF90_EHDFERR`
1737 
1738 : An error was reported by the HDF5 layer.
1739 
1740 
1741 
1742 ### Example
1743 
1744 
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}
1746 
1747 
1748 
1749 Get information about a member of an enum type.
1750 
1751 
1752 
1753 ### Usage
1754 
1755 
1756 
1757 
1758 ~~~~.fortran
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
1766 
1767 ~~~~
1768 
1769 
1770 
1771 `NCID`
1772 
1773 : The groupid where this enum type exists.
1774 
1775 `XTYPE`
1776 
1777 : The typeid for this enum type.
1778 
1779 `IDX`
1780 
1781 : The one-based index number for the member of interest.
1782 
1783 `NAME`
1784 
1785 : A character array which will get the name of the member. It will
1786  have a maximum length of NF90\_MAX\_NAME.
1787 
1788 `VALUE`
1789 
1790 : An integer that will get the value associated with this member.
1791 
1792 
1793 
1794 ### Errors
1795 
1796 `NF90_NOERR`
1797 
1798 : No error.
1799 
1800 `NF90_EBADTYPEID`
1801 
1802 : Bad type id.
1803 
1804 `NF90_EHDFERR`
1805 
1806 : An error was reported by the HDF5 layer.
1807 
1808 
1809 
1810 ### Example
1811 
1812 
1813 
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}
1815 
1816 
1817 
1818 Get the name which is associated with an enum member value.
1819 
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.
1822 
1823 
1824 
1825 ### Usage
1826 
1827 
1828 
1829 ~~~~.fortran
1830 
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
1837 
1838 
1839 ~~~~
1840 
1841 
1842 `NCID`
1843 
1844 : The groupid where this enum type exists.
1845 
1846 `XTYPE`
1847 
1848 : The typeid for this enum type.
1849 
1850 `VALUE`
1851 
1852 : The value for which an identifier is sought.
1853 
1854 `IDENTIFIER`
1855 
1856 : A character array that will get the identifier. It will have a
1857  maximum length of NF90\_MAX\_NAME.
1858 
1859 
1860 
1861 ### Return Code
1862 
1863 
1864 `NF90_NOERR`
1865 
1866 : No error.
1867 
1868 `NF90_EBADTYPEID`
1869 
1870 : Bad type id, or not an enum type.
1871 
1872 `NF90_EHDFERR`
1873 
1874 : An error was reported by the HDF5 layer.
1875 
1876 `NF90_EINVAL`
1877 
1878 : The value was not found in the enum.
1879 
1880 
1881 
1882 ### Example

Return to the Main Unidata NetCDF page.
Generated on Thu Nov 9 2017 06:56:52 for NetCDF-Fortran. NetCDF is a Unidata library.