1 The NetCDF Fortran 90 Interface Guide {#nc_f90_interface_guide}
2 =====================================
4 This document describes the Fortran 90 interface to the netCDF library.
5 It applies to netCDF version No value for VERSION. This document was
6 last updated in No value for UPDATED.
8 For a complete description of the netCDF format and utilities see the netCDF User's Guide.
13 — The Detailed Node Listing —
15 Use of the NetCDF Library
18 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
22 [1.2 Reading a NetCDF Dataset with Known
23 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
27 [1.3 Reading a netCDF Dataset with Unknown
28 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
32 [1.4 Writing Data in an Existing NetCDF
33 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
37 [1.5 Adding New Dimensions, Variables,
38 Attributes](#Adding-New-Dimensions)
42 [1.6 Error Handling](#Error-Handling)
46 [1.7 Compiling and Linking with the NetCDF
47 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
55 [2.1 Datasets Introduction](#Datasets-Introduction)
59 [2.2 NetCDF Library Interface
60 Descriptions](#NetCDF-Library-Interface-Descriptions)
64 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
68 [2.4 Get netCDF library version:
69 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
73 [2.5 NF90\_CREATE](#NF90_005fCREATE)
77 [2.6 NF90\_OPEN](#NF90_005fOPEN)
81 [2.7 NF90\_REDEF](#NF90_005fREDEF)
85 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
89 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
93 [2.10 NF90\_INQUIRE Family](#NF90_005fINQUIRE-Family)
97 [2.11 NF90\_SYNC](#NF90_005fSYNC)
101 [2.12 NF90\_ABORT](#NF90_005fABORT)
105 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
113 [3.1 Find a Group ID: NF90\_INQ\_NCID](#NF90_005fINQ_005fNCID)
117 [3.2 Get a List of Groups in a Group:
118 NF90\_INQ\_GRPS](#NF90_005fINQ_005fGRPS)
122 [3.3 Find all the Variables in a Group:
123 NF90\_INQ\_VARIDS](#NF90_005fINQ_005fVARIDS)
127 [3.4 Find all Dimensions Visible in a Group:
128 NF90\_INQ\_DIMIDS](#NF90_005fINQ_005fDIMIDS)
132 [3.5 Find the Length of a Group’s Full Name:
133 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN)
137 [3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME](#NF90_005fINQ_005fGRPNAME)
141 [3.7 Find a Group’s Full Name:
142 NF90\_INQ\_GRPNAME\_FULL](#NF90_005fINQ_005fGRPNAME_005fFULL)
146 [3.8 Find a Group’s Parent:
147 NF90\_INQ\_GRP\_PARENT](#NF90_005fINQ_005fGRP_005fPARENT)
151 [3.9 Find a Group by Name:
152 NF90\_INQ\_GRP\_NCID](#NF90_005fINQ_005fGRP_005fNCID)
156 [3.10 Find a Group by its Fully-qualified Name:
157 NF90\_INQ\_GRP\_FULL\_NCID](#NF90_005fINQ_005fGRP_005fFULL_005fNCID)
161 [3.11 Create a New Group: NF90\_DEF\_GRP](#NF90_005fDEF_005fGRP)
169 [4.1 Dimensions Introduction](#Dimensions-Introduction)
173 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
177 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
181 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
185 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
190 User Defined Data Types
193 [5.1 User Defined Types Introduction](#User-Defined-Types)
197 [5.2 Learn the IDs of All Types in Group:
198 NF90\_INQ\_TYPEIDS](#NF90_005fINQ_005fTYPEIDS)
202 [5.3 Find a Typeid from Group and Name:
203 nf90\_inq\_typeid](#nf90_005finq_005ftypeid)
207 [5.4 Learn About a User Defined Type:
208 NF90\_INQ\_TYPE](#NF90_005fINQ_005fTYPE)
212 [5.5 Learn About a User Defined Type:
213 NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE)
217 [5.6 Compound Types Introduction](#Compound-Types)
221 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
225 [5.8 Opaque Type Introduction](#Opaque-Type)
229 [5.9 Enum Type Introduction](#Enum-Type)
237 [5.5.1 Set a Variable Length Array with
238 NF90\_PUT\_VLEN\_ELEMENT](#NF90_005fPUT_005fVLEN_005fELEMENT)
242 [5.5.2 Set a Variable Length Array with
243 NF90\_GET\_VLEN\_ELEMENT](#NF90_005fGET_005fVLEN_005fELEMENT)
248 Compound Types Introduction
251 [5.6.1 Creating a Compound Type:
252 NF90\_DEF\_COMPOUND](#NF90_005fDEF_005fCOMPOUND)
256 [5.6.2 Inserting a Field into a Compound Type:
257 NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)
261 [5.6.3 Inserting an Array Field into a Compound Type:
262 NF90\_INSERT\_ARRAY\_COMPOUND](#NF90_005fINSERT_005fARRAY_005fCOMPOUND)
266 [5.6.4 Learn About a Compound Type:
267 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
271 [5.6.5 Learn About a Field of a Compound Type:
272 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
277 Variable Length Array Introduction
280 [5.7.1 Define a Variable Length Array (VLEN):
281 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
285 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
286 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
290 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
291 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
296 Opaque Type Introduction
299 [5.8.1 Creating Opaque Types:
300 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE)
304 [5.8.2 Learn About an Opaque Type:
305 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
313 [5.8.2 Learn About an Opaque Type:
314 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
319 Enum Type Introduction
322 [5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM](#NF90_005fDEF_005fENUM)
326 [5.9.2 Inserting a Field into a Enum Type:
327 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)
331 [5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM](#NF90_005fINQ_005fENUM)
335 [5.9.4 Learn the Name of a Enum Type:
336 nf90\_inq\_enum\_member](#NF90_005fINQ_005fENUM_005fMEMBER)
340 [5.9.5 Learn the Name of a Enum Type:
341 NF90\_INQ\_ENUM\_IDENT](#NF90_005fINQ_005fENUM_005fIDENT)
349 [6.1 Variables Introduction](#Variables-Introduction)
353 [6.2 Language Types Corresponding to netCDF external data
354 types](#Language_002dTypes)
358 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
364 [6.4 Define Fill Parameters for a Variable:
365 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
369 [6.5 Learn About Fill Parameters for a Variable:
370 `NF90_INQ_VAR_FILL`](#NF90_005fINQ_005fVAR_005fFILL)
374 [6.6 Get Information about a Variable from Its ID:
375 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
381 [6.7 Get the ID of a variable from the name:
382 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
386 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
392 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
398 [6.10 Reading and Writing Character String
399 Values](#Reading-and-Writing-Character-String-Values)
403 [6.11 Fill Values](#Fill-Values)
407 What’s Written Where there’s No Data?
409 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
413 [6.13 Change between Collective and Independent Parallel Access:
414 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
422 [7.1 Attributes Introduction](#Attributes-Introduction)
426 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
430 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
431 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
435 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
439 [7.5 Copy Attribute from One NetCDF to Another:
440 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
444 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
448 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
455 ------------------------------------------------------------------------
457 ------------------------------------------------------ ------------------------------------------------------------------------ --- ---------------------------------------------------------------------- ----------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
458 \[[<](#Top "Previous section in reading order")\] \[[>](#Creating-a-NetCDF-Dataset "Next section in reading order")\] \[[<<](#Top "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
459 ------------------------------------------------------ ------------------------------------------------------------------------ --- ---------------------------------------------------------------------- ----------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
461 1. Use of the NetCDF Library {.chapter}
462 ============================
464 You can use the netCDF library without knowing about all of the netCDF
465 interface. If you are creating a netCDF dataset, only a handful of
466 routines are required to define the necessary dimensions, variables, and
467 attributes, and to write the data to the netCDF dataset. (Even less are
468 needed if you use the ncgen utility to create the dataset before running
469 a program using netCDF library calls to write data. See
470 [(netcdf)ncgen](netcdf.html#ncgen) section ‘ncgen’ in NetCDF Users
471 Guide.) Similarly, if you are writing software to access data stored in
472 a particular netCDF object, only a small subset of the netCDF library is
473 required to open the netCDF dataset and access the data. Authors of
474 generic applications that access arbitrary netCDF datasets need to be
475 familiar with more of the netCDF library.
477 In this chapter we provide templates of common sequences of netCDF calls
478 needed for common uses. For clarity we present only the names of
479 routines; omit declarations and error checking; omit the type-specific
480 suffixes of routine names for variables and attributes; indent
481 statements that are typically invoked multiple times; and use ... to
482 represent arbitrary sequences of other statements. Full parameter lists
483 are described in later chapters.
485 ------------------------ ------------------------ ------------------------
486 [1.1 Creating a NetCDF
487 Dataset](#Creating-a-Net
490 [1.2 Reading a NetCDF
492 Names](#Reading-a-NetCDF
493 -Dataset-with-Known-Name
496 [1.3 Reading a netCDF
498 Names](#Reading-a-netCDF
499 -Dataset-with-Unknown-Na
502 [1.4 Writing Data in an
504 Dataset](#Writing-Data-i
505 n-an-Existing-NetCDF-Dat
509 Dimensions, Variables,
510 Attributes](#Adding-New-
514 Handling](#Error-Handlin
518 Linking with the NetCDF
519 Library](#Compiling-and-
520 Linking-with-the-NetCDF-
522 ------------------------ ------------------------ ------------------------
524 ------------------------------------------------------------------------
526 ---------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
527 \[[<](#Use-of-the-NetCDF-Library "Previous section in reading order")\] \[[>](#Reading-a-NetCDF-Dataset-with-Known-Names "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
528 ---------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
530 1.1 Creating a NetCDF Dataset {.section}
531 -----------------------------
533 Here is a typical sequence of netCDF calls used to create a new netCDF
536 +--------------------------------------+--------------------------------------+
538 | | NF90_CREATE ! create |
539 | | netCDF dataset: enter define mode |
541 | | NF90_DEF_DIM ! define |
542 | | dimensions: from name and length |
544 | | NF90_DEF_VAR ! define |
545 | | variables: from name, type, dims |
547 | | NF90_PUT_ATT ! assign |
548 | | attribute values |
550 | | NF90_ENDDEF ! end def |
551 | | initions: leave define mode |
553 | | NF90_PUT_VAR ! provide |
554 | | values for variable |
556 | | NF90_CLOSE ! close: |
557 | | save new netCDF dataset |
559 +--------------------------------------+--------------------------------------+
561 Only one call is needed to create a netCDF dataset, at which point you
562 will be in the first of two netCDF modes. When accessing an open netCDF
563 dataset, it is either in define mode or data mode. In define mode, you
564 can create dimensions, variables, and new attributes, but you cannot
565 read or write variable data. In data mode, you can access data and
566 change existing attributes, but you are not permitted to create new
567 dimensions, variables, or attributes.
569 One call to NF90\_DEF\_DIM is needed for each dimension created.
570 Similarly, one call to NF90\_DEF\_VAR is needed for each variable
571 creation, and one call to a member of the NF90\_PUT\_ATT family is
572 needed for each attribute defined and assigned a value. To leave define
573 mode and enter data mode, call NF90\_ENDDEF.
575 Once in data mode, you can add new data to variables, change old values,
576 and change values of existing attributes (so long as the attribute
577 changes do not require more storage space). Data of all types is written
578 to a netCDF variable using the NF90\_PUT\_VAR subroutine. Single values,
579 arrays, or array sections may be supplied to NF90\_PUT\_VAR; optional
580 arguments allow the writing of subsampled or mapped portions of the
581 variable. (Subsampled and mapped access are general forms of data access
582 that are explained later.)
584 Finally, you should explicitly close all netCDF datasets that have been
585 opened for writing by calling NF90\_CLOSE. By default, access to the
586 file system is buffered by the netCDF library. If a program terminates
587 abnormally with netCDF datasets open for writing, your most recent
588 modifications may be lost. This default buffering of data is disabled by
589 setting the NF90\_SHARE flag when opening the dataset. But even if this
590 flag is set, changes to attribute values or changes made in define mode
591 are not written out until NF90\_SYNC or NF90\_CLOSE is called.
593 ------------------------------------------------------------------------
595 ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
596 \[[<](#Creating-a-NetCDF-Dataset "Previous section in reading order")\] \[[>](#Reading-a-netCDF-Dataset-with-Unknown-Names "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
597 ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
599 1.2 Reading a NetCDF Dataset with Known Names {.section}
600 ---------------------------------------------
602 Here we consider the case where you know the names of not only the
603 netCDF datasets, but also the names of their dimensions, variables, and
604 attributes. (Otherwise you would have to do "inquire" calls.) The order
605 of typical C calls to read data from those variables in a netCDF dataset
608 +--------------------------------------+--------------------------------------+
610 | | NF90_OPEN ! open |
611 | | existing netCDF dataset |
613 | | NF90_INQ_DIMID ! get d |
616 | | NF90_INQ_VARID ! get v |
619 | | NF90_GET_ATT ! get a |
620 | | ttribute values |
622 | | NF90_GET_VAR ! get v |
623 | | alues of variables |
625 | | NF90_CLOSE ! close |
628 +--------------------------------------+--------------------------------------+
630 First, a single call opens the netCDF dataset, given the dataset name,
631 and returns a netCDF ID that is used to refer to the open netCDF dataset
632 in all subsequent calls.
634 Next, a call to NF90\_INQ\_DIMID for each dimension of interest gets the
635 dimension ID from the dimension name. Similarly, each required variable
636 ID is determined from its name by a call to NF90\_INQ\_VARID. Once
637 variable IDs are known, variable attribute values can be retrieved using
638 the netCDF ID, the variable ID, and the desired attribute name as input
639 to NF90\_GET\_ATT for each desired attribute. Variable data values can
640 be directly accessed from the netCDF dataset with calls to
643 Finally, the netCDF dataset is closed with NF90\_CLOSE. There is no need
644 to close a dataset open only for reading.
646 ------------------------------------------------------------------------
648 -------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
649 \[[<](#Reading-a-NetCDF-Dataset-with-Known-Names "Previous section in reading order")\] \[[>](#Writing-Data-in-an-Existing-NetCDF-Dataset "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
650 -------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
652 1.3 Reading a netCDF Dataset with Unknown Names {.section}
653 -----------------------------------------------
655 It is possible to write programs (e.g., generic software) which do such
656 things as processing every variable, without needing to know in advance
657 the names of these variables. Similarly, the names of dimensions and
658 attributes may be unknown.
660 Names and other information about netCDF objects may be obtained from
661 netCDF datasets by calling inquire functions. These return information
662 about a whole netCDF dataset, a dimension, a variable, or an attribute.
663 The following template illustrates how they are used:
665 +--------------------------------------+--------------------------------------+
667 | | NF90_OPEN ! ope |
668 | | n existing netCDF dataset |
670 | | NF90_INQUIRE ! fin |
671 | | d out what is in it |
673 | | NF90_INQUIRE_DIMENSION ! get |
674 | | dimension names, lengths |
676 | | NF90_INQUIRE_VARIABLE ! get |
677 | | variable names, types, shapes |
679 | | NF90_INQ_ATTNAME ! get |
680 | | attribute names |
682 | | NF90_INQUIRE_ATTRIBUTE ! |
683 | | get other attribute information |
685 | | NF90_GET_ATT ! get |
686 | | attribute values |
688 | | NF90_GET_VAR ! get |
689 | | values of variables |
691 | | NF90_CLOSE ! clo |
692 | | se netCDF dataset |
694 +--------------------------------------+--------------------------------------+
696 As in the previous example, a single call opens the existing netCDF
697 dataset, returning a netCDF ID. This netCDF ID is given to the
698 NF90\_INQUIRE routine, which returns the number of dimensions, the
699 number of variables, the number of global attributes, and the ID of the
700 unlimited dimension, if there is one.
702 All the inquire functions are inexpensive to use and require no I/O,
703 since the information they provide is stored in memory when a netCDF
704 dataset is first opened.
706 Dimension IDs use consecutive integers, beginning at 1. Also dimensions,
707 once created, cannot be deleted. Therefore, knowing the number of
708 dimension IDs in a netCDF dataset means knowing all the dimension IDs:
709 they are the integers 1, 2, 3, ...up to the number of dimensions. For
710 each dimension ID, a call to the inquire function
711 NF90\_INQUIRE\_DIMENSION returns the dimension name and length.
713 Variable IDs are also assigned from consecutive integers 1, 2, 3, ... up
714 to the number of variables. These can be used in NF90\_INQUIRE\_VARIABLE
715 calls to find out the names, types, shapes, and the number of attributes
716 assigned to each variable.
718 Once the number of attributes for a variable is known, successive calls
719 to NF90\_INQ\_ATTNAME return the name for each attribute given the
720 netCDF ID, variable ID, and attribute number. Armed with the attribute
721 name, a call to NF90\_INQUIRE\_ATTRIBUTE returns its type and length.
722 Given the type and length, you can allocate enough space to hold the
723 attribute values. Then a call to NF90\_GET\_ATT returns the attribute
726 Once the IDs and shapes of netCDF variables are known, data values can
727 be accessed by calling NF90\_GET\_VAR.
729 ------------------------------------------------------------------------
731 ---------------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
732 \[[<](#Reading-a-netCDF-Dataset-with-Unknown-Names "Previous section in reading order")\] \[[>](#Adding-New-Dimensions "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
733 ---------------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
735 1.4 Writing Data in an Existing NetCDF Dataset {.section}
736 ----------------------------------------------
738 With write access to an existing netCDF dataset, you can overwrite data
739 values in existing variables or append more data to record variables
740 along the unlimited (record) dimension. To append more data to
741 non-record variables requires changing the shape of such variables,
742 which means creating a new netCDF dataset, defining new variables with
743 the desired shape, and copying data. The netCDF data model was not
744 designed to make such "schema changes" efficient or easy, so it is best
745 to specify the shapes of variables correctly when you create a netCDF
746 dataset, and to anticipate which variables will later grow by using the
747 unlimited dimension in their definition.
749 The following code template lists a typical sequence of calls to
750 overwrite some existing values and add some new records to record
751 variables in an existing netCDF dataset with known variable names:
753 +--------------------------------------+--------------------------------------+
755 | | NF90_OPEN ! open ex |
756 | | isting netCDF dataset |
758 | | NF90_INQ_VARID ! get var |
761 | | NF90_PUT_VAR ! provide |
762 | | new values for variables, if any |
764 | | NF90_PUT_ATT ! provide |
765 | | new values for attributes, if any |
767 | | NF90_CLOSE ! close n |
770 +--------------------------------------+--------------------------------------+
772 A netCDF dataset is first opened by the NF90\_OPEN call. This call puts
773 the open dataset in data mode, which means existing data values can be
774 accessed and changed, existing attributes can be changed, but no new
775 dimensions, variables, or attributes can be added.
777 Next, calls to NF90\_INQ\_VARID get the variable ID from the name, for
778 each variable you want to write. Then each call to NF90\_PUT\_VAR writes
779 data into a specified variable, either a single value at a time, or a
780 whole set of values at a time, depending on which variant of the
781 interface is used. The calls used to overwrite values of non-record
782 variables are the same as are used to overwrite values of record
783 variables or append new data to record variables. The difference is
784 that, with record variables, the record dimension is extended by writing
785 values that don’t yet exist in the dataset. This extends all record
786 variables at once, writing "fill values" for record variables for which
787 the data has not yet been written (but see section [Fill
788 Values](#Fill-Values) to specify different behavior).
790 Calls to NF90\_PUT\_ATT may be used to change the values of existing
791 attributes, although data that changes after a file is created is
792 typically stored in variables rather than attributes.
794 Finally, you should explicitly close any netCDF datasets into which data
795 has been written by calling NF90\_CLOSE before program termination.
796 Otherwise, modifications to the dataset may be lost.
798 ------------------------------------------------------------------------
800 --------------------------------------------------------------------------------------------- ------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
801 \[[<](#Writing-Data-in-an-Existing-NetCDF-Dataset "Previous section in reading order")\] \[[>](#Error-Handling "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
802 --------------------------------------------------------------------------------------------- ------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
804 1.5 Adding New Dimensions, Variables, Attributes {.section}
805 ------------------------------------------------
807 An existing netCDF dataset can be extensively altered. New dimensions,
808 variables, and attributes can be added or existing ones renamed, and
809 existing attributes can be deleted. Existing dimensions, variables, and
810 attributes can be renamed. The following code template lists a typical
811 sequence of calls to add new netCDF components to an existing dataset:
813 +--------------------------------------+--------------------------------------+
815 | | NF90_OPEN ! open ex |
816 | | isting netCDF dataset |
818 | | NF90_REDEF ! put it |
819 | | into define mode |
821 | | NF90_DEF_DIM ! define |
822 | | additional dimensions (if any) |
824 | | NF90_DEF_VAR ! define |
825 | | additional variables (if any) |
827 | | NF90_PUT_ATT ! define |
828 | | other attributes (if any) |
830 | | NF90_ENDDEF ! check d |
831 | | efinitions, leave define mode |
833 | | NF90_PUT_VAR ! provide |
834 | | new variable values |
836 | | NF90_CLOSE ! close n |
839 +--------------------------------------+--------------------------------------+
841 A netCDF dataset is first opened by the NF90\_OPEN call. This call puts
842 the open dataset in data mode, which means existing data values can be
843 accessed and changed, existing attributes can be changed (so long as
844 they do not grow), but nothing can be added. To add new netCDF
845 dimensions, variables, or attributes you must enter define mode, by
846 calling NF90\_REDEF. In define mode, call NF90\_DEF\_DIM to define new
847 dimensions, NF90\_DEF\_VAR to define new variables, and NF90\_PUT\_ATT
848 to assign new attributes to variables or enlarge old attributes.
850 You can leave define mode and reenter data mode, checking all the new
851 definitions for consistency and committing the changes to disk, by
852 calling NF90\_ENDDEF. If you do not wish to reenter data mode, just call
853 NF90\_CLOSE, which will have the effect of first calling NF90\_ENDDEF.
855 Until the NF90\_ENDDEF call, you may back out of all the redefinitions
856 made in define mode and restore the previous state of the netCDF dataset
857 by calling NF90\_ABORT. You may also use the NF90\_ABORT call to restore
858 the netCDF dataset to a consistent state if the call to NF90\_ENDDEF
859 fails. If you have called NF90\_CLOSE from definition mode and the
860 implied call to NF90\_ENDDEF fails, NF90\_ABORT will automatically be
861 called to close the netCDF dataset and leave it in its previous
862 consistent state (before you entered define mode).
864 At most one process should have a netCDF dataset open for writing at one
865 time. The library is designed to provide limited support for multiple
866 concurrent readers with one writer, via disciplined use of the
867 NF90\_SYNC function and the NF90\_SHARE flag. If a writer makes changes
868 in define mode, such as the addition of new variables, dimensions, or
869 attributes, some means external to the library is necessary to prevent
870 readers from making concurrent accesses and to inform readers to call
871 NF90\_SYNC before the next access.
873 ------------------------------------------------------------------------
875 ------------------------------------------------------------------------ -------------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
876 \[[<](#Adding-New-Dimensions "Previous section in reading order")\] \[[>](#Compiling-and-Linking-with-the-NetCDF-Library "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
877 ------------------------------------------------------------------------ -------------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
879 1.6 Error Handling {.section}
882 The netCDF library provides the facilities needed to handle errors in a
883 flexible way. Each netCDF function returns an integer status value. If
884 the returned status value indicates an error, you may handle it in any
885 way desired, from printing an associated error message and exiting to
886 ignoring the error indication and proceeding (not recommended!). For
887 simplicity, the examples in this guide check the error status and call a
888 separate function to handle any errors.
890 The NF90\_STRERROR function is available to convert a returned integer
891 error status into an error message string.
893 Occasionally, low-level I/O errors may occur in a layer below the netCDF
894 library. For example, if a write operation causes you to exceed disk
895 quotas or to attempt to write to a device that is no longer available,
896 you may get an error from a layer below the netCDF library, but the
897 resulting write error will still be reflected in the returned status
900 ------------------------------------------------------------------------
902 ----------------------------------------------------------------- ------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
903 \[[<](#Error-Handling "Previous section in reading order")\] \[[>](#Datasets "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Use-of-the-NetCDF-Library "Up section")\] \[[>>](#Datasets "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
904 ----------------------------------------------------------------- ------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
906 1.7 Compiling and Linking with the NetCDF Library {.section}
907 -------------------------------------------------
909 Details of how to compile and link a program that uses the netCDF C or
910 Fortran interfaces differ, depending on the operating system, the
911 available compilers, and where the netCDF library and include files are
912 installed. Nevertheless, we provide here examples of how to compile and
913 link a program that uses the netCDF library on a Unix platform, so that
914 you can adjust these examples to fit your installation.
916 Every Fortran 90 procedure or module which references netCDF constants
917 or procedures must have access to the module information created when
918 the netCDF module was compiled. The suffix for this file is “MOD” (or
921 Most F90 compilers allow the user to specify the location of .MOD files,
922 usually with the -I flag.
924 +--------------------------------------+--------------------------------------+
926 | | f90 -c -I/usr/local/include mymodule |
929 +--------------------------------------+--------------------------------------+
931 Starting with version 3.6.2, another method of building the netCDF
932 fortran libraries became available. With the –enable-separate-fortran
933 option to configure, the user can specify that the C library should not
934 contain the fortran functions. In these cases an additional library,
935 libnetcdff.a (note the extra “f”) will be built. This library contains
936 the Fortran functions. Since verion 4.1.3, the netCDF Fortran software
937 and library is always distinct from the netCDF C library, but depends on
938 it. If it is installed as a shared library, you need only use
939 ‘-lnetcdff’ to specify the Fortran library for linking.
941 For more information about configure options, See
942 [(netcdf-install)Specifying the Environment for
943 Building](netcdf-install.html#Specifying-the-Environment-for-Building)
944 section ‘Specifying the Environment for Building’ in The NetCDF
945 Installation and Porting Guide.
947 If installed as a shared library, link, using something like:
949 +--------------------------------------+--------------------------------------+
951 | | f90 -o myprogram myprogram.o -L/usr/ |
952 | | local/lib -lnetcdff |
954 +--------------------------------------+--------------------------------------+
956 If installed as a static library, you will at least need to mention the
957 netCDF C library and perhaps other libraries, such as hdf5 or curl,
958 depending on how the C library was built. For example:
960 +--------------------------------------+--------------------------------------+
962 | | f90 -o myprogram myprogram.o -L/usr/ |
963 | | local/lib -lnetcdff -lnetcdf |
965 +--------------------------------------+--------------------------------------+
967 Use of the nf-config utility program, installed as part of the
968 netcdf-fortran software, provides an easier way to compile and link,
969 without needing to know the details of where the library has been
970 installed, or whether it is installed as a shared or static library.
972 To see all the options for ‘nf-config’, invoke it with the ‘–help’
975 Here’s an example of how you could use ‘nf-config’ to compile and link a
976 Fortran program in one step:
978 +--------------------------------------+--------------------------------------+
980 | | f90 myprogram.f90 -o myprogram `nf-c |
981 | | onfig --fflags --flibs` |
983 +--------------------------------------+--------------------------------------+
985 If it is installed on your system, you could also use the ‘pkg-config’
986 utility to compile and link Fortran programs with the netCDF libraries.
987 This is especially useful in Makefiles, to insulate them from changes to
988 library versions and dependencies. Here is an example of how you could
989 compile and link a Fortran program with netCDF libraries using
992 +--------------------------------------+--------------------------------------+
994 | | export PKG_CONFIG_PATH=/usr/local/li |
996 | | f90 myprogram.f90 -o myprogram `pkg- |
997 | | config --cflags --libs netcdf-fortra |
1000 +--------------------------------------+--------------------------------------+
1002 where here ‘–cflags’ means compiler flags and ‘libs’ requests that the
1003 approriate libraries be linked in.
1005 ------------------------------------------------------------------------
1007 ------------------------------------------------------------------------------------------------ -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- ----------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1008 \[[<](#Compiling-and-Linking-with-the-NetCDF-Library "Previous section in reading order")\] \[[>](#Datasets-Introduction "Next section in reading order")\] \[[<<](#Use-of-the-NetCDF-Library "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1009 ------------------------------------------------------------------------------------------------ -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- ----------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1011 2. Datasets {.chapter}
1014 ------------------------ ------------------------ ------------------------
1016 Introduction](#Datasets-
1021 Descriptions](#NetCDF-Li
1022 brary-Interface-Descript
1026 NF90\_STRERROR](#NF90_00
1029 [2.4 Get netCDF library
1031 NF90\_INQ\_LIBVERS](#NF9
1032 0_005fINQ_005fLIBVERS)
1035 NF90\_CREATE](#NF90_005f
1039 NF90\_OPEN](#NF90_005fOP
1043 NF90\_REDEF](#NF90_005fR
1047 NF90\_ENDDEF](#NF90_005f
1051 NF90\_CLOSE](#NF90_005fC
1055 Family](#NF90_005fINQUIR
1059 NF90\_SYNC](#NF90_005fSY
1063 NF90\_ABORT](#NF90_005fA
1067 NF90\_SET\_FILL](#NF90_0
1069 ------------------------ ------------------------ ------------------------
1071 ------------------------------------------------------------------------
1073 ----------------------------------------------------------- ------------------------------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1074 \[[<](#Datasets "Previous section in reading order")\] \[[>](#NetCDF-Library-Interface-Descriptions "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1075 ----------------------------------------------------------- ------------------------------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1077 2.1 Datasets Introduction {.section}
1078 -------------------------
1080 This chapter presents the interfaces of the netCDF functions that deal
1081 with a netCDF dataset or the whole netCDF library.
1083 A netCDF dataset that has not yet been opened can only be referred to by
1084 its dataset name. Once a netCDF dataset is opened, it is referred to by
1085 a netCDF ID, which is a small nonnegative integer returned when you
1086 create or open the dataset. A netCDF ID is much like a file descriptor
1087 in C or a logical unit number in FORTRAN. In any single program, the
1088 netCDF IDs of distinct open netCDF datasets are distinct. A single
1089 netCDF dataset may be opened multiple times and will then have multiple
1090 distinct netCDF IDs; however at most one of the open instances of a
1091 single netCDF dataset should permit writing. When an open netCDF dataset
1092 is closed, the ID is no longer associated with a netCDF dataset.
1094 Functions that deal with the netCDF library include:
1096 - Get version of library.
1097 - Get error message corresponding to a returned error code.
1099 The operations supported on a netCDF dataset as a single object are:
1101 - Create, given dataset name and whether to overwrite or not.
1102 - Open for access, given dataset name and read or write intent.
1103 - Put into define mode, to add dimensions, variables, or attributes.
1104 - Take out of define mode, checking consistency of additions.
1105 - Close, writing to disk if required.
1106 - Inquire about the number of dimensions, number of variables, number
1107 of global attributes, and ID of the unlimited dimension, if any.
1108 - Synchronize to disk to make sure it is current.
1109 - Set and unset nofill mode for optimized sequential writes.
1110 - After a summary of conventions used in describing the netCDF
1111 interfaces, the rest of this chapter presents a detailed description
1112 of the interfaces for these operations.
1114 ------------------------------------------------------------------------
1116 ------------------------------------------------------------------------ ---------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1117 \[[<](#Datasets-Introduction "Previous section in reading order")\] \[[>](#NF90_005fSTRERROR "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1118 ------------------------------------------------------------------------ ---------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1120 2.2 NetCDF Library Interface Descriptions {.section}
1121 -----------------------------------------
1123 Each interface description for a particular netCDF function in this and
1124 later chapters contains:
1126 - a description of the purpose of the function;
1127 - a Fortran 90 interface block that presents the type and order of the
1128 formal parameters to the function;
1129 - a description of each formal parameter in the C interface;
1130 - a list of possible error conditions; and
1131 - an example of a Fortran 90 program fragment calling the netCDF
1132 function (and perhaps other netCDF functions).
1134 The examples follow a simple convention for error handling, always
1135 checking the error status returned from each netCDF function call and
1136 calling a handle\_error function in case an error was detected. For an
1137 example of such a function, see Section 5.2 "Get error message
1138 corresponding to error status: nf90\_strerror".
1140 ------------------------------------------------------------------------
1142 ---------------------------------------------------------------------------------------- ----------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1143 \[[<](#NetCDF-Library-Interface-Descriptions "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fLIBVERS "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1144 ---------------------------------------------------------------------------------------- ----------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1146 2.3 NF90\_STRERROR {.section}
1149 The function NF90\_STRERROR returns a static reference to an error
1150 message string corresponding to an integer netCDF error status or to a
1151 system error number, presumably returned by a previous call to some
1152 other netCDF function. The list of netCDF error status codes is
1153 available in the appropriate include file for each language binding.
1158 +--------------------------------------+--------------------------------------+
1159 | | ``` {.example} |
1160 | | function nf90_strerror(ncerr) |
1161 | | integer, intent( in) :: ncerr |
1162 | | character(len = 80) :: nf90_stre |
1165 +--------------------------------------+--------------------------------------+
1169 : An error status that might have been returned from a previous call
1170 to some netCDF function.
1175 If you provide an invalid integer error status that does not correspond
1176 to any netCDF error message or or to any system error message (as
1177 understood by the system strerror function), NF90\_STRERROR returns a
1178 string indicating that there is no such error status.
1183 Here is an example of a simple error handling function that uses
1184 NF90\_STRERROR to print the error message corresponding to the netCDF
1185 error status returned from any netCDF function call and then exit:
1187 +--------------------------------------+--------------------------------------+
1188 | | ``` {.example} |
1189 | | subroutine handle_err(status) |
1190 | | integer, intent ( in) :: status |
1192 | | if(status /= nf90_noerr) then |
1193 | | print *, trim(nf90_strerror(sta |
1195 | | stop "Stopped" |
1197 | | end subroutine handle_err |
1199 +--------------------------------------+--------------------------------------+
1201 ------------------------------------------------------------------------
1203 -------------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1204 \[[<](#NF90_005fSTRERROR "Previous section in reading order")\] \[[>](#NF90_005fCREATE "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1205 -------------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1207 2.4 Get netCDF library version: NF90\_INQ\_LIBVERS {.section}
1208 --------------------------------------------------
1210 The function NF90\_INQ\_LIBVERS returns a string identifying the version
1211 of the netCDF library, and when it was built.
1216 +--------------------------------------+--------------------------------------+
1217 | | ``` {.example} |
1218 | | function nf90_inq_libvers() |
1219 | | character(len = 80) :: nf90_inq_l |
1222 +--------------------------------------+--------------------------------------+
1227 This function takes no arguments, and returns no error status.
1232 Here is an example using nf90\_inq\_libvers to print the version of the
1233 netCDF library with which the program is linked:
1235 +--------------------------------------+--------------------------------------+
1236 | | ``` {.example} |
1237 | | print *, trim(nf90_inq_libvers()) |
1239 +--------------------------------------+--------------------------------------+
1241 ------------------------------------------------------------------------
1243 --------------------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1244 \[[<](#NF90_005fINQ_005fLIBVERS "Previous section in reading order")\] \[[>](#NF90_005fOPEN "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1245 --------------------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1247 2.5 NF90\_CREATE {.section}
1250 This function creates a new netCDF dataset, returning a netCDF ID that
1251 can subsequently be used to refer to the netCDF dataset in other netCDF
1252 function calls. The new netCDF dataset opened for write access and
1253 placed in define mode, ready for you to add dimensions, variables, and
1256 A creation mode flag specifies whether to overwrite any existing dataset
1257 with the same name and whether access to the dataset is shared.
1262 +--------------------------------------+--------------------------------------+
1263 | | ``` {.example} |
1264 | | function nf90_create(path, cmode, |
1265 | | ncid, initialsize, bufrsize, cache_s |
1267 | | cache_nelems, cache_preemptio |
1268 | | n, comm, info) |
1270 | | character (len = *), intent(in) |
1272 | | integer, intent(in) :: cmode |
1273 | | integer, intent(out) :: ncid |
1274 | | integer, optional, intent(in) :: |
1276 | | integer, optional, intent(inout) |
1278 | | integer, optional, intent(in) :: |
1279 | | cache_size, cache_nelems |
1280 | | real, optional, intent(in) :: ca |
1281 | | che_preemption |
1282 | | integer, optional, intent(in) :: |
1284 | | integer :: nf90_create |
1286 +--------------------------------------+--------------------------------------+
1290 : The file name of the new netCDF dataset.
1294 : The creation mode flag. The following flags are available:
1295 NF90\_CLOBBER, NF90\_NOCLOBBER, NF90\_SHARE, NF90\_64BIT\_OFFSET,
1296 NF90\_NETCDF4, and NF90\_CLASSIC\_MODEL. (NF90\_HDF5 is deprecated,
1297 use NF90\_NETCDF4 instead).
1299 A zero value (defined for convenience as NF90\_CLOBBER) specifies:
1300 overwrite any existing dataset with the same file name, and buffer
1301 and cache accesses for efficiency. The dataset will be in netCDF
1302 classic format. See [(netcdf)NetCDF Classic Format
1303 Limitations](netcdf.html#NetCDF-Classic-Format-Limitations) section
1304 ‘NetCDF Classic Format Limitations’ in NetCDF Users’ Guide.
1306 Setting NF90\_NOCLOBBER means you do not want to clobber (overwrite)
1307 an existing dataset; an error (NF90\_EEXIST) is returned if the
1308 specified dataset already exists.
1310 The NF90\_SHARE flag is appropriate when one process may be writing
1311 the dataset and one or more other processes reading the dataset
1312 concurrently; it means that dataset accesses are not buffered and
1313 caching is limited. Since the buffering scheme is optimized for
1314 sequential access, programs that do not access data sequentially may
1315 see some performance improvement by setting the NF90\_SHARE flag.
1316 (This only applies to netCDF-3 classic or 64-bit offset files.)
1318 Setting NF90\_64BIT\_OFFSET causes netCDF to create a 64-bit offset
1319 format file, instead of a netCDF classic format file. The 64-bit
1320 offset format imposes far fewer restrictions on very large (i.e.
1321 over 2 GB) data files. See [(netcdf)Large File
1322 Support](netcdf.html#Large-File-Support) section ‘Large File
1323 Support’ in NetCDF Users’ Guide.
1325 Setting the NF90\_NETCDF4 flag causes netCDF to create a
1326 netCDF-4/HDF5 format output file.
1328 Oring the NF90\_CLASSIC\_MODEL flag with the NF90\_NETCDF4 flag
1329 causes the resulting netCDF-4/HDF5 file to restrict itself to the
1330 classic model - none of the new netCDF-4 data model features, such
1331 as groups or user-defined types, are allowed in such a file.
1335 : Returned netCDF ID.
1337 The following optional arguments allow additional performance tuning.
1341 : The initial size of the file (in bytes) at creation time. A value of
1342 0 causes the file size to be computed when nf90\_enddef is called.
1343 This is ignored for NetCDF-4/HDF5 files.
1347 : Controls a space versus time trade-off, memory allocated in the
1348 netcdf library versus number of system calls. Because of internal
1349 requirements, the value may not be set to exactly the
1350 value requested. The actual value chosen is returned.
1352 The library chooses a system-dependent default value if
1353 NF90\_SIZEHINT\_DEFAULT is supplied as input. If the "preferred I/O
1354 block size" is available from the stat() system call as member
1355 st\_blksize this value is used. Lacking that, twice the system
1356 pagesize is used. Lacking a call to discover the system pagesize,
1357 the default bufrsize is set to 8192 bytes.
1359 The bufrsize is a property of a given open netcdf descriptor ncid,
1360 it is not a persistent property of the netcdf dataset.
1362 This is ignored for NetCDF-4/HDF5 files.
1366 : If the cache\_size is provided when creating a netCDF-4/HDF5 file,
1367 it will be used instead of the default (32000000) as the size, in
1368 bytes, of the HDF5 chunk cache.
1372 : If cache\_nelems is provided when creating a netCDF-4/HDF5 file, it
1373 will be used instead of the default (1000) as the maximum number of
1374 elements in the HDF5 chunk cache.
1378 : If cache\_preemption is provided when creating a netCDF-4/HDF5 file,
1379 it will be used instead of the default (0.75) as the preemption
1380 value for the HDF5 chunk cache.
1384 : If the comm and info parameters are provided the file is created and
1385 opened for parallel I/O. Set the comm parameter to the MPI
1386 communicator (of type MPI\_Comm). If this parameter is provided the
1387 info parameter must also be provided.
1391 : If the comm and info parameters are provided the file is created and
1392 opened for parallel I/O. Set the comm parameter to the MPI
1393 information value (of type MPI\_Info). If this parameter is provided
1394 the comm parameter must also be provided.
1399 NF90\_CREATE returns the value NF90\_NOERR if no errors occurred.
1400 Possible causes of errors include:
1402 - Passing a dataset name that includes a directory that does
1404 - Specifying a dataset name of a file that exists and also
1405 specifying NF90\_NOCLOBBER.
1406 - Specifying a meaningless value for the creation mode.
1407 - Attempting to create a netCDF dataset in a directory where you don’t
1408 have permission to create files.
1413 In this example we create a netCDF dataset named foo.nc; we want the
1414 dataset to be created in the current directory only if a dataset with
1415 that name does not already exist:
1417 +--------------------------------------+--------------------------------------+
1418 | | ``` {.example} |
1421 | | integer :: ncid, status |
1423 | | status = nf90_create(path = "foo.nc |
1424 | | ", cmode = nf90_noclobber, ncid = nc |
1426 | | if (status /= nf90_noerr) call hand |
1427 | | le_err(status) |
1429 +--------------------------------------+--------------------------------------+
1431 ------------------------------------------------------------------------
1433 ------------------------------------------------------------------ ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1434 \[[<](#NF90_005fCREATE "Previous section in reading order")\] \[[>](#NF90_005fREDEF "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1435 ------------------------------------------------------------------ ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1437 2.6 NF90\_OPEN {.section}
1440 The function NF90\_OPEN opens an existing netCDF dataset for access.
1445 +--------------------------------------+--------------------------------------+
1446 | | ``` {.example} |
1447 | | function nf90_open(path, mode, nci |
1448 | | d, bufrsize, cache_size, cache_nelem |
1450 | | cache_preemptio |
1451 | | n, comm, info) |
1453 | | character (len = *), intent(in) |
1455 | | integer, intent(in) :: mode |
1456 | | integer, intent(out) :: ncid |
1457 | | integer, optional, intent(inout) |
1459 | | integer, optional, intent(in) :: |
1460 | | cache_size, cache_nelems |
1461 | | real, optional, intent(in) :: ca |
1462 | | che_preemption |
1463 | | integer, optional, intent(in) :: |
1465 | | integer :: nf90_open |
1467 +--------------------------------------+--------------------------------------+
1471 : File name for netCDF dataset to be opened. This may be an OPeNDAP
1472 URL if DAP support is enabled.
1476 : A zero value (or NF90\_NOWRITE) specifies: open the dataset with
1477 read-only access, buffering and caching accesses for efficiency
1479 Otherwise, the open mode is NF90\_WRITE, NF90\_SHARE,
1480 or NF90\_WRITE|NF90\_SHARE. Setting the NF90\_WRITE flag opens the
1481 dataset with read-write access. ("Writing" means any kind of change
1482 to the dataset, including appending or changing data, adding or
1483 renaming dimensions, variables, and attributes, or
1484 deleting attributes.) The NF90\_SHARE flag is appropriate when one
1485 process may be writing the dataset and one or more other processes
1486 reading the dataset concurrently (note that this is not the same as
1487 parallel I/O); it means that dataset accesses are not buffered and
1488 caching is limited. Since the buffering scheme is optimized for
1489 sequential access, programs that do not access data sequentially may
1490 see some performance improvement by setting the NF90\_SHARE flag.
1494 : Returned netCDF ID.
1496 The following optional argument allows additional performance tuning.
1500 : This parameter applies only when opening classic format or 64-bit
1501 offset files. It is ignored for netCDF-4/HDF5 files.
1503 It Controls a space versus time trade-off, memory allocated in the
1504 netcdf library versus number of system calls. Because of internal
1505 requirements, the value may not be set to exactly the
1506 value requested. The actual value chosen is returned.
1508 The library chooses a system-dependent default value if
1509 NF90\_SIZEHINT\_DEFAULT is supplied as input. If the "preferred I/O
1510 block size" is available from the stat() system call as member
1511 st\_blksize this value is used. Lacking that, twice the system
1512 pagesize is used. Lacking a call to discover the system pagesize,
1513 the default bufrsize is set to 8192 bytes.
1515 The bufrsize is a property of a given open netcdf descriptor ncid,
1516 it is not a persistent property of the netcdf dataset.
1520 : If the cache\_size is provided when opening a netCDF-4/HDF5 file, it
1521 will be used instead of the default (32000000) as the size, in
1522 bytes, of the HDF5 chunk cache.
1526 : If cache\_nelems is provided when opening a netCDF-4/HDF5 file, it
1527 will be used instead of the default (1000) as the maximum number of
1528 elements in the HDF5 chunk cache.
1532 : If cache\_preemption is provided when opening a netCDF-4/HDF5 file,
1533 it will be used instead of the default (0.75) as the preemption
1534 value for the HDF5 chunk cache.
1538 : If the comm and info parameters are provided the file is opened for
1539 parallel I/O. Set the comm parameter to the MPI communicator (of
1540 type MPI\_Comm). If this parameter is provided the info parameter
1541 must also be provided.
1545 : If the comm and info parameters are provided the file is opened for
1546 parallel I/O. Set the comm parameter to the MPI information value
1547 (of type MPI\_Info). If this parameter is provided the comm
1548 parameter must also be provided.
1553 NF90\_OPEN returns the value NF90\_NOERR if no errors occurred.
1554 Otherwise, the returned status indicates an error. Possible causes of
1557 - The specified netCDF dataset does not exist.
1558 - A meaningless mode was specified.
1563 Here is an example using NF90\_OPEN to open an existing netCDF dataset
1564 named foo.nc for read-only, non-shared access:
1566 +--------------------------------------+--------------------------------------+
1567 | | ``` {.example} |
1570 | | integer :: ncid, status |
1572 | | status = nf90_open(path = "foo.nc", |
1573 | | mode = nf90_nowrite, ncid = ncid) |
1574 | | if (status /= nf90_noerr) call hand |
1575 | | le_err(status) |
1577 +--------------------------------------+--------------------------------------+
1582 Here is an example using NF90\_OPEN to open an existing netCDF dataset
1583 for parallel I/O access. (Note the use of the comm and info parameters).
1584 This example is from test program nf\_test/f90tst\_parallel.f90.
1586 +--------------------------------------+--------------------------------------+
1587 | | ``` {.example} |
1590 | | integer :: ncid, status |
1592 | | ! Reopen the file. |
1593 | | call handle_err(nf90_open(FILE_NAM |
1594 | | E, nf90_nowrite, ncid, comm = MPI_CO |
1596 | | info = MPI_INFO_NULL)) |
1598 +--------------------------------------+--------------------------------------+
1600 ------------------------------------------------------------------------
1602 ---------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1603 \[[<](#NF90_005fOPEN "Previous section in reading order")\] \[[>](#NF90_005fENDDEF "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1604 ---------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1606 2.7 NF90\_REDEF {.section}
1609 The function NF90\_REDEF puts an open netCDF dataset into define mode,
1610 so dimensions, variables, and attributes can be added or renamed and
1611 attributes can be deleted.
1616 +--------------------------------------+--------------------------------------+
1617 | | ``` {.example} |
1618 | | function nf90_redef(ncid) |
1619 | | integer, intent( in) :: ncid |
1620 | | integer :: nf90_rede |
1623 +--------------------------------------+--------------------------------------+
1627 : netCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1632 NF90\_REDEF returns the value NF90\_NOERR if no errors occurred.
1633 Otherwise, the returned status indicates an error. Possible causes of
1636 - The specified netCDF dataset is already in define mode.
1637 - The specified netCDF dataset was opened for read-only.
1638 - The specified netCDF ID does not refer to an open netCDF dataset.
1643 Here is an example using NF90\_REDEF to open an existing netCDF dataset
1644 named foo.nc and put it into define mode:
1646 +--------------------------------------+--------------------------------------+
1647 | | ``` {.example} |
1650 | | integer :: ncid, status |
1652 | | status = nf90_open("foo.nc", nf90_w |
1653 | | rite, ncid) ! Open dataset |
1654 | | if (status /= nf90_noerr) call hand |
1655 | | le_err(status) |
1657 | | status = nf90_redef(ncid) |
1658 | | ! Put the file in defin |
1660 | | if (status /= nf90_noerr) call hand |
1661 | | le_err(status) |
1663 +--------------------------------------+--------------------------------------+
1665 ------------------------------------------------------------------------
1667 ----------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1668 \[[<](#NF90_005fREDEF "Previous section in reading order")\] \[[>](#NF90_005fCLOSE "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1669 ----------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1671 2.8 NF90\_ENDDEF {.section}
1674 The function NF90\_ENDDEF takes an open netCDF dataset out of define
1675 mode. The changes made to the netCDF dataset while it was in define mode
1676 are checked and committed to disk if no problems occurred. Non-record
1677 variables may be initialized to a "fill value" as well (see section
1678 [NF90\_SET\_FILL](#NF90_005fSET_005fFILL)). The netCDF dataset is then
1679 placed in data mode, so variable data can be read or written.
1681 This call may involve copying data under some circumstances. For a more
1682 extensive discussion See [(netcdf)File Structure and
1683 Performance](netcdf.html#File-Structure-and-Performance) section ‘File
1684 Structure and Performance’ in NetCDF Users Guide.
1689 +--------------------------------------+--------------------------------------+
1690 | | ``` {.example} |
1691 | | function nf90_enddef(ncid, h_minfre |
1692 | | e, v_align, v_minfree, r_align) |
1693 | | integer, intent( in) :: |
1695 | | integer, optional, intent( in) :: |
1696 | | h_minfree, v_align, v_minfree, r_al |
1701 +--------------------------------------+--------------------------------------+
1705 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1707 The following arguments allow additional performance tuning. Note: these
1708 arguments expose internals of the netcdf version 1 file format, and may
1709 not be available in future netcdf implementations.
1711 The current netcdf file format has three sections: the "header" section,
1712 the data section for fixed size variables, and the data section for
1713 variables which have an unlimited dimension (record variables). The
1714 header begins at the beginning of the file. The index (offset) of the
1715 beginning of the other two sections is contained in the header.
1716 Typically, there is no space between the sections. This causes copying
1717 overhead to accrue if one wishes to change the size of the sections, as
1718 may happen when changing the names of things, text attribute values,
1719 adding attributes or adding variables. Also, for buffered i/o, there may
1720 be advantages to aligning sections in certain ways.
1722 The minfree parameters allow one to control costs of future calls to
1723 nf90\_redef or nf90\_enddef by requesting that some space be available
1724 at the end of the section. The default value for both h\_minfree and
1727 The align parameters allow one to set the alignment of the beginning of
1728 the corresponding sections. The beginning of the section is rounded up
1729 to an index which is a multiple of the align parameter. The flag value
1730 NF90\_ALIGN\_CHUNK tells the library to use the bufrsize (see above) as
1731 the align parameter. The default value for both v\_align and r\_align is
1736 : Size of the pad (in bytes) at the end of the "header" section.
1740 : Size of the pad (in bytes) at the end of the data section for fixed
1745 : The alignment of the beginning of the data section for fixed
1750 : The alignment of the beginning of the data section for variables
1751 which have an unlimited dimension (record variables).
1756 NF90\_ENDDEF returns the value NF90\_NOERR if no errors occurred.
1757 Otherwise, the returned status indicates an error. Possible causes of
1760 - The specified netCDF dataset is not in define mode.
1761 - The specified netCDF ID does not refer to an open netCDF dataset.
1762 - The size of one or more variables exceed the size constraints for
1763 whichever variant of the file format is in use). See [(netcdf)Large
1764 File Support](netcdf.html#Large-File-Support) section ‘Large File
1765 Support’ in The NetCDF Users Guide.
1770 Here is an example using NF90\_ENDDEF to finish the definitions of a new
1771 netCDF dataset named foo.nc and put it into data mode:
1773 +--------------------------------------+--------------------------------------+
1774 | | ``` {.example} |
1777 | | integer :: ncid, status |
1779 | | status = nf90_create("foo.nc", nf90 |
1780 | | _noclobber, ncid) |
1781 | | if (status /= nf90_noerr) call hand |
1782 | | le_err(status) |
1783 | | ... ! create dimensions, variable |
1785 | | status = nf90_enddef(ncid) |
1786 | | if (status /= nf90_noerr) call hand |
1787 | | le_err(status) |
1789 +--------------------------------------+--------------------------------------+
1791 ------------------------------------------------------------------------
1793 ------------------------------------------------------------------ ---------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1794 \[[<](#NF90_005fENDDEF "Previous section in reading order")\] \[[>](#NF90_005fINQUIRE-Family "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1795 ------------------------------------------------------------------ ---------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1797 2.9 NF90\_CLOSE {.section}
1800 The function NF90\_CLOSE closes an open netCDF dataset. If the dataset
1801 is in define mode, NF90\_ENDDEF will be called before closing. (In this
1802 case, if NF90\_ENDDEF returns an error, NF90\_ABORT will automatically
1803 be called to restore the dataset to the consistent state before define
1804 mode was last entered.) After an open netCDF dataset is closed, its
1805 netCDF ID may be reassigned to the next netCDF dataset that is opened or
1811 +--------------------------------------+--------------------------------------+
1812 | | ``` {.example} |
1813 | | function nf90_close(ncid) |
1814 | | integer, intent( in) :: ncid |
1815 | | integer :: nf90_clos |
1818 +--------------------------------------+--------------------------------------+
1822 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1827 NF90\_CLOSE returns the value NF90\_NOERR if no errors occurred.
1828 Otherwise, the returned status indicates an error. Possible causes of
1831 - Define mode was entered and the automatic call made to
1832 NF90\_ENDDEF failed.
1833 - The specified netCDF ID does not refer to an open netCDF dataset.
1838 Here is an example using NF90\_CLOSE to finish the definitions of a new
1839 netCDF dataset named foo.nc and release its netCDF ID:
1841 +--------------------------------------+--------------------------------------+
1842 | | ``` {.example} |
1845 | | integer :: ncid, status |
1847 | | status = nf90_create("foo.nc", nf90 |
1848 | | _noclobber, ncid) |
1849 | | if (status /= nf90_noerr) call hand |
1850 | | le_err(status) |
1851 | | ... ! create dimensions, variable |
1853 | | status = nf90_close(ncid) |
1854 | | if (status /= nf90_noerr) call hand |
1855 | | le_err(status) |
1857 +--------------------------------------+--------------------------------------+
1859 ------------------------------------------------------------------------
1861 ----------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1862 \[[<](#NF90_005fCLOSE "Previous section in reading order")\] \[[>](#NF90_005fSYNC "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1863 ----------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1865 2.10 NF90\_INQUIRE Family {.section}
1866 -------------------------
1868 The NF90\_INQUIRE subroutine returns information about an open netCDF
1869 dataset, given its netCDF ID. The subroutine can be called from either
1870 define mode or data mode, and returns values for any or all of the
1871 following: the number of dimensions, the number of variables, the number
1872 of global attributes, and the dimension ID of the dimension defined with
1873 unlimited length, if any. An additional function, NF90\_INQ\_FORMAT,
1874 returns the (rarely needed) format version.
1876 No I/O is performed when NF90\_INQUIRE is called, since the required
1877 information is available in memory for each open netCDF dataset.
1882 +--------------------------------------+--------------------------------------+
1883 | | ``` {.example} |
1884 | | function nf90_inquire(ncid, nDimens |
1885 | | ions, nVariables, nAttributes, & |
1888 | | integer, intent( in) :: |
1890 | | integer, optional, intent(out) :: |
1891 | | nDimensions, nVariables, & |
1893 | | nAttributes, unlimitedDimId, & |
1899 +--------------------------------------+--------------------------------------+
1903 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1907 : Returned number of dimensions defined for this netCDF dataset.
1911 : Returned number of variables defined for this netCDF dataset.
1915 : Returned number of global attributes defined for this
1920 : Returned ID of the unlimited dimension, if there is one for this
1921 netCDF dataset. If no unlimited length dimension has been defined,
1926 : Returned integer indicating format version for this dataset, one of
1927 nf90\_format\_classic, nf90\_format\_64bit, nf90\_format\_netcdf4,
1928 or nf90\_format\_netcdf4\_classic. These are rarely needed by users
1929 or applications, since thhe library recognizes the format of a file
1930 it is accessing and handles it accordingly.
1935 Function NF90\_INQUIRE returns the value NF90\_NOERR if no errors
1936 occurred. Otherwise, the returned status indicates an error. Possible
1937 causes of errors include:
1939 - The specified netCDF ID does not refer to an open netCDF dataset.
1944 Here is an example using NF90\_INQUIRE to find out about a netCDF
1945 dataset named foo.nc:
1947 +--------------------------------------+--------------------------------------+
1948 | | ``` {.example} |
1951 | | integer :: ncid, status, nDims, nVa |
1952 | | rs, nGlobalAtts, unlimDimID |
1954 | | status = nf90_open("foo.nc", nf90_n |
1956 | | if (status /= nf90_noerr) call hand |
1957 | | le_err(status) |
1959 | | status = nf90_inquire(ncid, nDims, |
1960 | | nVars, nGlobalAtts, unlimdimid) |
1961 | | if (status /= nf90_noerr) call hand |
1962 | | le_err(status) |
1963 | | status = nf90_inquire(ncid, nDimens |
1964 | | ions = nDims, & |
1966 | | D = unlimdimid) |
1967 | | if (status /= nf90_noerr) call hand |
1968 | | le_err(status) |
1970 +--------------------------------------+--------------------------------------+
1972 ------------------------------------------------------------------------
1974 -------------------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1975 \[[<](#NF90_005fINQUIRE-Family "Previous section in reading order")\] \[[>](#NF90_005fABORT "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
1976 -------------------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1978 2.11 NF90\_SYNC {.section}
1981 The function NF90\_SYNC offers a way to synchronize the disk copy of a
1982 netCDF dataset with in-memory buffers. There are two reasons you might
1983 want to synchronize after writes:
1985 - To minimize data loss in case of abnormal termination, or
1986 - To make data available to other processes for reading immediately
1987 after it is written. But note that a process that already had the
1988 dataset open for reading would not see the number of records
1989 increase when the writing process calls NF90\_SYNC; to accomplish
1990 this, the reading process must call NF90\_SYNC.
1992 This function is backward-compatible with previous versions of the
1993 netCDF library. The intent was to allow sharing of a netCDF dataset
1994 among multiple readers and one writer, by having the writer call
1995 NF90\_SYNC after writing and the readers call NF90\_SYNC before each
1996 read. For a writer, this flushes buffers to disk. For a reader, it makes
1997 sure that the next read will be from disk rather than from previously
1998 cached buffers, so that the reader will see changes made by the writing
1999 process (e.g., the number of records written) without having to close
2000 and reopen the dataset. If you are only accessing a small amount of
2001 data, it can be expensive in computer resources to always synchronize to
2002 disk after every write, since you are giving up the benefits of
2005 An easier way to accomplish sharing (and what is now recommended) is to
2006 have the writer and readers open the dataset with the NF90\_SHARE flag,
2007 and then it will not be necessary to call NF90\_SYNC at all. However,
2008 the NF90\_SYNC function still provides finer granularity than the
2009 NF90\_SHARE flag, if only a few netCDF accesses need to be synchronized
2012 It is important to note that changes to the ancillary data, such as
2013 attribute values, are not propagated automatically by use of the
2014 NF90\_SHARE flag. Use of the NF90\_SYNC function is still required for
2017 Sharing datasets when the writer enters define mode to change the data
2018 schema requires extra care. In previous releases, after the writer left
2019 define mode, the readers were left looking at an old copy of the
2020 dataset, since the changes were made to a new copy. The only way readers
2021 could see the changes was by closing and reopening the dataset. Now the
2022 changes are made in place, but readers have no knowledge that their
2023 internal tables are now inconsistent with the new dataset schema. If
2024 netCDF datasets are shared across redefinition, some mechanism external
2025 to the netCDF library must be provided that prevents access by readers
2026 during redefinition and causes the readers to call NF90\_SYNC before any
2029 When calling NF90\_SYNC, the netCDF dataset must be in data mode. A
2030 netCDF dataset in define mode is synchronized to disk only when
2031 NF90\_ENDDEF is called. A process that is reading a netCDF dataset that
2032 another process is writing may call NF90\_SYNC to get updated with the
2033 changes made to the data by the writing process (e.g., the number of
2034 records written), without having to close and reopen the dataset.
2036 Data is automatically synchronized to disk when a netCDF dataset is
2037 closed, or whenever you leave define mode.
2042 +--------------------------------------+--------------------------------------+
2043 | | ``` {.example} |
2044 | | function nf90_sync(ncid) |
2045 | | integer, intent( in) :: ncid |
2046 | | integer :: nf90_sync |
2048 +--------------------------------------+--------------------------------------+
2052 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2057 NF90\_SYNC returns the value NF90\_NOERR if no errors occurred.
2058 Otherwise, the returned status indicates an error. Possible causes of
2061 - The netCDF dataset is in define mode.
2062 - The specified netCDF ID does not refer to an open netCDF dataset.
2067 Here is an example using NF90\_SYNC to synchronize the disk writes of a
2068 netCDF dataset named foo.nc:
2070 +--------------------------------------+--------------------------------------+
2071 | | ``` {.example} |
2074 | | integer :: ncid, status |
2076 | | status = nf90_open("foo.nc", nf90_w |
2078 | | if (status /= nf90_noerr) call hand |
2079 | | le_err(status) |
2081 | | ! write data or change attributes |
2083 | | status = NF90_SYNC(ncid) |
2084 | | if (status /= nf90_noerr) call hand |
2085 | | le_err(status) |
2087 +--------------------------------------+--------------------------------------+
2089 ------------------------------------------------------------------------
2091 ---------------------------------------------------------------- -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2092 \[[<](#NF90_005fSYNC "Previous section in reading order")\] \[[>](#NF90_005fSET_005fFILL "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2093 ---------------------------------------------------------------- -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2095 2.12 NF90\_ABORT {.section}
2098 You no longer need to call this function, since it is called
2099 automatically by NF90\_CLOSE in case the dataset is in define mode and
2100 something goes wrong with committing the changes. The function
2101 NF90\_ABORT just closes the netCDF dataset, if not in define mode. If
2102 the dataset is being created and is still in define mode, the dataset is
2103 deleted. If define mode was entered by a call to NF90\_REDEF, the netCDF
2104 dataset is restored to its state before definition mode was entered and
2105 the dataset is closed.
2110 +--------------------------------------+--------------------------------------+
2111 | | ``` {.example} |
2112 | | function nf90_abort(ncid) |
2113 | | integer, intent( in) :: ncid |
2114 | | integer :: nf90_abor |
2117 +--------------------------------------+--------------------------------------+
2121 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2126 NF90\_ABORT returns the value NF90\_NOERR if no errors occurred.
2127 Otherwise, the returned status indicates an error. Possible causes of
2130 - When called from define mode while creating a netCDF dataset,
2131 deletion of the dataset failed.
2132 - The specified netCDF ID does not refer to an open netCDF dataset.
2137 Here is an example using NF90\_ABORT to back out of redefinitions of a
2138 dataset named foo.nc:
2140 +--------------------------------------+--------------------------------------+
2141 | | ``` {.example} |
2144 | | integer :: ncid, status, LatDimID |
2146 | | status = nf90_open("foo.nc", nf90_w |
2148 | | if (status /= nf90_noerr) call hand |
2149 | | le_err(status) |
2151 | | status = nf90_redef(ncid) |
2152 | | if (status /= nf90_noerr) call hand |
2153 | | le_err(status) |
2155 | | status = nf90_def_dim(ncid, "Lat", |
2157 | | if (status /= nf90_noerr) then ! Di |
2158 | | mension definition failed |
2159 | | call handle_err(status) |
2160 | | status = nf90_abort(ncid) ! Abort |
2162 | | if (status /= nf90_noerr) call ha |
2163 | | ndle_err(status) |
2167 +--------------------------------------+--------------------------------------+
2169 ------------------------------------------------------------------------
2171 ----------------------------------------------------------------- ----------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2172 \[[<](#NF90_005fABORT "Previous section in reading order")\] \[[>](#Groups "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Datasets "Up section")\] \[[>>](#Groups "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2173 ----------------------------------------------------------------- ----------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2175 2.13 NF90\_SET\_FILL {.section}
2176 --------------------
2178 This function is intended for advanced usage, to optimize writes under
2179 some circumstances described below. The function NF90\_SET\_FILL sets
2180 the fill mode for a netCDF dataset open for writing and returns the
2181 current fill mode in a return parameter. The fill mode can be specified
2182 as either NF90\_FILL or NF90\_NOFILL. The default behavior corresponding
2183 to NF90\_FILL is that data is pre-filled with fill values, that is fill
2184 values are written when you create non-record variables or when you
2185 write a value beyond data that has not yet been written. This makes it
2186 possible to detect attempts to read data before it was written. See
2187 section [Fill Values](#Fill-Values), for more information on the use of
2188 fill values. See [(netcdf)Attribute
2189 Conventions](netcdf.html#Attribute-Conventions) section ‘Attribute
2190 Conventions’ in The NetCDF Users Guide, for information about how to
2191 define your own fill values.
2193 The behavior corresponding to NF90\_NOFILL overrides the default
2194 behavior of prefilling data with fill values. This can be used to
2195 enhance performance, because it avoids the duplicate writes that occur
2196 when the netCDF library writes fill values that are later overwritten
2199 A value indicating which mode the netCDF dataset was already in is
2200 returned. You can use this value to temporarily change the fill mode of
2201 an open netCDF dataset and then restore it to the previous mode.
2203 After you turn on NF90\_NOFILL mode for an open netCDF dataset, you must
2204 be certain to write valid data in all the positions that will later be
2205 read. Note that nofill mode is only a transient property of a netCDF
2206 dataset open for writing: if you close and reopen the dataset, it will
2207 revert to the default behavior. You can also revert to the default
2208 behavior by calling NF90\_SET\_FILL again to explicitly set the fill
2211 There are three situations where it is advantageous to set nofill mode:
2213 1. Creating and initializing a netCDF dataset. In this case, you should
2214 set nofill mode before calling NF90\_ENDDEF and then write
2215 completely all non-record variables and the initial records of all
2216 the record variables you want to initialize.
2217 2. Extending an existing record-oriented netCDF dataset. Set nofill
2218 mode after opening the dataset for writing, then append the
2219 additional records to the dataset completely, leaving no intervening
2221 3. Adding new variables that you are going to initialize to an existing
2222 netCDF dataset. Set nofill mode before calling NF90\_ENDDEF then
2223 write all the new variables completely.
2225 If the netCDF dataset has an unlimited dimension and the last record was
2226 written while in nofill mode, then the dataset may be shorter than if
2227 nofill mode was not set, but this will be completely transparent if you
2228 access the data only through the netCDF interfaces.
2230 The use of this feature may not be available (or even needed) in future
2231 releases. Programmers are cautioned against heavy reliance upon this
2237 +--------------------------------------+--------------------------------------+
2238 | | ``` {.example} |
2239 | | function nf90_set_fill(ncid, fillmo |
2241 | | integer, intent( in) :: ncid, fil |
2243 | | integer, intent(out) :: old_mode |
2244 | | integer :: nf90_set_ |
2247 +--------------------------------------+--------------------------------------+
2251 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2255 : Desired fill mode for the dataset, either NF90\_NOFILL
2260 : Returned current fill mode of the dataset before this call, either
2261 NF90\_NOFILL or NF90\_FILL.
2266 NF90\_SET\_FILL returns the value NF90\_NOERR if no errors occurred.
2267 Otherwise, the returned status indicates an error. Possible causes of
2270 - The specified netCDF ID does not refer to an open netCDF dataset.
2271 - The specified netCDF ID refers to a dataset open for
2273 - The fill mode argument is neither NF90\_NOFILL nor NF90\_FILL..
2278 Here is an example using NF90\_SET\_FILL to set nofill mode for
2279 subsequent writes of a netCDF dataset named foo.nc:
2281 +--------------------------------------+--------------------------------------+
2282 | | ``` {.example} |
2285 | | integer :: ncid, status, oldMode |
2287 | | status = nf90_open("foo.nc", nf90_w |
2289 | | if (status /= nf90_noerr) call hand |
2290 | | le_err(status) |
2292 | | ! Write data with prefilling behavi |
2295 | | status = nf90_set_fill(ncid, nf90_n |
2296 | | ofill, oldMode) |
2297 | | if (status /= nf90_noerr) call hand |
2298 | | le_err(status) |
2300 | | ! Write data with no prefilling |
2303 +--------------------------------------+--------------------------------------+
2305 ------------------------------------------------------------------------
2307 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2308 \[[<](#NF90_005fSET_005fFILL "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fNCID "Next section in reading order")\] \[[<<](#Datasets "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2309 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2311 3. Groups {.chapter}
2314 NetCDF-4 added support for hierarchical groups within netCDF datasets.
2316 Groups are identified with a ncid, which identifies both the open file,
2317 and the group within that file. When a file is opened with NF90\_OPEN or
2318 NF90\_CREATE, the ncid for the root group of that file is provided.
2319 Using that as a starting point, users can add new groups, or list and
2320 navigate existing groups.
2322 All netCDF calls take a ncid which determines where the call will take
2323 its action. For example, the NF90\_DEF\_VAR function takes a ncid as its
2324 first parameter. It will create a variable in whichever group its ncid
2325 refers to. Use the root ncid provided by NF90\_CREATE or NF90\_OPEN to
2326 create a variable in the root group. Or use NF90\_DEF\_GRP to create a
2327 group and use its ncid to define a variable in the new group.
2329 Variable are only visible in the group in which they are defined. The
2330 same applies to attributes. “Global” attributes are defined in whichever
2331 group is refered to by the ncid.
2333 Dimensions are visible in their groups, and all child groups.
2335 Group operations are only permitted on netCDF-4 files - that is, files
2336 created with the HDF5 flag in nf90\_create. (see section
2337 [NF90\_CREATE](#NF90_005fCREATE)). Groups are not compatible with the
2338 netCDF classic data model, so files created with the
2339 NF90\_CLASSIC\_MODEL file cannot contain groups (except the root group).
2341 ------------------------ ------------------------ ------------------------
2342 [3.1 Find a Group ID:
2343 NF90\_INQ\_NCID](#NF90_0
2348 NF90\_INQ\_GRPS](#NF90_0
2352 Variables in a Group:
2353 NF90\_INQ\_VARIDS](#NF90
2354 _005fINQ_005fVARIDS)
2356 [3.4 Find all Dimensions
2358 NF90\_INQ\_DIMIDS](#NF90
2359 _005fINQ_005fDIMIDS)
2361 [3.5 Find the Length of
2362 a Group’s Full Name:
2363 NF90\_INQ\_GRPNAME\_LEN]
2364 (#NF90_005fINQ_005fGRPNA
2369 NF90\_INQ\_GRPNAME](#NF9
2370 0_005fINQ_005fGRPNAME)
2372 [3.7 Find a Group’s Full
2374 NF90\_INQ\_GRPNAME\_FULL
2375 ](#NF90_005fINQ_005fGRPN
2380 NF90\_INQ\_GRP\_PARENT](
2381 #NF90_005fINQ_005fGRP_00
2384 [3.9 Find a Group by
2386 NF90\_INQ\_GRP\_NCID](#N
2387 F90_005fINQ_005fGRP_005f
2390 [3.10 Find a Group by
2393 NF90\_INQ\_GRP\_FULL\_NC
2394 ID](#NF90_005fINQ_005fGR
2395 P_005fFULL_005fNCID)
2399 NF90\_DEF\_GRP](#NF90_00
2401 ------------------------ ------------------------ ------------------------
2403 ------------------------------------------------------------------------
2405 --------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2406 \[[<](#Groups "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRPS "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2407 --------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2409 3.1 Find a Group ID: NF90\_INQ\_NCID {.section}
2410 ------------------------------------
2412 Given an ncid and group name (NULL or "" gets root group), return ncid
2418 +--------------------------------------+--------------------------------------+
2419 | | ``` {.example} |
2420 | | function nf90_inq_ncid(ncid, name, |
2422 | | integer, intent(in) :: ncid |
2423 | | character (len = *), intent(in) |
2425 | | integer, intent(out) :: grp_ncid |
2426 | | integer :: nf90_inq_ncid |
2428 +--------------------------------------+--------------------------------------+
2432 : The group id for this operation.
2436 : A character array that holds the name of the desired group. Must be
2437 less then NF90\_MAX\_NAME.
2441 : The ID of the group will go here.
2456 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2457 operations can only be performed on files defined with a create mode
2458 which includes flag HDF5. (see section
2459 [NF90\_OPEN](#NF90_005fOPEN)).
2463 : This file was created with the strict netcdf-3 flag, therefore
2464 netcdf-4 operations are not allowed. (see section
2465 [NF90\_OPEN](#NF90_005fOPEN)).
2469 : An error was reported by the HDF5 layer.
2474 This example is from nf90\_test/ftst\_groups.F.
2476 ------------------------------------------------------------------------
2478 ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2479 \[[<](#NF90_005fINQ_005fNCID "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fVARIDS "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2480 ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2482 3.2 Get a List of Groups in a Group: NF90\_INQ\_GRPS {.section}
2483 ----------------------------------------------------
2485 Given a location id, return the number of groups it contains, and an
2486 array of their ncids.
2491 +--------------------------------------+--------------------------------------+
2492 | | ``` {.example} |
2493 | | function nf90_inq_grps(ncid, numgr |
2495 | | integer, intent(in) :: ncid |
2496 | | integer, intent(out) :: numgrps |
2497 | | integer, intent(out) :: ncids |
2498 | | integer :: nf90_inq_grps |
2500 +--------------------------------------+--------------------------------------+
2504 : The group id for this operation.
2508 : An integer which will get number of groups in this group.
2512 : An array of ints which will receive the IDs of all the groups in
2528 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2529 operations can only be performed on files defined with a create mode
2530 which includes flag HDF5. (see section
2531 [NF90\_OPEN](#NF90_005fOPEN)).
2535 : This file was created with the strict netcdf-3 flag, therefore
2536 netcdf-4 operations are not allowed. (see section
2537 [NF90\_OPEN](#NF90_005fOPEN)).
2541 : An error was reported by the HDF5 layer.
2546 ------------------------------------------------------------------------
2548 ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2549 \[[<](#NF90_005fINQ_005fGRPS "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fDIMIDS "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2550 ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2552 3.3 Find all the Variables in a Group: NF90\_INQ\_VARIDS {.section}
2553 --------------------------------------------------------
2555 Find all varids for a location.
2560 +--------------------------------------+--------------------------------------+
2561 | | ``` {.example} |
2562 | | function nf90_inq_varids(ncid, nva |
2564 | | integer, intent(in) :: ncid |
2565 | | integer, intent(out) :: nvars |
2566 | | integer, intent(out) :: varids |
2567 | | integer :: nf90_inq_varids |
2569 +--------------------------------------+--------------------------------------+
2573 : The group id for this operation.
2577 : An already allocated array to store the list of varids. Use
2578 nf90\_inq\_nvars to find out how many variables there are. (see
2579 section [Get Information about a Variable from Its ID:
2580 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)).
2595 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2596 operations can only be performed on files defined with a create mode
2597 which includes flag HDF5. (see section
2598 [NF90\_OPEN](#NF90_005fOPEN)).
2602 : This file was created with the strict netcdf-3 flag, therefore
2603 netcdf-4 operations are not allowed. (see section
2604 [NF90\_OPEN](#NF90_005fOPEN)).
2608 : An error was reported by the HDF5 layer.
2613 ------------------------------------------------------------------------
2615 -------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2616 \[[<](#NF90_005fINQ_005fVARIDS "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRPNAME_005fLEN "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2617 -------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2619 3.4 Find all Dimensions Visible in a Group: NF90\_INQ\_DIMIDS {.section}
2620 -------------------------------------------------------------
2622 Find all dimids for a location. This finds all dimensions in a group, or
2628 +--------------------------------------+--------------------------------------+
2629 | | ``` {.example} |
2630 | | function nf90_inq_dimids(ncid, ndi |
2631 | | ms, dimids, include_parents) |
2632 | | integer, intent(in) :: ncid |
2633 | | integer, intent(out) :: ndims |
2634 | | integer, intent(out) :: dimids |
2635 | | integer, intent(out) :: include_ |
2637 | | integer :: nf90_inq_dimids |
2639 +--------------------------------------+--------------------------------------+
2643 : The group id for this operation.
2647 : Returned number of dimensions for this location. If include\_parents
2648 is non-zero, number of dimensions visible from this group, which
2649 includes dimensions in parent groups.
2653 : An array of ints when the dimids of the visible dimensions will
2654 be stashed. Use nf90\_inq\_ndims to find out how many dims are
2655 visible from this group. (see section [Get Information about a
2656 Variable from Its ID:
2657 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)).
2661 : If zero, only the group specified by NCID will be searched
2662 for dimensions. Otherwise parent groups will be searched too.
2677 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2678 operations can only be performed on files defined with a create mode
2679 which includes flag HDF5. (see section
2680 [NF90\_OPEN](#NF90_005fOPEN)).
2684 : This file was created with the strict netcdf-3 flag, therefore
2685 netcdf-4 operations are not allowed. (see section
2686 [NF90\_OPEN](#NF90_005fOPEN)).
2690 : An error was reported by the HDF5 layer.
2695 ------------------------------------------------------------------------
2697 -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2698 \[[<](#NF90_005fINQ_005fDIMIDS "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRPNAME "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2699 -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2701 3.5 Find the Length of a Group’s Full Name: NF90\_INQ\_GRPNAME\_LEN {.section}
2702 -------------------------------------------------------------------
2704 Given ncid, find length of the full name. (Root group is named "/", with
2710 +--------------------------------------+--------------------------------------+
2711 | | ``` {.example} |
2712 | | function nf90_inq_grpname_len(ncid |
2714 | | integer, intent(in) :: ncid |
2715 | | integer, intent(out) :: len |
2716 | | integer :: nf90_inq_grpname_len |
2717 | | end function nf90_inq_grpname_len |
2719 +--------------------------------------+--------------------------------------+
2723 : The group id for this operation.
2727 : An integer where the length will be placed.
2742 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2743 operations can only be performed on files defined with a create mode
2744 which includes flag HDF5. (see section
2745 [NF90\_OPEN](#NF90_005fOPEN)).
2749 : This file was created with the strict netcdf-3 flag, therefore
2750 netcdf-4 operations are not allowed. (see section
2751 [NF90\_OPEN](#NF90_005fOPEN)).
2755 : An error was reported by the HDF5 layer.
2760 ------------------------------------------------------------------------
2762 ----------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2763 \[[<](#NF90_005fINQ_005fGRPNAME_005fLEN "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRPNAME_005fFULL "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2764 ----------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2766 3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME {.section}
2767 -------------------------------------------
2769 Given ncid, find relative name of group. (Root group is named "/").
2771 The name provided by this function is relative to the parent group. For
2772 a full path name for the group is, with all parent groups included,
2773 separated with a forward slash (as in Unix directory names) See section
2774 [Find a Group’s Full Name:
2775 NF90\_INQ\_GRPNAME\_FULL](#NF90_005fINQ_005fGRPNAME_005fFULL).
2780 +--------------------------------------+--------------------------------------+
2781 | | ``` {.example} |
2782 | | function nf90_inq_grpname(ncid, na |
2784 | | integer, intent(in) :: ncid |
2785 | | character (len = *), intent(out) |
2787 | | integer :: nf90_inq_grpname |
2789 +--------------------------------------+--------------------------------------+
2793 : The group id for this operation.
2797 : The name of the group will be copied to this character array. The
2798 name will be less than NF90\_MAX\_NAME in length.
2813 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2814 operations can only be performed on files defined with a create mode
2815 which includes flag HDF5. (see section
2816 [NF90\_OPEN](#NF90_005fOPEN)).
2820 : This file was created with the strict netcdf-3 flag, therefore
2821 netcdf-4 operations are not allowed. (see section
2822 [NF90\_OPEN](#NF90_005fOPEN)).
2826 : An error was reported by the HDF5 layer.
2831 ------------------------------------------------------------------------
2833 --------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2834 \[[<](#NF90_005fINQ_005fGRPNAME "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRP_005fPARENT "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2835 --------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2837 3.7 Find a Group’s Full Name: NF90\_INQ\_GRPNAME\_FULL {.section}
2838 ------------------------------------------------------
2840 Given ncid, find complete name of group. (Root group is named "/").
2842 The name provided by this function is a full path name for the group is,
2843 with all parent groups included, separated with a forward slash (as in
2844 Unix directory names). For a name relative to the parent group See
2845 section [Find a Group’s Name:
2846 NF90\_INQ\_GRPNAME](#NF90_005fINQ_005fGRPNAME).
2848 To find the length of the full name See section [Find the Length of a
2850 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN).
2855 +--------------------------------------+--------------------------------------+
2856 | | ``` {.example} |
2857 | | function nf90_inq_grpname_full(nci |
2859 | | integer, intent(in) :: ncid |
2860 | | integer, intent(out) :: len |
2861 | | character (len = *), intent(out) |
2863 | | integer :: nf90_inq_grpname_full |
2865 +--------------------------------------+--------------------------------------+
2869 : The group id for this operation.
2873 : The length of the full group name will go here.
2877 : The name of the group will be copied to this character array.
2892 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2893 operations can only be performed on files defined with a create mode
2894 which includes flag HDF5. (see section
2895 [NF90\_OPEN](#NF90_005fOPEN)).
2899 : This file was created with the strict netcdf-3 flag, therefore
2900 netcdf-4 operations are not allowed. (see section
2901 [NF90\_OPEN](#NF90_005fOPEN)).
2905 : An error was reported by the HDF5 layer.
2910 This example is from test program nf\_test/f90tst\_grps.f90.
2912 +--------------------------------------+--------------------------------------+
2913 | | ``` {.example} |
2914 | | call check(nf90_inq_grpname_full(g |
2915 | | rpid1, len, name_in)) |
2916 | | if (name_in .ne. grp1_full_name) s |
2919 +--------------------------------------+--------------------------------------+
2921 ------------------------------------------------------------------------
2923 ------------------------------------------------------------------------------------ ---------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2924 \[[<](#NF90_005fINQ_005fGRPNAME_005fFULL "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRP_005fNCID "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2925 ------------------------------------------------------------------------------------ ---------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2927 3.8 Find a Group’s Parent: NF90\_INQ\_GRP\_PARENT {.section}
2928 -------------------------------------------------
2930 Given ncid, find the ncid of the parent group.
2932 When used with the root group, this function returns the NF90\_ENOGRP
2933 error (since the root group has no parent.)
2938 +--------------------------------------+--------------------------------------+
2939 | | ``` {.example} |
2940 | | function nf90_inq_grp_parent(ncid, |
2942 | | integer, intent(in) :: ncid |
2943 | | integer, intent(out) :: parent_n |
2945 | | integer :: nf90_inq_grp_parent |
2947 +--------------------------------------+--------------------------------------+
2955 : The ncid of the parent group will be copied here.
2970 : No parent group found (i.e. this is the root group).
2974 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
2975 operations can only be performed on files defined with a create mode
2976 which includes flag HDF5. (see section
2977 [NF90\_OPEN](#NF90_005fOPEN)).
2981 : This file was created with the strict netcdf-3 flag, therefore
2982 netcdf-4 operations are not allowed. (see section
2983 [NF90\_OPEN](#NF90_005fOPEN)).
2987 : An error was reported by the HDF5 layer.
2992 ------------------------------------------------------------------------
2994 ---------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2995 \[[<](#NF90_005fINQ_005fGRP_005fPARENT "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fGRP_005fFULL_005fNCID "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
2996 ---------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2998 3.9 Find a Group by Name: NF90\_INQ\_GRP\_NCID {.section}
2999 ----------------------------------------------
3001 Given a group name an an ncid, find the ncid of the group id.
3006 +--------------------------------------+--------------------------------------+
3007 | | ``` {.example} |
3008 | | function nf90_inq_grp_ncid(ncid, n |
3010 | | integer, intent(in) :: ncid |
3011 | | character (len = *), intent(in) |
3013 | | integer, intent(out) :: grpid |
3014 | | integer :: nf90_inq_grp_ncid |
3016 | | nf90_inq_grp_ncid = nf_inq_grp_n |
3017 | | cid(ncid, name, grpid) |
3018 | | end function nf90_inq_grp_ncid |
3020 +--------------------------------------+--------------------------------------+
3024 : The group id to look in.
3028 : The name of the group that should be found.
3032 : This will get the group id, if it is found.
3034 Return Codes {.heading}
3037 The following return codes may be returned by this function.
3049 : No name provided or name longer than NF90\_MAX\_NAME.
3053 : Named group not found.
3057 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
3058 operations can only be performed on files defined with a create mode
3059 which includes flag HDF5. (see section
3060 [NF90\_OPEN](#NF90_005fOPEN)).
3064 : This file was created with the strict netcdf-3 flag, therefore
3065 netcdf-4 operations are not allowed. (see section
3066 [NF90\_OPEN](#NF90_005fOPEN)).
3070 : An error was reported by the HDF5 layer.
3075 This example is from test program nf\_test/f90tst\_grps.f90.
3077 +--------------------------------------+--------------------------------------+
3078 | | ``` {.example} |
3079 | | ! Get the group ids for the newly |
3080 | | reopened file. |
3081 | | call check(nf90_inq_grp_ncid(ncid, |
3082 | | GRP1_NAME, grpid1)) |
3083 | | call check(nf90_inq_grp_ncid(grpid |
3084 | | 1, GRP2_NAME, grpid2)) |
3085 | | call check(nf90_inq_grp_ncid(grpid |
3086 | | 2, GRP3_NAME, grpid3)) |
3087 | | call check(nf90_inq_grp_ncid(grpid |
3088 | | 3, GRP4_NAME, grpid4)) |
3090 +--------------------------------------+--------------------------------------+
3092 ------------------------------------------------------------------------
3094 -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3095 \[[<](#NF90_005fINQ_005fGRP_005fNCID "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fGRP "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3096 -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3098 3.10 Find a Group by its Fully-qualified Name: NF90\_INQ\_GRP\_FULL\_NCID {.section}
3099 -------------------------------------------------------------------------
3101 Given a fully qualified group name an an ncid, find the ncid of the
3107 +--------------------------------------+--------------------------------------+
3108 | | ``` {.example} |
3109 | | function nf90_inq_grpname_full(nci |
3111 | | integer, intent(in) :: ncid |
3112 | | integer, intent(out) :: len |
3113 | | character (len = *), intent(out) |
3115 | | integer :: nf90_inq_grpname_full |
3117 | | nf90_inq_grpname_full = nf_inq_g |
3118 | | rpname_full(ncid, len, name) |
3119 | | end function nf90_inq_grpname_full |
3121 +--------------------------------------+--------------------------------------+
3125 : The group id to look in.
3129 : The fully-qualified group name.
3133 : This will get the group id, if it is found.
3135 Return Codes {.heading}
3138 The following return codes may be returned by this function.
3150 : No name provided or name longer than NF90\_MAX\_NAME.
3154 : Named group not found.
3158 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
3159 operations can only be performed on files defined with a create mode
3160 which includes flag HDF5. (see section
3161 [NF90\_OPEN](#NF90_005fOPEN)).
3165 : This file was created with the strict netcdf-3 flag, therefore
3166 netcdf-4 operations are not allowed. (see section
3167 [NF90\_OPEN](#NF90_005fOPEN)).
3171 : An error was reported by the HDF5 layer.
3176 This example is from test program nf\_test/tstf90\_grps.f90.
3178 +--------------------------------------+--------------------------------------+
3179 | | ``` {.example} |
3180 | | ! Check for the groups with full g |
3182 | | write(grp1_full_name, '(AA)') '/', |
3184 | | call check(nf90_inq_grp_full_ncid( |
3185 | | ncid, grp1_full_name, grpid1)) |
3187 +--------------------------------------+--------------------------------------+
3189 ------------------------------------------------------------------------
3191 ----------------------------------------------------------------------------------------- --------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3192 \[[<](#NF90_005fINQ_005fGRP_005fFULL_005fNCID "Previous section in reading order")\] \[[>](#Dimensions "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Groups "Up section")\] \[[>>](#Dimensions "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3193 ----------------------------------------------------------------------------------------- --------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3195 3.11 Create a New Group: NF90\_DEF\_GRP {.section}
3196 ---------------------------------------
3198 Create a group. Its location id is returned in new\_ncid.
3203 +--------------------------------------+--------------------------------------+
3204 | | ``` {.example} |
3205 | | function nf90_def_grp(parent_ncid, |
3206 | | name, new_ncid) |
3207 | | integer, intent(in) :: parent_nc |
3209 | | character (len = *), intent(in) |
3211 | | integer, intent(out) :: new_ncid |
3212 | | integer :: nf90_def_grp |
3214 +--------------------------------------+--------------------------------------+
3218 : The group id of the parent group.
3222 : The name of the new group, which must be different from the name of
3223 any variable within the same parent group.
3227 : The ncid of the new group will be placed there.
3242 : That name is in use. Group names must be unique within a group.
3246 : Name exceed max length NF90\_MAX\_NAME.
3250 : Name contains illegal characters.
3254 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
3255 operations can only be performed on files defined with a create mode
3256 which includes flag HDF5. (see section
3257 [NF90\_OPEN](#NF90_005fOPEN)).
3261 : This file was created with the strict netcdf-3 flag, therefore
3262 netcdf-4 operations are not allowed. (see section
3263 [NF90\_OPEN](#NF90_005fOPEN)).
3267 : An error was reported by the HDF5 layer.
3271 : Attempt to write to a read-only file.
3275 : Not in define mode.
3280 +--------------------------------------+--------------------------------------+
3281 | | ``` {.example} |
3282 | | C Create the netCDF file. |
3283 | | retval = nf90_create(file_name |
3284 | | , NF90_NETCDF4, ncid) |
3285 | | if (retval .ne. nf90_noerr) ca |
3286 | | ll handle_err(retval) |
3288 | | C Create a group and a subgroup. |
3289 | | retval = nf90_def_grp(ncid, gr |
3290 | | oup_name, grpid) |
3291 | | if (retval .ne. nf90_noerr) ca |
3292 | | ll handle_err(retval) |
3293 | | retval = nf90_def_grp(grpid, s |
3294 | | ub_group_name, sub_grpid) |
3295 | | if (retval .ne. nf90_noerr) ca |
3296 | | ll handle_err(retval) |
3298 +--------------------------------------+--------------------------------------+
3300 ------------------------------------------------------------------------
3302 ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3303 \[[<](#NF90_005fDEF_005fGRP "Previous section in reading order")\] \[[>](#Dimensions-Introduction "Next section in reading order")\] \[[<<](#Groups "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3304 ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3306 4. Dimensions {.chapter}
3309 ------------------------ ------------------------ ------------------------
3311 Introduction](#Dimension
3315 NF90\_DEF\_DIM](#NF90_00
3319 NF90\_INQ\_DIMID](#NF90_
3323 NF90\_INQUIRE\_DIMENSION
3324 ](#NF90_005fINQUIRE_005f
3328 NF90\_RENAME\_DIM](#NF90
3329 _005fRENAME_005fDIM)
3330 ------------------------ ------------------------ ------------------------
3332 ------------------------------------------------------------------------
3334 ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3335 \[[<](#Dimensions "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fDIM "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Dimensions "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3336 ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3338 4.1 Dimensions Introduction {.section}
3339 ---------------------------
3341 Dimensions for a netCDF dataset are defined when it is created, while
3342 the netCDF dataset is in define mode. Additional dimensions may be added
3343 later by reentering define mode. A netCDF dimension has a name and a
3344 length. At most one dimension in a netCDF dataset can have the unlimited
3345 length, which means variables using this dimension can grow along this
3348 There is a suggested limit (512) to the number of dimensions that can be
3349 defined in a single netCDF dataset. The limit is the value of the
3350 constant NF90\_MAX\_DIMS. The purpose of the limit is to make writing
3351 generic applications simpler. They need only provide an array of
3352 NF90\_MAX\_DIMS dimensions to handle any netCDF dataset. The
3353 implementation of the netCDF library does not enforce this advisory
3354 maximum, so it is possible to use more dimensions, if necessary, but
3355 netCDF utilities that assume the advisory maximums may not be able to
3356 handle the resulting netCDF datasets.
3358 Ordinarily, the name and length of a dimension are fixed when the
3359 dimension is first defined. The name may be changed later, but the
3360 length of a dimension (other than the unlimited dimension) cannot be
3361 changed without copying all the data to a new netCDF dataset with a
3362 redefined dimension length.
3364 A netCDF dimension in an open netCDF dataset is referred to by a small
3365 integer called a dimension ID. In the Fortran 90 interface, dimension
3366 IDs are 1, 2, 3, ..., in the order in which the dimensions were defined.
3368 Operations supported on dimensions are:
3370 - Create a dimension, given its name and length.
3371 - Get a dimension ID from its name.
3372 - Get a dimension’s name and length from its ID.
3373 - Rename a dimension.
3375 ------------------------------------------------------------------------
3377 -------------------------------------------------------------------------- --------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3378 \[[<](#Dimensions-Introduction "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fDIMID "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Dimensions "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3379 -------------------------------------------------------------------------- --------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3381 4.2 NF90\_DEF\_DIM {.section}
3384 The function NF90\_DEF\_DIM adds a new dimension to an open netCDF
3385 dataset in define mode. It returns (as an argument) a dimension ID,
3386 given the netCDF ID, the dimension name, and the dimension length. At
3387 most one unlimited length dimension, called the record dimension, may be
3388 defined for each netCDF dataset.
3393 +--------------------------------------+--------------------------------------+
3394 | | ``` {.example} |
3395 | | function nf90_def_dim(ncid, name, l |
3397 | | integer, intent( in) |
3399 | | character (len = *), intent( in) |
3401 | | integer, intent( in) |
3403 | | integer, intent(out) |
3406 | | :: nf90_def_dim |
3408 +--------------------------------------+--------------------------------------+
3412 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3420 : Length of dimension; that is, number of values for this dimension as
3421 an index to variables that use it. This should be either a positive
3422 integer or the predefined constant NF90\_UNLIMITED.
3426 : Returned dimension ID.
3431 NF90\_DEF\_DIM returns the value NF90\_NOERR if no errors occurred.
3432 Otherwise, the returned status indicates an error. Possible causes of
3435 - The netCDF dataset is not in definition mode.
3436 - The specified dimension name is the name of another
3438 - The specified length is not greater than zero.
3439 - The specified length is unlimited, but there is already an unlimited
3440 length dimension defined for this netCDF dataset.
3441 - The specified netCDF ID does not refer to an open netCDF dataset.
3446 Here is an example using NF90\_DEF\_DIM to create a dimension named lat
3447 of length 18 and a unlimited dimension named rec in a new netCDF dataset
3450 +--------------------------------------+--------------------------------------+
3451 | | ``` {.example} |
3454 | | integer :: ncid, status, LatDimID, |
3457 | | status = nf90_create("foo.nc", nf90 |
3458 | | _noclobber, ncid) |
3459 | | if (status /= nf90_noerr) call hand |
3460 | | le_err(status) |
3462 | | status = nf90_def_dim(ncid, "Lat", |
3464 | | if (status /= nf90_noerr) call hand |
3465 | | le_err(status) |
3466 | | status = nf90_def_dim(ncid, "Record |
3467 | | ", nf90_unlimited, RecordDimID) |
3468 | | if (status /= nf90_noerr) call hand |
3469 | | le_err(status) |
3471 +--------------------------------------+--------------------------------------+
3473 ------------------------------------------------------------------------
3475 ----------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3476 \[[<](#NF90_005fDEF_005fDIM "Previous section in reading order")\] \[[>](#NF90_005fINQUIRE_005fDIMENSION "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Dimensions "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3477 ----------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3479 4.3 NF90\_INQ\_DIMID {.section}
3480 --------------------
3482 The function NF90\_INQ\_DIMID returns (as an argument) the ID of a
3483 netCDF dimension, given the name of the dimension. If ndims is the
3484 number of dimensions defined for a netCDF dataset, each dimension has an
3485 ID between 1 and ndims.
3490 +--------------------------------------+--------------------------------------+
3491 | | ``` {.example} |
3492 | | function nf90_inq_dimid(ncid, name, |
3494 | | integer, intent( in) |
3496 | | character (len = *), intent( in) |
3498 | | integer, intent(out) |
3501 | | :: nf90_inq_dimid |
3503 +--------------------------------------+--------------------------------------+
3507 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3515 : Returned dimension ID.
3520 NF90\_INQ\_DIMID returns the value NF90\_NOERR if no errors occurred.
3521 Otherwise, the returned status indicates an error. Possible causes of
3524 - The name that was specified is not the name of a dimension in the
3526 - The specified netCDF ID does not refer to an open netCDF dataset.
3531 Here is an example using NF90\_INQ\_DIMID to determine the dimension ID
3532 of a dimension named lat, assumed to have been defined previously in an
3533 existing netCDF dataset named foo.nc:
3535 +--------------------------------------+--------------------------------------+
3536 | | ``` {.example} |
3539 | | integer :: ncid, status, LatDimID |
3541 | | status = nf90_open("foo.nc", nf90_n |
3543 | | if (status /= nf90_noerr) call hand |
3544 | | le_err(status) |
3546 | | status = nf90_inq_dimid(ncid, "Lat" |
3548 | | if (status /= nf90_noerr) call hand |
3549 | | le_err(status) |
3551 +--------------------------------------+--------------------------------------+
3553 ------------------------------------------------------------------------
3555 ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3556 \[[<](#NF90_005fINQ_005fDIMID "Previous section in reading order")\] \[[>](#NF90_005fRENAME_005fDIM "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Dimensions "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3557 ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3559 4.4 NF90\_INQUIRE\_DIMENSION {.section}
3560 ----------------------------
3562 This function information about a netCDF dimension. Information about a
3563 dimension includes its name and its length. The length for the unlimited
3564 dimension, if any, is the number of records written so far.
3569 +--------------------------------------+--------------------------------------+
3570 | | ``` {.example} |
3571 | | function nf90_inquire_dimension(nci |
3572 | | d, dimid, name, len) |
3574 | | tent( in) :: ncid, dimid |
3575 | | character (len = *), optional, in |
3576 | | tent(out) :: name |
3577 | | integer, optional, in |
3578 | | tent(out) :: len |
3580 | | :: nf90_inquire_dimension |
3582 +--------------------------------------+--------------------------------------+
3586 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3590 : Dimension ID, from a previous call to NF90\_INQ\_DIMID
3595 : Returned dimension name. The caller must allocate space for the
3596 returned name. The maximum possible length, in characters, of a
3597 dimension name is given by the predefined constant NF90\_MAX\_NAME.
3601 : Returned length of dimension. For the unlimited dimension, this is
3602 the current maximum value used for writing any variables with this
3603 dimension, that is the maximum record number.
3608 These functions return the value NF90\_NOERR if no errors occurred.
3609 Otherwise, the returned status indicates an error. Possible causes of
3612 - The dimension ID is invalid for the specified netCDF dataset.
3613 - The specified netCDF ID does not refer to an open netCDF dataset.
3618 Here is an example using NF90\_INQ\_DIM to determine the length of a
3619 dimension named lat, and the name and current maximum length of the
3620 unlimited dimension for an existing netCDF dataset named foo.nc:
3622 +--------------------------------------+--------------------------------------+
3623 | | ``` {.example} |
3626 | | integer :: ncid, status, LatDimID, |
3628 | | integer :: nLats, nRecords |
3629 | | character(len = nf90_max_name) :: R |
3632 | | status = nf90_open("foo.nc", nf90_n |
3634 | | if (status /= nf90_noerr) call hand |
3635 | | le_err(status) |
3636 | | ! Get ID of unlimited dimension |
3637 | | status = nf90_inquire(ncid, unlimit |
3638 | | edDimId = RecordDimID) |
3639 | | if (status /= nf90_noerr) call hand |
3640 | | le_err(status) |
3642 | | status = nf90_inq_dimid(ncid, "Lat" |
3644 | | if (status /= nf90_noerr) call hand |
3645 | | le_err(status) |
3646 | | ! How many values of "lat" are ther |
3648 | | status = nf90_inquire_dimension(nci |
3649 | | d, LatDimID, len = nLats) |
3650 | | if (status /= nf90_noerr) call hand |
3651 | | le_err(status) |
3652 | | ! What is the name of the unlimited |
3653 | | dimension, how many records are the |
3655 | | status = nf90_inquire_dimension(nci |
3656 | | d, RecordDimID, & |
3658 | | e = RecordDimName, len = Records) |
3659 | | if (status /= nf90_noerr) call hand |
3660 | | le_err(status) |
3662 +--------------------------------------+--------------------------------------+
3664 ------------------------------------------------------------------------
3666 --------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3667 \[[<](#NF90_005fINQUIRE_005fDIMENSION "Previous section in reading order")\] \[[>](#User-Defined-Data-Types "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Dimensions "Up section")\] \[[>>](#User-Defined-Data-Types "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3668 --------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3670 4.5 NF90\_RENAME\_DIM {.section}
3671 ---------------------
3673 The function NF90\_RENAME\_DIM renames an existing dimension in a netCDF
3674 dataset open for writing. If the new name is longer than the old name,
3675 the netCDF dataset must be in define mode. You cannot rename a dimension
3676 to have the same name as another dimension.
3681 +--------------------------------------+--------------------------------------+
3682 | | ``` {.example} |
3683 | | function nf90_rename_dim(ncid, dimi |
3685 | | integer, intent( in) |
3687 | | character (len = *), intent( in) |
3689 | | integer, intent( in) |
3692 | | :: nf90_rename_dim |
3694 +--------------------------------------+--------------------------------------+
3698 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3702 : Dimension ID, from a previous call to NF90\_INQ\_DIMID
3707 : New dimension name.
3712 NF90\_RENAME\_DIM returns the value NF90\_NOERR if no errors occurred.
3713 Otherwise, the returned status indicates an error. Possible causes of
3716 - The new name is the name of another dimension.
3717 - The dimension ID is invalid for the specified netCDF dataset.
3718 - The specified netCDF ID does not refer to an open netCDF dataset.
3719 - The new name is longer than the old name and the netCDF dataset is
3725 Here is an example using NF90\_RENAME\_DIM to rename the dimension lat
3726 to latitude in an existing netCDF dataset named foo.nc:
3728 +--------------------------------------+--------------------------------------+
3729 | | ``` {.example} |
3732 | | integer :: ncid, status, LatDimID |
3734 | | status = nf90_open("foo.nc", nf90_w |
3736 | | if (status /= nf90_noerr) call hand |
3737 | | le_err(status) |
3739 | | ! Put in define mode so we can rena |
3740 | | me the dimension |
3741 | | status = nf90_redef(ncid) |
3742 | | if (status /= nf90_noerr) call hand |
3743 | | le_err(status) |
3744 | | ! Get the dimension ID for "Lat"... |
3745 | | status = nf90_inq_dimid(ncid, "Lat" |
3747 | | if (status /= nf90_noerr) call hand |
3748 | | le_err(status) |
3749 | | ! ... and change the name to "Latit |
3751 | | status = nf90_rename_dim(ncid, LatD |
3752 | | imID, "Latitude") |
3753 | | if (status /= nf90_noerr) call hand |
3754 | | le_err(status) |
3755 | | ! Leave define mode |
3756 | | status = nf90_enddef(ncid) |
3757 | | if (status /= nf90_noerr) call hand |
3758 | | le_err(status) |
3760 +--------------------------------------+--------------------------------------+
3762 ------------------------------------------------------------------------
3764 -------------------------------------------------------------------------- ----------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3765 \[[<](#NF90_005fRENAME_005fDIM "Previous section in reading order")\] \[[>](#User-Defined-Types "Next section in reading order")\] \[[<<](#Dimensions "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3766 -------------------------------------------------------------------------- ----------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3768 5. User Defined Data Types {.chapter}
3769 ==========================
3771 ------------------------ ------------------------ ------------------------
3772 [5.1 User Defined Types
3773 Introduction](#User-Defi
3776 [5.2 Learn the IDs of
3778 NF90\_INQ\_TYPEIDS](#NF9
3779 0_005fINQ_005fTYPEIDS)
3781 [5.3 Find a Typeid from
3783 nf90\_inq\_typeid](#nf90
3784 _005finq_005ftypeid)
3786 [5.4 Learn About a User
3788 NF90\_INQ\_TYPE](#NF90_0
3791 [5.5 Learn About a User
3793 NF90\_INQ\_USER\_TYPE](#
3794 NF90_005fINQ_005fUSER_00
3798 Introduction](#Compound-
3801 [5.7 Variable Length
3803 Introduction](#Variable-
3807 Introduction](#Opaque-Ty
3811 Introduction](#Enum-Type
3813 ------------------------ ------------------------ ------------------------
3815 ------------------------------------------------------------------------
3817 -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3818 \[[<](#User-Defined-Data-Types "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fTYPEIDS "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3819 -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3821 5.1 User Defined Types Introduction {.section}
3822 -----------------------------------
3824 NetCDF-4 has added support for four different user defined data types.
3828 : Like a C struct, a compound type is a collection of types, including
3829 other user defined types, in one package.
3831 `variable length array type`
3833 : The variable length array may be used to store ragged arrays.
3837 : This type has only a size per element, and no other
3842 : Like an enumeration in C, this type lets you assign text values to
3843 integer values, and store the integer values.
3845 Users may construct user defined type with the various NF90\_DEF\_\*
3846 functions described in this section. They may learn about user defined
3847 types by using the NF90\_INQ\_ functions defined in this section.
3849 Once types are constructed, define variables of the new type with
3850 NF90\_DEF\_VAR (see section [Create a Variable:
3851 `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)). Write to them with
3852 NF90\_PUT\_VAR (see section [Writing Data Values:
3853 NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)). Read data of user-defined type
3854 with NF90\_GET\_VAR (see section [Reading Data Values:
3855 NF90\_GET\_VAR](#NF90_005fGET_005fVAR)).
3857 Create attributes of the new type with NF90\_PUT\_ATT (see section
3858 [Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)). Read
3859 attributes of the new type with NF90\_GET\_ATT (see section [Get
3860 Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)).
3862 ------------------------------------------------------------------------
3864 --------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3865 \[[<](#User-Defined-Types "Previous section in reading order")\] \[[>](#nf90_005finq_005ftypeid "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3866 --------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3868 5.2 Learn the IDs of All Types in Group: NF90\_INQ\_TYPEIDS {.section}
3869 -----------------------------------------------------------
3871 Learn the number of types defined in a group, and their IDs.
3876 +--------------------------------------+--------------------------------------+
3877 | | ``` {.example} |
3878 | | function nf90_inq_typeids(ncid, nt |
3879 | | ypes, typeids) |
3880 | | integer, intent(in) :: ncid |
3881 | | integer, intent(out) :: ntypes |
3882 | | integer, intent(out) :: typeids |
3883 | | integer :: nf90_inq_typeids |
3885 +--------------------------------------+--------------------------------------+
3893 : A pointer to int which will get the number of types defined in
3894 the group. If NULL, ignored.
3898 : A pointer to an int array which will get the typeids. If
3915 ------------------------------------------------------------------------
3917 --------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3918 \[[<](#NF90_005fINQ_005fTYPEIDS "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fTYPE "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3919 --------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3921 5.3 Find a Typeid from Group and Name: nf90\_inq\_typeid {.section}
3922 --------------------------------------------------------
3924 Given a group ID and a type name, find the ID of the type. If the type
3925 is not found in the group, then the parents are searched. If still not
3926 found, the entire file is searched.
3931 +--------------------------------------+--------------------------------------+
3932 | | ``` {.example} |
3933 | | int nf90_inq_typeid(int ncid, char * |
3934 | | name, nf90_type *typeidp); |
3936 +--------------------------------------+--------------------------------------+
3944 : The name of a type.
3948 : The typeid, if found.
3968 ------------------------------------------------------------------------
3970 -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3971 \[[<](#nf90_005finq_005ftypeid "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fUSER_005fTYPE "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
3972 -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3974 5.4 Learn About a User Defined Type: NF90\_INQ\_TYPE {.section}
3975 ----------------------------------------------------
3977 Given an ncid and a typeid, get the information about a type. This
3978 function will work on any type, including atomic and any user defined
3979 type, whether compound, opaque, enumeration, or variable length array.
3981 For even more information about a user defined type [Learn About a User
3982 Defined Type: NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE).
3987 +--------------------------------------+--------------------------------------+
3988 | | ``` {.example} |
3989 | | function nf90_inq_type(ncid, xtype |
3991 | | integer, intent(in) :: ncid |
3992 | | integer, intent(in) :: xtype |
3993 | | character (len = *), intent(out) |
3995 | | integer, intent(out) :: size |
3996 | | integer :: nf90_inq_type |
3998 +--------------------------------------+--------------------------------------+
4002 : The ncid for the group containing the type (ignored for
4007 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
4008 NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN, or
4009 NF90\_INQ\_VAR, or as found in netcdf.inc in the list of atomic
4010 types (NF90\_CHAR, NF90\_INT, etc.).
4014 : The name of the user defined type will be copied here. It will be
4015 NF90\_MAX\_NAME bytes or less. For atomic types, the type name from
4020 : The (in-memory) size of the type (in bytes) will be copied here.
4021 VLEN type size is the size of one element of the VLEN. String size
4022 is returned as the size of one char.
4024 Return Codes {.heading}
4037 : Seeking a user-defined type in a netCDF-3 file.
4041 : Seeking a user-defined type in a netCDF-4 file for which classic
4042 model has been turned on.
4046 : Bad group ID in ncid.
4050 : Type ID not found.
4054 : An error was reported by the HDF5 layer.
4059 ------------------------------------------------------------------------
4061 ------------------------------------------------------------------------ -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4062 \[[<](#NF90_005fINQ_005fTYPE "Previous section in reading order")\] \[[>](#NF90_005fPUT_005fVLEN_005fELEMENT "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4063 ------------------------------------------------------------------------ -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4065 5.5 Learn About a User Defined Type: NF90\_INQ\_USER\_TYPE {.section}
4066 ----------------------------------------------------------
4068 Given an ncid and a typeid, get the information about a user defined
4069 type. This function will work on any user defined type, whether
4070 compound, opaque, enumeration, or variable length array.
4075 +--------------------------------------+--------------------------------------+
4076 | | ``` {.example} |
4077 | | function nf90_inq_user_type(ncid, |
4078 | | xtype, name, size, base_typeid, nfie |
4080 | | integer, intent(in) :: ncid |
4081 | | integer, intent(in) :: xtype |
4082 | | character (len = *), intent(out) |
4084 | | integer, intent(out) :: size |
4085 | | integer, intent(out) :: base_typ |
4087 | | integer, intent(out) :: nfields |
4088 | | integer, intent(out) :: class |
4089 | | integer :: nf90_inq_user_type |
4091 +--------------------------------------+--------------------------------------+
4095 : The ncid for the group containing the user defined type.
4099 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
4100 NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN,
4105 : The name of the user defined type will be copied here. It will be
4106 NF90\_MAX\_NAME bytes or less.
4110 : The (in-memory) size of the user defined type will be copied here.
4114 : The base typeid will be copied here for vlen and enum types.
4118 : The number of fields will be copied here for enum and
4123 : The class of the user defined type, NF90\_VLEN, NF90\_OPAQUE,
4124 NF90\_ENUM, or NF90\_COMPOUND, will be copied here.
4143 : An error was reported by the HDF5 layer.
4148 ------------------------ ------------------------ ------------------------
4149 [5.5.1 Set a Variable
4151 NF90\_PUT\_VLEN\_ELEMENT
4152 ](#NF90_005fPUT_005fVLEN
4155 [5.5.2 Set a Variable
4157 NF90\_GET\_VLEN\_ELEMENT
4158 ](#NF90_005fGET_005fVLEN
4160 ------------------------ ------------------------ ------------------------
4162 ------------------------------------------------------------------------
4164 --------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4165 \[[<](#NF90_005fINQ_005fUSER_005fTYPE "Previous section in reading order")\] \[[>](#NF90_005fGET_005fVLEN_005fELEMENT "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#NF90_005fINQ_005fUSER_005fTYPE "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4166 --------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4168 ### 5.5.1 Set a Variable Length Array with NF90\_PUT\_VLEN\_ELEMENT {.subsection}
4170 Use this to set the element of the (potentially) n-dimensional array of
4171 VLEN. That is, this sets the data in one variable length array.
4176 +--------------------------------------+--------------------------------------+
4177 | | ``` {.example} |
4178 | | INTEGER FUNCTION NF90_PUT_VLEN_ELEME |
4179 | | NT(INTEGER NCID, INTEGER XTYPE, |
4180 | | CHARACTER*(*) VLEN_ELEMENT, |
4181 | | INTEGER LEN, DATA) |
4183 +--------------------------------------+--------------------------------------+
4187 : The ncid of the file that contains the VLEN type.
4191 : The type of the VLEN.
4195 : The VLEN element to be set.
4199 : The number of entries in this array.
4203 : The data to be stored. Must match the base type of this VLEN.
4214 : Can’t find the typeid.
4222 : Group ID part of ncid was invalid.
4227 This example is from nf90\_test/ftst\_vars4.F.
4229 +--------------------------------------+--------------------------------------+
4230 | | ``` {.example} |
4231 | | C Set up the vlen with this help |
4232 | | er function, since F90 can't deal |
4233 | | C with pointers. |
4234 | | retval = nf90_put_vlen_element |
4235 | | (ncid, vlen_typeid, vlen, |
4236 | | & vlen_len, data1) |
4237 | | if (retval .ne. nf90_noerr) ca |
4238 | | ll handle_err(retval) |
4240 +--------------------------------------+--------------------------------------+
4242 ------------------------------------------------------------------------
4244 ------------------------------------------------------------------------------------ ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4245 \[[<](#NF90_005fPUT_005fVLEN_005fELEMENT "Previous section in reading order")\] \[[>](#Compound-Types "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#NF90_005fINQ_005fUSER_005fTYPE "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4246 ------------------------------------------------------------------------------------ ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4248 ### 5.5.2 Set a Variable Length Array with NF90\_GET\_VLEN\_ELEMENT {.subsection}
4250 Use this to set the element of the (potentially) n-dimensional array of
4251 VLEN. That is, this sets the data in one variable length array.
4256 +--------------------------------------+--------------------------------------+
4257 | | ``` {.example} |
4258 | | INTEGER FUNCTION NF90_GET_VLEN_ELEME |
4259 | | NT(INTEGER NCID, INTEGER XTYPE, |
4260 | | CHARACTER*(*) VLEN_ELEMENT, |
4261 | | INTEGER LEN, DATA) |
4263 +--------------------------------------+--------------------------------------+
4267 : The ncid of the file that contains the VLEN type.
4271 : The type of the VLEN.
4275 : The VLEN element to be set.
4279 : This will be set to the number of entries in this array.
4283 : The data will be copied here. Sufficient storage must be available
4284 or bad things will happen to you.
4295 : Can’t find the typeid.
4303 : Group ID part of ncid was invalid.
4308 ------------------------------------------------------------------------
4310 ------------------------------------------------------------------------------------ ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4311 \[[<](#NF90_005fGET_005fVLEN_005fELEMENT "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fCOMPOUND "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4312 ------------------------------------------------------------------------------------ ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4314 5.6 Compound Types Introduction {.section}
4315 -------------------------------
4317 NetCDF-4 added support for compound types, which allow users to
4318 construct a new type - a combination of other types, like a C struct.
4320 Compound types are not supported in classic or 64-bit offset format
4323 To write data in a compound type, first use nf90\_def\_compound to
4324 create the type, multiple calls to nf90\_insert\_compound to add to the
4325 compound type, and then write data with the appropriate nf90\_put\_var1,
4326 nf90\_put\_vara, nf90\_put\_vars, or nf90\_put\_varm call.
4328 To read data written in a compound type, you must know its structure.
4329 Use the NF90\_INQ\_COMPOUND functions to learn about the compound type.
4331 In Fortran a character buffer must be used for the compound data. The
4332 user must read the data from within that buffer in the same way that the
4333 C compiler which compiled netCDF would store the structure.
4335 The use of compound types introduces challenges and portability issues
4338 ------------------------ ------------------------ ------------------------
4341 NF90\_DEF\_COMPOUND](#NF
4342 90_005fDEF_005fCOMPOUND)
4344 [5.6.2 Inserting a Field
4345 into a Compound Type:
4346 NF90\_INSERT\_COMPOUND](
4347 #NF90_005fINSERT_005fCOM
4353 NF90\_INSERT\_ARRAY\_COM
4354 POUND](#NF90_005fINSERT_
4355 005fARRAY_005fCOMPOUND)
4357 [5.6.4 Learn About a
4359 NF90\_INQ\_COMPOUND](#NF
4360 90_005fINQ_005fCOMPOUND)
4362 [5.6.5 Learn About a
4365 NF90\_INQ\_COMPOUND\_FIE
4366 LD](#NF90_005fINQ_005fCO
4368 ------------------------ ------------------------ ------------------------
4370 ------------------------------------------------------------------------
4372 ----------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4373 \[[<](#Compound-Types "Previous section in reading order")\] \[[>](#NF90_005fINSERT_005fCOMPOUND "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Compound-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4374 ----------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4376 ### 5.6.1 Creating a Compound Type: NF90\_DEF\_COMPOUND {.subsection}
4378 Create a compound type. Provide an ncid, a name, and a total size (in
4379 bytes) of one element of the completed compound type.
4381 After calling this function, fill out the type with repeated calls to
4382 NF90\_INSERT\_COMPOUND (see section [Inserting a Field into a Compound
4383 Type: NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)). Call
4384 NF90\_INSERT\_COMPOUND once for each field you wish to insert into the
4387 Note that there does not seem to be a fully portable way to read such
4388 types into structures in Fortran 90 (and there are no structures in
4389 Fortran 77). Dozens of top-notch programmers are swarming over this
4390 problem in a sub-basement of Unidata’s giant underground bunker in
4393 Fortran users may use character buffers to read and write compound
4394 types. User are invited to try classic Fortran features such as the
4395 equivilence and the common block statment.
4400 +--------------------------------------+--------------------------------------+
4401 | | ``` {.example} |
4402 | | function nf90_def_compound(ncid, s |
4403 | | ize, name, typeid) |
4404 | | integer, intent(in) :: ncid |
4405 | | integer, intent(in) :: size |
4406 | | character (len = *), intent(in) |
4408 | | integer, intent(out) :: typeid |
4409 | | integer :: nf90_def_compound |
4411 +--------------------------------------+--------------------------------------+
4415 : The groupid where this compound type will be created.
4419 : The size, in bytes, of the compound type.
4423 : The name of the new compound type.
4427 : The typeid of the new type will be placed here.
4442 : That name is in use. Compound type names must be unique in the
4447 : Name exceeds max length NF90\_MAX\_NAME.
4451 : Name contains illegal characters.
4455 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
4456 operations can only be performed on files defined with a create mode
4457 which includes flag NF90\_NETCDF4. (see section
4458 [NF90\_OPEN](#NF90_005fOPEN)).
4462 : This file was created with the strict netcdf-3 flag, therefore
4463 netcdf-4 operations are not allowed. (see section
4464 [NF90\_OPEN](#NF90_005fOPEN)).
4468 : An error was reported by the HDF5 layer.
4472 : Attempt to write to a read-only file.
4476 : Not in define mode.
4481 ------------------------------------------------------------------------
4483 ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4484 \[[<](#NF90_005fDEF_005fCOMPOUND "Previous section in reading order")\] \[[>](#NF90_005fINSERT_005fARRAY_005fCOMPOUND "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Compound-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4485 ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4487 ### 5.6.2 Inserting a Field into a Compound Type: NF90\_INSERT\_COMPOUND {.subsection}
4489 Insert a named field into a compound type.
4494 +--------------------------------------+--------------------------------------+
4495 | | ``` {.example} |
4496 | | function nf90_insert_compound(ncid |
4497 | | , xtype, name, offset, field_typeid) |
4498 | | integer, intent(in) :: ncid |
4499 | | integer, intent(in) :: xtype |
4500 | | character (len = *), intent(in) |
4502 | | integer, intent(in) :: offset |
4503 | | integer, intent(in) :: field_typ |
4505 | | integer :: nf90_insert_compound |
4507 +--------------------------------------+--------------------------------------+
4511 : The typeid for this compound type, as returned by
4512 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4516 : The name of the new field.
4520 : Offset in byte from the beginning of the compound type for
4525 : The type of the field to be inserted.
4540 : That name is in use. Field names must be unique within a
4545 : Name exceed max length NF90\_MAX\_NAME.
4549 : Name contains illegal characters.
4553 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
4554 operations can only be performed on files defined with a create mode
4555 which includes flag NF90\_NETCDF4. (see section
4556 [NF90\_OPEN](#NF90_005fOPEN)).
4560 : This file was created with the strict netcdf-3 flag, therefore
4561 netcdf-4 operations are not allowed. (see section
4562 [NF90\_OPEN](#NF90_005fOPEN)).
4566 : An error was reported by the HDF5 layer.
4570 : Not in define mode.
4575 ------------------------------------------------------------------------
4577 ------------------------------------------------------------------------------- ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4578 \[[<](#NF90_005fINSERT_005fCOMPOUND "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fCOMPOUND "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Compound-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4579 ------------------------------------------------------------------------------- ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4581 ### 5.6.3 Inserting an Array Field into a Compound Type: NF90\_INSERT\_ARRAY\_COMPOUND {.subsection}
4583 Insert a named array field into a compound type.
4588 +--------------------------------------+--------------------------------------+
4589 | | ``` {.example} |
4590 | | function nf90_insert_array_compoun |
4591 | | d(ncid, xtype, name, offset, field_t |
4593 | | ndims, dim_sizes) |
4594 | | integer, intent(in) :: ncid |
4595 | | integer, intent(in) :: xtype |
4596 | | character (len = *), intent(in) |
4598 | | integer, intent(in) :: offset |
4599 | | integer, intent(in) :: field_typ |
4601 | | integer, intent(in) :: ndims |
4602 | | integer, intent(in) :: dim_sizes |
4603 | | integer :: nf90_insert_array_com |
4606 +--------------------------------------+--------------------------------------+
4610 : The ID of the file that contains the array type and the
4615 : The typeid for this compound type, as returned by
4616 nf90\_def\_compound, or nf90\_inq\_var.
4620 : The name of the new field.
4624 : Offset in byte from the beginning of the compound type for
4629 : The base type of the array to be inserted.
4633 : The number of dimensions for the array to be inserted.
4637 : An array containing the sizes of each dimension.
4652 : That name is in use. Field names must be unique within a
4657 : Name exceed max length NF90\_MAX\_NAME.
4661 : Name contains illegal characters.
4665 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
4666 operations can only be performed on files defined with a create mode
4667 which includes flag NF90\_NETCDF4. (see section
4668 [NF90\_OPEN](#NF90_005fOPEN)).
4672 : This file was created with the strict netcdf-3 flag, therefore
4673 netcdf-4 operations are not allowed. (see section
4674 [NF90\_OPEN](#NF90_005fOPEN)).
4678 : An error was reported by the HDF5 layer.
4682 : Not in define mode.
4686 : Attempt to change type that has already been committed. The first
4687 time the file leaves define mode, all defined types are committed,
4688 and can’t be changed. If you wish to add an array to a compound
4689 type, you must do so before the compound type is committed.
4694 ------------------------------------------------------------------------
4696 ----------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4697 \[[<](#NF90_005fINSERT_005fARRAY_005fCOMPOUND "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fCOMPOUND_005fFIELD "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Compound-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4698 ----------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4700 ### 5.6.4 Learn About a Compound Type: NF90\_INQ\_COMPOUND {.subsection}
4702 Get the number of fields, length in bytes, and name of a compound type.
4704 In addtion to the NF90\_INQ\_COMPOUND function, three additional
4705 functions are provided which get only the name, size, and number of
4711 +--------------------------------------+--------------------------------------+
4712 | | ``` {.example} |
4713 | | function nf90_inq_compound(ncid, x |
4714 | | type, name, size, nfields) |
4715 | | integer, intent(in) :: ncid |
4716 | | integer, intent(in) :: xtype |
4717 | | character (len = *), intent(out) |
4719 | | integer, intent(out) :: size |
4720 | | integer, intent(out) :: nfields |
4721 | | integer :: nf90_inq_compound |
4723 | | function nf90_inq_compound_name(nc |
4724 | | id, xtype, name) |
4725 | | integer, intent(in) :: ncid |
4726 | | integer, intent(in) :: xtype |
4727 | | character (len = *), intent(out) |
4729 | | integer :: nf90_inq_compound_nam |
4732 | | function nf90_inq_compound_size(nc |
4733 | | id, xtype, size) |
4734 | | integer, intent(in) :: ncid |
4735 | | integer, intent(in) :: xtype |
4736 | | integer, intent(out) :: size |
4737 | | integer :: nf90_inq_compound_siz |
4740 | | function nf90_inq_compound_nfields |
4741 | | (ncid, xtype, nfields) |
4742 | | integer, intent(in) :: ncid |
4743 | | integer, intent(in) :: xtype |
4744 | | integer, intent(out) :: nfields |
4745 | | integer :: nf90_inq_compound_nfi |
4748 +--------------------------------------+--------------------------------------+
4752 : The ID of any group in the file that contains the compound type.
4756 : The typeid for this compound type, as returned by
4757 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4761 : Character array which will get the name of the compound type. It
4762 will have a maximum length of NF90\_MAX\_NAME.
4766 : The size of the compound type in bytes will be put here.
4770 : The number of fields in the compound type will be placed here.
4772 Return Codes {.heading}
4781 : Couldn’t find this ncid.
4785 : Not a netCDF-4/HDF5 file.
4789 : A netCDF-4/HDF5 file, but with CLASSIC\_MODEL. No user defined types
4790 are allowed in the classic model.
4794 : This type not a compound type.
4802 : An error was reported by the HDF5 layer.
4807 ------------------------------------------------------------------------
4809 ---------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4810 \[[<](#NF90_005fINQ_005fCOMPOUND "Previous section in reading order")\] \[[>](#Variable-Length-Array "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Compound-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4811 ---------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4813 ### 5.6.5 Learn About a Field of a Compound Type: NF90\_INQ\_COMPOUND\_FIELD {.subsection}
4815 Get information about one of the fields of a compound type.
4820 +--------------------------------------+--------------------------------------+
4821 | | ``` {.example} |
4822 | | function nf90_inq_compound_field(n |
4823 | | cid, xtype, fieldid, name, offset, & |
4824 | | field_typeid, ndims, dim_size |
4826 | | integer, intent(in) :: ncid |
4827 | | integer, intent(in) :: xtype |
4828 | | integer, intent(in) :: fieldid |
4829 | | character (len = *), intent(out) |
4831 | | integer, intent(out) :: offset |
4832 | | integer, intent(out) :: field_ty |
4834 | | integer, intent(out) :: ndims |
4835 | | integer, intent(out) :: dim_size |
4837 | | integer :: nf90_inq_compound_fie |
4840 | | function nf90_inq_compound_fieldna |
4841 | | me(ncid, xtype, fieldid, name) |
4842 | | integer, intent(in) :: ncid |
4843 | | integer, intent(in) :: xtype |
4844 | | integer, intent(in) :: fieldid |
4845 | | character (len = *), intent(out) |
4847 | | integer :: nf90_inq_compound_fie |
4850 | | function nf90_inq_compound_fieldin |
4851 | | dex(ncid, xtype, name, fieldid) |
4852 | | integer, intent(in) :: ncid |
4853 | | integer, intent(in) :: xtype |
4854 | | character (len = *), intent(in) |
4856 | | integer, intent(out) :: fieldid |
4857 | | integer :: nf90_inq_compound_fie |
4860 | | function nf90_inq_compound_fieldof |
4861 | | fset(ncid, xtype, fieldid, offset) |
4862 | | integer, intent(in) :: ncid |
4863 | | integer, intent(in) :: xtype |
4864 | | integer, intent(in) :: fieldid |
4865 | | integer, intent(out) :: offset |
4866 | | integer :: nf90_inq_compound_fie |
4869 | | function nf90_inq_compound_fieldty |
4870 | | pe(ncid, xtype, fieldid, field_typei |
4872 | | integer, intent(in) :: ncid |
4873 | | integer, intent(in) :: xtype |
4874 | | integer, intent(in) :: fieldid |
4875 | | integer, intent(out) :: field_ty |
4877 | | integer :: nf90_inq_compound_fie |
4880 | | function nf90_inq_compound_fieldnd |
4881 | | ims(ncid, xtype, fieldid, ndims) |
4882 | | integer, intent(in) :: ncid |
4883 | | integer, intent(in) :: xtype |
4884 | | integer, intent(in) :: fieldid |
4885 | | integer, intent(out) :: ndims |
4886 | | integer :: nf90_inq_compound_fie |
4889 | | function nf90_inq_cmp_fielddim_siz |
4890 | | es(ncid, xtype, fieldid, dim_sizes) |
4891 | | integer, intent(in) :: ncid |
4892 | | integer, intent(in) :: xtype |
4893 | | integer, intent(in) :: fieldid |
4894 | | integer, intent(out) :: dim_size |
4896 | | integer :: nf90_inq_cmp_fielddim |
4899 +--------------------------------------+--------------------------------------+
4903 : The groupid where this compound type exists.
4907 : The typeid for this compound type, as returned by
4908 NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4912 : A one-based index number specifying a field in the compound type.
4916 : A character array which will get the name of the field. The name
4917 will be NF90\_MAX\_NAME characters, at most.
4921 : An integer which will get the offset of the field.
4925 : An integer which will get the typeid of the field.
4929 : An integer which will get the number of dimensions of the field.
4933 : An integer array which will get the dimension sizes of the field.
4948 : An error was reported by the HDF5 layer.
4953 ------------------------------------------------------------------------
4955 -------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4956 \[[<](#NF90_005fINQ_005fCOMPOUND_005fFIELD "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fVLEN "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
4957 -------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4959 5.7 Variable Length Array Introduction {.section}
4960 --------------------------------------
4962 NetCDF-4 added support for a variable length array type. This is not
4963 supported in classic or 64-bit offset files, or in netCDF-4 files which
4964 were created with the NF90\_CLASSIC\_MODEL flag.
4966 A variable length array is represented in C as a structure from HDF5,
4967 the nf90\_vlen\_t structure. It contains a len member, which contains
4968 the length of that array, and a pointer to the array.
4970 So an array of VLEN in C is an array of nc\_vlen\_t structures. The only
4971 way to handle this in Fortran is with a character buffer sized correctly
4974 VLEN arrays are handled differently with respect to allocation of
4975 memory. Generally, when reading data, it is up to the user to malloc
4976 (and subsequently free) the memory needed to hold the data. It is up to
4977 the user to ensure that enough memory is allocated.
4979 With VLENs, this is impossible. The user cannot know the size of an
4980 array of VLEN until after reading the array. Therefore when reading VLEN
4981 arrays, the netCDF library will allocate the memory for the data within
4984 It is up to the user, however, to eventually free this memory. This is
4985 not just a matter of one call to free, with the pointer to the array of
4986 VLENs; each VLEN contains a pointer which must be freed.
4988 Compression is permitted but may not be effective for VLEN data, because
4989 the compression is applied to the nc\_vlen\_t structures, rather than
4992 ------------------------ ------------------------ ------------------------
4993 [5.7.1 Define a Variable
4994 Length Array (VLEN):
4995 NF90\_DEF\_VLEN](#NF90_0
4998 [5.7.2 Learning about a
4999 Variable Length Array
5001 NF90\_INQ\_VLEN](#NF90_0
5004 [5.7.3 Releasing Memory
5005 for a Variable Length
5007 NF90\_FREE\_VLEN](#NF90_
5009 ------------------------ ------------------------ ------------------------
5011 ------------------------------------------------------------------------
5013 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5014 \[[<](#Variable-Length-Array "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fVLEN "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Variable-Length-Array "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5015 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5017 ### 5.7.1 Define a Variable Length Array (VLEN): NF90\_DEF\_VLEN {.subsection}
5019 Use this function to define a variable length array type.
5024 +--------------------------------------+--------------------------------------+
5025 | | ``` {.example} |
5026 | | function nf90_def_vlen(ncid, name, |
5027 | | base_typeid, xtypeid) |
5028 | | integer, intent(in) :: ncid |
5029 | | character (len = *), intent(in) |
5031 | | integer, intent(in) :: base_type |
5033 | | integer, intent(out) :: xtypeid |
5034 | | integer :: nf90_def_vlen |
5036 +--------------------------------------+--------------------------------------+
5040 : The ncid of the file to create the VLEN type in.
5044 : A name for the VLEN type.
5048 : The typeid of the base type of the VLEN. For example, for a VLEN of
5049 shorts, the base type is NF90\_SHORT. This can be a user
5054 : The typeid of the new VLEN type will be set here.
5065 : NF90\_MAX\_NAME exceeded.
5069 : Name is already in use.
5073 : Attribute or variable name contains illegal characters.
5081 : Group ID part of ncid was invalid.
5094 ------------------------------------------------------------------------
5096 ------------------------------------------------------------------------ --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5097 \[[<](#NF90_005fDEF_005fVLEN "Previous section in reading order")\] \[[>](#NF90_005fFREE_005fVLEN "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Variable-Length-Array "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5098 ------------------------------------------------------------------------ --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5100 ### 5.7.2 Learning about a Variable Length Array (VLEN) Type: NF90\_INQ\_VLEN {.subsection}
5102 Use this type to learn about a vlen.
5107 +--------------------------------------+--------------------------------------+
5108 | | ``` {.example} |
5109 | | function nf90_inq_vlen(ncid, xtype |
5110 | | , name, datum_size, base_nc_type) |
5111 | | integer, intent(in) :: ncid |
5112 | | integer, intent(in) :: xtype |
5113 | | character (len = *), intent(out) |
5115 | | integer, intent(out) :: datum_si |
5117 | | integer, intent(out) :: base_nc_ |
5119 | | integer :: nf90_inq_vlen |
5121 +--------------------------------------+--------------------------------------+
5125 : The ncid of the file that contains the VLEN type.
5129 : The type of the VLEN to inquire about.
5133 : The name of the VLEN type. The name will be NF90\_MAX\_NAME
5138 : A pointer to a size\_t, this will get the size of one element of
5143 : An integer that will get the type of the VLEN base type. (In other
5144 words, what type is this a VLEN of?)
5155 : Can’t find the typeid.
5163 : Group ID part of ncid was invalid.
5168 ------------------------------------------------------------------------
5170 ------------------------------------------------------------------------ ---------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5171 \[[<](#NF90_005fINQ_005fVLEN "Previous section in reading order")\] \[[>](#Opaque-Type "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Variable-Length-Array "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5172 ------------------------------------------------------------------------ ---------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5174 ### 5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type: NF90\_FREE\_VLEN {.subsection}
5176 When a VLEN is read into user memory from the file, the HDF5 library
5177 performs memory allocations for each of the variable length arrays
5178 contained within the VLEN structure. This memory must be freed by the
5179 user to avoid memory leaks.
5181 This violates the normal netCDF expectation that the user is responsible
5182 for all memory allocation. But, with VLEN arrays, the underlying HDF5
5183 library allocates the memory for the user, and the user is responsible
5184 for deallocating that memory.
5189 +--------------------------------------+--------------------------------------+
5190 | | ``` {.example} |
5191 | | function nf90_free_vlen(vl) |
5192 | | character (len = *), intent(in) |
5194 | | integer :: nf90_free_vlen |
5195 | | end function nf90_free_vlen |
5197 +--------------------------------------+--------------------------------------+
5201 : The variable length array structure which is to be freed.
5212 : Can’t find the typeid.
5217 ------------------------------------------------------------------------
5219 ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5220 \[[<](#NF90_005fFREE_005fVLEN "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fOPAQUE "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5221 ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5223 5.8 Opaque Type Introduction {.section}
5224 ----------------------------
5226 NetCDF-4 added support for the opaque type. This is not supported in
5227 classic or 64-bit offset files.
5229 The opaque type is a type which is a collection of objects of a known
5230 size. (And each object is the same size). Nothing is known to netCDF
5231 about the contents of these blobs of data, except their size in bytes,
5232 and the name of the type.
5234 To use an opaque type, first define it with [Creating Opaque Types:
5235 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE). If encountering an enum
5236 type in a new data file, use [Learn About an Opaque Type:
5237 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE) to learn its name and size.
5239 ------------------------ ------------------------ ------------------------
5240 [5.8.1 Creating Opaque
5242 NF90\_DEF\_OPAQUE](#NF90
5243 _005fDEF_005fOPAQUE)
5245 [5.8.2 Learn About an
5247 NF90\_INQ\_OPAQUE](#NF90
5248 _005fINQ_005fOPAQUE)
5249 ------------------------ ------------------------ ------------------------
5251 ------------------------------------------------------------------------
5253 -------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5254 \[[<](#Opaque-Type "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fOPAQUE "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Opaque-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5255 -------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5257 ### 5.8.1 Creating Opaque Types: NF90\_DEF\_OPAQUE {.subsection}
5259 Create an opaque type. Provide a size and a name.
5264 +--------------------------------------+--------------------------------------+
5265 | | ``` {.example} |
5266 | | function nf90_def_opaque(ncid, siz |
5267 | | e, name, xtype) |
5268 | | integer, intent(in) :: ncid |
5269 | | integer, intent(in) :: size |
5270 | | character (len = *), intent(in) |
5272 | | integer, intent(out) :: xtype |
5273 | | integer :: nf90_def_opaque |
5275 +--------------------------------------+--------------------------------------+
5279 : The groupid where the type will be created. The type may be used
5280 anywhere in the file, no matter what group it is in.
5284 : The name for this type. Must be shorter than NF90\_MAX\_NAME.
5288 : The size of each opaque object.
5292 : Pointer where the new typeid for this type is returned. Use this
5293 typeid when defining variables of this type with [Create a Variable:
5294 `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR).
5313 : An error was reported by the HDF5 layer.
5318 ------------------------ ------------------------ ------------------------
5319 [5.8.2 Learn About an
5321 NF90\_INQ\_OPAQUE](#NF90
5322 _005fINQ_005fOPAQUE)
5323 ------------------------ ------------------------ ------------------------
5325 ------------------------------------------------------------------------
5327 -------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5328 \[[<](#NF90_005fDEF_005fOPAQUE "Previous section in reading order")\] \[[>](#Enum-Type "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Opaque-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5329 -------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5331 ### 5.8.2 Learn About an Opaque Type: NF90\_INQ\_OPAQUE {.subsection}
5333 Given a typeid, get the information about an opaque type.
5338 +--------------------------------------+--------------------------------------+
5339 | | ``` {.example} |
5340 | | function nf90_inq_opaque(ncid, xty |
5341 | | pe, name, size) |
5342 | | integer, intent(in) :: ncid |
5343 | | integer, intent(in) :: xtype |
5344 | | character (len = *), intent(out) |
5346 | | integer, intent(out) :: size |
5347 | | integer :: nf90_inq_opaque |
5349 +--------------------------------------+--------------------------------------+
5353 : The ncid for the group containing the opaque type.
5357 : The typeid for this opaque type, as returned by NF90\_DEF\_COMPOUND,
5362 : The name of the opaque type will be copied here. It will be
5363 NF90\_MAX\_NAME bytes or less.
5367 : The size of the opaque type will be copied here.
5386 : An error was reported by the HDF5 layer.
5391 ------------------------------------------------------------------------
5393 -------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5394 \[[<](#NF90_005fINQ_005fOPAQUE "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fENUM "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#User-Defined-Data-Types "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5395 -------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5397 5.9 Enum Type Introduction {.section}
5398 --------------------------
5400 NetCDF-4 added support for the enum type. This is not supported in
5401 classic or 64-bit offset files.
5403 ------------------------ ------------------------ ------------------------
5404 [5.9.1 Creating a Enum
5406 NF90\_DEF\_ENUM](#NF90_0
5409 [5.9.2 Inserting a Field
5411 NF90\_INSERT\_ENUM](#NF9
5412 0_005fINSERT_005fENUM)
5414 [5.9.3 Learn About a
5416 NF90\_INQ\_ENUM](#NF90_0
5419 [5.9.4 Learn the Name of
5421 nf90\_inq\_enum\_member]
5422 (#NF90_005fINQ_005fENUM_
5425 [5.9.5 Learn the Name of
5427 NF90\_INQ\_ENUM\_IDENT](
5428 #NF90_005fINQ_005fENUM_0
5430 ------------------------ ------------------------ ------------------------
5432 ------------------------------------------------------------------------
5434 ------------------------------------------------------------ ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5435 \[[<](#Enum-Type "Previous section in reading order")\] \[[>](#NF90_005fINSERT_005fENUM "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Enum-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5436 ------------------------------------------------------------ ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5438 ### 5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM {.subsection}
5440 Create an enum type. Provide an ncid, a name, and a base integer type.
5442 After calling this function, fill out the type with repeated calls to
5443 NF90\_INSERT\_ENUM (see section [Inserting a Field into a Enum Type:
5444 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)). Call NF90\_INSERT\_ENUM
5445 once for each value you wish to make part of the enumeration.
5450 +--------------------------------------+--------------------------------------+
5451 | | ``` {.example} |
5452 | | function nf90_def_enum(ncid, base_ |
5453 | | typeid, name, typeid) |
5454 | | integer, intent(in) :: ncid |
5455 | | integer, intent(in) :: base_type |
5457 | | character (len = *), intent(in) |
5459 | | integer, intent(out) :: typeid |
5460 | | integer :: nf90_def_enum |
5462 +--------------------------------------+--------------------------------------+
5466 : The groupid where this compound type will be created.
5470 : The base integer type for this enum. Must be one of: NF90\_BYTE,
5471 NF90\_UBYTE, NF90\_SHORT, NF90\_USHORT, NF90\_INT, NF90\_UINT,
5472 NF90\_INT64, NF90\_UINT64.
5476 : The name of the new enum type.
5480 : The typeid of the new type will be placed here.
5495 : That name is in use. Compound type names must be unique in the
5500 : Name exceeds max length NF90\_MAX\_NAME.
5504 : Name contains illegal characters.
5508 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
5509 operations can only be performed on files defined with a create mode
5510 which includes flag NF90\_NETCDF4. (see section
5511 [NF90\_OPEN](#NF90_005fOPEN)).
5515 : This file was created with the strict netcdf-3 flag, therefore
5516 netcdf-4 operations are not allowed. (see section
5517 [NF90\_OPEN](#NF90_005fOPEN)).
5521 : An error was reported by the HDF5 layer.
5525 : Attempt to write to a read-only file.
5529 : Not in define mode.
5534 ------------------------------------------------------------------------
5536 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5537 \[[<](#NF90_005fDEF_005fENUM "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fENUM "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Enum-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5538 ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5540 ### 5.9.2 Inserting a Field into a Enum Type: NF90\_INSERT\_ENUM {.subsection}
5542 Insert a named member into a enum type.
5547 +--------------------------------------+--------------------------------------+
5548 | | ``` {.example} |
5549 | | function nf90_insert_enum(ncid, xt |
5550 | | ype, name, value) |
5551 | | integer, intent(in) :: ncid |
5552 | | integer, intent(in) :: xtype |
5553 | | character (len = *), intent(in) |
5555 | | integer, intent(in) :: value |
5556 | | integer :: nf90_insert_enum |
5558 +--------------------------------------+--------------------------------------+
5562 : The ncid of the group which contains the type.
5566 : The typeid for this enum type, as returned by nf90\_def\_enum,
5571 : The identifier of the new member.
5575 : The value that is to be associated with this member.
5590 : That name is in use. Field names must be unique within a enum type.
5594 : Name exceed max length NF90\_MAX\_NAME.
5598 : Name contains illegal characters.
5602 : Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
5603 operations can only be performed on files defined with a create mode
5604 which includes flag NF90\_NETCDF4. (see section
5605 [NF90\_OPEN](#NF90_005fOPEN)).
5609 : This file was created with the strict netcdf-3 flag, therefore
5610 netcdf-4 operations are not allowed. (see section
5611 [NF90\_OPEN](#NF90_005fOPEN)).
5615 : An error was reported by the HDF5 layer.
5619 : Not in define mode.
5624 ------------------------------------------------------------------------
5626 --------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5627 \[[<](#NF90_005fINSERT_005fENUM "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fENUM_005fMEMBER "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Enum-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5628 --------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5630 ### 5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM {.subsection}
5632 Get information about a user-defined enumeration type.
5637 +--------------------------------------+--------------------------------------+
5638 | | ``` {.example} |
5639 | | function nf90_inq_enum(ncid, xtype |
5640 | | , name, base_nc_type, base_size, num |
5642 | | integer, intent(in) :: ncid |
5643 | | integer, intent(in) :: xtype |
5644 | | character (len = *), intent(out) |
5646 | | integer, intent(out) :: base_nc_ |
5648 | | integer, intent(out) :: base_siz |
5650 | | integer, intent(out) :: num_memb |
5652 | | integer :: nf90_inq_enum |
5654 +--------------------------------------+--------------------------------------+
5658 : The group ID of the group which holds the enum type.
5662 : The typeid for this enum type, as returned by NF90\_DEF\_ENUM,
5667 : Character array which will get the name. It will have a maximum
5668 length of NF90\_MAX\_NAME.
5672 : An integer which will get the base integer type of this enum.
5676 : An integer which will get the size (in bytes) of the base integer
5681 : An integer which will get the number of members defined for this
5697 : An error was reported by the HDF5 layer.
5702 ------------------------------------------------------------------------
5704 ------------------------------------------------------------------------ ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5705 \[[<](#NF90_005fINQ_005fENUM "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fENUM_005fIDENT "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Enum-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5706 ------------------------------------------------------------------------ ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5708 ### 5.9.4 Learn the Name of a Enum Type: nf90\_inq\_enum\_member {.subsection}
5710 Get information about a member of an enum type.
5715 +--------------------------------------+--------------------------------------+
5716 | | ``` {.example} |
5717 | | function nf90_inq_enum_member(ncid |
5718 | | , xtype, idx, name, value) |
5719 | | integer, intent(in) :: ncid |
5720 | | integer, intent(in) :: xtype |
5721 | | integer, intent(in) :: idx |
5722 | | character (len = *), intent(out) |
5724 | | integer, intent(in) :: value |
5725 | | integer :: nf90_inq_enum_member |
5727 +--------------------------------------+--------------------------------------+
5731 : The groupid where this enum type exists.
5735 : The typeid for this enum type.
5739 : The one-based index number for the member of interest.
5743 : A character array which will get the name of the member. It will
5744 have a maximum length of NF90\_MAX\_NAME.
5748 : An integer that will get the value associated with this member.
5763 : An error was reported by the HDF5 layer.
5768 ------------------------------------------------------------------------
5770 ----------------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5771 \[[<](#NF90_005fINQ_005fENUM_005fMEMBER "Previous section in reading order")\] \[[>](#Variables "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Enum-Type "Up section")\] \[[>>](#Variables "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5772 ----------------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5774 ### 5.9.5 Learn the Name of a Enum Type: NF90\_INQ\_ENUM\_IDENT {.subsection}
5776 Get the name which is associated with an enum member value.
5778 This is similar to NF90\_INQ\_ENUM\_MEMBER, but instead of using the
5779 index of the member, you use the value of the member.
5784 +--------------------------------------+--------------------------------------+
5785 | | ``` {.example} |
5786 | | function nf90_inq_enum_ident(ncid, |
5787 | | xtype, value, idx) |
5788 | | integer, intent(in) :: ncid |
5789 | | integer, intent(in) :: xtype |
5790 | | integer, intent(in) :: value |
5791 | | integer, intent(out) :: idx |
5792 | | integer :: nf90_inq_enum_ident |
5794 +--------------------------------------+--------------------------------------+
5798 : The groupid where this enum type exists.
5802 : The typeid for this enum type.
5806 : The value for which an identifier is sought.
5810 : A character array that will get the identifier. It will have a
5811 maximum length of NF90\_MAX\_NAME.
5813 Return Code {.heading}
5822 : Bad type id, or not an enum type.
5826 : An error was reported by the HDF5 layer.
5830 : The value was not found in the enum.
5835 ------------------------------------------------------------------------
5837 ---------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5838 \[[<](#NF90_005fINQ_005fENUM_005fIDENT "Previous section in reading order")\] \[[>](#Variables-Introduction "Next section in reading order")\] \[[<<](#User-Defined-Data-Types "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5839 ---------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5841 6. Variables {.chapter}
5844 ------------------------ ------------------------ ------------------------
5846 Introduction](#Variables
5850 Corresponding to netCDF
5852 types](#Language_002dTyp
5855 [6.3 Create a Variable: Create a Variable
5856 `NF90_DEF_VAR`](#NF90_00
5862 `nf90_def_var_fill`](#NF
5863 90_005fDEF_005fVAR_005fF
5866 [6.5 Learn About Fill
5869 `NF90_INQ_VAR_FILL`](#NF
5870 90_005fINQ_005fVAR_005fF
5873 [6.6 Get Information Get Var Metadata
5874 about a Variable from
5876 NF90\_INQUIRE\_VARIABLE]
5877 (#NF90_005fINQUIRE_005fV
5880 [6.7 Get the ID of a
5881 variable from the name:
5882 NF90\_INQ\_VARID](#NF90_
5885 [6.8 Writing Data Write data
5887 NF90\_PUT\_VAR](#NF90_00
5890 [6.9 Reading Data Read data
5892 NF90\_GET\_VAR](#NF90_00
5896 Writing Character String
5897 Values](#Reading-and-Wri
5898 ting-Character-String-Va
5901 [6.11 Fill What’s Written Where
5902 Values](#Fill-Values) there’s No Data?
5905 NF90\_RENAME\_VAR](#NF90
5906 _005fRENAME_005fVAR)
5908 [6.13 Change between
5910 Independent Parallel
5912 NF90\_VAR\_PAR\_ACCESS](
5913 #NF90_005fVAR_005fPAR_00
5915 ------------------------ ------------------------ ------------------------
5917 ------------------------------------------------------------------------
5919 ------------------------------------------------------------ ----------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5920 \[[<](#Variables "Previous section in reading order")\] \[[>](#Language_002dTypes "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5921 ------------------------------------------------------------ ----------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5923 6.1 Variables Introduction {.section}
5924 --------------------------
5926 Variables for a netCDF dataset are defined when the dataset is created,
5927 while the netCDF dataset is in define mode. Other variables may be added
5928 later by reentering define mode. A netCDF variable has a name, a type,
5929 and a shape, which are specified when it is defined. A variable may also
5930 have values, which are established later in data mode.
5932 Ordinarily, the name, type, and shape are fixed when the variable is
5933 first defined. The name may be changed, but the type and shape of a
5934 variable cannot be changed. However, a variable defined in terms of the
5935 unlimited dimension can grow without bound in that dimension.
5937 A netCDF variable in an open netCDF dataset is referred to by a small
5938 integer called a variable ID.
5940 Variable IDs reflect the order in which variables were defined within a
5941 netCDF dataset. Variable IDs are 1, 2, 3,..., in the order in which the
5942 variables were defined. A function is available for getting the variable
5943 ID from the variable name and vice-versa.
5945 Attributes (see [Attributes](#Attributes)) may be associated with a
5946 variable to specify such properties as units.
5948 Operations supported on variables are:
5950 - Create a variable, given its name, data type, and shape.
5951 - Get a variable ID from its name.
5952 - Get a variable’s name, data type, shape, and number of attributes
5954 - Put a data value into a variable, given variable ID, indices,
5956 - Put an array of values into a variable, given variable ID, corner
5957 indices, edge lengths, and a block of values.
5958 - Put a subsampled or mapped array-section of values into a variable,
5959 given variable ID, corner indices, edge lengths, stride vector,
5960 index mapping vector, and a block of values.
5961 - Get a data value from a variable, given variable ID and indices.
5962 - Get an array of values from a variable, given variable ID, corner
5963 indices, and edge lengths.
5964 - Get a subsampled or mapped array-section of values from a variable,
5965 given variable ID, corner indices, edge lengths, stride vector, and
5966 index mapping vector.
5967 - Rename a variable.
5969 ------------------------------------------------------------------------
5971 ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5972 \[[<](#Variables-Introduction "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fVAR "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
5973 ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5975 6.2 Language Types Corresponding to netCDF external data types {.section}
5976 --------------------------------------------------------------
5978 The following table gives the netCDF external data types and the
5979 corresponding type constants for defining variables in the FORTRAN
5982 -------- ---------------------- ------
5983 Type FORTRAN API Mnemonic Bits
5986 short NF90\_SHORT 16
5988 float NF90\_FLOAT 32
5989 double NF90\_DOUBLE 64
5990 -------- ---------------------- ------
5992 The first column gives the netCDF external data type, which is the same
5993 as the CDL data type. The next column gives the corresponding Fortran 90
5994 parameter for use in netCDF functions (the parameters are defined in the
5995 netCDF Fortran 90 module netcdf.f90). The last column gives the number
5996 of bits used in the external representation of values of the
5999 Note that there are no netCDF types corresponding to 64-bit integers or
6000 to characters wider than 8 bits in the current version of the netCDF
6003 ------------------------------------------------------------------------
6005 --------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6006 \[[<](#Language_002dTypes "Previous section in reading order")\] \[[>](#NF90_005fDEF_005fVAR_005fFILL "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6007 --------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6009 6.3 Create a Variable: `NF90_DEF_VAR` {.section}
6010 -------------------------------------
6012 The function NF90\_DEF\_VAR adds a new variable to an open netCDF
6013 dataset in define mode. It returns (as an argument) a variable ID, given
6014 the netCDF ID, the variable name, the variable type, the number of
6015 dimensions, and a list of the dimension IDs.
6017 Optional arguments allow additional settings for variables in
6018 netCDF-4/HDF5 files. These parameters allow data compression and control
6019 of the layout of the data on disk for performance tuning. These
6020 parameters may also be used to set the chunk sizes to get chunked
6021 storage, or to set the contiguous flag to get contiguous storage.
6023 Variables that make use of one or more unlimited dimensions,
6024 compression, or checksums must use chunking. Such variables are created
6025 with default chunk sizes of 1 for each unlimited dimension and the
6026 dimension length for other dimensions, except that if the resulting
6027 chunks are too large, the default chunk sizes for non-record dimensions
6030 All parameters after the varid are optional, and only supported if
6031 netCDF was built with netCDF-4 features enabled, and if the variable is
6032 in a netCDF-4/HDF5 file.
6037 +--------------------------------------+--------------------------------------+
6038 | | ``` {.example} |
6039 | | function nf90_def_var(ncid, name, x |
6040 | | type, dimids, varid, contiguous, & |
6041 | | chunksizes, deflate_level, sh |
6042 | | uffle, fletcher32, endianness, & |
6043 | | cache_size, cache_nelems, cac |
6044 | | he_preemption) |
6045 | | integer, intent(in) :: ncid |
6046 | | character (len = *), intent(in) : |
6048 | | integer, intent( in) :: xtype |
6049 | | integer, scalar or dimension(:), |
6050 | | intent(in), optional :: dimids |
6051 | | integer, intent(out) :: varid |
6052 | | logical, optional, intent(in) :: |
6054 | | integer, optional, dimension(:), |
6055 | | intent(in) :: chunksizes |
6056 | | integer, optional, intent(in) :: |
6058 | | logical, optional, intent(in) :: |
6059 | | shuffle, fletcher32 |
6060 | | integer, optional, intent(in) :: |
6062 | | integer, optional, intent(in) :: |
6063 | | cache_size, cache_nelems, cache_pre |
6066 | | :: nf90_def_var |
6068 +--------------------------------------+--------------------------------------+
6072 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6080 : One of the set of predefined netCDF external data types. The type of
6081 this parameter, NF90\_TYPE, is defined in the netCDF header file.
6082 The valid netCDF external data types are NF90\_BYTE, NF90\_CHAR,
6083 NF90\_SHORT, NF90\_INT, NF90\_FLOAT, and NF90\_DOUBLE. If the file
6084 is a NetCDF-4/HDF5 file, the additional types NF90\_UBYTE,
6085 NF90\_USHORT, NF90\_UINT, NF90\_INT64, NF90\_UINT64, and
6086 NF90\_STRING may be used, as well as a user defined type ID.
6090 : Scalar or vector of dimension IDs corresponding to the
6091 variable dimensions. For example, a vector of 2 dimension IDs
6092 specifies a 2-dimensional matrix.
6094 If an integer is passed for this parameter, a 1-D variable
6097 If this parameter is not passed (or is a 1D array of size zero) it
6098 means the variable is a scalar with no dimensions.
6100 For classic data model files, if the ID of the unlimited dimension
6101 is included, it must be first. In expanded model netCDF4/HDF5 files,
6102 there may be any number of unlimited dimensions, and they may be
6103 used in any element of the dimids array.
6105 This argument is optional, and if absent specifies a scalar with
6110 : Returned variable ID.
6114 : If NF90\_CONTIGUOUS, then contiguous storage is used for
6115 this variable. Variables that use deflation, shuffle filter, or
6116 checksums, or that have one or more unlimited dimensions cannot use
6119 If NF90\_CHUNKED, then chunked storage is used for this variable.
6120 Chunk sizes may be specified with the chunksizes parameter. Default
6121 sizes will be used if chunking is required and this function is
6124 By default contiguous storage is used for fix-sized variables when
6125 conpression, chunking, shuffle, and checksums are not used.
6129 : An array of chunk number of elements. This array has the number of
6130 elements along each dimension of the data chunk. The array must have
6131 the one chunksize for each dimension in the variable.
6133 The total size of a chunk must be less than 4 GiB. That is, the
6134 product of all chunksizes and the size of the data (or the size of
6135 nc\_vlen\_t for VLEN types) must be less than 4 GiB. (This is a very
6136 large chunk size in any case.)
6138 If not provided, but chunked data are needed, then default
6139 chunksizes will be chosen. For more information see [The NetCDF
6140 Users Guide: (netcdf)Chunking](netcdf.html#Chunking) section
6141 ‘Chunking’ in The NetCDF Users Guide.
6145 : If non-zero, turn on the shuffle filter.
6149 : If the deflate parameter is non-zero, set the deflate level to
6150 this value. Must be between 1 and 9.
6154 : Set to true to turn on fletcher32 checksums for this variable.
6158 : Set to NF90\_ENDIAN\_LITTLE for little-endian format,
6159 NF90\_ENDIAN\_BIG for big-endian format, and NF90\_ENDIAN\_NATIVE
6160 (the default) for the native endianness of the platform.
6164 : The size of the per-variable cache in MegaBytes.
6168 : The number slots in the per-variable chunk cache (should be a prime
6169 number larger than the number of chunks in the cache).
6173 : The preemtion value must be between 0 and 100 inclusive and
6174 indicates how much chunks that have been fully read are favored
6175 for preemption. A value of zero means fully read chunks are treated
6176 no differently than other chunks (the preemption is strictly LRU)
6177 while a value of 100 means fully read chunks are always preempted
6178 before other chunks.
6180 Return Codes {.heading}
6183 NF90\_DEF\_VAR returns the value NF90\_NOERR if no errors occurred.
6184 Otherwise, the returned status indicates an error.
6186 - NF90\_EBADNAME The specified variable name is the name of another
6188 - NF90\_EBADTYPE The specified type is not a valid netCDF type.
6189 - NF90\_EMAXDIMS The specified number of dimensions is negative or
6190 more than the constant NF90\_MAX\_VAR\_DIMS, the maximum number of
6191 dimensions permitted for a netCDF variable. (Does not apply to
6192 netCDF-4/HDF5 files unless they were created with the
6193 CLASSIC\_MODE flag.)
6194 - NF90\_EBADDIM One or more of the dimension IDs in the list of
6195 dimensions is not a valid dimension ID for the netCDF dataset.
6196 - NF90\_EMAXVARS The number of variables would exceed the constant
6197 NF90\_MAX\_VARS, the maximum number of variables permitted in a
6198 classic netCDF dataset. (Does not apply to netCDF-4/HDF5 files
6199 unless they were created with the CLASSIC\_MODE flag.)
6200 - NF90\_BADID The specified netCDF ID does not refer to an open
6202 - NF90\_ENOTNC4 NetCDF-4 operation attempted on a files that is not a
6203 netCDF-4/HDF5 file. Only variables in NetCDF-4/HDF5 files may use
6204 compression, chunking, and endianness control.
6205 - NF90\_ENOTVAR Can’t find this variable.
6206 - NF90\_EINVAL Invalid input. This may be because contiguous storage
6207 is requested for a variable that has compression, checksums,
6208 chunking, or one or more unlimited dimensions.
6209 - NF90\_ELATEDEF This variable has already been the subject of a
6210 NF90\_ENDDEF call. Once enddef has been called, it is impossible to
6211 set the chunking for a variable. (In netCDF-4/HDF5 files
6212 NF90\_ENDDEF will be called automatically for any data read
6214 - NF90\_ENOTINDEFINE Not in define mode. This is returned for netCDF
6215 classic or 64-bit offset files, or for netCDF-4 files, when they
6216 were been created with NF90\_STRICT\_NC3 flag. (see section
6217 [NF90\_CREATE](#NF90_005fCREATE)).
6218 - NF90\_ESTRICTNC3 Trying to create a var some place other than the
6219 root group in a netCDF file with NF90\_STRICT\_NC3 turned on.
6224 Here is an example using NF90\_DEF\_VAR to create a variable named rh of
6225 type double with three dimensions, time, lat, and lon in a new netCDF
6226 dataset named foo.nc:
6228 +--------------------------------------+--------------------------------------+
6229 | | ``` {.example} |
6232 | | integer :: status, ncid |
6233 | | integer :: LonDimId, LatDimId, Time |
6235 | | integer :: RhVarId |
6237 | | status = nf90_create("foo.nc", nf90 |
6238 | | _NoClobber, ncid) |
6239 | | if(status /= nf90_NoErr) call handl |
6240 | | e_error(status) |
6242 | | ! Define the dimensions |
6243 | | status = nf90_def_dim(ncid, "lat", |
6245 | | if(status /= nf90_NoErr) call handl |
6246 | | e_error(status) |
6247 | | status = nf90_def_dim(ncid, "lon", |
6249 | | if(status /= nf90_NoErr) call handl |
6250 | | e_error(status) |
6251 | | status = nf90_def_dim(ncid, "time", |
6252 | | nf90_unlimited, TimeDimId) |
6253 | | if(status /= nf90_NoErr) call handl |
6254 | | e_error(status) |
6256 | | ! Define the variable |
6257 | | status = nf90_def_var(ncid, "rh", n |
6260 | | LatDimID, TimeDimID /), RhVarId) |
6261 | | if(status /= nf90_NoErr) call handl |
6262 | | e_error(status) |
6264 +--------------------------------------+--------------------------------------+
6266 In the following example, from nf\_test/f90tst\_vars2.f90, chunking,
6267 checksums, and endianness control are all used in a netCDF-4/HDF5 file.
6269 +--------------------------------------+--------------------------------------+
6270 | | ``` {.example} |
6271 | | ! Create the netCDF file. |
6272 | | call check(nf90_create(FILE_NAME, |
6273 | | nf90_netcdf4, ncid, cache_nelems = C |
6274 | | ACHE_NELEMS, & |
6275 | | cache_size = CACHE_SIZE)) |
6277 | | ! Define the dimensions. |
6278 | | call check(nf90_def_dim(ncid, "x", |
6280 | | call check(nf90_def_dim(ncid, "y", |
6282 | | dimids = (/ y_dimid, x_dimid /) |
6284 | | ! Define some variables. |
6285 | | chunksizes = (/ NY, NX /) |
6286 | | call check(nf90_def_var(ncid, VAR1 |
6287 | | _NAME, NF90_INT, dimids, varid1, chu |
6288 | | nksizes = chunksizes, & |
6289 | | shuffle = .TRUE., fletcher32 |
6290 | | = .TRUE., endianness = nf90_endian_b |
6291 | | ig, deflate_level = DEFLATE_LEVEL)) |
6292 | | call check(nf90_def_var(ncid, VAR2 |
6293 | | _NAME, NF90_INT, dimids, varid2, con |
6294 | | tiguous = .TRUE.)) |
6295 | | call check(nf90_def_var(ncid, VAR3 |
6296 | | _NAME, NF90_INT64, varid3)) |
6297 | | call check(nf90_def_var(ncid, VAR4 |
6298 | | _NAME, NF90_INT, x_dimid, varid4, co |
6299 | | ntiguous = .TRUE.)) |
6301 +--------------------------------------+--------------------------------------+
6303 ------------------------------------------------------------------------
6305 ----------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6306 \[[<](#NF90_005fDEF_005fVAR "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fVAR_005fFILL "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6307 ----------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6309 6.4 Define Fill Parameters for a Variable: `nf90_def_var_fill` {.section}
6310 --------------------------------------------------------------
6312 The function NF90\_DEF\_VAR\_FILL sets the fill parameters for a
6313 variable in a netCDF-4 file.
6315 This function must be called after the variable is defined, but before
6316 NF90\_ENDDEF is called.
6321 +--------------------------------------+--------------------------------------+
6322 | | ``` {.example} |
6323 | | NF90_DEF_VAR_FILL(INTEGER NCID, INTE |
6324 | | GER VARID, INTEGER NO_FILL, FILL_VAL |
6327 +--------------------------------------+--------------------------------------+
6331 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6339 : Set to non-zero value to set no\_fill mode on a variable. When this
6340 mode is on, fill values will not be written for the variable. This
6341 is helpful in high performance applications. For netCDF-4/HDF5 files
6342 (whether classic model or not), this may only be changed after the
6343 variable is defined, but before it is committed to disk (i.e. before
6344 the first NF90\_ENDDEF after the NF90\_DEF\_VAR.) For classic and
6345 64-bit offset file, the no\_fill mode may be turned on and off at
6350 : A value which will be used as the fill value for the variable. Must
6351 be the same type as the variable. This will be written to a
6352 \_FillValue attribute, created for this purpose. If NULL, this
6353 argument will be ignored.
6355 Return Codes {.heading}
6368 : Not a netCDF-4 file.
6372 : Can’t find this variable.
6376 : This variable has already been the subject of a NF90\_ENDDEF call.
6377 In netCDF-4 files NF90\_ENDDEF will be called automatically for any
6378 data read or write. Once enddef has been called, it is impossible to
6379 set the fill for a variable.
6383 : Not in define mode. This is returned for netCDF classic or 64-bit
6384 offset files, or for netCDF-4 files, when they were been created
6385 with NF90\_STRICT\_NC3 flag. (see section
6386 [NF90\_CREATE](#NF90_005fCREATE)).
6390 : Attempt to create object in read-only file.
6395 ------------------------------------------------------------------------
6397 -------------------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6398 \[[<](#NF90_005fDEF_005fVAR_005fFILL "Previous section in reading order")\] \[[>](#NF90_005fINQUIRE_005fVARIABLE "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6399 -------------------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6401 6.5 Learn About Fill Parameters for a Variable: `NF90_INQ_VAR_FILL` {.section}
6402 -------------------------------------------------------------------
6404 The function NF90\_INQ\_VAR\_FILL returns the fill settings for a
6405 variable in a netCDF-4 file.
6410 +--------------------------------------+--------------------------------------+
6411 | | ``` {.example} |
6412 | | NF90_INQ_VAR_FILL(INTEGER NCID, INTE |
6413 | | GER VARID, INTEGER NO_FILL, FILL_VAL |
6416 +--------------------------------------+--------------------------------------+
6420 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6428 : An integer which will get a 1 if no\_fill mode is set for this
6429 variable, and a zero if it is not set
6433 : This will get the fill value for this variable. This parameter will
6434 be ignored if it is NULL.
6436 Return Codes {.heading}
6449 : Not a netCDF-4 file.
6453 : Can’t find this variable.
6458 ------------------------------------------------------------------------
6460 -------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6461 \[[<](#NF90_005fINQ_005fVAR_005fFILL "Previous section in reading order")\] \[[>](#NF90_005fINQ_005fVARID "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6462 -------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6464 6.6 Get Information about a Variable from Its ID: NF90\_INQUIRE\_VARIABLE {.section}
6465 -------------------------------------------------------------------------
6467 NF90\_INQUIRE\_VARIABLE returns information about a netCDF variable
6468 given its ID. Information about a variable includes its name, type,
6469 number of dimensions, a list of dimension IDs describing the shape of
6470 the variable, and the number of variable attributes that have been
6471 assigned to the variable.
6473 All parameters after nAtts are optional, and only supported if netCDF
6474 was built with netCDF-4 features enabled, and if the variable is in a
6480 +--------------------------------------+--------------------------------------+
6481 | | ``` {.example} |
6482 | | function nf90_inquire_variable(nci |
6483 | | d, varid, name, xtype, ndims, dimids |
6485 | | contiguous, chunksizes, defla |
6486 | | te_level, shuffle, fletcher32, endia |
6488 | | integer, intent(in) :: ncid, var |
6490 | | character (len = *), optional, i |
6491 | | ntent(out) :: name |
6492 | | integer, optional, intent(out) : |
6493 | | : xtype, ndims |
6494 | | integer, dimension(:), optional, |
6495 | | intent(out) :: dimids |
6496 | | integer, optional, intent(out) : |
6498 | | logical, optional, intent(out) : |
6500 | | integer, optional, dimension(:), |
6501 | | intent(out) :: chunksizes |
6502 | | integer, optional, intent(out) : |
6503 | | : deflate_level |
6504 | | logical, optional, intent(out) : |
6505 | | : shuffle, fletcher32 |
6506 | | integer, optional, intent(out) : |
6508 | | integer :: nf90_inquire_variable |
6510 +--------------------------------------+--------------------------------------+
6514 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6522 : Returned variable name. The caller must allocate space for the
6523 returned name. The maximum possible length, in characters, of a
6524 variable name is given by the predefined constant NF90\_MAX\_NAME.
6528 : Returned variable type, one of the set of predefined netCDF external
6529 data types. The valid netCDF external data types are NF90\_BYTE,
6530 NF90\_CHAR, NF90\_SHORT, NF90\_INT, NF90\_FLOAT, AND NF90\_DOUBLE.
6534 : Returned number of dimensions the variable was defined as using. For
6535 example, 2 indicates a matrix, 1 indicates a vector, and 0 means the
6536 variable is a scalar with no dimensions.
6540 : Returned vector of \*ndimsp dimension IDs corresponding to the
6541 variable dimensions. The caller must allocate enough space for a
6542 vector of at least \*ndimsp integers to be returned. The maximum
6543 possible number of dimensions for a variable is given by the
6544 predefined constant NF90\_MAX\_VAR\_DIMS.
6548 : Returned number of variable attributes assigned to this variable.
6552 : On return, set to NF90\_CONTIGUOUS if this variable uses contiguous
6553 storage, NF90\_CHUNKED if it uses chunked storage.
6557 : An array of chunk sizes. The array must have the one element for
6558 each dimension in the variable.
6562 : True if the shuffle filter is turned on for this variable.
6566 : The deflate\_level from 0 to 9. A value of zero indicates no
6567 deflation is in use.
6571 : Set to true if the fletcher32 checksum filter is turned on for
6576 : Will be set to NF90\_ENDIAN\_LITTLE if this variable is stored in
6577 little-endian format, NF90\_ENDIAN\_BIG if it is stored in
6578 big-endian format, and NF90\_ENDIAN\_NATIVE if the endianness is not
6579 set, and the variable is not created yet.
6581 These functions return the value NF90\_NOERR if no errors occurred.
6582 Otherwise, the returned status indicates an error. Possible causes of
6585 - The variable ID is invalid for the specified netCDF dataset.
6586 - The specified netCDF ID does not refer to an open netCDF dataset.
6591 Here is an example using NF90\_INQ\_VAR to find out about a variable
6592 named rh in an existing netCDF dataset named foo.nc:
6594 +--------------------------------------+--------------------------------------+
6595 | | ``` {.example} |
6599 | | :: status, ncid, & |
6603 | | numDims, numAtts |
6604 | | integer, dimension(nf90_max_var_dim |
6605 | | s) :: rhDimIds |
6607 | | status = nf90_open("foo.nc", nf90_N |
6609 | | if(status /= nf90_NoErr) call handl |
6610 | | e_error(status) |
6612 | | status = nf90_inq_varid(ncid, "rh", |
6614 | | if(status /= nf90_NoErr) call handl |
6616 | | status = nf90_inquire_variable(ncid |
6617 | | , RhVarId, ndims = numDims, natts = |
6619 | | if(status /= nf90_NoErr) call handl |
6621 | | status = nf90_inquire_variable(ncid |
6622 | | , RhVarId, dimids = rhDimIds(:numDim |
6624 | | if(status /= nf90_NoErr) call handl |
6627 +--------------------------------------+--------------------------------------+
6629 ------------------------------------------------------------------------
6631 -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6632 \[[<](#NF90_005fINQUIRE_005fVARIABLE "Previous section in reading order")\] \[[>](#NF90_005fPUT_005fVAR "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6633 -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6635 6.7 Get the ID of a variable from the name: NF90\_INQ\_VARID {.section}
6636 ------------------------------------------------------------
6638 Given the name of a varaible, nf90\_inq\_varid finds the variable ID.
6643 +--------------------------------------+--------------------------------------+
6644 | | ``` {.example} |
6645 | | function nf90_inq_varid(ncid, name |
6647 | | integer, intent(in) :: ncid |
6648 | | character (len = *), intent( in) |
6650 | | integer, intent(out) :: varid |
6651 | | integer :: nf90_inq_varid |
6653 +--------------------------------------+--------------------------------------+
6657 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6661 : The variable name. The maximum possible length, in characters, of a
6662 variable name is given by the predefined constant NF90\_MAX\_NAME.
6668 These functions return the value NF90\_NOERR if no errors occurred.
6669 Otherwise, the returned status indicates an error. Possible causes of
6672 - Variable not found.
6673 - The specified netCDF ID does not refer to an open netCDF dataset.
6678 Here is an example using NF90\_INQ\_VARID to find out about a variable
6679 named rh in an existing netCDF dataset named foo.nc:
6681 +--------------------------------------+--------------------------------------+
6682 | | ``` {.example} |
6686 | | :: status, ncid, & |
6690 | | numDims, numAtts |
6691 | | integer, dimension(nf90_max_var_dim |
6692 | | s) :: rhDimIds |
6694 | | status = nf90_open("foo.nc", nf90_N |
6696 | | if(status /= nf90_NoErr) call handl |
6697 | | e_error(status) |
6699 | | status = nf90_inq_varid(ncid, "rh", |
6701 | | if(status /= nf90_NoErr) call handl |
6703 | | status = nf90_inquire_variable(ncid |
6704 | | , RhVarId, ndims = numDims, natts = |
6706 | | if(status /= nf90_NoErr) call handl |
6708 | | status = nf90_inquire_variable(ncid |
6709 | | , RhVarId, dimids = rhDimIds(:numDim |
6711 | | if(status /= nf90_NoErr) call handl |
6714 +--------------------------------------+--------------------------------------+
6716 ------------------------------------------------------------------------
6718 ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6719 \[[<](#NF90_005fINQ_005fVARID "Previous section in reading order")\] \[[>](#NF90_005fGET_005fVAR "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
6720 ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6722 6.8 Writing Data Values: NF90\_PUT\_VAR {.section}
6723 ---------------------------------------
6725 The function NF90\_PUT\_VAR puts one or more data values into the
6726 variable of an open netCDF dataset that is in data mode. Required inputs
6727 are the netCDF ID, the variable ID, and one or more data values.
6728 Optional inputs may indicate the starting position of the data values in
6729 the netCDF variable (argument start), the sampling frequency with which
6730 data values are written into the netCDF variable (argument stride), and
6731 a mapping between the dimensions of the data array and the netCDF
6732 variable (argument map). The values to be written are associated with
6733 the netCDF variable by assuming that the first dimension of the netCDF
6734 variable varies fastest in the Fortran 90 interface. Data values are
6735 converted to the external type of the variable, if necessary.
6737 Take care when using the simplest forms of this interface with record
6738 variables (variables that use the NF90\_UNLIMITED dimension) when you
6739 don’t specify how many records are to be written. If you try to write
6740 all the values of a record variable into a netCDF file that has no
6741 record data yet (hence has 0 records), nothing will be written.
6742 Similarly, if you try to write all the values of a record variable from
6743 an array but there are more records in the file than you assume, more
6744 in-memory data will be accessed than you expect, which may cause a
6745 segmentation violation. To avoid such problems, it is better to specify
6746 start and count arguments for variables that use the NF90\_UNLIMITED
6752 +--------------------------------------+--------------------------------------+
6753 | | ``` {.example} |
6754 | | function nf90_put_var(ncid, varid, |
6755 | | values, start, count, stride, map) |
6757 | | intent( in) :: ncid, varid |
6758 | | any valid type, scalar or array o |
6761 | | intent( in) :: values |
6762 | | integer, dimension(:), optional, |
6763 | | intent( in) :: start, count, stride, |
6766 | | :: nf90_put_var |
6768 +--------------------------------------+--------------------------------------+
6772 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6780 : The data value(s) to be written. The data may be of any type, and
6781 may be a scalar or an array of any rank. You cannot put CHARACTER
6782 data into a numeric variable or numeric data into a text variable.
6783 For numeric data, if the type of data differs from the netCDF
6784 variable type, type conversion will occur. See [(netcdf)Type
6785 Conversion](netcdf.html#Type-Conversion) section ‘Type Conversion’
6786 in NetCDF Users Guide.
6790 : A vector of integers specifying the index in the variable where the
6791 first (or only) of the data values will be written. The indices are
6792 relative to 1, so for example, the first data value of a variable
6793 would have index (1, 1, ..., 1). The elements of start correspond,
6794 in order, to the variable’s dimensions. Hence, if the variable is a
6795 record variable, the last index would correspond to the starting
6796 record number for writing the data values.
6798 By default, start(:) = 1.
6802 : A vector of integers specifying the number of indices selected along
6803 each dimension. To write a single value, for example, specify count
6804 as (1, 1, ..., 1). The elements of count correspond, in order, to
6805 the variable’s dimensions. Hence, if the variable is a record
6806 variable, the last element of count corresponds to a count of the
6807 number of records to write.
6809 By default, count(:numDims) = shape(values) and count(numDims + 1:)
6810 = 1, where numDims = size(shape(values)).
6814 : A vector of integers that specifies the sampling interval along each
6815 dimension of the netCDF variable. The elements of the stride vector
6816 correspond, in order, to the netCDF variable’s dimensions (stride(1)
6817 gives the sampling interval along the most rapidly varying dimension
6818 of the netCDF variable). Sampling intervals are specified in
6819 type-independent units of elements (a value of 1 selects consecutive
6820 elements of the netCDF variable along the corresponding dimension, a
6821 value of 2 selects every other element, etc.).
6823 By default, stride(:) = 1.
6827 : A vector of integers that specifies the mapping between the
6828 dimensions of a netCDF variable and the in-memory structure of the
6829 internal data array. The elements of the index mapping vector
6830 correspond, in order, to the netCDF variable’s dimensions (map(1)
6831 gives the distance between elements of the internal array
6832 corresponding to the most rapidly varying dimension of the
6833 netCDF variable). Distances between elements are specified in units
6836 By default, edgeLengths = shape(values), and map = (/ 1,
6837 (product(edgeLengths(:i)), i = 1, size(edgeLengths) - 1) /), that
6838 is, there is no mapping.
6840 Use of Fortran 90 intrinsic functions (including reshape, transpose,
6841 and spread) may let you avoid using this argument.
6846 NF90\_PUT\_VAR1\_ type returns the value NF90\_NOERR if no errors
6847 occurred. Otherwise, the returned status indicates an error. Possible
6848 causes of errors include:
6850 - The variable ID is invalid for the specified netCDF dataset.
6851 - The specified indices were out of range for the rank of the
6852 specified variable. For example, a negative index or an index that
6853 is larger than the corresponding dimension length will cause
6855 - The specified value is out of the range of values representable by
6856 the external data type of the variable.
6857 - The specified netCDF is in define mode rather than data mode.
6858 - The specified netCDF ID does not refer to an open netCDF dataset.
6863 Here is an example using NF90\_PUT\_VAR to set the (4,3,2) element of
6864 the variable named rh to 0.5 in an existing netCDF dataset named foo.nc.
6865 For simplicity in this example, we assume that we know that rh is
6866 dimensioned with lon, lat, and time, so we want to set the value of rh
6867 that corresponds to the fourth lon value, the third lat value, and the
6870 +--------------------------------------+--------------------------------------+
6871 | | ``` {.example} |
6874 | | integer :: ncId, rhVarId, status |
6876 | | status = nf90_open("foo.nc", nf90_W |
6878 | | if(status /= nf90_NoErr) call handl |
6881 | | status = nf90_inq_varid(ncid, "rh", |
6883 | | if(status /= nf90_NoErr) call handl |
6885 | | status = nf90_put_var(ncid, rhVarId |
6886 | | , 0.5, start = (/ 4, 3, 2 /) ) |
6887 | | if(status /= nf90_NoErr) call handl |
6890 +--------------------------------------+--------------------------------------+
6892 In this example we use NF90\_PUT\_VAR to add or change all the values of
6893 the variable named rh to 0.5 in an existing netCDF dataset named foo.nc.
6894 We assume that we know that rh is dimensioned with lon, lat, and time.
6895 In this example we query the netCDF file to discover the lengths of the
6896 dimensions, then use the Fortran 90 intrinsic function reshape to create
6897 a temporary array of data values which is the same shape as the netCDF
6900 +--------------------------------------+--------------------------------------+
6901 | | ``` {.example} |
6905 | | :: ncId, rhVarId,status, |
6908 | | lonDimID, latDimId, timeDimId, |
6911 | | numLons, numLats, numTimes, |
6915 | | integer, dimension(nf90_max_var_dim |
6918 | | status = nf90_open("foo.nc", nf90_W |
6920 | | if(status /= nf90_NoErr) call handl |
6923 | | status = nf90_inq_varid(ncid, "rh", |
6925 | | if(status /= nf90_NoErr) call handl |
6927 | | ! How big is the netCDF variable, t |
6928 | | hat is, what are the lengths of |
6929 | | ! its constituent dimensions? |
6930 | | status = nf90_inquire_variable(ncid |
6931 | | , rhVarId, dimids = dimIDs) |
6932 | | if(status /= nf90_NoErr) call handl |
6934 | | status = nf90_inquire_dimension(nci |
6935 | | d, dimIDs(1), len = numLons) |
6936 | | if(status /= nf90_NoErr) call handl |
6938 | | status = nf90_inquire_dimension(nci |
6939 | | d, dimIDs(2), len = numLats) |
6940 | | if(status /= nf90_NoErr) call handl |
6942 | | status = nf90_inquire_dimension(nci |
6943 | | d, dimIDs(3), len = numTimes) |
6944 | | if(status /= nf90_NoErr) call handl |
6947 | | ! Make a temporary array the same s |
6948 | | hape as the netCDF variable. |
6949 | | status = nf90_put_var(ncid, rhVarId |
6953 | | = 1, numLons * numLats * numTimes) / |
6956 | | umLons, numLats, numTimes /) ) |
6957 | | if(status /= nf90_NoErr) call handl |
6960 +--------------------------------------+--------------------------------------+
6962 Here is an example using NF90\_PUT\_VAR to add or change a section of
6963 the variable named rh to 0.5 in an existing netCDF dataset named foo.nc.
6964 For simplicity in this example, we assume that we know that rh is
6965 dimensioned with lon, lat, and time, that there are ten lon values, five
6966 lat values, and three time values, and that we want to replace all the
6967 values at the last time.
6969 +--------------------------------------+--------------------------------------+
6970 | | ``` {.example} |
6973 | | integer :: ncId, rhVarId |
6975 | | integer, parameter :: numLons = 10, |
6976 | | numLats = 5, numTimes = 3 |
6977 | | real, dimension(numLons, numLats) & |
6980 | | status = nf90_open("foo.nc", nf90_W |
6982 | | if(status /= nf90_NoErr) call handl |
6985 | | status = nf90_inq_varid(ncid, "rh", |
6987 | | if(status /= nf90_NoErr) call handl |
6989 | | ! Fill in all values at the last ti |
6991 | | rhValues(:, :) = 0.5 |
6992 | | status = nf90_put_var(ncid, rhVarId |
6995 | | 1, numTimes /), & |
6997 | | mLats, numLons, 1 /)) |
6998 | | if(status /= nf90_NoErr) call handl |
7001 +--------------------------------------+--------------------------------------+
7003 Here is an example of using NF90\_PUT\_VAR to write every other point of
7004 a netCDF variable named rh having dimensions (6, 4).
7006 +--------------------------------------+--------------------------------------+
7007 | | ``` {.example} |
7010 | | integer :: ncId, rhVarId |
7012 | | integer, parameter :: numLons = 6, |
7014 | | real, dimension(numLons, numLats) & |
7015 | | :: rhValues = 0. |
7018 | | status = nf90_open("foo.nc", nf90_W |
7020 | | if(status /= nf90_NoErr) call handl |
7023 | | status = nf90_inq_varid(ncid, "rh", |
7025 | | if(status /= nf90_NoErr) call handl |
7028 | | ! Fill in every other value using a |
7029 | | n array section |
7030 | | status = nf90_put_var(ncid, rhVarId |
7031 | | , rhValues(::2, ::2), & |
7034 | | if(status /= nf90_NoErr) call handl |
7037 +--------------------------------------+--------------------------------------+
7039 The following map vector shows the default mapping between a 2x3x4
7040 netCDF variable and an internal array of the same shape:
7042 +--------------------------------------+--------------------------------------+
7043 | | ``` {.example} |
7044 | | real, dimension(2, 3, 4):: a ! |
7045 | | same shape as netCDF variable |
7046 | | integer, dimension(3) :: map |
7047 | | = (/ 1, 2, 6 /) |
7048 | | ! netCDF dimens |
7049 | | ion inter-element distance |
7050 | | ! ------------- |
7051 | | --- ---------------------- |
7052 | | ! most rapidly |
7054 | | ! intermediate |
7055 | | 2 (= map(1)*2) |
7056 | | ! most slowly v |
7057 | | arying 6 (= map(2)*3) |
7059 +--------------------------------------+--------------------------------------+
7061 Using the map vector above obtains the same result as simply not passing
7062 a map vector at all.
7064 Here is an example of using nf90\_put\_var to write a netCDF variable
7065 named rh whose dimensions are the transpose of the Fortran 90 array:
7067 +--------------------------------------+--------------------------------------+
7068 | | ``` {.example} |
7072 | | : ncId, rhVarId, status |
7073 | | integer, parameter : |
7074 | | : numLons = 6, numLats = 4 |
7075 | | real, dimension(numLons, numLats) : |
7077 | | ! netCDF variable has dimensions (n |
7078 | | umLats, numLons) |
7080 | | status = nf90_open("foo.nc", nf90_W |
7082 | | if(status /= nf90_NoErr) call handl |
7085 | | status = nf90_inq_varid(ncid, "rh", |
7087 | | if(status /= nf90_NoErr) call handl |
7090 | | !Write transposed values: map vecto |
7091 | | r would be (/ 1, numLats /) for |
7092 | | ! no transposition |
7093 | | status = nf90_put_var(ncid, rhVarId |
7094 | | ,rhValues, map = (/ numLons, 1 /)) |
7095 | | if(status /= nf90_NoErr) call handl |
7098 +--------------------------------------+--------------------------------------+
7100 The same effect can be obtained more simply using Fortran 90 intrinsic
7103 +--------------------------------------+--------------------------------------+
7104 | | ``` {.example} |
7108 | | : ncId, rhVarId, status |
7109 | | integer, parameter : |
7110 | | : numLons = 6, numLats = 4 |
7111 | | real, dimension(numLons, numLats) : |
7113 | | ! netCDF variable has dimensions (n |
7114 | | umLats, numLons) |
7116 | | status = nf90_open("foo.nc", nf90_W |
7118 | | if(status /= nf90_NoErr) call handl |
7121 | | status = nf90_inq_varid(ncid, "rh", |
7123 | | if(status /= nf90_NoErr) call handl |
7126 | | status = nf90_put_var(ncid, rhVarId |
7127 | | , transpose(rhValues)) |
7128 | | if(status /= nf90_NoErr) call handl |
7131 +--------------------------------------+--------------------------------------+
7133 ------------------------------------------------------------------------
7135 ----------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7136 \[[<](#NF90_005fPUT_005fVAR "Previous section in reading order")\] \[[>](#Reading-and-Writing-Character-String-Values "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7137 ----------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7139 6.9 Reading Data Values: NF90\_GET\_VAR {.section}
7140 ---------------------------------------
7142 The function NF90\_GET\_VAR gets one or more data values from a netCDF
7143 variable of an open netCDF dataset that is in data mode. Required inputs
7144 are the netCDF ID, the variable ID, and a specification for the data
7145 values into which the data will be read. Optional inputs may indicate
7146 the starting position of the data values in the netCDF variable
7147 (argument start), the sampling frequency with which data values are read
7148 from the netCDF variable (argument stride), and a mapping between the
7149 dimensions of the data array and the netCDF variable (argument map). The
7150 values to be read are associated with the netCDF variable by assuming
7151 that the first dimension of the netCDF variable varies fastest in the
7152 Fortran 90 interface. Data values are converted from the external type
7153 of the variable, if necessary.
7155 Take care when using the simplest forms of this interface with record
7156 variables (variables that use the NF90\_UNLIMITED dimension) when you
7157 don’t specify how many records are to be read. If you try to read all
7158 the values of a record variable into an array but there are more records
7159 in the file than you assume, more data will be read than you expect,
7160 which may cause a segmentation violation. To avoid such problems, it is
7161 better to specify the optional start and count arguments for variables
7162 that use the NF90\_UNLIMITED dimension.
7164 In netCDF classic model the maximum integer size is NF90\_INT, the
7165 4-byte signed integer. Reading variables into an eight-byte integer
7166 array from a classic model file will read from an NF90\_INT. Reading
7167 variables into an eight-byte integer in a netCDF-4/HDF5 (without classic
7168 model flag) will read from an NF90\_INT64
7173 +--------------------------------------+--------------------------------------+
7174 | | ``` {.example} |
7175 | | function nf90_get_var(ncid, varid, |
7176 | | values, start, count, stride, map) |
7178 | | intent( in) :: ncid, varid |
7179 | | any valid type, scalar or array o |
7182 | | intent(out) :: values |
7183 | | integer, dimension(:), optional, |
7184 | | intent( in) :: start, count, stride, |
7187 | | :: nf90_get_var |
7189 +--------------------------------------+--------------------------------------+
7193 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
7201 : The data value(s) to be read. The data may be of any type, and may
7202 be a scalar or an array of any rank. You cannot read CHARACTER data
7203 from a numeric variable or numeric data from a text variable. For
7204 numeric data, if the type of data differs from the netCDF variable
7205 type, type conversion will occur. See [(netcdf)Type
7206 Conversion](netcdf.html#Type-Conversion) section ‘Type Conversion’
7207 in NetCDF Users Guide.
7211 : A vector of integers specifying the index in the variable from which
7212 the first (or only) of the data values will be read. The indices are
7213 relative to 1, so for example, the first data value of a variable
7214 would have index (1, 1, ..., 1). The elements of start correspond,
7215 in order, to the variable’s dimensions. Hence, if the variable is a
7216 record variable, the last index would correspond to the starting
7217 record number for writing the data values.
7219 By default, start(:) = 1.
7223 : A vector of integers specifying the number of indices selected along
7224 each dimension. To read a single value, for example, specify count
7225 as (1, 1, ..., 1). The elements of count correspond, in order, to
7226 the variable’s dimensions. Hence, if the variable is a record
7227 variable, the last element of count corresponds to a count of the
7228 number of records to read.
7230 By default, count(:numDims) = shape(values) and count(numDims + 1:)
7231 = 1, where numDims = size(shape(values)).
7235 : A vector of integers that specifies the sampling interval along each
7236 dimension of the netCDF variable. The elements of the stride vector
7237 correspond, in order, to the netCDF variable’s dimensions (stride(1)
7238 gives the sampling interval along the most rapidly varying dimension
7239 of the netCDF variable). Sampling intervals are specified in
7240 type-independent units of elements (a value of 1 selects consecutive
7241 elements of the netCDF variable along the corresponding dimension, a
7242 value of 2 selects every other element, etc.).
7244 By default, stride(:) = 1.
7248 : A vector of integers that specifies the mapping between the
7249 dimensions of a netCDF variable and the in-memory structure of the
7250 internal data array. The elements of the index mapping vector
7251 correspond, in order, to the netCDF variable’s dimensions (map(1)
7252 gives the distance between elements of the internal array
7253 corresponding to the most rapidly varying dimension of the
7254 netCDF variable). Distances between elements are specified in units
7257 By default, edgeLengths = shape(values), and map = (/ 1,
7258 (product(edgeLengths(:i)), i = 1, size(edgeLengths) - 1) /), that
7259 is, there is no mapping.
7261 Use of Fortran 90 intrinsic functions (including reshape, transpose,
7262 and spread) may let you avoid using this argument.
7267 NF90\_GET\_VAR returns the value NF90\_NOERR if no errors occurred.
7268 Otherwise, the returned status indicates an error. Possible causes of
7271 - The variable ID is invalid for the specified netCDF dataset.
7272 - The assumed or specified start, count, and stride generate an index
7273 which is out of range. Note that no error checking is possible on
7275 - One or more of the specified values are out of the range of values
7276 representable by the desired type.
7277 - The specified netCDF is in define mode rather than data mode.
7278 - The specified netCDF ID does not refer to an open netCDF dataset.
7280 (As noted above, another possible source of error is using this
7281 interface to read all the values of a record variable without specifying
7282 the number of records. If there are more records in the file than you
7283 assume, more data will be read than you expect!)
7288 Here is an example using NF90\_GET\_VAR to read the (4,3,2) element of
7289 the variable named rh from an existing netCDF dataset named foo.nc. For
7290 simplicity in this example, we assume that we know that rh is
7291 dimensioned with lon, lat, and time, so we want to read the value of rh
7292 that corresponds to the fourth lon value, the third lat value, and the
7295 +--------------------------------------+--------------------------------------+
7296 | | ``` {.example} |
7299 | | integer :: ncId, rhVarId, status |
7300 | | real :: rhValue |
7302 | | status = nf90_open("foo.nc", nf90_N |
7304 | | if(status /= nf90_NoErr) call handl |
7307 | | status = nf90_inq_varid(ncid, "rh", |
7309 | | if(status /= nf90_NoErr) call handl |
7311 | | status = nf90_get_var(ncid, rhVarId |
7312 | | , rhValue, start = (/ 4, 3, 2 /) ) |
7313 | | if(status /= nf90_NoErr) call handl |
7316 +--------------------------------------+--------------------------------------+
7318 In this example we use NF90\_GET\_VAR to read all the values of the
7319 variable named rh from an existing netCDF dataset named foo.nc. We
7320 assume that we know that rh is dimensioned with lon, lat, and time. In
7321 this example we query the netCDF file to discover the lengths of the
7322 dimensions, then allocate a Fortran 90 array the same shape as the
7325 +--------------------------------------+--------------------------------------+
7326 | | ``` {.example} |
7330 | | :: ncId, rhVarId, & |
7332 | | lonDimID, latDimId, timeDimId, |
7335 | | numLons, numLats, numTimes, |
7339 | | integer, dimension(nf90_max_var_dim |
7341 | | real, dimension(:, :, :), allocatab |
7342 | | le :: rhValues |
7344 | | status = nf90_open("foo.nc", nf90_N |
7346 | | if(status /= nf90_NoErr) call handl |
7349 | | status = nf90_inq_varid(ncid, "rh", |
7351 | | if(status /= nf90_NoErr) call handl |
7353 | | ! How big is the netCDF variable, t |
7354 | | hat is, what are the lengths of |
7355 | | ! its constituent dimensions? |
7356 | | status = nf90_inquire_variable(ncid |
7357 | | , rhVarId, dimids = dimIDs) |
7358 | | if(status /= nf90_NoErr) call handl |
7360 | | status = nf90_inquire_dimension(nci |
7361 | | d, dimIDs(1), len = numLons) |
7362 | | if(status /= nf90_NoErr) call handl |
7364 | | status = nf90_inquire_dimension(nci |
7365 | | d, dimIDs(2), len = numLats) |
7366 | | if(status /= nf90_NoErr) call handl |
7368 | | status = nf90_inquire_dimension(nci |
7369 | | d, dimIDs(3), len = numTimes) |
7370 | | if(status /= nf90_NoErr) call handl |
7372 | | allocate(rhValues(numLons, numLats, |
7375 | | status = nf90_get_var(ncid, rhVarId |
7377 | | if(status /= nf90_NoErr) call handl |
7380 +--------------------------------------+--------------------------------------+
7382 Here is an example using NF90\_GET\_VAR to read a section of the
7383 variable named rh from an existing netCDF dataset named foo.nc. For
7384 simplicity in this example, we assume that we know that rh is
7385 dimensioned with lon, lat, and time, that there are ten lon values, five
7386 lat values, and three time values, and that we want to replace all the
7387 values at the last time.
7389 +--------------------------------------+--------------------------------------+
7390 | | ``` {.example} |
7393 | | integer :: ncId, rhVarId |
7395 | | integer, parameter :: numLons = 10, |
7396 | | numLats = 5, numTimes = 3 |
7397 | | real, dimension(numLons, numLats, n |
7401 | | status = nf90_open("foo.nc", nf90_N |
7403 | | if(status /= nf90_NoErr) call handl |
7406 | | status = nf90_inq_varid(ncid, "rh", |
7408 | | if(status /= nf90_NoErr) call handl |
7410 | | !Read the values at the last time b |
7411 | | y passing an array section |
7412 | | status = nf90_get_var(ncid, rhVarId |
7413 | | , rhValues(:, :, 3), & |
7415 | | 1, numTimes /), & |
7417 | | mLons, numLats, 1 /)) |
7418 | | if(status /= nf90_NoErr) call handl |
7421 +--------------------------------------+--------------------------------------+
7423 Here is an example of using NF90\_GET\_VAR to read every other point of
7424 a netCDF variable named rh having dimensions (6, 4).
7426 +--------------------------------------+--------------------------------------+
7427 | | ``` {.example} |
7430 | | integer :: ncId, rhVarId |
7432 | | integer, parameter :: numLons = 6, |
7434 | | real, dimension(numLons, numLats) & |
7437 | | status = nf90_open("foo.nc", nf90_N |
7439 | | if(status /= nf90_NoErr) call handl |
7442 | | status = nf90_inq_varid(ncid, "rh", |
7444 | | if(status /= nf90_NoErr) call handl |
7447 | | ! Read every other value into an ar |
7449 | | status = nf90_get_var(ncid, rhVarId |
7450 | | , rhValues(::2, ::2) & |
7453 | | if(status /= nf90_NoErr) call handl |
7456 +--------------------------------------+--------------------------------------+
7458 The following map vector shows the default mapping between a 2x3x4
7459 netCDF variable and an internal array of the same shape:
7461 +--------------------------------------+--------------------------------------+
7462 | | ``` {.example} |
7463 | | real, dimension(2, 3, 4):: a ! |
7464 | | same shape as netCDF variable |
7465 | | integer, dimension(3) :: map |
7466 | | = (/ 1, 2, 6 /) |
7467 | | ! netCDF dimens |
7468 | | ion inter-element distance |
7469 | | ! ------------- |
7470 | | --- ---------------------- |
7471 | | ! most rapidly |
7473 | | ! intermediate |
7474 | | 2 (= map(1)*2) |
7475 | | ! most slowly v |
7476 | | arying 6 (= map(2)*3) |
7478 +--------------------------------------+--------------------------------------+
7480 Using the map vector above obtains the same result as simply not passing
7481 a map vector at all.
7483 Here is an example of using nf90\_get\_var to read a netCDF variable
7484 named rh whose dimensions are the transpose of the Fortran 90 array:
7486 +--------------------------------------+--------------------------------------+
7487 | | ``` {.example} |
7491 | | : ncId, rhVarId, status |
7492 | | integer, parameter : |
7493 | | : numLons = 6, numLats = 4 |
7494 | | real, dimension(numLons, numLats) : |
7496 | | ! netCDF variable has dimensions (n |
7497 | | umLats, numLons) |
7499 | | status = nf90_open("foo.nc", nf90_N |
7501 | | if(status /= nf90_NoErr) call handl |
7504 | | status = nf90_inq_varid(ncid, "rh", |
7506 | | if(status /= nf90_NoErr) call handl |
7509 | | ! Read transposed values: map vecto |
7510 | | r would be (/ 1, numLats /) for |
7511 | | ! no transposition |
7512 | | status = nf90_get_var(ncid, rhVarId |
7513 | | ,rhValues, map = (/ numLons, 1 /)) |
7514 | | if(status /= nf90_NoErr) call handl |
7517 +--------------------------------------+--------------------------------------+
7519 The same effect can be obtained more simply, though using more memory,
7520 using Fortran 90 intrinsic functions:
7522 +--------------------------------------+--------------------------------------+
7523 | | ``` {.example} |
7527 | | : ncId, rhVarId, status |
7528 | | integer, parameter : |
7529 | | : numLons = 6, numLats = 4 |
7530 | | real, dimension(numLons, numLats) : |
7532 | | ! netCDF variable has dimensions (n |
7533 | | umLats, numLons) |
7534 | | real, dimension(numLons, numLats) : |
7537 | | status = nf90_open("foo.nc", nf90_N |
7539 | | if(status /= nf90_NoErr) call handl |
7542 | | status = nf90_inq_varid(ncid, "rh", |
7544 | | if(status /= nf90_NoErr) call handl |
7547 | | status = nf90_get_var(ncid, rhVarId |
7548 | | , tempValues)) |
7549 | | if(status /= nf90_NoErr) call handl |
7551 | | rhValues(:, :) = transpose(tempValu |
7554 +--------------------------------------+--------------------------------------+
7556 ------------------------------------------------------------------------
7558 ----------------------------------------------------------------------- ---------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7559 \[[<](#NF90_005fGET_005fVAR "Previous section in reading order")\] \[[>](#Fill-Values "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7560 ----------------------------------------------------------------------- ---------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7562 6.10 Reading and Writing Character String Values {.section}
7563 ------------------------------------------------
7565 Character strings are not a primitive netCDF external data type under
7566 the classic netCDF data model, in part because FORTRAN does not support
7567 the abstraction of variable-length character strings (the FORTRAN LEN
7568 function returns the static length of a character string, not its
7569 dynamic length). As a result, a character string cannot be written or
7570 read as a single object in the netCDF interface. Instead, a character
7571 string must be treated as an array of characters, and array access must
7572 be used to read and write character strings as variable data in netCDF
7573 datasets. Furthermore, variable-length strings are not supported by the
7574 netCDF classic interface except by convention; for example, you may
7575 treat a zero byte as terminating a character string, but you must
7576 explicitly specify the length of strings to be read from and written to
7579 Character strings as attribute values are easier to use, since the
7580 strings are treated as a single unit for access. However, the value of a
7581 character-string attribute in the classic netCDF interface is still an
7582 array of characters with an explicit length that must be specified when
7583 the attribute is defined.
7585 When you define a variable that will have character-string values, use a
7586 character-position dimension as the most quickly varying dimension for
7587 the variable (the first dimension for the variable in Fortran 90). The
7588 length of the character-position dimension will be the maximum string
7589 length of any value to be stored in the character-string variable. Space
7590 for maximum-length strings will be allocated in the disk representation
7591 of character-string variables whether you use the space or not. If two
7592 or more variables have the same maximum length, the same
7593 character-position dimension may be used in defining the variable
7596 To write a character-string value into a character-string variable, use
7597 either entire variable access or array access. The latter requires that
7598 you specify both a corner and a vector of edge lengths. The
7599 character-position dimension at the corner should be one for Fortran 90.
7600 If the length of the string to be written is n, then the vector of edge
7601 lengths will specify n in the character-position dimension, and one for
7602 all the other dimensions: (n, 1, 1, ..., 1).
7604 In Fortran 90, fixed-length strings may be written to a netCDF dataset
7605 without a terminating character, to save space. Variable-length strings
7606 should follow the C convention of writing strings with a terminating
7607 zero byte so that the intended length of the string can be determined
7608 when it is later read by either C or Fortran 90 programs. It is the
7609 users responsibility to provide such null termination.
7611 If you are writing data in the default prefill mode (see next section),
7612 you can ensure that simple strings represented as 1-dimensional
7613 character arrays are null terminated in the netCDF file by writing fewer
7614 characters than the length declared when the variable was defined. That
7615 way, the extra unwritten characters will be filled with the default
7616 character fill value, which is a null byte. The Fortran intrinsic TRIM
7617 function can be used to trim trailing blanks from the character string
7618 argument to NF90\_PUT\_VAR to make the argument shorter than the
7619 declared length. If prefill is not on, the data writer must explicitly
7620 provide a null terminating byte.
7622 Here is an example illustrating this way of writing strings to character
7625 +--------------------------------------+--------------------------------------+
7626 | | ``` {.example} |
7629 | | integer status |
7631 | | : ncid, oceanStrLenID, oceanId |
7632 | | integer, parameter : |
7633 | | : MaxOceanNameLen = 20 |
7634 | | character, (len = MaxOceanNameLen): |
7637 | | status = nf90_create("foo.nc", nf90 |
7638 | | _NoClobber, ncid) |
7639 | | if(status /= nf90_NoErr) call handl |
7642 | | status = nf90_def_dim(ncid, "oceanS |
7643 | | trLen", MaxOceanNameLen, oceanStrLen |
7645 | | if(status /= nf90_NoErr) call handl |
7648 | | status = nf90_def_var(ncid, "ocean" |
7649 | | , nf90_char, (/ oceanStrLenId /), oc |
7651 | | if(status /= nf90_NoErr) call handl |
7654 | | ! Leave define mode, which prefills |
7655 | | netCDF variables with fill values |
7656 | | status = nf90_enddef(ncid) |
7657 | | if (status /= nf90_noerr) call hand |
7658 | | le_err(status) |
7660 | | ! Note that this assignment adds bl |
7662 | | ocean = "Pacific" |
7663 | | ! Using trim removes trailing blank |
7664 | | s, prefill provides null |
7665 | | ! termination, so C programs can la |
7666 | | ter get intended string. |
7667 | | status = nf90_put_var(ncid, oceanId |
7668 | | , trim(ocean)) |
7669 | | if(status /= nf90_NoErr) call handl |
7672 +--------------------------------------+--------------------------------------+
7674 ------------------------------------------------------------------------
7676 ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7677 \[[<](#Reading-and-Writing-Character-String-Values "Previous section in reading order")\] \[[>](#NF90_005fRENAME_005fVAR "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7678 ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7680 6.11 Fill Values {.section}
7683 What happens when you try to read a value that was never written in an
7684 open netCDF dataset? You might expect that this should always be an
7685 error, and that you should get an error message or an error status
7686 returned. You do get an error if you try to read data from a netCDF
7687 dataset that is not open for reading, if the variable ID is invalid for
7688 the specified netCDF dataset, or if the specified indices are not
7689 properly within the range defined by the dimension lengths of the
7690 specified variable. Otherwise, reading a value that was not written
7691 returns a special fill value used to fill in any undefined values when a
7692 netCDF variable is first written.
7694 You may ignore fill values and use the entire range of a netCDF external
7695 data type, but in this case you should make sure you write all data
7696 values before reading them. If you know you will be writing all the data
7697 before reading it, you can specify that no prefilling of variables with
7698 fill values will occur by calling writing. This may provide a
7699 significant performance gain for netCDF writes.
7701 The variable attribute \_FillValue may be used to specify the fill value
7702 for a variable. There are default fill values for each type, defined in
7703 module netcdf: NF90\_FILL\_CHAR, NF90\_FILL\_INT1 (same as
7704 NF90\_FILL\_BYTE), NF90\_FILL\_INT2 (same as NF90\_FILL\_SHORT),
7705 NF90\_FILL\_INT, NF90\_FILL\_REAL (same as NF90\_FILL\_FLOAT), and
7708 The netCDF byte and character types have different default fill values.
7709 The default fill value for characters is the zero byte, a useful value
7710 for detecting the end of variable-length C character strings. If you
7711 need a fill value for a byte variable, it is recommended that you
7712 explicitly define an appropriate \_FillValue attribute, as generic
7713 utilities such as ncdump will not assume a default fill value for byte
7716 Type conversion for fill values is identical to type conversion for
7717 other values: attempting to convert a value from one type to another
7718 type that can’t represent the value results in a range error. Such
7719 errors may occur on writing or reading values from a larger type (such
7720 as double) to a smaller type (such as float), if the fill value for the
7721 larger type cannot be represented in the smaller type.
7723 ------------------------------------------------------------------------
7725 -------------------------------------------------------------- ------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7726 \[[<](#Fill-Values "Previous section in reading order")\] \[[>](#NF90_005fVAR_005fPAR_005fACCESS "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7727 -------------------------------------------------------------- ------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7729 6.12 NF90\_RENAME\_VAR {.section}
7730 ----------------------
7732 The function NF90\_RENAME\_VAR changes the name of a netCDF variable in
7733 an open netCDF dataset. If the new name is longer than the old name, the
7734 netCDF dataset must be in define mode. You cannot rename a variable to
7735 have the name of any existing variable.
7740 +--------------------------------------+--------------------------------------+
7741 | | ``` {.example} |
7742 | | function nf90_rename_var(ncid, vari |
7744 | | integer, intent( in) |
7745 | | :: ncid, varid |
7746 | | character (len = *), intent( in) |
7749 | | :: nf90_rename_var |
7751 +--------------------------------------+--------------------------------------+
7755 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
7763 : New name for the specified variable.
7768 NF90\_RENAME\_VAR returns the value NF90\_NOERR if no errors occurred.
7769 Otherwise, the returned status indicates an error. Possible causes of
7772 - The new name is in use as the name of another variable.
7773 - The variable ID is invalid for the specified netCDF dataset.
7774 - The specified netCDF ID does not refer to an open netCDF dataset.
7779 Here is an example using NF90\_RENAME\_VAR to rename the variable rh to
7780 rel\_hum in an existing netCDF dataset named foo.nc:
7782 +--------------------------------------+--------------------------------------+
7783 | | ``` {.example} |
7786 | | integer :: ncId, rhVarId, status |
7788 | | status = nf90_open("foo.nc", nf90_W |
7790 | | if(status /= nf90_NoErr) call handl |
7793 | | status = nf90_inq_varid(ncid, "rh", |
7795 | | if(status /= nf90_NoErr) call handl |
7797 | | status = nf90_redef(ncid) ! Enter |
7798 | | define mode to change variable name |
7799 | | if(status /= nf90_NoErr) call handl |
7801 | | status = nf90_rename_var(ncid, rhVa |
7802 | | rId, "rel_hum") |
7803 | | if(status /= nf90_NoErr) call handl |
7805 | | status = nf90_enddef(ncid) ! Leave |
7807 | | if(status /= nf90_NoErr) call handl |
7810 +--------------------------------------+--------------------------------------+
7812 ------------------------------------------------------------------------
7814 -------------------------------------------------------------------------- --------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7815 \[[<](#NF90_005fRENAME_005fVAR "Previous section in reading order")\] \[[>](#Attributes "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Variables "Up section")\] \[[>>](#Attributes "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7816 -------------------------------------------------------------------------- --------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7818 6.13 Change between Collective and Independent Parallel Access: NF90\_VAR\_PAR\_ACCESS {.section}
7819 --------------------------------------------------------------------------------------
7821 The function NF90\_VAR\_PAR\_ACCESS changes whether read/write
7822 operations on a parallel file system are performed collectively or
7823 independently (the default) on the variable. This function can only be
7824 called if the file was created (see [NF90\_CREATE](#NF90_005fCREATE)) or
7825 opened (see [NF90\_OPEN](#NF90_005fOPEN)) for parallel I/O.
7827 This function is only available if the netCDF library was built with
7828 parallel I/O enabled.
7830 Calling this function affects only the open file - information about
7831 whether a variable is to be accessed collectively or independently is
7832 not written to the data file. Every time you open a file on a parallel
7833 file system, all variables default to independent operations. The change
7834 of a variable to collective access lasts only as long as that file is
7837 The variable can be changed from collective to independent, and back, as
7840 Classic and 64-bit offset files, when opened for parallel access, use
7841 the parallel-netcdf (a.k.a. pnetcdf) library, which does not allow
7842 per-variable changes of access mode - the entire file must be access
7843 independently or collectively. For classic and 64-bit offset files, the
7844 nf90\_var\_par\_access function changes the access for all variables in
7850 +--------------------------------------+--------------------------------------+
7851 | | ``` {.example} |
7852 | | function nf90_var_par_access(ncid, |
7853 | | varid, access) |
7854 | | integer, intent(in) :: ncid |
7855 | | integer, intent(in) :: varid |
7856 | | integer, intent(in) :: access |
7857 | | integer :: nf90_var_par_access |
7858 | | end function nf90_var_par_access |
7860 +--------------------------------------+--------------------------------------+
7864 : NetCDF ID, from a previous call to NF90\_OPEN (see
7865 [NF90\_OPEN](#NF90_005fOPEN)) or NF90\_CREATE (see
7866 [NF90\_CREATE](#NF90_005fCREATE)).
7874 : NF90\_INDEPENDENT to set this variable to independent operations.
7875 NF90\_COLLECTIVE to set it to collective operations.
7877 Return Values {.heading}
7886 : No variable found.
7890 : File not opened for parallel access.
7895 This example comes from test program nf\_test/f90tst\_parallel.f90. For
7896 this test to be run, netCDF must have been built with a parallel-enabled
7897 HDF5, and –enable-parallel-tests must have been used when configuring
7900 +--------------------------------------+--------------------------------------+
7901 | | ``` {.example} |
7902 | | ! Reopen the file. |
7903 | | call handle_err(nf90_open(FILE_NAM |
7904 | | E, nf90_nowrite, ncid, comm = MPI_CO |
7906 | | info = MPI_INFO_NULL)) |
7908 | | ! Set collective access on this va |
7909 | | riable. This will cause all |
7910 | | ! reads/writes to happen together |
7911 | | on every processor. |
7912 | | call handle_err(nf90_var_par_acces |
7913 | | s(ncid, varid, nf90_collective)) |
7915 | | ! Read this processor's data. |
7916 | | call handle_err(nf90_get_var(ncid, |
7917 | | varid, data_in, start = start, coun |
7920 +--------------------------------------+--------------------------------------+
7922 ------------------------------------------------------------------------
7924 ---------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------- ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7925 \[[<](#NF90_005fVAR_005fPAR_005fACCESS "Previous section in reading order")\] \[[>](#Attributes-Introduction "Next section in reading order")\] \[[<<](#Variables "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7926 ---------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------- ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7928 7. Attributes {.chapter}
7931 ------------------------ ------------------------ ------------------------
7933 Introduction](#Attribute
7938 NF90\_PUT\_ATT](#NF90_00
7941 [7.3 Get Information
7943 NF90\_INQUIRE\_ATTRIBUTE
7945 NF90\_INQ\_ATTNAME](#NF9
7946 0_005fINQUIRE_005fATTRIB
7949 [7.4 Get Attribute’s
7951 NF90\_GET\_ATT](#NF90_00
7954 [7.5 Copy Attribute from
7955 One NetCDF to Another:
7956 NF90\_COPY\_ATT](#NF90_0
7961 NF90\_RENAME\_ATT](#NF90
7962 _005fRENAME_005fATT)
7965 NF90\_DEL\_ATT](#NF90_00
7967 ------------------------ ------------------------ ------------------------
7969 ------------------------------------------------------------------------
7971 ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7972 \[[<](#Attributes "Previous section in reading order")\] \[[>](#NF90_005fPUT_005fATT "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
7973 ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7975 7.1 Attributes Introduction {.section}
7976 ---------------------------
7978 Attributes may be associated with each netCDF variable to specify such
7979 properties as units, special values, maximum and minimum valid values,
7980 scaling factors, and offsets. Attributes for a netCDF dataset are
7981 defined when the dataset is first created, while the netCDF dataset is
7982 in define mode. Additional attributes may be added later by reentering
7983 define mode. A netCDF attribute has a netCDF variable to which it is
7984 assigned, a name, a type, a length, and a sequence of one or more
7985 values. An attribute is designated by its variable ID and name. When an
7986 attribute name is not known, it may be designated by its variable ID and
7987 number in order to determine its name, using the function
7990 The attributes associated with a variable are typically defined
7991 immediately after the variable is created, while still in define mode.
7992 The data type, length, and value of an attribute may be changed even
7993 when in data mode, as long as the changed attribute requires no more
7994 space than the attribute as originally defined.
7996 It is also possible to have attributes that are not associated with any
7997 variable. These are called global attributes and are identified by using
7998 NF90\_GLOBAL as a variable pseudo-ID. Global attributes are usually
7999 related to the netCDF dataset as a whole and may be used for purposes
8000 such as providing a title or processing history for a netCDF dataset.
8002 Attributes are much more useful when they follow established community
8003 conventions. See [(netcdf)Attribute
8004 Conventions](netcdf.html#Attribute-Conventions) section ‘Attribute
8005 Conventions’ in The NetCDF Users Guide.
8007 Operations supported on attributes are:
8009 - Create an attribute, given its variable ID, name, data type, length,
8011 - Get attribute’s data type and length from its variable ID and name.
8012 - Get attribute’s value from its variable ID and name.
8013 - Copy attribute from one netCDF variable to another.
8014 - Get name of attribute from its number.
8015 - Rename an attribute.
8016 - Delete an attribute.
8018 ------------------------------------------------------------------------
8020 -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8021 \[[<](#Attributes-Introduction "Previous section in reading order")\] \[[>](#NF90_005fINQUIRE_005fATTRIBUTE "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8022 -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8024 7.2 Create an Attribute: NF90\_PUT\_ATT {.section}
8025 ---------------------------------------
8027 The function NF90\_PUT\_ATTadds or changes a variable attribute or
8028 global attribute of an open netCDF dataset. If this attribute is new, or
8029 if the space required to store the attribute is greater than before, the
8030 netCDF dataset must be in define mode.
8035 Although it’s possible to create attributes of all types, text and
8036 double attributes are adequate for most purposes.
8038 +--------------------------------------+--------------------------------------+
8039 | | ``` {.example} |
8040 | | function nf90_put_att(ncid, varid, |
8042 | | integer, intent( in) : |
8044 | | character(len = *), intent( in) : |
8046 | | scalar character string or any nu |
8047 | | meric type, scalar, or array of rank |
8052 | | : nf90_put_att |
8054 +--------------------------------------+--------------------------------------+
8058 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8062 : Variable ID of the variable to which the attribute will be assigned
8063 or NF90\_GLOBAL for a global attribute.
8067 : Attribute name. Attribute name conventions are assumed by some
8068 netCDF generic applications, e.g., ‘units’ as the name for a string
8069 attribute that gives the units for a netCDF variable. See
8070 [(netcdf)Attribute Conventions](netcdf.html#Attribute-Conventions)
8071 section ‘Attribute Conventions’ in The NetCDF Users Guide.
8075 : A numeric rank 1 array of attribute values or a scalar. The external
8076 data type of the attribute is set to match the internal
8077 representation of the argument, that is if values is a two byte
8078 integer array, the attribute will be of type NF90\_INT2. Fortran 90
8079 intrinsic functions can be used to convert attributes to the
8085 NF90\_PUT\_ATT returns the value NF90\_NOERR if no errors occurred.
8086 Otherwise, the returned status indicates an error. Possible causes of
8089 - The variable ID is invalid for the specified netCDF dataset.
8090 - The specified netCDF type is invalid.
8091 - The specified length is negative.
8092 - The specified open netCDF dataset is in data mode and the specified
8093 attribute would expand.
8094 - The specified open netCDF dataset is in data mode and the specified
8095 attribute does not already exist.
8096 - The specified netCDF ID does not refer to an open netCDF dataset.
8097 - The number of attributes for this variable exceeds NF90\_MAX\_ATTRS.
8102 Here is an example using NF90\_PUT\_ATT to add a variable attribute
8103 named valid\_range for a netCDF variable named rh and a global attribute
8104 named title to an existing netCDF dataset named foo.nc:
8106 +--------------------------------------+--------------------------------------+
8107 | | ``` {.example} |
8110 | | integer :: ncid, status, RHVarID |
8112 | | status = nf90_open("foo.nc", nf90_w |
8114 | | if (status /= nf90_noerr) call hand |
8115 | | le_err(status) |
8117 | | ! Enter define mode so we can add t |
8119 | | status = nf90_redef(ncid) |
8120 | | if (status /= nf90_noerr) call hand |
8121 | | le_err(status) |
8122 | | ! Get the variable ID for "rh"... |
8123 | | status = nf90_inq_varid(ncid, "rh", |
8125 | | if (status /= nf90_noerr) call hand |
8126 | | le_err(status) |
8127 | | ! ... put the range attribute, set |
8128 | | ting it to eight byte reals... |
8129 | | status = nf90_put_att(ncid, RHVarID |
8130 | | , "valid_range", real((/ 0, 100 /)) |
8131 | | ! ... and the title attribute. |
8132 | | if (status /= nf90_noerr) call hand |
8133 | | le_err(status) |
8134 | | status = nf90_put_att(ncid, RHVarID |
8135 | | , "title", "example netCDF dataset") |
8137 | | if (status /= nf90_noerr) call hand |
8138 | | le_err(status) |
8139 | | ! Leave define mode |
8140 | | status = nf90_enddef(ncid) |
8141 | | if (status /= nf90_noerr) call hand |
8142 | | le_err(status) |
8144 +--------------------------------------+--------------------------------------+
8146 ------------------------------------------------------------------------
8148 ----------------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8149 \[[<](#NF90_005fPUT_005fATT "Previous section in reading order")\] \[[>](#NF90_005fGET_005fATT "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8150 ----------------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8152 7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and NF90\_INQ\_ATTNAME {.section}
8153 ---------------------------------------------------------------------------------------
8155 The function NF90\_INQUIRE\_ATTRIBUTE returns information about a netCDF
8156 attribute given the variable ID and attribute name. Information about an
8157 attribute includes its type, length, name, and number. See
8158 NF90\_GET\_ATT for getting attribute values.
8160 The function NF90\_INQ\_ATTNAME gets the name of an attribute, given its
8161 variable ID and number. This function is useful in generic applications
8162 that need to get the names of all the attributes associated with a
8163 variable, since attributes are accessed by name rather than number in
8164 all other attribute functions. The number of an attribute is more
8165 volatile than the name, since it can change when other attributes of the
8166 same variable are deleted. This is why an attribute number is not called
8172 +--------------------------------------+--------------------------------------+
8173 | | ``` {.example} |
8174 | | function nf90_inquire_attribute(nci |
8175 | | d, varid, name, xtype, len, attnum) |
8176 | | integer, intent( in) |
8177 | | :: ncid, varid |
8178 | | character (len = *), intent( in) |
8180 | | integer, intent(out), |
8181 | | optional :: xtype, len, attnum |
8183 | | :: nf90_inquire_attribute |
8184 | | function nf90_inq_attname(ncid, var |
8185 | | id, attnum, name) |
8186 | | integer, intent( in) |
8187 | | :: ncid, varid, attnum |
8188 | | character (len = *), intent(out) |
8191 | | :: nf90_inq_attname |
8193 +--------------------------------------+--------------------------------------+
8197 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8201 : Variable ID of the attribute’s variable, or NF90\_GLOBAL for a
8206 : Attribute name. For NF90\_INQ\_ATTNAME, this is a pointer to the
8207 location for the returned attribute name.
8211 : Returned attribute type, one of the set of predefined netCDF
8212 external data types. The valid netCDF external data types are
8213 NF90\_BYTE, NF90\_CHAR, NF90\_SHORT, NF90\_INT, NF90\_FLOAT,
8218 : Returned number of values currently stored in the attribute. For a
8219 string-valued attribute, this is the number of characters in
8224 : For NF90\_INQ\_ATTNAME, the input attribute number; for
8225 NF90\_INQ\_ATTID, the returned attribute number. The attributes for
8226 each variable are numbered from 1 (the first attribute) to NATTS,
8227 where NATTS is the number of attributes for the variable, as
8228 returned from a call to NF90\_INQ\_VARNATTS.
8230 (If you already know an attribute name, knowing its number is not
8231 very useful, because accessing information about an attribute
8237 Each function returns the value NF90\_NOERR if no errors occurred.
8238 Otherwise, the returned status indicates an error. Possible causes of
8241 - The variable ID is invalid for the specified netCDF dataset.
8242 - The specified attribute does not exist.
8243 - The specified netCDF ID does not refer to an open netCDF dataset.
8244 - For NF90\_INQ\_ATTNAME, the specified attribute number is negative
8245 or more than the number of attributes defined for the
8251 Here is an example using NF90\_INQUIRE\_ATTRIBUTE to inquire about the
8252 lengths of an attribute named valid\_range for a netCDF variable named
8253 rh and a global attribute named title in an existing netCDF dataset
8256 +--------------------------------------+--------------------------------------+
8257 | | ``` {.example} |
8260 | | integer :: ncid, status |
8261 | | integer :: RHVarID |
8263 | | integer :: validRangeLength, titleL |
8264 | | ength ! Attribute lengths |
8266 | | status = nf90_open("foo.nc", nf90_n |
8268 | | if (status /= nf90_noerr) call hand |
8269 | | le_err(status) |
8271 | | ! Get the variable ID for "rh"... |
8272 | | status = nf90_inq_varid(ncid, "rh", |
8274 | | if (status /= nf90_noerr) call hand |
8275 | | le_err(status) |
8276 | | ! ... get the length of the "valid |
8277 | | _range" attribute... |
8278 | | status = nf90_inquire_attribute(nci |
8279 | | d, RHVarID, "valid_range", & |
8281 | | idRangeLength) |
8282 | | if (status /= nf90_noerr) call hand |
8283 | | le_err(status) |
8284 | | ! ... and the global title attribut |
8286 | | status = nf90_inquire_attribute(nci |
8287 | | d, nf90_global, "title", len = title |
8289 | | if (status /= nf90_noerr) call hand |
8290 | | le_err(status) |
8292 +--------------------------------------+--------------------------------------+
8294 ------------------------------------------------------------------------
8296 --------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8297 \[[<](#NF90_005fINQUIRE_005fATTRIBUTE "Previous section in reading order")\] \[[>](#NF90_005fCOPY_005fATT "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8298 --------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8300 7.4 Get Attribute’s Values: NF90\_GET\_ATT {.section}
8301 ------------------------------------------
8303 Function nf90\_get\_att gets the value(s) of a netCDF attribute, given
8304 its variable ID and name.
8309 +--------------------------------------+--------------------------------------+
8310 | | ``` {.example} |
8311 | | function nf90_get_att(ncid, varid, |
8313 | | integer, intent( in) : |
8315 | | character(len = *), intent( in) : |
8317 | | any valid type, scalar or array o |
8322 | | : nf90_get_att |
8324 +--------------------------------------+--------------------------------------+
8328 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8332 : Variable ID of the attribute’s variable, or NF90\_GLOBAL for a
8341 : Returned attribute values. All elements of the vector of attribute
8342 values are returned, so you must provide enough space to hold them.
8343 If you don’t know how much space to reserve, call
8344 NF90\_INQUIRE\_ATTRIBUTE first to find out the length of
8345 the attribute. If there is only a single attribute values may be
8346 a scalar. If the attribute is of type character values should be a
8347 variable of type character with the len Fortran 90 attribute set to
8348 an appropriate value (i.e. character (len = 80) :: values). You
8349 cannot read character data from a numeric variable or numeric data
8350 from a text variable. For numeric data, if the type of data differs
8351 from the netCDF variable type, type conversion will occur. See
8352 [(netcdf)Type Conversion](netcdf.html#Type-Conversion) section ‘Type
8353 Conversion’ in NetCDF Users Guide.
8358 NF90\_GET\_ATT\_ type returns the value NF90\_NOERR if no errors
8359 occurred. Otherwise, the returned status indicates an error. Possible
8360 causes of errors include:
8362 - The variable ID is invalid for the specified netCDF dataset.
8363 - The specified attribute does not exist.
8364 - The specified netCDF ID does not refer to an open netCDF dataset.
8365 - One or more of the attribute values are out of the range of values
8366 representable by the desired type.
8371 Here is an example using NF90\_GET\_ATT to determine the values of an
8372 attribute named valid\_range for a netCDF variable named rh and a global
8373 attribute named title in an existing netCDF dataset named foo.nc. In
8374 this example, it is assumed that we don’t know how many values will be
8375 returned, so we first inquire about the length of the attributes to make
8376 sure we have enough space to store them:
8378 +--------------------------------------+--------------------------------------+
8379 | | ``` {.example} |
8382 | | integer :: ncid, statu |
8384 | | integer :: RHVarID |
8386 | | integer :: validRangeL |
8387 | | ength, titleLength ! Attribute lengt |
8389 | | real, dimension(:), allocatable, & |
8391 | | character (len = 80) :: title |
8394 | | status = nf90_open("foo.nc", nf90_n |
8396 | | if (status /= nf90_noerr) call hand |
8397 | | le_err(status) |
8399 | | ! Find the lengths of the attribute |
8401 | | status = nf90_inq_varid(ncid, "rh", |
8403 | | if (status /= nf90_noerr) call hand |
8404 | | le_err(status) |
8405 | | status = nf90_inquire_attribute(nci |
8406 | | d, RHVarID, "valid_range", & |
8408 | | idRangeLength) |
8409 | | if (status /= nf90_noerr) call hand |
8410 | | le_err(status) |
8411 | | status = nf90_inquire_attribute(nci |
8412 | | d, nf90_global, "title", len = title |
8414 | | if (status /= nf90_noerr) call hand |
8415 | | le_err(status) |
8417 | | !Allocate space to hold attribute v |
8418 | | alues, check string lengths |
8419 | | allocate(validRange(validRangeLengt |
8420 | | h), stat = status) |
8421 | | if(status /= 0 .or. len(title) < ti |
8423 | | print *, "Not enough space to put |
8424 | | attribute values." |
8427 | | ! Read the attributes. |
8428 | | status = nf90_get_att(ncid, RHVarID |
8429 | | , "valid_range", validRange) |
8430 | | if (status /= nf90_noerr) call hand |
8431 | | le_err(status) |
8432 | | status = nf90_get_att(ncid, nf90_gl |
8433 | | obal, "title", title) |
8434 | | if (status /= nf90_noerr) call hand |
8435 | | le_err(status) |
8437 +--------------------------------------+--------------------------------------+
8439 ------------------------------------------------------------------------
8441 ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8442 \[[<](#NF90_005fGET_005fATT "Previous section in reading order")\] \[[>](#NF90_005fRENAME_005fATT "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8443 ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8445 7.5 Copy Attribute from One NetCDF to Another: NF90\_COPY\_ATT {.section}
8446 --------------------------------------------------------------
8448 The function NF90\_COPY\_ATT copies an attribute from one open netCDF
8449 dataset to another. It can also be used to copy an attribute from one
8450 variable to another within the same netCDF dataset.
8452 If used to copy an attribute of user-defined type, then that
8453 user-defined type must already be defined in the target file. In the
8454 case of user-defined attributes, enddef/redef is called for ncid\_in and
8455 ncid\_out if they are in define mode. (This is the ensure that all
8456 user-defined types are committed to the file(s) before the copy is
8462 +--------------------------------------+--------------------------------------+
8463 | | ``` {.example} |
8464 | | function nf90_copy_att(ncid_in, var |
8465 | | id_in, name, ncid_out, varid_out) |
8466 | | integer, intent( in) |
8467 | | :: ncid_in, varid_in |
8468 | | character (len = *), intent( in) |
8470 | | integer, intent( in) |
8471 | | :: ncid_out, varid_out |
8473 | | :: nf90_copy_att |
8475 +--------------------------------------+--------------------------------------+
8479 : The netCDF ID of an input netCDF dataset from which the attribute
8480 will be copied, from a previous call to NF90\_OPEN or NF90\_CREATE.
8484 : ID of the variable in the input netCDF dataset from which the
8485 attribute will be copied, or NF90\_GLOBAL for a global attribute.
8489 : Name of the attribute in the input netCDF dataset to be copied.
8493 : The netCDF ID of the output netCDF dataset to which the attribute
8494 will be copied, from a previous call to NF90\_OPEN or NF90\_CREATE.
8495 It is permissible for the input and output netCDF IDs to be
8496 the same. The output netCDF dataset should be in define mode if the
8497 attribute to be copied does not already exist for the target
8498 variable, or if it would cause an existing target attribute to grow.
8502 : ID of the variable in the output netCDF dataset to which the
8503 attribute will be copied, or NF90\_GLOBAL to copy to a
8509 NF90\_COPY\_ATT returns the value NF90\_NOERR if no errors occurred.
8510 Otherwise, the returned status indicates an error. Possible causes of
8513 - The input or output variable ID is invalid for the specified
8515 - The specified attribute does not exist.
8516 - The output netCDF is not in define mode and the attribute is new for
8517 the output dataset is larger than the existing attribute.
8518 - The input or output netCDF ID does not refer to an open
8524 Here is an example using NF90\_COPY\_ATT to copy the variable attribute
8525 units from the variable rh in an existing netCDF dataset named foo.nc to
8526 the variable avgrh in another existing netCDF dataset named bar.nc,
8527 assuming that the variable avgrh already exists, but does not yet have a
8530 +--------------------------------------+--------------------------------------+
8531 | | ``` {.example} |
8534 | | integer :: ncid1, ncid2, status |
8535 | | integer :: RHVarID, avgRHVarID ! |
8538 | | status = nf90_open("foo.nc", nf90_n |
8539 | | owrite, ncid1) |
8540 | | if (status /= nf90_noerr) call hand |
8541 | | le_err(status) |
8542 | | status = nf90_open("bar.nc", nf90_w |
8544 | | if (status /= nf90_noerr) call hand |
8545 | | le_err(status) |
8547 | | ! Find the IDs of the variables |
8548 | | status = nf90_inq_varid(ncid1, "rh" |
8550 | | if (status /= nf90_noerr) call hand |
8551 | | le_err(status) |
8552 | | status = nf90_inq_varid(ncid1, "avg |
8553 | | rh", avgRHVarID) |
8554 | | if (status /= nf90_noerr) call hand |
8555 | | le_err(status) |
8557 | | status = nf90_redef(ncid2) ! Ente |
8559 | | if (status /= nf90_noerr) call hand |
8560 | | le_err(status) |
8561 | | ! Copy variable attribute from "rh" |
8562 | | in file 1 to "avgrh" in file 1 |
8563 | | status = nf90_copy_att(ncid1, RHVar |
8564 | | ID, "units", ncid2, avgRHVarID) |
8565 | | if (status /= nf90_noerr) call hand |
8566 | | le_err(status) |
8567 | | status = nf90_enddef(ncid2) |
8568 | | if (status /= nf90_noerr) call hand |
8569 | | le_err(status) |
8571 +--------------------------------------+--------------------------------------+
8573 ------------------------------------------------------------------------
8575 ------------------------------------------------------------------------ ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8576 \[[<](#NF90_005fCOPY_005fATT "Previous section in reading order")\] \[[>](#NF90_005fDEL_005fATT "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8577 ------------------------------------------------------------------------ ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8579 7.6 Rename an Attribute: NF90\_RENAME\_ATT {.section}
8580 ------------------------------------------
8582 The function NF90\_RENAME\_ATT changes the name of an attribute. If the
8583 new name is longer than the original name, the netCDF dataset must be in
8584 define mode. You cannot rename an attribute to have the same name as
8585 another attribute of the same variable.
8590 +--------------------------------------+--------------------------------------+
8591 | | ``` {.example} |
8592 | | function nf90_rename_att(ncid, vari |
8593 | | d, curname, newname) |
8594 | | integer, intent( in) |
8595 | | :: ncid, varid |
8596 | | character (len = *), intent( in) |
8597 | | :: curname, newname |
8599 | | :: nf90_rename_att |
8601 +--------------------------------------+--------------------------------------+
8605 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE
8609 : ID of the attribute’s variable, or NF90\_GLOBAL for a global
8614 : The current attribute name.
8618 : The new name to be assigned to the specified attribute. If the new
8619 name is longer than the current name, the netCDF dataset must be in
8625 NF90\_RENAME\_ATT returns the value NF90\_NOERR if no errors occurred.
8626 Otherwise, the returned status indicates an error. Possible causes of
8629 - The specified variable ID is not valid.
8630 - The new attribute name is already in use for another attribute of
8631 the specified variable.
8632 - The specified netCDF dataset is in data mode and the new name is
8633 longer than the old name.
8634 - The specified attribute does not exist.
8635 - The specified netCDF ID does not refer to an open netCDF dataset.
8640 Here is an example using NF90\_RENAME\_ATT to rename the variable
8641 attribute units to Units for a variable rh in an existing netCDF dataset
8644 +--------------------------------------+--------------------------------------+
8645 | | ``` {.example} |
8648 | | integer :: ncid1, status |
8649 | | integer :: RHVarID ! Variab |
8652 | | status = nf90_open("foo.nc", nf90_n |
8654 | | if (status /= nf90_noerr) call hand |
8655 | | le_err(status) |
8657 | | ! Find the IDs of the variables |
8658 | | status = nf90_inq_varid(ncid, "rh", |
8660 | | if (status /= nf90_noerr) call hand |
8661 | | le_err(status) |
8663 | | status = nf90_rename_att(ncid, RHVa |
8664 | | rID, "units", "Units") |
8665 | | if (status /= nf90_noerr) call hand |
8666 | | le_err(status) |
8668 +--------------------------------------+--------------------------------------+
8670 ------------------------------------------------------------------------
8672 -------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8673 \[[<](#NF90_005fRENAME_005fATT "Previous section in reading order")\] \[[>](#Summary-of-Fortran-90-Interface "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[>>](#Summary-of-Fortran-90-Interface "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8674 -------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8676 7.7 NF90\_DEL\_ATT {.section}
8679 The function NF90\_DEL\_ATT deletes a netCDF attribute from an open
8680 netCDF dataset. The netCDF dataset must be in define mode.
8685 +--------------------------------------+--------------------------------------+
8686 | | ``` {.example} |
8687 | | function nf90_del_att(ncid, varid, |
8689 | | integer, intent( in) |
8690 | | :: ncid, varid |
8691 | | character (len = *), intent( in) |
8694 | | :: nf90_del_att |
8696 +--------------------------------------+--------------------------------------+
8700 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8704 : ID of the attribute’s variable, or NF90\_GLOBAL for a
8709 : The name of the attribute to be deleted.
8714 NF90\_DEL\_ATT returns the value NF90\_NOERR if no errors occurred.
8715 Otherwise, the returned status indicates an error. Possible causes of
8718 - The specified variable ID is not valid.
8719 - The specified netCDF dataset is in data mode.
8720 - The specified attribute does not exist.
8721 - The specified netCDF ID does not refer to an open netCDF dataset.
8726 Here is an example using NF90\_DEL\_ATT to delete the variable attribute
8727 Units for a variable rh in an existing netCDF dataset named foo.nc:
8729 +--------------------------------------+--------------------------------------+
8730 | | ``` {.example} |
8733 | | integer :: ncid1, status |
8734 | | integer :: RHVarID ! Variab |
8737 | | status = nf90_open("foo.nc", nf90_n |
8739 | | if (status /= nf90_noerr) call hand |
8740 | | le_err(status) |
8742 | | ! Find the IDs of the variables |
8743 | | status = nf90_inq_varid(ncid, "rh", |
8745 | | if (status /= nf90_noerr) call hand |
8746 | | le_err(status) |
8748 | | status = nf90_redef(ncid) ! Enter |
8750 | | if (status /= nf90_noerr) call hand |
8751 | | le_err(status) |
8752 | | status = nf90_del_att(ncid, RHVarID |
8754 | | if (status /= nf90_noerr) call hand |
8755 | | le_err(status) |
8756 | | status = nf90_enddef(ncid) |
8757 | | if (status /= nf90_noerr) call hand |
8758 | | le_err(status) |
8760 +--------------------------------------+--------------------------------------+
8762 ------------------------------------------------------------------------
8764 ----------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8765 \[[<](#NF90_005fDEL_005fATT "Previous section in reading order")\] \[[>](#FORTRAN-77-to-Fortran-90-Transition-Guide "Next section in reading order")\] \[[<<](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#FORTRAN-77-to-Fortran-90-Transition-Guide "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8766 ----------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8768 A. Appendix A - Summary of Fortran 90 Interface {.appendix}
8769 ===============================================
8773 +--------------------------------------+--------------------------------------+
8774 | | ``` {.example} |
8775 | | function nf90_inq_libvers() |
8776 | | character(len = 80) :: nf90_inq_l |
8778 | | function nf90_strerror(ncerr) |
8779 | | integer, intent( in) :: ncerr |
8780 | | character(len = 80) :: nf90_stre |
8782 | | function nf90_create(path, cmode, n |
8784 | | character (len = *), intent(in |
8786 | | integer, intent(in |
8788 | | integer, optional, intent(in |
8789 | | ) :: initialsize |
8790 | | integer, optional, intent(inout |
8791 | | ) :: chunksize |
8792 | | integer, intent( out |
8795 | | :: nf90_create |
8796 | | function nf90_open(path, mode, ncid |
8798 | | character (len = *), intent(in |
8800 | | integer, intent(in |
8802 | | integer, intent( out |
8804 | | integer, optional, intent(inout |
8805 | | ) :: chunksize |
8808 | | function nf90_set_fill(ncid, fillmo |
8810 | | integer, intent( in) :: ncid, fil |
8812 | | integer, intent(out) :: old_mode |
8813 | | integer :: nf90_set_ |
8815 | | function nf90_redef(ncid) |
8816 | | integer, intent( in) :: ncid |
8817 | | integer :: nf90_rede |
8819 | | function nf90_enddef(ncid, h_minfre |
8820 | | e, v_align, v_minfree, r_align) |
8821 | | integer, intent( in) :: |
8823 | | integer, optional, intent( in) :: |
8824 | | h_minfree, v_align, v_minfree, r_al |
8828 | | function nf90_sync(ncid) |
8829 | | integer, intent( in) :: ncid |
8830 | | integer :: nf90_sync |
8831 | | function nf90_abort(ncid) |
8832 | | integer, intent( in) :: ncid |
8833 | | integer :: nf90_abor |
8835 | | function nf90_close(ncid) |
8836 | | integer, intent( in) :: ncid |
8837 | | integer :: nf90_clos |
8839 | | function nf90_Inquire(ncid, nDimens |
8840 | | ions, nVariables, nAttributes, & |
8841 | | unlimitedDimId |
8843 | | integer, intent( in) :: |
8845 | | integer, optional, intent(out) :: |
8846 | | nDimensions, nVariables, nAttribute |
8853 +--------------------------------------+--------------------------------------+
8857 +--------------------------------------+--------------------------------------+
8858 | | ``` {.example} |
8859 | | function nf90_def_dim(ncid, name, l |
8861 | | integer, intent( in) |
8863 | | character (len = *), intent( in) |
8865 | | integer, intent( in) |
8867 | | integer, intent(out) |
8870 | | :: nf90_def_dim |
8871 | | function nf90_inq_dimid(ncid, name, |
8873 | | integer, intent( in) |
8875 | | character (len = *), intent( in) |
8877 | | integer, intent(out) |
8880 | | :: nf90_inq_dimid |
8881 | | function nf90_inquire_dimension(nci |
8882 | | d, dimid, name, len) |
8884 | | tent( in) :: ncid, dimid |
8885 | | character (len = *), optional, in |
8886 | | tent(out) :: name |
8887 | | integer, optional, in |
8888 | | tent(out) :: len |
8890 | | :: nf90_inquire_dimension |
8891 | | function nf90_rename_dim(ncid, dimi |
8893 | | integer, intent( in) |
8895 | | character (len = *), intent( in) |
8897 | | integer, intent( in) |
8900 | | :: nf90_rename_dim |
8902 +--------------------------------------+--------------------------------------+
8906 +--------------------------------------+--------------------------------------+
8907 | | ``` {.example} |
8908 | | function nf90_def_var(ncid, name, x |
8909 | | type, dimids, varid) |
8910 | | integer, intent( in |
8912 | | character (len = *), intent( in |
8914 | | integer, intent( in |
8916 | | integer, dimension(:), intent( in |
8917 | | ) :: dimids ! May be omitted, scalar |
8922 | | :: nf90_def_var |
8923 | | function nf90_inq_varid(ncid, name, |
8925 | | integer, intent( in) |
8927 | | character (len = *), intent( in) |
8929 | | integer, intent(out) |
8932 | | :: nf90_inq_varid |
8933 | | function nf90_inquire_variable(ncid |
8934 | | , varid, name, xtype, ndims, & |
8938 | | intent( in) :: ncid, varid |
8939 | | character (len = *), optional, |
8940 | | intent(out) :: name |
8941 | | integer, optional, |
8942 | | intent(out) :: xtype, ndims |
8943 | | integer, dimension(*), optional, |
8944 | | intent(out) :: dimids |
8945 | | integer, optional, |
8946 | | intent(out) :: nAtts |
8948 | | :: nf90_inquire_variable |
8949 | | function nf90_put_var(ncid, varid, |
8950 | | values, start, stride, map) |
8952 | | intent( in) :: ncid, varid |
8953 | | any valid type, scalar or array o |
8956 | | intent( in) :: values |
8957 | | integer, dimension(:), optional, |
8958 | | intent( in) :: start, count, stride, |
8961 | | :: nf90_put_var |
8962 | | function nf90_get_var(ncid, varid, |
8963 | | values, start, stride, map) |
8965 | | intent( in) :: ncid, varid |
8966 | | any valid type, scalar or array o |
8969 | | intent(out) :: values |
8970 | | integer, dimension(:), optional, |
8971 | | intent( in) :: start, count, stride, |
8974 | | :: nf90_get_var |
8975 | | function nf90_rename_var(ncid, vari |
8977 | | integer, intent( in) |
8978 | | :: ncid, varid |
8979 | | character (len = *), intent( in) |
8982 | | :: nf90_rename_var |
8984 +--------------------------------------+--------------------------------------+
8988 +--------------------------------------+--------------------------------------+
8989 | | ``` {.example} |
8990 | | function nf90_inquire_attribute(nci |
8991 | | d, varid, name, xtype, len, attnum) |
8992 | | integer, intent( in) |
8993 | | :: ncid, varid |
8994 | | character (len = *), intent( in) |
8996 | | integer, intent(out), |
8997 | | optional :: xtype, len, attnum |
8999 | | :: nf90_inquire_attribute |
9000 | | function nf90_inq_attname(ncid, var |
9001 | | id, attnum, name) |
9002 | | integer, intent( in) |
9003 | | :: ncid, varid, attnum |
9004 | | character (len = *), intent(out) |
9007 | | :: nf90_inq_attname |
9008 | | function nf90_put_att(ncid, varid, |
9010 | | integer, intent( in) : |
9012 | | character(len = *), intent( in) : |
9014 | | scalar character string or any nu |
9015 | | meric type, scalar, or array of rank |
9020 | | : nf90_put_att |
9021 | | function nf90_get_att(ncid, varid, |
9023 | | integer, intent( in) : |
9025 | | character(len = *), intent( in) : |
9027 | | any valid type, scalar or array o |
9032 | | :: nf90_get_att |
9033 | | function nf90_copy_att(ncid_in, var |
9034 | | id_in, name, ncid_out, varid_out) |
9035 | | integer, intent( in) |
9036 | | :: ncid_in, varid_in |
9037 | | character (len = *), intent( in) |
9039 | | integer, intent( in) |
9040 | | :: ncid_out, varid_out |
9042 | | :: nf90_copy_att |
9043 | | function nf90_rename_att(ncid, vari |
9044 | | d, curname, newname) |
9045 | | integer, intent( in) |
9046 | | :: ncid, varid |
9047 | | character (len = *), intent( in) |
9048 | | :: curname, newname |
9050 | | :: nf90_rename_att |
9051 | | function nf90_del_att(ncid, varid, |
9053 | | integer, intent( in) |
9054 | | :: ncid, varid |
9055 | | character (len = *), intent( in) |
9058 | | :: nf90_del_att |
9060 +--------------------------------------+--------------------------------------+
9062 ------------------------------------------------------------------------
9064 ---------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------------- ----------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9065 \[[<](#Summary-of-Fortran-90-Interface "Previous section in reading order")\] \[[>](#The-new-Fortran-90-interface "Next section in reading order")\] \[[<<](#Summary-of-Fortran-90-Interface "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[>>](#Combined-Index "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9066 ---------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------------- ----------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9068 B. Appendix B - FORTRAN 77 to Fortran 90 Transition Guide {.appendix}
9069 =========================================================
9071 ------------------------------------------------------------------------
9073 -------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9074 \[[<](#FORTRAN-77-to-Fortran-90-Transition-Guide "Previous section in reading order")\] \[[>](#Changes-to-Inquiry-functions "Next section in reading order")\] \[[<<](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[>>](#Combined-Index "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9075 -------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9077 The new Fortran 90 interface {.unnumberedsec}
9078 ----------------------------
9080 The Fortran 90 interface to the netCDF library closely follows the
9081 FORTRAN 77 interface. In most cases, function and constant names and
9082 argument lists are the same, except that nf90\_ replaces nf\_ in names.
9083 The Fortran 90 interface is much smaller than the FORTRAN 77 interface,
9084 however. This has been accomplished by using optional arguments and
9085 overloaded functions wherever possible.
9087 Because FORTRAN 77 is a subset of Fortran 90, there is no reason to
9088 modify working FORTRAN code to use the Fortran 90 interface. New code,
9089 however, can easily be patterned after existing FORTRAN while taking
9090 advantage of the simpler interface. Some compilers may provide
9091 additional support when using Fortran 90. For example, compilers may
9092 issue warnings if arguments with intent( in) are not set before they are
9093 passed to a procedure.
9095 The Fortran 90 interface is currently implemented as a set of wrappers
9096 around the base FORTRAN subroutines in the netCDF distribution. Future
9097 versions may be implemented entirely in Fortran 90, adding additional
9098 error checking possibilities.
9100 ------------------------------------------------------------------------
9102 ------------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9103 \[[<](#The-new-Fortran-90-interface "Previous section in reading order")\] \[[>](#Changes-to-put-and-get-function "Next section in reading order")\] \[[<<](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[>>](#Combined-Index "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9104 ------------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9106 Changes to Inquiry functions {.unnumberedsec}
9107 ----------------------------
9109 In the Fortran 90 interface there are two inquiry functions each for
9110 dimensions, variables, and attributes, and a single inquiry function for
9111 datasets. These functions take optional arguments, allowing users to
9112 request only the information they need. These functions replace the
9113 many-argument and single-argument inquiry functions in the FORTRAN
9116 As an example, compare the attribute inquiry functions in the Fortran 90
9119 +--------------------------------------+--------------------------------------+
9120 | | ``` {.example} |
9121 | | function nf90_inquire_attribute(nci |
9122 | | d, varid, name, xtype, len, attnum) |
9123 | | integer, intent( in) |
9124 | | :: ncid, varid |
9125 | | character (len = *), intent( in) |
9127 | | integer, intent(out), |
9128 | | optional :: xtype, len, attnum |
9130 | | :: nf90_inquire_attribute |
9131 | | function nf90_inq_attname(ncid, var |
9132 | | id, attnum, name) |
9133 | | integer, intent( in) |
9134 | | :: ncid, varid, attnum |
9135 | | character (len = *), intent(out) |
9138 | | :: nf90_inq_attname |
9140 +--------------------------------------+--------------------------------------+
9142 with those in the FORTRAN interface
9144 +--------------------------------------+--------------------------------------+
9145 | | ``` {.example} |
9146 | | INTEGER FUNCTION NF_INQ_ATT |
9147 | | (NCID, VARID, NAME, xtype, len) |
9148 | | INTEGER FUNCTION NF_INQ_ATTID |
9149 | | (NCID, VARID, NAME, attnum) |
9150 | | INTEGER FUNCTION NF_INQ_ATTTYPE |
9151 | | (NCID, VARID, NAME, xtype) |
9152 | | INTEGER FUNCTION NF_INQ_ATTLEN |
9153 | | (NCID, VARID, NAME, len) |
9154 | | INTEGER FUNCTION NF_INQ_ATTNAME |
9155 | | (NCID, VARID, ATTNUM, name) |
9157 +--------------------------------------+--------------------------------------+
9159 ------------------------------------------------------------------------
9161 ------------------------------------------------------------------------------- ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9162 \[[<](#Changes-to-Inquiry-functions "Previous section in reading order")\] \[[>](#Combined-Index "Next section in reading order")\] \[[<<](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[>>](#Combined-Index "Next chapter")\] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9163 ------------------------------------------------------------------------------- ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9165 Changes to put and get function {.unnumberedsec}
9166 -------------------------------
9168 The biggest simplification in the Fortran 90 is in the nf90\_put\_var
9169 and nf90\_get\_var functions. Both functions are overloaded: the values
9170 argument can be a scalar or an array any rank (7 is the maximum rank
9171 allowed by Fortran 90), and may be of any numeric type or the default
9172 character type. The netCDF library provides transparent conversion
9173 between the external representation of the data and the desired internal
9176 The start, count, stride, and map arguments to nf90\_put\_var and
9177 nf90\_get\_var are optional. By default, data is read from or written to
9178 consecutive values of starting at the origin of the netCDF variable; the
9179 shape of the argument determines how many values are read from or
9180 written to each dimension. Any or all of these arguments may be supplied
9181 to override the default behavior.
9183 Note also that Fortran 90 allows arbitrary array sections to be passed
9184 to any procedure, which may greatly simplify programming. For examples
9185 see [Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR) and
9186 [Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR).
9188 ------------------------------------------------------------------------
9190 ---------------------------------------------------------------------------------- ------------ --- ------------------------------------------------------------------------------------------------------------ ----------------------------- ---------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9191 \[[<](#Changes-to-put-and-get-function "Previous section in reading order")\] \[ > \] \[[<<](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[ >> \] \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9192 ---------------------------------------------------------------------------------- ------------ --- ------------------------------------------------------------------------------------------------------------ ----------------------------- ---------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9197 ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9198 Jump to: [**A**](#Index_cp_letter-A) [**C**](#Index_cp_letter-C) [**D**](#Index_cp_letter-D) [**E**](#Index_cp_letter-E) [**F**](#Index_cp_letter-F) [**G**](#Index_cp_letter-G) [**I**](#Index_cp_letter-I) [**L**](#Index_cp_letter-L) [**N**](#Index_cp_letter-N) [**O**](#Index_cp_letter-O) [**R**](#Index_cp_letter-R) [**U**](#Index_cp_letter-U) [**V**](#Index_cp_letter-V) [**W**](#Index_cp_letter-W)
9199 ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9205 ------------------------------------------------------------------------
9209 [attributes, adding](#index-attributes_002c-adding)
9211 [1.5 Adding New Dimensions, Variables,
9212 Attributes](#Adding-New-Dimensions)
9214 ------------------------------------------------------------------------
9218 [common netcdf commands](#index-common-netcdf-commands)
9220 [1. Use of the NetCDF Library](#Use-of-the-NetCDF-Library)
9222 [compiling with netCDF library](#index-compiling-with-netCDF-library)
9224 [1.7 Compiling and Linking with the NetCDF
9225 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9227 [compound types, overview](#index-compound-types_002c-overview)
9229 [5.6 Compound Types Introduction](#Compound-Types)
9231 ------------------------------------------------------------------------
9235 [dataset, creating](#index-dataset_002c-creating)
9237 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9239 [datasets, overview](#index-datasets_002c-overview)
9241 [2.1 Datasets Introduction](#Datasets-Introduction)
9243 [dimensions, adding](#index-dimensions_002c-adding)
9245 [1.5 Adding New Dimensions, Variables,
9246 Attributes](#Adding-New-Dimensions)
9248 ------------------------------------------------------------------------
9252 [enum type](#index-enum-type)
9254 [5.9 Enum Type Introduction](#Enum-Type)
9256 [error handling](#index-error-handling)
9258 [1.6 Error Handling](#Error-Handling)
9260 ------------------------------------------------------------------------
9266 [6.4 Define Fill Parameters for a Variable:
9267 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9269 ------------------------------------------------------------------------
9273 [groups, overview](#index-groups_002c-overview)
9275 [3. Groups](#Groups)
9277 ------------------------------------------------------------------------
9281 [interface descriptions](#index-interface-descriptions)
9283 [2.2 NetCDF Library Interface
9284 Descriptions](#NetCDF-Library-Interface-Descriptions)
9286 ------------------------------------------------------------------------
9290 [linking to netCDF library](#index-linking-to-netCDF-library)
9292 [1.7 Compiling and Linking with the NetCDF
9293 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9295 ------------------------------------------------------------------------
9299 [nf-config](#index-nf_002dconfig)
9301 [1.7 Compiling and Linking with the NetCDF
9302 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9304 [NF90\_ABORT](#index-NF90_005fABORT)
9306 [2.12 NF90\_ABORT](#NF90_005fABORT)
9308 [NF90\_ABORT , example](#index-NF90_005fABORT-_002c-example)
9310 [2.12 NF90\_ABORT](#NF90_005fABORT)
9312 [NF90\_CLOSE](#index-NF90_005fCLOSE)
9314 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
9316 [NF90\_CLOSE , example](#index-NF90_005fCLOSE-_002c-example)
9318 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
9320 [NF90\_CLOSE, typical use](#index-NF90_005fCLOSE_002c-typical-use)
9322 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9324 [NF90\_COPY\_ATT](#index-NF90_005fCOPY_005fATT)
9326 [7.5 Copy Attribute from One NetCDF to Another:
9327 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
9329 [NF90\_COPY\_ATT, example](#index-NF90_005fCOPY_005fATT_002c-example)
9331 [7.5 Copy Attribute from One NetCDF to Another:
9332 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
9334 [NF90\_CREATE](#index-NF90_005fCREATE)
9336 [2.5 NF90\_CREATE](#NF90_005fCREATE)
9338 [NF90\_CREATE , example](#index-NF90_005fCREATE-_002c-example)
9340 [2.5 NF90\_CREATE](#NF90_005fCREATE)
9342 [NF90\_CREATE, typical use](#index-NF90_005fCREATE_002c-typical-use)
9344 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9346 [NF90\_DEF\_COMPOUND](#index-NF90_005fDEF_005fCOMPOUND)
9348 [5.6.1 Creating a Compound Type:
9349 NF90\_DEF\_COMPOUND](#NF90_005fDEF_005fCOMPOUND)
9351 [NF90\_DEF\_DIM](#index-NF90_005fDEF_005fDIM)
9353 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
9355 [NF90\_DEF\_DIM, example](#index-NF90_005fDEF_005fDIM_002c-example)
9357 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
9359 [NF90\_DEF\_DIM, typical
9360 use](#index-NF90_005fDEF_005fDIM_002c-typical-use)
9362 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9364 [NF90\_DEF\_ENUM](#index-NF90_005fDEF_005fENUM)
9366 [5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM](#NF90_005fDEF_005fENUM)
9368 [NF90\_DEF\_GRP](#index-NF90_005fDEF_005fGRP)
9370 [3.11 Create a New Group: NF90\_DEF\_GRP](#NF90_005fDEF_005fGRP)
9372 [NF90\_DEF\_OPAQUE](#index-NF90_005fDEF_005fOPAQUE)
9374 [5.8.1 Creating Opaque Types:
9375 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE)
9377 [NF90\_DEF\_VAR](#index-NF90_005fDEF_005fVAR)
9379 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
9381 [NF90\_DEF\_VAR, example](#index-NF90_005fDEF_005fVAR_002c-example)
9383 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
9385 [NF90\_DEF\_VAR, typical
9386 use](#index-NF90_005fDEF_005fVAR_002c-typical-use)
9388 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9390 [NF90\_DEF\_VAR\_FILL](#index-NF90_005fDEF_005fVAR_005fFILL)
9392 [6.4 Define Fill Parameters for a Variable:
9393 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9395 [NF90\_DEF\_VLEN](#index-NF90_005fDEF_005fVLEN)
9397 [5.7.1 Define a Variable Length Array (VLEN):
9398 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
9400 [NF90\_DEL\_ATT](#index-NF90_005fDEL_005fATT)
9402 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
9404 [NF90\_DEL\_ATT , example](#index-NF90_005fDEL_005fATT-_002c-example)
9406 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
9408 [NF90\_ENDDEF](#index-NF90_005fENDDEF)
9410 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
9412 [NF90\_ENDDEF , example](#index-NF90_005fENDDEF-_002c-example)
9414 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
9416 [NF90\_ENDDEF, typical use](#index-NF90_005fENDDEF_002c-typical-use)
9418 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9420 [NF90\_FREE\_VLEN](#index-NF90_005fFREE_005fVLEN)
9422 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
9423 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
9425 [NF90\_GET\_ATT](#index-NF90_005fGET_005fATT)
9427 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
9429 [NF90\_GET\_ATT, example](#index-NF90_005fGET_005fATT_002c-example)
9431 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
9433 [NF90\_GET\_ATT, typical
9434 use](#index-NF90_005fGET_005fATT_002c-typical-use)
9436 [1.2 Reading a NetCDF Dataset with Known
9437 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9439 [NF90\_GET\_ATT, typical
9440 use](#index-NF90_005fGET_005fATT_002c-typical-use-1)
9442 [1.3 Reading a netCDF Dataset with Unknown
9443 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9445 [NF90\_GET\_VAR](#index-NF90_005fGET_005fVAR)
9447 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
9449 [NF90\_GET\_VAR, example](#index-NF90_005fGET_005fVAR_002c-example)
9451 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
9453 [NF90\_GET\_VAR, typical
9454 use](#index-NF90_005fGET_005fVAR_002c-typical-use)
9456 [1.2 Reading a NetCDF Dataset with Known
9457 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9459 [NF90\_GET\_VLEN\_ELEMENT](#index-NF90_005fGET_005fVLEN_005fELEMENT)
9461 [5.5.2 Set a Variable Length Array with
9462 NF90\_GET\_VLEN\_ELEMENT](#NF90_005fGET_005fVLEN_005fELEMENT)
9464 [NF90\_INQUIRE, typical use](#index-NF90_005fINQUIRE_002c-typical-use)
9466 [1.3 Reading a netCDF Dataset with Unknown
9467 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9469 [NF90\_INQUIRE\_ATTRIBUTE](#index-NF90_005fINQUIRE_005fATTRIBUTE)
9471 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9472 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9474 [NF90\_INQUIRE\_ATTRIBUTE,
9475 example](#index-NF90_005fINQUIRE_005fATTRIBUTE_002c-example)
9477 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9478 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9480 [NF90\_INQUIRE\_ATTRIBUTE, typical
9481 use](#index-NF90_005fINQUIRE_005fATTRIBUTE_002c-typical-use)
9483 [1.3 Reading a netCDF Dataset with Unknown
9484 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9486 [NF90\_INQUIRE\_DIMENSION](#index-NF90_005fINQUIRE_005fDIMENSION)
9488 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
9490 [NF90\_INQUIRE\_DIMENSION ,
9491 example](#index-NF90_005fINQUIRE_005fDIMENSION-_002c-example)
9493 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
9495 [NF90\_INQUIRE\_DIMENSION, typical
9496 use](#index-NF90_005fINQUIRE_005fDIMENSION_002c-typical-use)
9498 [1.3 Reading a netCDF Dataset with Unknown
9499 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9501 [NF90\_INQUIRE\_VARIABLE](#index-NF90_005fINQUIRE_005fVARIABLE)
9503 [6.6 Get Information about a Variable from Its ID:
9504 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
9506 [NF90\_INQUIRE\_VARIABLE ,
9507 example](#index-NF90_005fINQUIRE_005fVARIABLE-_002c-example)
9509 [6.6 Get Information about a Variable from Its ID:
9510 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
9512 [NF90\_INQUIRE\_VARIABLE, typical
9513 use](#index-NF90_005fINQUIRE_005fVARIABLE_002c-typical-use)
9515 [1.3 Reading a netCDF Dataset with Unknown
9516 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9518 [NF90\_INQ\_ATTNAME](#index-NF90_005fINQ_005fATTNAME)
9520 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9521 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9523 [NF90\_INQ\_ATTNAME,
9524 example](#index-NF90_005fINQ_005fATTNAME_002c-example)
9526 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9527 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9529 [NF90\_INQ\_ATTNAME, typical
9530 use](#index-NF90_005fINQ_005fATTNAME_002c-typical-use)
9532 [1.3 Reading a netCDF Dataset with Unknown
9533 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9535 [NF90\_INQ\_CMP\_FIELDDIM\_SIZES](#index-NF90_005fINQ_005fCMP_005fFIELDDIM_005fSIZES)
9537 [5.6.5 Learn About a Field of a Compound Type:
9538 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9540 [NF90\_INQ\_COMPOUND](#index-NF90_005fINQ_005fCOMPOUND)
9542 [5.6.4 Learn About a Compound Type:
9543 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9545 [NF90\_INQ\_COMPOUND\_FIELD](#index-NF90_005fINQ_005fCOMPOUND_005fFIELD)
9547 [5.6.5 Learn About a Field of a Compound Type:
9548 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9550 [NF90\_INQ\_COMPOUND\_FIELDINDEX](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDINDEX)
9552 [5.6.5 Learn About a Field of a Compound Type:
9553 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9555 [NF90\_INQ\_COMPOUND\_FIELDNAME](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDNAME)
9557 [5.6.5 Learn About a Field of a Compound Type:
9558 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9560 [NF90\_INQ\_COMPOUND\_FIELDNDIMS](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDNDIMS)
9562 [5.6.5 Learn About a Field of a Compound Type:
9563 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9565 [NF90\_INQ\_COMPOUND\_FIELDOFFSET](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDOFFSET)
9567 [5.6.5 Learn About a Field of a Compound Type:
9568 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9570 [NF90\_INQ\_COMPOUND\_FIELDTYPE](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDTYPE)
9572 [5.6.5 Learn About a Field of a Compound Type:
9573 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9575 [NF90\_INQ\_COMPOUND\_NAME](#index-NF90_005fINQ_005fCOMPOUND_005fNAME)
9577 [5.6.4 Learn About a Compound Type:
9578 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9580 [NF90\_INQ\_COMPOUND\_NFIELDS](#index-NF90_005fINQ_005fCOMPOUND_005fNFIELDS)
9582 [5.6.4 Learn About a Compound Type:
9583 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9585 [NF90\_INQ\_COMPOUND\_SIZE](#index-NF90_005fINQ_005fCOMPOUND_005fSIZE)
9587 [5.6.4 Learn About a Compound Type:
9588 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9590 [NF90\_INQ\_DIMID](#index-NF90_005fINQ_005fDIMID)
9592 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
9595 example](#index-NF90_005fINQ_005fDIMID-_002c-example)
9597 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
9599 [NF90\_INQ\_DIMID, typical
9600 use](#index-NF90_005fINQ_005fDIMID_002c-typical-use)
9602 [1.2 Reading a NetCDF Dataset with Known
9603 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9605 [NF90\_INQ\_DIMIDS](#index-NF90_005fINQ_005fDIMIDS)
9607 [3.4 Find all Dimensions Visible in a Group:
9608 NF90\_INQ\_DIMIDS](#NF90_005fINQ_005fDIMIDS)
9610 [NF90\_INQ\_ENUM](#index-NF90_005fINQ_005fENUM)
9612 [5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM](#NF90_005fINQ_005fENUM)
9614 [NF90\_INQ\_ENUM\_IDENT](#index-NF90_005fINQ_005fENUM_005fIDENT)
9616 [5.9.5 Learn the Name of a Enum Type:
9617 NF90\_INQ\_ENUM\_IDENT](#NF90_005fINQ_005fENUM_005fIDENT)
9619 [nf90\_inq\_enum\_member](#index-nf90_005finq_005fenum_005fmember)
9621 [5.9.4 Learn the Name of a Enum Type:
9622 nf90\_inq\_enum\_member](#NF90_005fINQ_005fENUM_005fMEMBER)
9624 [NF90\_INQ\_GRPNAME](#index-NF90_005fINQ_005fGRPNAME)
9626 [3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME](#NF90_005fINQ_005fGRPNAME)
9628 [NF90\_INQ\_GRPNAME\_FULL](#index-NF90_005fINQ_005fGRPNAME_005fFULL)
9630 [3.7 Find a Group’s Full Name:
9631 NF90\_INQ\_GRPNAME\_FULL](#NF90_005fINQ_005fGRPNAME_005fFULL)
9633 [NF90\_INQ\_GRPNAME\_LEN](#index-NF90_005fINQ_005fGRPNAME_005fLEN)
9635 [3.5 Find the Length of a Group’s Full Name:
9636 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN)
9638 [NF90\_INQ\_GRPS](#index-NF90_005fINQ_005fGRPS)
9640 [3.2 Get a List of Groups in a Group:
9641 NF90\_INQ\_GRPS](#NF90_005fINQ_005fGRPS)
9643 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT)
9645 [3.8 Find a Group’s Parent:
9646 NF90\_INQ\_GRP\_PARENT](#NF90_005fINQ_005fGRP_005fPARENT)
9648 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT-1)
9650 [3.9 Find a Group by Name:
9651 NF90\_INQ\_GRP\_NCID](#NF90_005fINQ_005fGRP_005fNCID)
9653 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT-2)
9655 [3.10 Find a Group by its Fully-qualified Name:
9656 NF90\_INQ\_GRP\_FULL\_NCID](#NF90_005fINQ_005fGRP_005fFULL_005fNCID)
9658 [NF90\_INQ\_LIBVERS](#index-NF90_005fINQ_005fLIBVERS)
9660 [2.4 Get netCDF library version:
9661 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
9663 [NF90\_INQ\_LIBVERS,
9664 example](#index-NF90_005fINQ_005fLIBVERS_002c-example)
9666 [2.4 Get netCDF library version:
9667 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
9669 [NF90\_INQ\_NCID](#index-NF90_005fINQ_005fNCID)
9671 [3.1 Find a Group ID: NF90\_INQ\_NCID](#NF90_005fINQ_005fNCID)
9673 [NF90\_INQ\_OPAQUE](#index-NF90_005fINQ_005fOPAQUE)
9675 [5.8.2 Learn About an Opaque Type:
9676 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
9678 [NF90\_INQ\_TYPE](#index-NF90_005fINQ_005fTYPE)
9680 [5.4 Learn About a User Defined Type:
9681 NF90\_INQ\_TYPE](#NF90_005fINQ_005fTYPE)
9683 [nf90\_inq\_typeid](#index-nf90_005finq_005ftypeid)
9685 [5.3 Find a Typeid from Group and Name:
9686 nf90\_inq\_typeid](#nf90_005finq_005ftypeid)
9688 [NF90\_INQ\_TYPEIDS](#index-NF90_005fINQ_005fTYPEIDS)
9690 [5.2 Learn the IDs of All Types in Group:
9691 NF90\_INQ\_TYPEIDS](#NF90_005fINQ_005fTYPEIDS)
9693 [NF90\_INQ\_USER\_TYPE](#index-NF90_005fINQ_005fUSER_005fTYPE)
9695 [5.5 Learn About a User Defined Type:
9696 NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE)
9698 [NF90\_INQ\_VARID](#index-NF90_005fINQ_005fVARID)
9700 [6.7 Get the ID of a variable from the name:
9701 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
9703 [NF90\_INQ\_VARID, example](#index-NF90_005fINQ_005fVARID_002c-example)
9705 [6.7 Get the ID of a variable from the name:
9706 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
9708 [NF90\_INQ\_VARID, typical
9709 use](#index-NF90_005fINQ_005fVARID_002c-typical-use)
9711 [1.2 Reading a NetCDF Dataset with Known
9712 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9714 [NF90\_INQ\_VARID, typical
9715 use](#index-NF90_005fINQ_005fVARID_002c-typical-use-1)
9717 [1.4 Writing Data in an Existing NetCDF
9718 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9720 [NF90\_INQ\_VARIDS](#index-NF90_005fINQ_005fVARIDS)
9722 [3.3 Find all the Variables in a Group:
9723 NF90\_INQ\_VARIDS](#NF90_005fINQ_005fVARIDS)
9725 [NF90\_INQ\_VAR\_FILL](#index-NF90_005fINQ_005fVAR_005fFILL)
9727 [6.5 Learn About Fill Parameters for a Variable:
9728 `NF90_INQ_VAR_FILL`](#NF90_005fINQ_005fVAR_005fFILL)
9730 [NF90\_INQ\_VLEN](#index-NF90_005fINQ_005fVLEN)
9732 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
9733 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
9735 [NF90\_INSERT\_ARRAY\_COMPOUND](#index-NF90_005fINSERT_005fARRAY_005fCOMPOUND)
9737 [5.6.3 Inserting an Array Field into a Compound Type:
9738 NF90\_INSERT\_ARRAY\_COMPOUND](#NF90_005fINSERT_005fARRAY_005fCOMPOUND)
9740 [NF90\_INSERT\_COMPOUND](#index-NF90_005fINSERT_005fCOMPOUND)
9742 [5.6.2 Inserting a Field into a Compound Type:
9743 NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)
9745 [NF90\_INSERT\_ENUM](#index-NF90_005fINSERT_005fENUM)
9747 [5.9.2 Inserting a Field into a Enum Type:
9748 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)
9750 [NF90\_OPEN](#index-NF90_005fOPEN)
9752 [2.6 NF90\_OPEN](#NF90_005fOPEN)
9754 [NF90\_OPEN , example](#index-NF90_005fOPEN-_002c-example)
9756 [2.6 NF90\_OPEN](#NF90_005fOPEN)
9758 [NF90\_OPEN, typical use](#index-NF90_005fOPEN_002c-typical-use)
9760 [1.2 Reading a NetCDF Dataset with Known
9761 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9763 [NF90\_PUT\_ATT](#index-NF90_005fPUT_005fATT)
9765 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
9767 [NF90\_PUT\_ATT, example](#index-NF90_005fPUT_005fATT_002c-example)
9769 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
9771 [NF90\_PUT\_ATT, typical
9772 use](#index-NF90_005fPUT_005fATT_002c-typical-use)
9774 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9776 [NF90\_PUT\_ATT, typical
9777 use](#index-NF90_005fPUT_005fATT_002c-typical-use-1)
9779 [1.4 Writing Data in an Existing NetCDF
9780 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9782 [NF90\_PUT\_VAR](#index-NF90_005fPUT_005fVAR)
9784 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
9786 [NF90\_PUT\_VAR, example](#index-NF90_005fPUT_005fVAR_002c-example)
9788 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
9790 [NF90\_PUT\_VAR, typical
9791 use](#index-NF90_005fPUT_005fVAR_002c-typical-use)
9793 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9795 [NF90\_PUT\_VAR, typical
9796 use](#index-NF90_005fPUT_005fVAR_002c-typical-use-1)
9798 [1.4 Writing Data in an Existing NetCDF
9799 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9801 [NF90\_PUT\_VLEN\_ELEMENT](#index-NF90_005fPUT_005fVLEN_005fELEMENT)
9803 [5.5.1 Set a Variable Length Array with
9804 NF90\_PUT\_VLEN\_ELEMENT](#NF90_005fPUT_005fVLEN_005fELEMENT)
9806 [NF90\_REDEF](#index-NF90_005fREDEF)
9808 [2.7 NF90\_REDEF](#NF90_005fREDEF)
9810 [NF90\_REDEF , example](#index-NF90_005fREDEF-_002c-example)
9812 [2.7 NF90\_REDEF](#NF90_005fREDEF)
9814 [NF90\_REDEF, typical use](#index-NF90_005fREDEF_002c-typical-use)
9816 [1.5 Adding New Dimensions, Variables,
9817 Attributes](#Adding-New-Dimensions)
9819 [NF90\_RENAME\_ATT](#index-NF90_005fRENAME_005fATT)
9821 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
9824 example](#index-NF90_005fRENAME_005fATT_002c-example)
9826 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
9828 [NF90\_RENAME\_DIM](#index-NF90_005fRENAME_005fDIM)
9830 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
9832 [NF90\_RENAME\_DIM ,
9833 example](#index-NF90_005fRENAME_005fDIM-_002c-example)
9835 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
9837 [NF90\_RENAME\_VAR](#index-NF90_005fRENAME_005fVAR)
9839 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
9841 [NF90\_RENAME\_VAR ,
9842 example](#index-NF90_005fRENAME_005fVAR-_002c-example)
9844 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
9846 [NF90\_SET\_FILL](#index-NF90_005fSET_005fFILL)
9848 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
9850 [NF90\_SET\_FILL , example](#index-NF90_005fSET_005fFILL-_002c-example)
9852 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
9854 [NF90\_STRERROR](#index-NF90_005fSTRERROR)
9856 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
9858 [NF90\_STRERROR, example](#index-NF90_005fSTRERROR_002c-example)
9860 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
9863 introduction](#index-NF90_005fSTRERROR_002c-introduction)
9865 [1.6 Error Handling](#Error-Handling)
9867 [NF90\_SYNC](#index-NF90_005fSYNC)
9869 [2.11 NF90\_SYNC](#NF90_005fSYNC)
9871 [NF90\_SYNC , example](#index-NF90_005fSYNC-_002c-example)
9873 [2.11 NF90\_SYNC](#NF90_005fSYNC)
9875 [NF90\_VAR\_PAR\_ACCESS](#index-NF90_005fVAR_005fPAR_005fACCESS)
9877 [6.13 Change between Collective and Independent Parallel Access:
9878 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
9880 [NF90\_VAR\_PAR\_ACCESS,
9881 example](#index-NF90_005fVAR_005fPAR_005fACCESS_002c-example)
9883 [6.13 Change between Collective and Independent Parallel Access:
9884 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
9886 ------------------------------------------------------------------------
9890 [opaque type](#index-opaque-type)
9892 [5.8 Opaque Type Introduction](#Opaque-Type)
9894 ------------------------------------------------------------------------
9898 [reading dataset with unknown
9899 names](#index-reading-dataset-with-unknown-names)
9901 [1.3 Reading a netCDF Dataset with Unknown
9902 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9904 ------------------------------------------------------------------------
9908 [user defined types](#index-user-defined-types)
9910 [5. User Defined Data Types](#User-Defined-Data-Types)
9912 [user defined types, overview](#index-user-defined-types_002c-overview)
9914 [5.1 User Defined Types Introduction](#User-Defined-Types)
9916 [users’ guide, netcdf](#index-users_0027-guide_002c-netcdf)
9918 [1. Use of the NetCDF Library](#Use-of-the-NetCDF-Library)
9920 ------------------------------------------------------------------------
9924 [variable length array type,
9925 overview](#index-variable-length-array-type_002c-overview)
9927 [5. User Defined Data Types](#User-Defined-Data-Types)
9929 [variable length arrays](#index-variable-length-arrays)
9931 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
9933 [variables, adding](#index-variables_002c-adding)
9935 [1.5 Adding New Dimensions, Variables,
9936 Attributes](#Adding-New-Dimensions)
9938 [variables, fill](#index-variables_002c-fill)
9940 [6.4 Define Fill Parameters for a Variable:
9941 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9945 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
9947 [VLEN, defining](#index-VLEN_002c-defining)
9949 [5.7.1 Define a Variable Length Array (VLEN):
9950 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
9952 [VLEN, defining](#index-VLEN_002c-defining-1)
9954 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
9955 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
9957 [VLEN, defining](#index-VLEN_002c-defining-2)
9959 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
9960 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
9962 ------------------------------------------------------------------------
9966 [writing to existing dataset](#index-writing-to-existing-dataset)
9968 [1.4 Writing Data in an Existing NetCDF
9969 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9971 ------------------------------------------------------------------------
9973 ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9974 Jump to: [**A**](#Index_cp_letter-A) [**C**](#Index_cp_letter-C) [**D**](#Index_cp_letter-D) [**E**](#Index_cp_letter-E) [**F**](#Index_cp_letter-F) [**G**](#Index_cp_letter-G) [**I**](#Index_cp_letter-I) [**L**](#Index_cp_letter-L) [**N**](#Index_cp_letter-N) [**O**](#Index_cp_letter-O) [**R**](#Index_cp_letter-R) [**U**](#Index_cp_letter-U) [**V**](#Index_cp_letter-V) [**W**](#Index_cp_letter-W)
9975 ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9977 ------------------------------------------------------------------------
9979 ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9980 \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9981 ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9986 This document was generated by *Ward Fisher* on *July 14, 2015* using
9987 [*texi2html 1.82*](http://www.nongnu.org/texi2html/).
9989 The buttons in the navigation panels have the following meaning:
9991 Button Name Go to From 1.2.3 go to
9992 ---------------- ------------- ----------------------------------------------- ------------------
9993 \[ < \] Back Previous section in reading order 1.2.2
9994 \[ > \] Forward Next section in reading order 1.2.4
9995 \[ << \] FastBack Beginning of this chapter or previous chapter 1
9996 \[ Up \] Up Up section 1.2
9997 \[ >> \] FastForward Next chapter 2
9998 \[Top\] Top Cover (top) of document
9999 \[Contents\] Contents Table of contents
10000 \[Index\] Index Index
10001 \[ ? \] About About (help)
10003 where the **Example** assumes that the current position is at
10004 **Subsubsection One-Two-Three** of a document of the following
10008 - 1.1 Subsection One-One
10010 - 1.2 Subsection One-Two
10011 - 1.2.1 Subsubsection One-Two-One
10012 - 1.2.2 Subsubsection One-Two-Two
10013 - 1.2.3 Subsubsection One-Two-Three **<== Current
10015 - 1.2.4 Subsubsection One-Two-Four
10016 - 1.3 Subsection One-Three
10018 - 1.4 Subsection One-Four
10020 ------------------------------------------------------------------------
10022 This document was generated by *Ward Fisher* on *July 14, 2015* using
10023 [*texi2html 1.82*](http://www.nongnu.org/texi2html/).\