NetCDF-Fortran  4.4.3
netcdf-f90.md
1 The NetCDF Fortran 90 Interface Guide {#nc_f90_interface_guide}
2 =====================================
3 
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.
7 
8 For a complete description of the netCDF format and utilities see the netCDF User's Guide.
9 
10  
11 
12 ``` {.menu-comment}
13  — The Detailed Node Listing —
14 
15 Use of the NetCDF Library
16 ```
17 
18 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
19 
20   
21 
22 [1.2 Reading a NetCDF Dataset with Known
23 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
24 
25   
26 
27 [1.3 Reading a netCDF Dataset with Unknown
28 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
29 
30   
31 
32 [1.4 Writing Data in an Existing NetCDF
33 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
34 
35   
36 
37 [1.5 Adding New Dimensions, Variables,
38 Attributes](#Adding-New-Dimensions)
39 
40   
41 
42 [1.6 Error Handling](#Error-Handling)
43 
44   
45 
46 [1.7 Compiling and Linking with the NetCDF
47 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
48 
49   
50 
51 ``` {.menu-comment}
52 Datasets
53 ```
54 
55 [2.1 Datasets Introduction](#Datasets-Introduction)
56 
57   
58 
59 [2.2 NetCDF Library Interface
60 Descriptions](#NetCDF-Library-Interface-Descriptions)
61 
62   
63 
64 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
65 
66   
67 
68 [2.4 Get netCDF library version:
69 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
70 
71   
72 
73 [2.5 NF90\_CREATE](#NF90_005fCREATE)
74 
75   
76 
77 [2.6 NF90\_OPEN](#NF90_005fOPEN)
78 
79   
80 
81 [2.7 NF90\_REDEF](#NF90_005fREDEF)
82 
83   
84 
85 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
86 
87   
88 
89 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
90 
91   
92 
93 [2.10 NF90\_INQUIRE Family](#NF90_005fINQUIRE-Family)
94 
95   
96 
97 [2.11 NF90\_SYNC](#NF90_005fSYNC)
98 
99   
100 
101 [2.12 NF90\_ABORT](#NF90_005fABORT)
102 
103   
104 
105 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
106 
107   
108 
109 ``` {.menu-comment}
110 Groups
111 ```
112 
113 [3.1 Find a Group ID: NF90\_INQ\_NCID](#NF90_005fINQ_005fNCID)
114 
115   
116 
117 [3.2 Get a List of Groups in a Group:
118 NF90\_INQ\_GRPS](#NF90_005fINQ_005fGRPS)
119 
120   
121 
122 [3.3 Find all the Variables in a Group:
123 NF90\_INQ\_VARIDS](#NF90_005fINQ_005fVARIDS)
124 
125   
126 
127 [3.4 Find all Dimensions Visible in a Group:
128 NF90\_INQ\_DIMIDS](#NF90_005fINQ_005fDIMIDS)
129 
130   
131 
132 [3.5 Find the Length of a Group’s Full Name:
133 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN)
134 
135   
136 
137 [3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME](#NF90_005fINQ_005fGRPNAME)
138 
139   
140 
141 [3.7 Find a Group’s Full Name:
142 NF90\_INQ\_GRPNAME\_FULL](#NF90_005fINQ_005fGRPNAME_005fFULL)
143 
144   
145 
146 [3.8 Find a Group’s Parent:
147 NF90\_INQ\_GRP\_PARENT](#NF90_005fINQ_005fGRP_005fPARENT)
148 
149   
150 
151 [3.9 Find a Group by Name:
152 NF90\_INQ\_GRP\_NCID](#NF90_005fINQ_005fGRP_005fNCID)
153 
154   
155 
156 [3.10 Find a Group by its Fully-qualified Name:
157 NF90\_INQ\_GRP\_FULL\_NCID](#NF90_005fINQ_005fGRP_005fFULL_005fNCID)
158 
159   
160 
161 [3.11 Create a New Group: NF90\_DEF\_GRP](#NF90_005fDEF_005fGRP)
162 
163   
164 
165 ``` {.menu-comment}
166 Dimensions
167 ```
168 
169 [4.1 Dimensions Introduction](#Dimensions-Introduction)
170 
171   
172 
173 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
174 
175   
176 
177 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
178 
179   
180 
181 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
182 
183   
184 
185 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
186 
187   
188 
189 ``` {.menu-comment}
190 User Defined Data Types
191 ```
192 
193 [5.1 User Defined Types Introduction](#User-Defined-Types)
194 
195   
196 
197 [5.2 Learn the IDs of All Types in Group:
198 NF90\_INQ\_TYPEIDS](#NF90_005fINQ_005fTYPEIDS)
199 
200   
201 
202 [5.3 Find a Typeid from Group and Name:
203 nf90\_inq\_typeid](#nf90_005finq_005ftypeid)
204 
205   
206 
207 [5.4 Learn About a User Defined Type:
208 NF90\_INQ\_TYPE](#NF90_005fINQ_005fTYPE)
209 
210   
211 
212 [5.5 Learn About a User Defined Type:
213 NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE)
214 
215   
216 
217 [5.6 Compound Types Introduction](#Compound-Types)
218 
219   
220 
221 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
222 
223   
224 
225 [5.8 Opaque Type Introduction](#Opaque-Type)
226 
227   
228 
229 [5.9 Enum Type Introduction](#Enum-Type)
230 
231   
232 
233 ``` {.menu-comment}
234 Example
235 ```
236 
237 [5.5.1 Set a Variable Length Array with
238 NF90\_PUT\_VLEN\_ELEMENT](#NF90_005fPUT_005fVLEN_005fELEMENT)
239 
240   
241 
242 [5.5.2 Set a Variable Length Array with
243 NF90\_GET\_VLEN\_ELEMENT](#NF90_005fGET_005fVLEN_005fELEMENT)
244 
245   
246 
247 ``` {.menu-comment}
248 Compound Types Introduction
249 ```
250 
251 [5.6.1 Creating a Compound Type:
252 NF90\_DEF\_COMPOUND](#NF90_005fDEF_005fCOMPOUND)
253 
254   
255 
256 [5.6.2 Inserting a Field into a Compound Type:
257 NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)
258 
259   
260 
261 [5.6.3 Inserting an Array Field into a Compound Type:
262 NF90\_INSERT\_ARRAY\_COMPOUND](#NF90_005fINSERT_005fARRAY_005fCOMPOUND)
263 
264   
265 
266 [5.6.4 Learn About a Compound Type:
267 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
268 
269   
270 
271 [5.6.5 Learn About a Field of a Compound Type:
272 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
273 
274   
275 
276 ``` {.menu-comment}
277 Variable Length Array Introduction
278 ```
279 
280 [5.7.1 Define a Variable Length Array (VLEN):
281 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
282 
283   
284 
285 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
286 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
287 
288   
289 
290 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
291 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
292 
293   
294 
295 ``` {.menu-comment}
296 Opaque Type Introduction
297 ```
298 
299 [5.8.1 Creating Opaque Types:
300 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE)
301 
302   
303 
304 [5.8.2 Learn About an Opaque Type:
305 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
306 
307   
308 
309 ``` {.menu-comment}
310 Example
311 ```
312 
313 [5.8.2 Learn About an Opaque Type:
314 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
315 
316   
317 
318 ``` {.menu-comment}
319 Enum Type Introduction
320 ```
321 
322 [5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM](#NF90_005fDEF_005fENUM)
323 
324   
325 
326 [5.9.2 Inserting a Field into a Enum Type:
327 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)
328 
329   
330 
331 [5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM](#NF90_005fINQ_005fENUM)
332 
333   
334 
335 [5.9.4 Learn the Name of a Enum Type:
336 nf90\_inq\_enum\_member](#NF90_005fINQ_005fENUM_005fMEMBER)
337 
338   
339 
340 [5.9.5 Learn the Name of a Enum Type:
341 NF90\_INQ\_ENUM\_IDENT](#NF90_005fINQ_005fENUM_005fIDENT)
342 
343   
344 
345 ``` {.menu-comment}
346 Variables
347 ```
348 
349 [6.1 Variables Introduction](#Variables-Introduction)
350 
351   
352 
353 [6.2 Language Types Corresponding to netCDF external data
354 types](#Language_002dTypes)
355 
356   
357 
358 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
359 
360   
361 
362 Create a Variable
363 
364 [6.4 Define Fill Parameters for a Variable:
365 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
366 
367   
368 
369 [6.5 Learn About Fill Parameters for a Variable:
370 `NF90_INQ_VAR_FILL`](#NF90_005fINQ_005fVAR_005fFILL)
371 
372   
373 
374 [6.6 Get Information about a Variable from Its ID:
375 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
376 
377   
378 
379 Get Var Metadata
380 
381 [6.7 Get the ID of a variable from the name:
382 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
383 
384   
385 
386 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
387 
388   
389 
390 Write data
391 
392 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
393 
394   
395 
396 Read data
397 
398 [6.10 Reading and Writing Character String
399 Values](#Reading-and-Writing-Character-String-Values)
400 
401   
402 
403 [6.11 Fill Values](#Fill-Values)
404 
405   
406 
407 What’s Written Where there’s No Data?
408 
409 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
410 
411   
412 
413 [6.13 Change between Collective and Independent Parallel Access:
414 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
415 
416   
417 
418 ``` {.menu-comment}
419 Attributes
420 ```
421 
422 [7.1 Attributes Introduction](#Attributes-Introduction)
423 
424   
425 
426 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
427 
428   
429 
430 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
431 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
432 
433   
434 
435 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
436 
437   
438 
439 [7.5 Copy Attribute from One NetCDF to Another:
440 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
441 
442   
443 
444 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
445 
446   
447 
448 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
449 
450   
451 
452 ``` {.menu-comment}
453 ```
454 
455 ------------------------------------------------------------------------
456 
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  ------------------------------------------------------ ------------------------------------------------------------------------ --- ---------------------------------------------------------------------- ----------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
460 
461 1. Use of the NetCDF Library {.chapter}
462 ============================
463 
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.
476 
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.
484 
485  ------------------------ ------------------------ ------------------------
486  [1.1 Creating a NetCDF   
487  Dataset](#Creating-a-Net
488  CDF-Dataset)
489 
490  [1.2 Reading a NetCDF   
491  Dataset with Known
492  Names](#Reading-a-NetCDF
493  -Dataset-with-Known-Name
494  s)
495 
496  [1.3 Reading a netCDF   
497  Dataset with Unknown
498  Names](#Reading-a-netCDF
499  -Dataset-with-Unknown-Na
500  mes)
501 
502  [1.4 Writing Data in an   
503  Existing NetCDF
504  Dataset](#Writing-Data-i
505  n-an-Existing-NetCDF-Dat
506  aset)
507 
508  [1.5 Adding New   
509  Dimensions, Variables,
510  Attributes](#Adding-New-
511  Dimensions)
512 
513  [1.6 Error   
514  Handling](#Error-Handlin
515  g)
516 
517  [1.7 Compiling and   
518  Linking with the NetCDF
519  Library](#Compiling-and-
520  Linking-with-the-NetCDF-
521  Library)
522  ------------------------ ------------------------ ------------------------
523 
524 ------------------------------------------------------------------------
525 
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  ---------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
529 
530 1.1 Creating a NetCDF Dataset {.section}
531 -----------------------------
532 
533 Here is a typical sequence of netCDF calls used to create a new netCDF
534 dataset:
535 
536 +--------------------------------------+--------------------------------------+
537 |   | ``` {.example} |
538 | | NF90_CREATE ! create |
539 | | netCDF dataset: enter define mode |
540 | | ... |
541 | | NF90_DEF_DIM ! define |
542 | | dimensions: from name and length |
543 | | ... |
544 | | NF90_DEF_VAR ! define |
545 | | variables: from name, type, dims |
546 | | ... |
547 | | NF90_PUT_ATT ! assign |
548 | | attribute values |
549 | | ... |
550 | | NF90_ENDDEF ! end def |
551 | | initions: leave define mode |
552 | | ... |
553 | | NF90_PUT_VAR ! provide |
554 | | values for variable |
555 | | ... |
556 | | NF90_CLOSE ! close: |
557 | | save new netCDF dataset |
558 | | ``` |
559 +--------------------------------------+--------------------------------------+
560 
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.
568 
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.
574 
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.)
583 
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.
592 
593 ------------------------------------------------------------------------
594 
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  ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
598 
599 1.2 Reading a NetCDF Dataset with Known Names {.section}
600 ---------------------------------------------
601 
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
606 is:
607 
608 +--------------------------------------+--------------------------------------+
609 |   | ``` {.example} |
610 | | NF90_OPEN ! open |
611 | | existing netCDF dataset |
612 | | ... |
613 | | NF90_INQ_DIMID ! get d |
614 | | imension IDs |
615 | | ... |
616 | | NF90_INQ_VARID ! get v |
617 | | ariable IDs |
618 | | ... |
619 | | NF90_GET_ATT ! get a |
620 | | ttribute values |
621 | | ... |
622 | | NF90_GET_VAR ! get v |
623 | | alues of variables |
624 | | ... |
625 | | NF90_CLOSE ! close |
626 | | netCDF dataset |
627 | | ``` |
628 +--------------------------------------+--------------------------------------+
629 
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.
633 
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
641 NF90\_GET\_VAR.
642 
643 Finally, the netCDF dataset is closed with NF90\_CLOSE. There is no need
644 to close a dataset open only for reading.
645 
646 ------------------------------------------------------------------------
647 
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  -------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
651 
652 1.3 Reading a netCDF Dataset with Unknown Names {.section}
653 -----------------------------------------------
654 
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.
659 
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:
664 
665 +--------------------------------------+--------------------------------------+
666 |   | ``` {.example} |
667 | | NF90_OPEN ! ope |
668 | | n existing netCDF dataset |
669 | | ... |
670 | | NF90_INQUIRE ! fin |
671 | | d out what is in it |
672 | | ... |
673 | | NF90_INQUIRE_DIMENSION ! get |
674 | | dimension names, lengths |
675 | | ... |
676 | | NF90_INQUIRE_VARIABLE ! get |
677 | | variable names, types, shapes |
678 | | ... |
679 | | NF90_INQ_ATTNAME ! get |
680 | | attribute names |
681 | | ... |
682 | | NF90_INQUIRE_ATTRIBUTE ! |
683 | | get other attribute information |
684 | | ... |
685 | | NF90_GET_ATT ! get |
686 | | attribute values |
687 | | ... |
688 | | NF90_GET_VAR ! get |
689 | | values of variables |
690 | | ... |
691 | | NF90_CLOSE ! clo |
692 | | se netCDF dataset |
693 | | ``` |
694 +--------------------------------------+--------------------------------------+
695 
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.
701 
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.
705 
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.
712 
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.
717 
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
724 values.
725 
726 Once the IDs and shapes of netCDF variables are known, data values can
727 be accessed by calling NF90\_GET\_VAR.
728 
729 ------------------------------------------------------------------------
730 
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  ---------------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
734 
735 1.4 Writing Data in an Existing NetCDF Dataset {.section}
736 ----------------------------------------------
737 
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.
748 
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:
752 
753 +--------------------------------------+--------------------------------------+
754 |   | ``` {.example} |
755 | | NF90_OPEN ! open ex |
756 | | isting netCDF dataset |
757 | | ... |
758 | | NF90_INQ_VARID ! get var |
759 | | iable IDs |
760 | | ... |
761 | | NF90_PUT_VAR ! provide |
762 | | new values for variables, if any |
763 | | ... |
764 | | NF90_PUT_ATT ! provide |
765 | | new values for attributes, if any |
766 | | ... |
767 | | NF90_CLOSE ! close n |
768 | | etCDF dataset |
769 | | ``` |
770 +--------------------------------------+--------------------------------------+
771 
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.
776 
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).
789 
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.
793 
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.
797 
798 ------------------------------------------------------------------------
799 
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  --------------------------------------------------------------------------------------------- ------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
803 
804 1.5 Adding New Dimensions, Variables, Attributes {.section}
805 ------------------------------------------------
806 
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:
812 
813 +--------------------------------------+--------------------------------------+
814 |   | ``` {.example} |
815 | | NF90_OPEN ! open ex |
816 | | isting netCDF dataset |
817 | | ... |
818 | | NF90_REDEF ! put it |
819 | | into define mode |
820 | | ... |
821 | | NF90_DEF_DIM ! define |
822 | | additional dimensions (if any) |
823 | | ... |
824 | | NF90_DEF_VAR ! define |
825 | | additional variables (if any) |
826 | | ... |
827 | | NF90_PUT_ATT ! define |
828 | | other attributes (if any) |
829 | | ... |
830 | | NF90_ENDDEF ! check d |
831 | | efinitions, leave define mode |
832 | | ... |
833 | | NF90_PUT_VAR ! provide |
834 | | new variable values |
835 | | ... |
836 | | NF90_CLOSE ! close n |
837 | | etCDF dataset |
838 | | ``` |
839 +--------------------------------------+--------------------------------------+
840 
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.
849 
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.
854 
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).
863 
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.
872 
873 ------------------------------------------------------------------------
874 
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  ------------------------------------------------------------------------ -------------------------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
878 
879 1.6 Error Handling {.section}
880 ------------------
881 
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.
889 
890 The NF90\_STRERROR function is available to convert a returned integer
891 error status into an error message string.
892 
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
898 value.
899 
900 ------------------------------------------------------------------------
901 
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  ----------------------------------------------------------------- ------------------------------------------------------- --- -------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
905 
906 1.7 Compiling and Linking with the NetCDF Library {.section}
907 -------------------------------------------------
908 
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.
915 
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
919 sometimes “mod”).
920 
921 Most F90 compilers allow the user to specify the location of .MOD files,
922 usually with the -I flag.
923 
924 +--------------------------------------+--------------------------------------+
925 |   | ``` {.example} |
926 | | f90 -c -I/usr/local/include mymodule |
927 | | .f90 |
928 | | ``` |
929 +--------------------------------------+--------------------------------------+
930 
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.
940 
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.
946 
947 If installed as a shared library, link, using something like:
948 
949 +--------------------------------------+--------------------------------------+
950 |   | ``` {.example} |
951 | | f90 -o myprogram myprogram.o -L/usr/ |
952 | | local/lib -lnetcdff |
953 | | ``` |
954 +--------------------------------------+--------------------------------------+
955 
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:
959 
960 +--------------------------------------+--------------------------------------+
961 |   | ``` {.example} |
962 | | f90 -o myprogram myprogram.o -L/usr/ |
963 | | local/lib -lnetcdff -lnetcdf |
964 | | ``` |
965 +--------------------------------------+--------------------------------------+
966 
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.
971 
972 To see all the options for ‘nf-config’, invoke it with the ‘–help’
973 argument.
974 
975 Here’s an example of how you could use ‘nf-config’ to compile and link a
976 Fortran program in one step:
977 
978 +--------------------------------------+--------------------------------------+
979 |   | ``` {.example} |
980 | | f90 myprogram.f90 -o myprogram `nf-c |
981 | | onfig --fflags --flibs` |
982 | | ``` |
983 +--------------------------------------+--------------------------------------+
984 
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
990 pkg-config:
991 
992 +--------------------------------------+--------------------------------------+
993 |   | ``` {.example} |
994 | | export PKG_CONFIG_PATH=/usr/local/li |
995 | | b/pkgconfig |
996 | | f90 myprogram.f90 -o myprogram `pkg- |
997 | | config --cflags --libs netcdf-fortra |
998 | | n` |
999 | | ``` |
1000 +--------------------------------------+--------------------------------------+
1001 
1002 where here ‘–cflags’ means compiler flags and ‘libs’ requests that the
1003 approriate libraries be linked in.
1004 
1005 ------------------------------------------------------------------------
1006 
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  ------------------------------------------------------------------------------------------------ -------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------- ----------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1010 
1011 2. Datasets {.chapter}
1012 ===========
1013 
1014  ------------------------ ------------------------ ------------------------
1015  [2.1 Datasets   
1016  Introduction](#Datasets-
1017  Introduction)
1018 
1019  [2.2 NetCDF Library   
1020  Interface
1021  Descriptions](#NetCDF-Li
1022  brary-Interface-Descript
1023  ions)
1024 
1025  [2.3   
1026  NF90\_STRERROR](#NF90_00
1027  5fSTRERROR)
1028 
1029  [2.4 Get netCDF library   
1030  version:
1031  NF90\_INQ\_LIBVERS](#NF9
1032  0_005fINQ_005fLIBVERS)
1033 
1034  [2.5   
1035  NF90\_CREATE](#NF90_005f
1036  CREATE)
1037 
1038  [2.6   
1039  NF90\_OPEN](#NF90_005fOP
1040  EN)
1041 
1042  [2.7   
1043  NF90\_REDEF](#NF90_005fR
1044  EDEF)
1045 
1046  [2.8   
1047  NF90\_ENDDEF](#NF90_005f
1048  ENDDEF)
1049 
1050  [2.9   
1051  NF90\_CLOSE](#NF90_005fC
1052  LOSE)
1053 
1054  [2.10 NF90\_INQUIRE   
1055  Family](#NF90_005fINQUIR
1056  E-Family)
1057 
1058  [2.11   
1059  NF90\_SYNC](#NF90_005fSY
1060  NC)
1061 
1062  [2.12   
1063  NF90\_ABORT](#NF90_005fA
1064  BORT)
1065 
1066  [2.13   
1067  NF90\_SET\_FILL](#NF90_0
1068  05fSET_005fFILL)
1069  ------------------------ ------------------------ ------------------------
1070 
1071 ------------------------------------------------------------------------
1072 
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  ----------------------------------------------------------- ------------------------------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1076 
1077 2.1 Datasets Introduction {.section}
1078 -------------------------
1079 
1080 This chapter presents the interfaces of the netCDF functions that deal
1081 with a netCDF dataset or the whole netCDF library.
1082 
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.
1093 
1094 Functions that deal with the netCDF library include:
1095 
1096 - Get version of library.
1097 - Get error message corresponding to a returned error code.
1098 
1099 The operations supported on a netCDF dataset as a single object are:
1100 
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.
1113 
1114 ------------------------------------------------------------------------
1115 
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  ------------------------------------------------------------------------ ---------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1119 
1120 2.2 NetCDF Library Interface Descriptions {.section}
1121 -----------------------------------------
1122 
1123 Each interface description for a particular netCDF function in this and
1124 later chapters contains:
1125 
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).
1133 
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".
1139 
1140 ------------------------------------------------------------------------
1141 
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  ---------------------------------------------------------------------------------------- ----------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1145 
1146 2.3 NF90\_STRERROR {.section}
1147 ------------------
1148 
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.
1154 
1155 Usage {.heading}
1156 -----
1157 
1158 +--------------------------------------+--------------------------------------+
1159 |   | ``` {.example} |
1160 | | function nf90_strerror(ncerr) |
1161 | | integer, intent( in) :: ncerr |
1162 | | character(len = 80) :: nf90_stre |
1163 | | rror |
1164 | | ``` |
1165 +--------------------------------------+--------------------------------------+
1166 
1167  `NCERR`
1168 
1169 : An error status that might have been returned from a previous call
1170  to some netCDF function.
1171 
1172 Errors {.heading}
1173 ------
1174 
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.
1179 
1180 Example {.heading}
1181 -------
1182 
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:
1186 
1187 +--------------------------------------+--------------------------------------+
1188 |   | ``` {.example} |
1189 | | subroutine handle_err(status) |
1190 | | integer, intent ( in) :: status |
1191 | | |
1192 | | if(status /= nf90_noerr) then |
1193 | | print *, trim(nf90_strerror(sta |
1194 | | tus)) |
1195 | | stop "Stopped" |
1196 | | end if |
1197 | | end subroutine handle_err |
1198 | | ``` |
1199 +--------------------------------------+--------------------------------------+
1200 
1201 ------------------------------------------------------------------------
1202 
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  -------------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1206 
1207 2.4 Get netCDF library version: NF90\_INQ\_LIBVERS {.section}
1208 --------------------------------------------------
1209 
1210 The function NF90\_INQ\_LIBVERS returns a string identifying the version
1211 of the netCDF library, and when it was built.
1212 
1213 Usage {.heading}
1214 -----
1215 
1216 +--------------------------------------+--------------------------------------+
1217 |   | ``` {.example} |
1218 | | function nf90_inq_libvers() |
1219 | | character(len = 80) :: nf90_inq_l |
1220 | | ibvers |
1221 | | ``` |
1222 +--------------------------------------+--------------------------------------+
1223 
1224 Errors {.heading}
1225 ------
1226 
1227 This function takes no arguments, and returns no error status.
1228 
1229 Example {.heading}
1230 -------
1231 
1232 Here is an example using nf90\_inq\_libvers to print the version of the
1233 netCDF library with which the program is linked:
1234 
1235 +--------------------------------------+--------------------------------------+
1236 |   | ``` {.example} |
1237 | | print *, trim(nf90_inq_libvers()) |
1238 | | ``` |
1239 +--------------------------------------+--------------------------------------+
1240 
1241 ------------------------------------------------------------------------
1242 
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  --------------------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1246 
1247 2.5 NF90\_CREATE {.section}
1248 ----------------
1249 
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
1254 attributes.
1255 
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.
1258 
1259 Usage {.heading}
1260 -----
1261 
1262 +--------------------------------------+--------------------------------------+
1263 |   | ``` {.example} |
1264 | | function nf90_create(path, cmode, |
1265 | | ncid, initialsize, bufrsize, cache_s |
1266 | | ize, & |
1267 | | cache_nelems, cache_preemptio |
1268 | | n, comm, info) |
1269 | | implicit none |
1270 | | character (len = *), intent(in) |
1271 | | :: path |
1272 | | integer, intent(in) :: cmode |
1273 | | integer, intent(out) :: ncid |
1274 | | integer, optional, intent(in) :: |
1275 | | initialsize |
1276 | | integer, optional, intent(inout) |
1277 | | :: bufrsize |
1278 | | integer, optional, intent(in) :: |
1279 | | cache_size, cache_nelems |
1280 | | real, optional, intent(in) :: ca |
1281 | | che_preemption |
1282 | | integer, optional, intent(in) :: |
1283 | | comm, info |
1284 | | integer :: nf90_create |
1285 | | ``` |
1286 +--------------------------------------+--------------------------------------+
1287 
1288  `path`
1289 
1290 : The file name of the new netCDF dataset.
1291 
1292  `cmode`
1293 
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).
1298 
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.
1305 
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.
1309 
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.)
1317 
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.
1324 
1325  Setting the NF90\_NETCDF4 flag causes netCDF to create a
1326  netCDF-4/HDF5 format output file.
1327 
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.
1332 
1333  `ncid`
1334 
1335 : Returned netCDF ID.
1336 
1337 The following optional arguments allow additional performance tuning.
1338 
1339  `initialsize`
1340 
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.
1344 
1345  `bufrsize`
1346 
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.
1351 
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.
1358 
1359  The bufrsize is a property of a given open netcdf descriptor ncid,
1360  it is not a persistent property of the netcdf dataset.
1361 
1362  This is ignored for NetCDF-4/HDF5 files.
1363 
1364  `cache_size`
1365 
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.
1369 
1370  `cache_nelems`
1371 
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.
1375 
1376  `cache_premtion`
1377 
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.
1381 
1382  `comm`
1383 
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.
1388 
1389  `info`
1390 
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.
1395 
1396 Errors {.heading}
1397 ------
1398 
1399 NF90\_CREATE returns the value NF90\_NOERR if no errors occurred.
1400 Possible causes of errors include:
1401 
1402 - Passing a dataset name that includes a directory that does
1403  not exist.
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.
1409 
1410 Example {.heading}
1411 -------
1412 
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:
1416 
1417 +--------------------------------------+--------------------------------------+
1418 |   | ``` {.example} |
1419 | | use netcdf |
1420 | | implicit none |
1421 | | integer :: ncid, status |
1422 | | ... |
1423 | | status = nf90_create(path = "foo.nc |
1424 | | ", cmode = nf90_noclobber, ncid = nc |
1425 | | id) |
1426 | | if (status /= nf90_noerr) call hand |
1427 | | le_err(status) |
1428 | | ``` |
1429 +--------------------------------------+--------------------------------------+
1430 
1431 ------------------------------------------------------------------------
1432 
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  ------------------------------------------------------------------ ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1436 
1437 2.6 NF90\_OPEN {.section}
1438 --------------
1439 
1440 The function NF90\_OPEN opens an existing netCDF dataset for access.
1441 
1442 Usage {.heading}
1443 -----
1444 
1445 +--------------------------------------+--------------------------------------+
1446 |   | ``` {.example} |
1447 | | function nf90_open(path, mode, nci |
1448 | | d, bufrsize, cache_size, cache_nelem |
1449 | | s, & |
1450 | | cache_preemptio |
1451 | | n, comm, info) |
1452 | | implicit none |
1453 | | character (len = *), intent(in) |
1454 | | :: path |
1455 | | integer, intent(in) :: mode |
1456 | | integer, intent(out) :: ncid |
1457 | | integer, optional, intent(inout) |
1458 | | :: bufrsize |
1459 | | integer, optional, intent(in) :: |
1460 | | cache_size, cache_nelems |
1461 | | real, optional, intent(in) :: ca |
1462 | | che_preemption |
1463 | | integer, optional, intent(in) :: |
1464 | | comm, info |
1465 | | integer :: nf90_open |
1466 | | ``` |
1467 +--------------------------------------+--------------------------------------+
1468 
1469  `path`
1470 
1471 : File name for netCDF dataset to be opened. This may be an OPeNDAP
1472  URL if DAP support is enabled.
1473 
1474  `mode`
1475 
1476 : A zero value (or NF90\_NOWRITE) specifies: open the dataset with
1477  read-only access, buffering and caching accesses for efficiency
1478 
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.
1491 
1492  `ncid`
1493 
1494 : Returned netCDF ID.
1495 
1496 The following optional argument allows additional performance tuning.
1497 
1498  `bufrsize`
1499 
1500 : This parameter applies only when opening classic format or 64-bit
1501  offset files. It is ignored for netCDF-4/HDF5 files.
1502 
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.
1507 
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.
1514 
1515  The bufrsize is a property of a given open netcdf descriptor ncid,
1516  it is not a persistent property of the netcdf dataset.
1517 
1518  `cache_size`
1519 
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.
1523 
1524  `cache_nelems`
1525 
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.
1529 
1530  `cache_premtion`
1531 
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.
1535 
1536  `comm`
1537 
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.
1542 
1543  `info`
1544 
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.
1549 
1550 Errors {.heading}
1551 ------
1552 
1553 NF90\_OPEN returns the value NF90\_NOERR if no errors occurred.
1554 Otherwise, the returned status indicates an error. Possible causes of
1555 errors include:
1556 
1557 - The specified netCDF dataset does not exist.
1558 - A meaningless mode was specified.
1559 
1560 Example {.heading}
1561 -------
1562 
1563 Here is an example using NF90\_OPEN to open an existing netCDF dataset
1564 named foo.nc for read-only, non-shared access:
1565 
1566 +--------------------------------------+--------------------------------------+
1567 |   | ``` {.example} |
1568 | | use netcdf |
1569 | | implicit none |
1570 | | integer :: ncid, status |
1571 | | ... |
1572 | | status = nf90_open(path = "foo.nc", |
1573 | | mode = nf90_nowrite, ncid = ncid) |
1574 | | if (status /= nf90_noerr) call hand |
1575 | | le_err(status) |
1576 | | ``` |
1577 +--------------------------------------+--------------------------------------+
1578 
1579 Example {.heading}
1580 -------
1581 
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.
1585 
1586 +--------------------------------------+--------------------------------------+
1587 |   | ``` {.example} |
1588 | | use netcdf |
1589 | | implicit none |
1590 | | integer :: ncid, status |
1591 | | ... |
1592 | | ! Reopen the file. |
1593 | | call handle_err(nf90_open(FILE_NAM |
1594 | | E, nf90_nowrite, ncid, comm = MPI_CO |
1595 | | MM_WORLD, & |
1596 | | info = MPI_INFO_NULL)) |
1597 | | ``` |
1598 +--------------------------------------+--------------------------------------+
1599 
1600 ------------------------------------------------------------------------
1601 
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  ---------------------------------------------------------------- -------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1605 
1606 2.7 NF90\_REDEF {.section}
1607 ---------------
1608 
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.
1612 
1613 Usage {.heading}
1614 -----
1615 
1616 +--------------------------------------+--------------------------------------+
1617 |   | ``` {.example} |
1618 | | function nf90_redef(ncid) |
1619 | | integer, intent( in) :: ncid |
1620 | | integer :: nf90_rede |
1621 | | f |
1622 | | ``` |
1623 +--------------------------------------+--------------------------------------+
1624 
1625  `ncid`
1626 
1627 : netCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1628 
1629 Errors {.heading}
1630 ------
1631 
1632 NF90\_REDEF returns the value NF90\_NOERR if no errors occurred.
1633 Otherwise, the returned status indicates an error. Possible causes of
1634 errors include:
1635 
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.
1639 
1640 Example {.heading}
1641 -------
1642 
1643 Here is an example using NF90\_REDEF to open an existing netCDF dataset
1644 named foo.nc and put it into define mode:
1645 
1646 +--------------------------------------+--------------------------------------+
1647 |   | ``` {.example} |
1648 | | use netcdf |
1649 | | implicit none |
1650 | | integer :: ncid, status |
1651 | | ... |
1652 | | status = nf90_open("foo.nc", nf90_w |
1653 | | rite, ncid) ! Open dataset |
1654 | | if (status /= nf90_noerr) call hand |
1655 | | le_err(status) |
1656 | | ... |
1657 | | status = nf90_redef(ncid) |
1658 | | ! Put the file in defin |
1659 | | e mode |
1660 | | if (status /= nf90_noerr) call hand |
1661 | | le_err(status) |
1662 | | ``` |
1663 +--------------------------------------+--------------------------------------+
1664 
1665 ------------------------------------------------------------------------
1666 
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  ----------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1670 
1671 2.8 NF90\_ENDDEF {.section}
1672 ----------------
1673 
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.
1680 
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.
1685 
1686 Usage {.heading}
1687 -----
1688 
1689 +--------------------------------------+--------------------------------------+
1690 |   | ``` {.example} |
1691 | | function nf90_enddef(ncid, h_minfre |
1692 | | e, v_align, v_minfree, r_align) |
1693 | | integer, intent( in) :: |
1694 | | ncid |
1695 | | integer, optional, intent( in) :: |
1696 | | h_minfree, v_align, v_minfree, r_al |
1697 | | ign |
1698 | | integer :: |
1699 | | nf90_enddef |
1700 | | ``` |
1701 +--------------------------------------+--------------------------------------+
1702 
1703  `ncid`
1704 
1705 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1706 
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.
1710 
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.
1721 
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
1725 v\_minfree is 0.
1726 
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
1732 4 bytes.
1733 
1734  `h_minfree`
1735 
1736 : Size of the pad (in bytes) at the end of the "header" section.
1737 
1738  `v_minfree`
1739 
1740 : Size of the pad (in bytes) at the end of the data section for fixed
1741  size variables.
1742 
1743  `v_align`
1744 
1745 : The alignment of the beginning of the data section for fixed
1746  size variables.
1747 
1748  `r_align`
1749 
1750 : The alignment of the beginning of the data section for variables
1751  which have an unlimited dimension (record variables).
1752 
1753 Errors {.heading}
1754 ------
1755 
1756 NF90\_ENDDEF returns the value NF90\_NOERR if no errors occurred.
1757 Otherwise, the returned status indicates an error. Possible causes of
1758 errors include:
1759 
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.
1766 
1767 Example {.heading}
1768 -------
1769 
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:
1772 
1773 +--------------------------------------+--------------------------------------+
1774 |   | ``` {.example} |
1775 | | use netcdf |
1776 | | implicit none |
1777 | | integer :: ncid, status |
1778 | | ... |
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 |
1784 | | s, attributes |
1785 | | status = nf90_enddef(ncid) |
1786 | | if (status /= nf90_noerr) call hand |
1787 | | le_err(status) |
1788 | | ``` |
1789 +--------------------------------------+--------------------------------------+
1790 
1791 ------------------------------------------------------------------------
1792 
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  ------------------------------------------------------------------ ---------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1796 
1797 2.9 NF90\_CLOSE {.section}
1798 ---------------
1799 
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
1806 created.
1807 
1808 Usage {.heading}
1809 -----
1810 
1811 +--------------------------------------+--------------------------------------+
1812 |   | ``` {.example} |
1813 | | function nf90_close(ncid) |
1814 | | integer, intent( in) :: ncid |
1815 | | integer :: nf90_clos |
1816 | | e |
1817 | | ``` |
1818 +--------------------------------------+--------------------------------------+
1819 
1820  `ncid`
1821 
1822 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1823 
1824 Errors {.heading}
1825 ------
1826 
1827 NF90\_CLOSE returns the value NF90\_NOERR if no errors occurred.
1828 Otherwise, the returned status indicates an error. Possible causes of
1829 errors include:
1830 
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.
1834 
1835 Example {.heading}
1836 -------
1837 
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:
1840 
1841 +--------------------------------------+--------------------------------------+
1842 |   | ``` {.example} |
1843 | | use netcdf |
1844 | | implicit none |
1845 | | integer :: ncid, status |
1846 | | ... |
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 |
1852 | | s, attributes |
1853 | | status = nf90_close(ncid) |
1854 | | if (status /= nf90_noerr) call hand |
1855 | | le_err(status) |
1856 | | ``` |
1857 +--------------------------------------+--------------------------------------+
1858 
1859 ------------------------------------------------------------------------
1860 
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  ----------------------------------------------------------------- ------------------------------------------------------------ --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1864 
1865 2.10 NF90\_INQUIRE Family {.section}
1866 -------------------------
1867 
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.
1875 
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.
1878 
1879 Usage {.heading}
1880 -----
1881 
1882 +--------------------------------------+--------------------------------------+
1883 |   | ``` {.example} |
1884 | | function nf90_inquire(ncid, nDimens |
1885 | | ions, nVariables, nAttributes, & |
1886 | | unlimitedDimI |
1887 | | d, formatNum) |
1888 | | integer, intent( in) :: |
1889 | | ncid |
1890 | | integer, optional, intent(out) :: |
1891 | | nDimensions, nVariables, & |
1892 | | |
1893 | | nAttributes, unlimitedDimId, & |
1894 | | |
1895 | | formatNum |
1896 | | integer :: |
1897 | | nf90_inquire |
1898 | | ``` |
1899 +--------------------------------------+--------------------------------------+
1900 
1901  `ncid`
1902 
1903 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
1904 
1905  `nDimensions`
1906 
1907 : Returned number of dimensions defined for this netCDF dataset.
1908 
1909  `nVariables`
1910 
1911 : Returned number of variables defined for this netCDF dataset.
1912 
1913  `nAttributes`
1914 
1915 : Returned number of global attributes defined for this
1916  netCDF dataset.
1917 
1918  `unlimitedDimID`
1919 
1920 : Returned ID of the unlimited dimension, if there is one for this
1921  netCDF dataset. If no unlimited length dimension has been defined,
1922  -1 is returned.
1923 
1924  `format`
1925 
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.
1931 
1932 Errors {.heading}
1933 ------
1934 
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:
1938 
1939 - The specified netCDF ID does not refer to an open netCDF dataset.
1940 
1941 Example {.heading}
1942 -------
1943 
1944 Here is an example using NF90\_INQUIRE to find out about a netCDF
1945 dataset named foo.nc:
1946 
1947 +--------------------------------------+--------------------------------------+
1948 |   | ``` {.example} |
1949 | | use netcdf |
1950 | | implicit none |
1951 | | integer :: ncid, status, nDims, nVa |
1952 | | rs, nGlobalAtts, unlimDimID |
1953 | | ... |
1954 | | status = nf90_open("foo.nc", nf90_n |
1955 | | owrite, ncid) |
1956 | | if (status /= nf90_noerr) call hand |
1957 | | le_err(status) |
1958 | | ... |
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, & |
1965 | | unlimitedDimI |
1966 | | D = unlimdimid) |
1967 | | if (status /= nf90_noerr) call hand |
1968 | | le_err(status) |
1969 | | ``` |
1970 +--------------------------------------+--------------------------------------+
1971 
1972 ------------------------------------------------------------------------
1973 
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  -------------------------------------------------------------------------- ------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
1977 
1978 2.11 NF90\_SYNC {.section}
1979 ---------------
1980 
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:
1984 
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.
1991 
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
2003 buffering.
2004 
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
2010 among processes.
2011 
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
2015 this purpose.
2016 
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
2027 subsequent access.
2028 
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.
2035 
2036 Data is automatically synchronized to disk when a netCDF dataset is
2037 closed, or whenever you leave define mode.
2038 
2039 Usage {.heading}
2040 -----
2041 
2042 +--------------------------------------+--------------------------------------+
2043 |   | ``` {.example} |
2044 | | function nf90_sync(ncid) |
2045 | | integer, intent( in) :: ncid |
2046 | | integer :: nf90_sync |
2047 | | ``` |
2048 +--------------------------------------+--------------------------------------+
2049 
2050  `ncid`
2051 
2052 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2053 
2054 Errors {.heading}
2055 ------
2056 
2057 NF90\_SYNC returns the value NF90\_NOERR if no errors occurred.
2058 Otherwise, the returned status indicates an error. Possible causes of
2059 errors include:
2060 
2061 - The netCDF dataset is in define mode.
2062 - The specified netCDF ID does not refer to an open netCDF dataset.
2063 
2064 Example {.heading}
2065 -------
2066 
2067 Here is an example using NF90\_SYNC to synchronize the disk writes of a
2068 netCDF dataset named foo.nc:
2069 
2070 +--------------------------------------+--------------------------------------+
2071 |   | ``` {.example} |
2072 | | use netcdf |
2073 | | implicit none |
2074 | | integer :: ncid, status |
2075 | | ... |
2076 | | status = nf90_open("foo.nc", nf90_w |
2077 | | rite, ncid) |
2078 | | if (status /= nf90_noerr) call hand |
2079 | | le_err(status) |
2080 | | ... |
2081 | | ! write data or change attributes |
2082 | | ... |
2083 | | status = NF90_SYNC(ncid) |
2084 | | if (status /= nf90_noerr) call hand |
2085 | | le_err(status) |
2086 | | ``` |
2087 +--------------------------------------+--------------------------------------+
2088 
2089 ------------------------------------------------------------------------
2090 
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  ---------------------------------------------------------------- -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2094 
2095 2.12 NF90\_ABORT {.section}
2096 ----------------
2097 
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.
2106 
2107 Usage {.heading}
2108 -----
2109 
2110 +--------------------------------------+--------------------------------------+
2111 |   | ``` {.example} |
2112 | | function nf90_abort(ncid) |
2113 | | integer, intent( in) :: ncid |
2114 | | integer :: nf90_abor |
2115 | | t |
2116 | | ``` |
2117 +--------------------------------------+--------------------------------------+
2118 
2119  `ncid`
2120 
2121 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2122 
2123 Errors {.heading}
2124 ------
2125 
2126 NF90\_ABORT returns the value NF90\_NOERR if no errors occurred.
2127 Otherwise, the returned status indicates an error. Possible causes of
2128 errors include:
2129 
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.
2133 
2134 Example {.heading}
2135 -------
2136 
2137 Here is an example using NF90\_ABORT to back out of redefinitions of a
2138 dataset named foo.nc:
2139 
2140 +--------------------------------------+--------------------------------------+
2141 |   | ``` {.example} |
2142 | | use netcdf |
2143 | | implicit none |
2144 | | integer :: ncid, status, LatDimID |
2145 | | ... |
2146 | | status = nf90_open("foo.nc", nf90_w |
2147 | | rite, ncid) |
2148 | | if (status /= nf90_noerr) call hand |
2149 | | le_err(status) |
2150 | | ... |
2151 | | status = nf90_redef(ncid) |
2152 | | if (status /= nf90_noerr) call hand |
2153 | | le_err(status) |
2154 | | ... |
2155 | | status = nf90_def_dim(ncid, "Lat", |
2156 | | 18, LatDimID) |
2157 | | if (status /= nf90_noerr) then ! Di |
2158 | | mension definition failed |
2159 | | call handle_err(status) |
2160 | | status = nf90_abort(ncid) ! Abort |
2161 | | redefinitions |
2162 | | if (status /= nf90_noerr) call ha |
2163 | | ndle_err(status) |
2164 | | end if |
2165 | | ... |
2166 | | ``` |
2167 +--------------------------------------+--------------------------------------+
2168 
2169 ------------------------------------------------------------------------
2170 
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  ----------------------------------------------------------------- ----------------------------------------------------- --- --------------------------------------------------------------------------- ---------------------------------- ---------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2174 
2175 2.13 NF90\_SET\_FILL {.section}
2176 --------------------
2177 
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.
2192 
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
2197 with data.
2198 
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.
2202 
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
2209 mode to NF90\_FILL.
2210 
2211 There are three situations where it is advantageous to set nofill mode:
2212 
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
2220  unwritten records.
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.
2224 
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.
2229 
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
2232 feature.
2233 
2234 Usage {.heading}
2235 -----
2236 
2237 +--------------------------------------+--------------------------------------+
2238 |   | ``` {.example} |
2239 | | function nf90_set_fill(ncid, fillmo |
2240 | | de, old_mode) |
2241 | | integer, intent( in) :: ncid, fil |
2242 | | lmode |
2243 | | integer, intent(out) :: old_mode |
2244 | | integer :: nf90_set_ |
2245 | | fill |
2246 | | ``` |
2247 +--------------------------------------+--------------------------------------+
2248 
2249  `ncid`
2250 
2251 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
2252 
2253  `fillmode`
2254 
2255 : Desired fill mode for the dataset, either NF90\_NOFILL
2256  or NF90\_FILL.
2257 
2258  `old_mode`
2259 
2260 : Returned current fill mode of the dataset before this call, either
2261  NF90\_NOFILL or NF90\_FILL.
2262 
2263 Errors {.heading}
2264 ------
2265 
2266 NF90\_SET\_FILL returns the value NF90\_NOERR if no errors occurred.
2267 Otherwise, the returned status indicates an error. Possible causes of
2268 errors include:
2269 
2270 - The specified netCDF ID does not refer to an open netCDF dataset.
2271 - The specified netCDF ID refers to a dataset open for
2272  read-only access.
2273 - The fill mode argument is neither NF90\_NOFILL nor NF90\_FILL..
2274 
2275 Example {.heading}
2276 -------
2277 
2278 Here is an example using NF90\_SET\_FILL to set nofill mode for
2279 subsequent writes of a netCDF dataset named foo.nc:
2280 
2281 +--------------------------------------+--------------------------------------+
2282 |   | ``` {.example} |
2283 | | use netcdf |
2284 | | implicit none |
2285 | | integer :: ncid, status, oldMode |
2286 | | ... |
2287 | | status = nf90_open("foo.nc", nf90_w |
2288 | | rite, ncid) |
2289 | | if (status /= nf90_noerr) call hand |
2290 | | le_err(status) |
2291 | | ... |
2292 | | ! Write data with prefilling behavi |
2293 | | or |
2294 | | ... |
2295 | | status = nf90_set_fill(ncid, nf90_n |
2296 | | ofill, oldMode) |
2297 | | if (status /= nf90_noerr) call hand |
2298 | | le_err(status) |
2299 | | ... |
2300 | | ! Write data with no prefilling |
2301 | | ... |
2302 | | ``` |
2303 +--------------------------------------+--------------------------------------+
2304 
2305 ------------------------------------------------------------------------
2306 
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  ------------------------------------------------------------------------ -------------------------------------------------------------------- --- --------------------------------------------------------------------------- ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2310 
2311 3. Groups {.chapter}
2312 =========
2313 
2314 NetCDF-4 added support for hierarchical groups within netCDF datasets.
2315 
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.
2321 
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.
2328 
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.
2332 
2333 Dimensions are visible in their groups, and all child groups.
2334 
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).
2340 
2341  ------------------------ ------------------------ ------------------------
2342  [3.1 Find a Group ID:   
2343  NF90\_INQ\_NCID](#NF90_0
2344  05fINQ_005fNCID)
2345 
2346  [3.2 Get a List of   
2347  Groups in a Group:
2348  NF90\_INQ\_GRPS](#NF90_0
2349  05fINQ_005fGRPS)
2350 
2351  [3.3 Find all the   
2352  Variables in a Group:
2353  NF90\_INQ\_VARIDS](#NF90
2354  _005fINQ_005fVARIDS)
2355 
2356  [3.4 Find all Dimensions   
2357  Visible in a Group:
2358  NF90\_INQ\_DIMIDS](#NF90
2359  _005fINQ_005fDIMIDS)
2360 
2361  [3.5 Find the Length of   
2362  a Group’s Full Name:
2363  NF90\_INQ\_GRPNAME\_LEN]
2364  (#NF90_005fINQ_005fGRPNA
2365  ME_005fLEN)
2366 
2367  [3.6 Find a Group’s   
2368  Name:
2369  NF90\_INQ\_GRPNAME](#NF9
2370  0_005fINQ_005fGRPNAME)
2371 
2372  [3.7 Find a Group’s Full   
2373  Name:
2374  NF90\_INQ\_GRPNAME\_FULL
2375  ](#NF90_005fINQ_005fGRPN
2376  AME_005fFULL)
2377 
2378  [3.8 Find a Group’s   
2379  Parent:
2380  NF90\_INQ\_GRP\_PARENT](
2381  #NF90_005fINQ_005fGRP_00
2382  5fPARENT)
2383 
2384  [3.9 Find a Group by   
2385  Name:
2386  NF90\_INQ\_GRP\_NCID](#N
2387  F90_005fINQ_005fGRP_005f
2388  NCID)
2389 
2390  [3.10 Find a Group by   
2391  its Fully-qualified
2392  Name:
2393  NF90\_INQ\_GRP\_FULL\_NC
2394  ID](#NF90_005fINQ_005fGR
2395  P_005fFULL_005fNCID)
2396 
2397  [3.11 Create a New   
2398  Group:
2399  NF90\_DEF\_GRP](#NF90_00
2400  5fDEF_005fGRP)
2401  ------------------------ ------------------------ ------------------------
2402 
2403 ------------------------------------------------------------------------
2404 
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  --------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2408 
2409 3.1 Find a Group ID: NF90\_INQ\_NCID {.section}
2410 ------------------------------------
2411 
2412 Given an ncid and group name (NULL or "" gets root group), return ncid
2413 of the named group.
2414 
2415 Usage {.heading}
2416 -----
2417 
2418 +--------------------------------------+--------------------------------------+
2419 |   | ``` {.example} |
2420 | | function nf90_inq_ncid(ncid, name, |
2421 | | grp_ncid) |
2422 | | integer, intent(in) :: ncid |
2423 | | character (len = *), intent(in) |
2424 | | :: name |
2425 | | integer, intent(out) :: grp_ncid |
2426 | | integer :: nf90_inq_ncid |
2427 | | ``` |
2428 +--------------------------------------+--------------------------------------+
2429 
2430  `NCID`
2431 
2432 : The group id for this operation.
2433 
2434  `NAME`
2435 
2436 : A character array that holds the name of the desired group. Must be
2437  less then NF90\_MAX\_NAME.
2438 
2439  `GRPID`
2440 
2441 : The ID of the group will go here.
2442 
2443 Errors {.heading}
2444 ------
2445 
2446  `NF90_NOERR`
2447 
2448 : No error.
2449 
2450  `NF90_EBADID`
2451 
2452 : Bad group id.
2453 
2454  `NF90_ENOTNC4`
2455 
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)).
2460 
2461  `NF90_ESTRICTNC3`
2462 
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)).
2466 
2467  `NF90_EHDFERR`
2468 
2469 : An error was reported by the HDF5 layer.
2470 
2471 Example {.heading}
2472 -------
2473 
2474 This example is from nf90\_test/ftst\_groups.F.
2475 
2476 ------------------------------------------------------------------------
2477 
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  ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2481 
2482 3.2 Get a List of Groups in a Group: NF90\_INQ\_GRPS {.section}
2483 ----------------------------------------------------
2484 
2485 Given a location id, return the number of groups it contains, and an
2486 array of their ncids.
2487 
2488 Usage {.heading}
2489 -----
2490 
2491 +--------------------------------------+--------------------------------------+
2492 |   | ``` {.example} |
2493 | | function nf90_inq_grps(ncid, numgr |
2494 | | ps, ncids) |
2495 | | integer, intent(in) :: ncid |
2496 | | integer, intent(out) :: numgrps |
2497 | | integer, intent(out) :: ncids |
2498 | | integer :: nf90_inq_grps |
2499 | | ``` |
2500 +--------------------------------------+--------------------------------------+
2501 
2502  `NCID`
2503 
2504 : The group id for this operation.
2505 
2506  `NUMGRPS`
2507 
2508 : An integer which will get number of groups in this group.
2509 
2510  `NCIDS`
2511 
2512 : An array of ints which will receive the IDs of all the groups in
2513  this group.
2514 
2515 Errors {.heading}
2516 ------
2517 
2518  `NF90_NOERR`
2519 
2520 : No error.
2521 
2522  `NF90_EBADID`
2523 
2524 : Bad group id.
2525 
2526  `NF90_ENOTNC4`
2527 
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)).
2532 
2533  `NF90_ESTRICTNC3`
2534 
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)).
2538 
2539  `NF90_EHDFERR`
2540 
2541 : An error was reported by the HDF5 layer.
2542 
2543 Example {.heading}
2544 -------
2545 
2546 ------------------------------------------------------------------------
2547 
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  ------------------------------------------------------------------------ ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2551 
2552 3.3 Find all the Variables in a Group: NF90\_INQ\_VARIDS {.section}
2553 --------------------------------------------------------
2554 
2555 Find all varids for a location.
2556 
2557 Usage {.heading}
2558 -----
2559 
2560 +--------------------------------------+--------------------------------------+
2561 |   | ``` {.example} |
2562 | | function nf90_inq_varids(ncid, nva |
2563 | | rs, varids) |
2564 | | integer, intent(in) :: ncid |
2565 | | integer, intent(out) :: nvars |
2566 | | integer, intent(out) :: varids |
2567 | | integer :: nf90_inq_varids |
2568 | | ``` |
2569 +--------------------------------------+--------------------------------------+
2570 
2571  `NCID`
2572 
2573 : The group id for this operation.
2574 
2575  `VARIDS`
2576 
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)).
2581 
2582 Errors {.heading}
2583 ------
2584 
2585  `NF90_NOERR`
2586 
2587 : No error.
2588 
2589  `NF90_EBADID`
2590 
2591 : Bad group id.
2592 
2593  `NF90_ENOTNC4`
2594 
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)).
2599 
2600  `NF90_ESTRICTNC3`
2601 
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)).
2605 
2606  `NF90_EHDFERR`
2607 
2608 : An error was reported by the HDF5 layer.
2609 
2610 Example {.heading}
2611 -------
2612 
2613 ------------------------------------------------------------------------
2614 
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  -------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2618 
2619 3.4 Find all Dimensions Visible in a Group: NF90\_INQ\_DIMIDS {.section}
2620 -------------------------------------------------------------
2621 
2622 Find all dimids for a location. This finds all dimensions in a group, or
2623 any of its parents.
2624 
2625 Usage {.heading}
2626 -----
2627 
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_ |
2636 | | parents |
2637 | | integer :: nf90_inq_dimids |
2638 | | ``` |
2639 +--------------------------------------+--------------------------------------+
2640 
2641  `NCID`
2642 
2643 : The group id for this operation.
2644 
2645  `NDIMS`
2646 
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.
2650 
2651  `DIMIDS`
2652 
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)).
2658 
2659  `INCLUDE_PARENTS`
2660 
2661 : If zero, only the group specified by NCID will be searched
2662  for dimensions. Otherwise parent groups will be searched too.
2663 
2664 Errors {.heading}
2665 ------
2666 
2667  `NF90_NOERR`
2668 
2669 : No error.
2670 
2671  `NF90_EBADID`
2672 
2673 : Bad group id.
2674 
2675  `NF90_ENOTNC4`
2676 
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)).
2681 
2682  `NF90_ESTRICTNC3`
2683 
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)).
2687 
2688  `NF90_EHDFERR`
2689 
2690 : An error was reported by the HDF5 layer.
2691 
2692 Example {.heading}
2693 -------
2694 
2695 ------------------------------------------------------------------------
2696 
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  -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2700 
2701 3.5 Find the Length of a Group’s Full Name: NF90\_INQ\_GRPNAME\_LEN {.section}
2702 -------------------------------------------------------------------
2703 
2704 Given ncid, find length of the full name. (Root group is named "/", with
2705 length 1.)
2706 
2707 Usage {.heading}
2708 -----
2709 
2710 +--------------------------------------+--------------------------------------+
2711 |   | ``` {.example} |
2712 | | function nf90_inq_grpname_len(ncid |
2713 | | , len) |
2714 | | integer, intent(in) :: ncid |
2715 | | integer, intent(out) :: len |
2716 | | integer :: nf90_inq_grpname_len |
2717 | | end function nf90_inq_grpname_len |
2718 | | ``` |
2719 +--------------------------------------+--------------------------------------+
2720 
2721  `NCID`
2722 
2723 : The group id for this operation.
2724 
2725  `LEN`
2726 
2727 : An integer where the length will be placed.
2728 
2729 Errors {.heading}
2730 ------
2731 
2732  `NF90_NOERR`
2733 
2734 : No error.
2735 
2736  `NF90_EBADID`
2737 
2738 : Bad group id.
2739 
2740  `NF90_ENOTNC4`
2741 
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)).
2746 
2747  `NF90_ESTRICTNC3`
2748 
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)).
2752 
2753  `NF90_EHDFERR`
2754 
2755 : An error was reported by the HDF5 layer.
2756 
2757 Example {.heading}
2758 -------
2759 
2760 ------------------------------------------------------------------------
2761 
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  ----------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2765 
2766 3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME {.section}
2767 -------------------------------------------
2768 
2769 Given ncid, find relative name of group. (Root group is named "/").
2770 
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).
2776 
2777 Usage {.heading}
2778 -----
2779 
2780 +--------------------------------------+--------------------------------------+
2781 |   | ``` {.example} |
2782 | | function nf90_inq_grpname(ncid, na |
2783 | | me) |
2784 | | integer, intent(in) :: ncid |
2785 | | character (len = *), intent(out) |
2786 | | :: name |
2787 | | integer :: nf90_inq_grpname |
2788 | | ``` |
2789 +--------------------------------------+--------------------------------------+
2790 
2791  `NCID`
2792 
2793 : The group id for this operation.
2794 
2795  `NAME`
2796 
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.
2799 
2800 Errors {.heading}
2801 ------
2802 
2803  `NF90_NOERR`
2804 
2805 : No error.
2806 
2807  `NF90_EBADID`
2808 
2809 : Bad group id.
2810 
2811  `NF90_ENOTNC4`
2812 
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)).
2817 
2818  `NF90_ESTRICTNC3`
2819 
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)).
2823 
2824  `NF90_EHDFERR`
2825 
2826 : An error was reported by the HDF5 layer.
2827 
2828 Example {.heading}
2829 -------
2830 
2831 ------------------------------------------------------------------------
2832 
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  --------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2836 
2837 3.7 Find a Group’s Full Name: NF90\_INQ\_GRPNAME\_FULL {.section}
2838 ------------------------------------------------------
2839 
2840 Given ncid, find complete name of group. (Root group is named "/").
2841 
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).
2847 
2848 To find the length of the full name See section [Find the Length of a
2849 Group’s Full Name:
2850 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN).
2851 
2852 Usage {.heading}
2853 -----
2854 
2855 +--------------------------------------+--------------------------------------+
2856 |   | ``` {.example} |
2857 | | function nf90_inq_grpname_full(nci |
2858 | | d, len, name) |
2859 | | integer, intent(in) :: ncid |
2860 | | integer, intent(out) :: len |
2861 | | character (len = *), intent(out) |
2862 | | :: name |
2863 | | integer :: nf90_inq_grpname_full |
2864 | | ``` |
2865 +--------------------------------------+--------------------------------------+
2866 
2867  `NCID`
2868 
2869 : The group id for this operation.
2870 
2871  `LEN`
2872 
2873 : The length of the full group name will go here.
2874 
2875  `NAME`
2876 
2877 : The name of the group will be copied to this character array.
2878 
2879 Errors {.heading}
2880 ------
2881 
2882  `NF90_NOERR`
2883 
2884 : No error.
2885 
2886  `NF90_EBADID`
2887 
2888 : Bad group id.
2889 
2890  `NF90_ENOTNC4`
2891 
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)).
2896 
2897  `NF90_ESTRICTNC3`
2898 
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)).
2902 
2903  `NF90_EHDFERR`
2904 
2905 : An error was reported by the HDF5 layer.
2906 
2907 Example {.heading}
2908 -------
2909 
2910 This example is from test program nf\_test/f90tst\_grps.f90.
2911 
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 |
2917 | | top 62 |
2918 | | ``` |
2919 +--------------------------------------+--------------------------------------+
2920 
2921 ------------------------------------------------------------------------
2922 
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  ------------------------------------------------------------------------------------ ---------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2926 
2927 3.8 Find a Group’s Parent: NF90\_INQ\_GRP\_PARENT {.section}
2928 -------------------------------------------------
2929 
2930 Given ncid, find the ncid of the parent group.
2931 
2932 When used with the root group, this function returns the NF90\_ENOGRP
2933 error (since the root group has no parent.)
2934 
2935 Usage {.heading}
2936 -----
2937 
2938 +--------------------------------------+--------------------------------------+
2939 |   | ``` {.example} |
2940 | | function nf90_inq_grp_parent(ncid, |
2941 | | parent_ncid) |
2942 | | integer, intent(in) :: ncid |
2943 | | integer, intent(out) :: parent_n |
2944 | | cid |
2945 | | integer :: nf90_inq_grp_parent |
2946 | | ``` |
2947 +--------------------------------------+--------------------------------------+
2948 
2949  `NCID`
2950 
2951 : The group id.
2952 
2953  `PARENT_NCID`
2954 
2955 : The ncid of the parent group will be copied here.
2956 
2957 Errors {.heading}
2958 ------
2959 
2960  `NF90_NOERR`
2961 
2962 : No error.
2963 
2964  `NF90_EBADID`
2965 
2966 : Bad group id.
2967 
2968  `NF90_ENOGRP`
2969 
2970 : No parent group found (i.e. this is the root group).
2971 
2972  `NF90_ENOTNC4`
2973 
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)).
2978 
2979  `NF90_ESTRICTNC3`
2980 
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)).
2984 
2985  `NF90_EHDFERR`
2986 
2987 : An error was reported by the HDF5 layer.
2988 
2989 Example {.heading}
2990 -------
2991 
2992 ------------------------------------------------------------------------
2993 
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  ---------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
2997 
2998 3.9 Find a Group by Name: NF90\_INQ\_GRP\_NCID {.section}
2999 ----------------------------------------------
3000 
3001 Given a group name an an ncid, find the ncid of the group id.
3002 
3003 Usage {.heading}
3004 -----
3005 
3006 +--------------------------------------+--------------------------------------+
3007 |   | ``` {.example} |
3008 | | function nf90_inq_grp_ncid(ncid, n |
3009 | | ame, grpid) |
3010 | | integer, intent(in) :: ncid |
3011 | | character (len = *), intent(in) |
3012 | | :: name |
3013 | | integer, intent(out) :: grpid |
3014 | | integer :: nf90_inq_grp_ncid |
3015 | | |
3016 | | nf90_inq_grp_ncid = nf_inq_grp_n |
3017 | | cid(ncid, name, grpid) |
3018 | | end function nf90_inq_grp_ncid |
3019 | | ``` |
3020 +--------------------------------------+--------------------------------------+
3021 
3022  `NCID`
3023 
3024 : The group id to look in.
3025 
3026  `GRP_NAME`
3027 
3028 : The name of the group that should be found.
3029 
3030  `GRP_NCID`
3031 
3032 : This will get the group id, if it is found.
3033 
3034 Return Codes {.heading}
3035 ------------
3036 
3037 The following return codes may be returned by this function.
3038 
3039  `NF90_NOERR`
3040 
3041 : No error.
3042 
3043  `NF90_EBADID`
3044 
3045 : Bad group id.
3046 
3047  `NF90_EINVAL`
3048 
3049 : No name provided or name longer than NF90\_MAX\_NAME.
3050 
3051  `NF90_ENOGRP`
3052 
3053 : Named group not found.
3054 
3055  `NF90_ENOTNC4`
3056 
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)).
3061 
3062  `NF90_ESTRICTNC3`
3063 
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)).
3067 
3068  `NF90_EHDFERR`
3069 
3070 : An error was reported by the HDF5 layer.
3071 
3072 Example {.heading}
3073 -------
3074 
3075 This example is from test program nf\_test/f90tst\_grps.f90.
3076 
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)) |
3089 | | ``` |
3090 +--------------------------------------+--------------------------------------+
3091 
3092 ------------------------------------------------------------------------
3093 
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  -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3097 
3098 3.10 Find a Group by its Fully-qualified Name: NF90\_INQ\_GRP\_FULL\_NCID {.section}
3099 -------------------------------------------------------------------------
3100 
3101 Given a fully qualified group name an an ncid, find the ncid of the
3102 group id.
3103 
3104 Usage {.heading}
3105 -----
3106 
3107 +--------------------------------------+--------------------------------------+
3108 |   | ``` {.example} |
3109 | | function nf90_inq_grpname_full(nci |
3110 | | d, len, name) |
3111 | | integer, intent(in) :: ncid |
3112 | | integer, intent(out) :: len |
3113 | | character (len = *), intent(out) |
3114 | | :: name |
3115 | | integer :: nf90_inq_grpname_full |
3116 | | |
3117 | | nf90_inq_grpname_full = nf_inq_g |
3118 | | rpname_full(ncid, len, name) |
3119 | | end function nf90_inq_grpname_full |
3120 | | ``` |
3121 +--------------------------------------+--------------------------------------+
3122 
3123  `NCID`
3124 
3125 : The group id to look in.
3126 
3127  `FULL_NAME`
3128 
3129 : The fully-qualified group name.
3130 
3131  `GRP_NCID`
3132 
3133 : This will get the group id, if it is found.
3134 
3135 Return Codes {.heading}
3136 ------------
3137 
3138 The following return codes may be returned by this function.
3139 
3140  `NF90_NOERR`
3141 
3142 : No error.
3143 
3144  `NF90_EBADID`
3145 
3146 : Bad group id.
3147 
3148  `NF90_EINVAL`
3149 
3150 : No name provided or name longer than NF90\_MAX\_NAME.
3151 
3152  `NF90_ENOGRP`
3153 
3154 : Named group not found.
3155 
3156  `NF90_ENOTNC4`
3157 
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)).
3162 
3163  `NF90_ESTRICTNC3`
3164 
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)).
3168 
3169  `NF90_EHDFERR`
3170 
3171 : An error was reported by the HDF5 layer.
3172 
3173 Example {.heading}
3174 -------
3175 
3176 This example is from test program nf\_test/tstf90\_grps.f90.
3177 
3178 +--------------------------------------+--------------------------------------+
3179 |   | ``` {.example} |
3180 | | ! Check for the groups with full g |
3181 | | roup names. |
3182 | | write(grp1_full_name, '(AA)') '/', |
3183 | | GRP1_NAME |
3184 | | call check(nf90_inq_grp_full_ncid( |
3185 | | ncid, grp1_full_name, grpid1)) |
3186 | | ``` |
3187 +--------------------------------------+--------------------------------------+
3188 
3189 ------------------------------------------------------------------------
3190 
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  ----------------------------------------------------------------------------------------- --------------------------------------------------------- --- ------------------------------------------------------------------------- -------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3194 
3195 3.11 Create a New Group: NF90\_DEF\_GRP {.section}
3196 ---------------------------------------
3197 
3198 Create a group. Its location id is returned in new\_ncid.
3199 
3200 Usage {.heading}
3201 -----
3202 
3203 +--------------------------------------+--------------------------------------+
3204 |   | ``` {.example} |
3205 | | function nf90_def_grp(parent_ncid, |
3206 | | name, new_ncid) |
3207 | | integer, intent(in) :: parent_nc |
3208 | | id |
3209 | | character (len = *), intent(in) |
3210 | | :: name |
3211 | | integer, intent(out) :: new_ncid |
3212 | | integer :: nf90_def_grp |
3213 | | ``` |
3214 +--------------------------------------+--------------------------------------+
3215 
3216  `PARENT_NCID`
3217 
3218 : The group id of the parent group.
3219 
3220  `NAME`
3221 
3222 : The name of the new group, which must be different from the name of
3223  any variable within the same parent group.
3224 
3225  `NEW_NCID`
3226 
3227 : The ncid of the new group will be placed there.
3228 
3229 Errors {.heading}
3230 ------
3231 
3232  `NF90_NOERR`
3233 
3234 : No error.
3235 
3236  `NF90_EBADID`
3237 
3238 : Bad group id.
3239 
3240  `NF90_ENAMEINUSE`
3241 
3242 : That name is in use. Group names must be unique within a group.
3243 
3244  `NF90_EMAXNAME`
3245 
3246 : Name exceed max length NF90\_MAX\_NAME.
3247 
3248  `NF90_EBADNAME`
3249 
3250 : Name contains illegal characters.
3251 
3252  `NF90_ENOTNC4`
3253 
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)).
3258 
3259  `NF90_ESTRICTNC3`
3260 
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)).
3264 
3265  `NF90_EHDFERR`
3266 
3267 : An error was reported by the HDF5 layer.
3268 
3269  `NF90_EPERM`
3270 
3271 : Attempt to write to a read-only file.
3272 
3273  `NF90_ENOTINDEFINE`
3274 
3275 : Not in define mode.
3276 
3277 Example {.heading}
3278 -------
3279 
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) |
3287 | | |
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) |
3297 | | ``` |
3298 +--------------------------------------+--------------------------------------+
3299 
3300 ------------------------------------------------------------------------
3301 
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  ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3305 
3306 4. Dimensions {.chapter}
3307 =============
3308 
3309  ------------------------ ------------------------ ------------------------
3310  [4.1 Dimensions   
3311  Introduction](#Dimension
3312  s-Introduction)
3313 
3314  [4.2   
3315  NF90\_DEF\_DIM](#NF90_00
3316  5fDEF_005fDIM)
3317 
3318  [4.3   
3319  NF90\_INQ\_DIMID](#NF90_
3320  005fINQ_005fDIMID)
3321 
3322  [4.4   
3323  NF90\_INQUIRE\_DIMENSION
3324  ](#NF90_005fINQUIRE_005f
3325  DIMENSION)
3326 
3327  [4.5   
3328  NF90\_RENAME\_DIM](#NF90
3329  _005fRENAME_005fDIM)
3330  ------------------------ ------------------------ ------------------------
3331 
3332 ------------------------------------------------------------------------
3333 
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  ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3337 
3338 4.1 Dimensions Introduction {.section}
3339 ---------------------------
3340 
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
3346 dimension.
3347 
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.
3357 
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.
3363 
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.
3367 
3368 Operations supported on dimensions are:
3369 
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.
3374 
3375 ------------------------------------------------------------------------
3376 
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  -------------------------------------------------------------------------- --------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3380 
3381 4.2 NF90\_DEF\_DIM {.section}
3382 ------------------
3383 
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.
3389 
3390 Usage {.heading}
3391 -----
3392 
3393 +--------------------------------------+--------------------------------------+
3394 |   | ``` {.example} |
3395 | | function nf90_def_dim(ncid, name, l |
3396 | | en, dimid) |
3397 | | integer, intent( in) |
3398 | | :: ncid |
3399 | | character (len = *), intent( in) |
3400 | | :: name |
3401 | | integer, intent( in) |
3402 | | :: len |
3403 | | integer, intent(out) |
3404 | | :: dimid |
3405 | | integer |
3406 | | :: nf90_def_dim |
3407 | | ``` |
3408 +--------------------------------------+--------------------------------------+
3409 
3410  `ncid`
3411 
3412 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3413 
3414  `name`
3415 
3416 : Dimension name.
3417 
3418  `len`
3419 
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.
3423 
3424  `dimid`
3425 
3426 : Returned dimension ID.
3427 
3428 Errors {.heading}
3429 ------
3430 
3431 NF90\_DEF\_DIM returns the value NF90\_NOERR if no errors occurred.
3432 Otherwise, the returned status indicates an error. Possible causes of
3433 errors include:
3434 
3435 - The netCDF dataset is not in definition mode.
3436 - The specified dimension name is the name of another
3437  existing dimension.
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.
3442 
3443 Example {.heading}
3444 -------
3445 
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
3448 named foo.nc:
3449 
3450 +--------------------------------------+--------------------------------------+
3451 |   | ``` {.example} |
3452 | | use netcdf |
3453 | | implicit none |
3454 | | integer :: ncid, status, LatDimID, |
3455 | | RecordDimID |
3456 | | ... |
3457 | | status = nf90_create("foo.nc", nf90 |
3458 | | _noclobber, ncid) |
3459 | | if (status /= nf90_noerr) call hand |
3460 | | le_err(status) |
3461 | | ... |
3462 | | status = nf90_def_dim(ncid, "Lat", |
3463 | | 18, LatDimID) |
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) |
3470 | | ``` |
3471 +--------------------------------------+--------------------------------------+
3472 
3473 ------------------------------------------------------------------------
3474 
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  ----------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3478 
3479 4.3 NF90\_INQ\_DIMID {.section}
3480 --------------------
3481 
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.
3486 
3487 Usage {.heading}
3488 -----
3489 
3490 +--------------------------------------+--------------------------------------+
3491 |   | ``` {.example} |
3492 | | function nf90_inq_dimid(ncid, name, |
3493 | | dimid) |
3494 | | integer, intent( in) |
3495 | | :: ncid |
3496 | | character (len = *), intent( in) |
3497 | | :: name |
3498 | | integer, intent(out) |
3499 | | :: dimid |
3500 | | integer |
3501 | | :: nf90_inq_dimid |
3502 | | ``` |
3503 +--------------------------------------+--------------------------------------+
3504 
3505  `ncid`
3506 
3507 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3508 
3509  `name`
3510 
3511 : Dimension name.
3512 
3513  `dimid`
3514 
3515 : Returned dimension ID.
3516 
3517 Errors {.heading}
3518 ------
3519 
3520 NF90\_INQ\_DIMID returns the value NF90\_NOERR if no errors occurred.
3521 Otherwise, the returned status indicates an error. Possible causes of
3522 errors include:
3523 
3524 - The name that was specified is not the name of a dimension in the
3525  netCDF dataset.
3526 - The specified netCDF ID does not refer to an open netCDF dataset.
3527 
3528 Example {.heading}
3529 -------
3530 
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:
3534 
3535 +--------------------------------------+--------------------------------------+
3536 |   | ``` {.example} |
3537 | | use netcdf |
3538 | | implicit none |
3539 | | integer :: ncid, status, LatDimID |
3540 | | ... |
3541 | | status = nf90_open("foo.nc", nf90_n |
3542 | | owrite, ncid) |
3543 | | if (status /= nf90_noerr) call hand |
3544 | | le_err(status) |
3545 | | ... |
3546 | | status = nf90_inq_dimid(ncid, "Lat" |
3547 | | , LatDimID) |
3548 | | if (status /= nf90_noerr) call hand |
3549 | | le_err(status) |
3550 | | ``` |
3551 +--------------------------------------+--------------------------------------+
3552 
3553 ------------------------------------------------------------------------
3554 
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  ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3558 
3559 4.4 NF90\_INQUIRE\_DIMENSION {.section}
3560 ----------------------------
3561 
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.
3565 
3566 Usage {.heading}
3567 -----
3568 
3569 +--------------------------------------+--------------------------------------+
3570 |   | ``` {.example} |
3571 | | function nf90_inquire_dimension(nci |
3572 | | d, dimid, name, len) |
3573 | | integer, in |
3574 | | tent( in) :: ncid, dimid |
3575 | | character (len = *), optional, in |
3576 | | tent(out) :: name |
3577 | | integer, optional, in |
3578 | | tent(out) :: len |
3579 | | integer |
3580 | | :: nf90_inquire_dimension |
3581 | | ``` |
3582 +--------------------------------------+--------------------------------------+
3583 
3584  `ncid`
3585 
3586 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3587 
3588  `dimid`
3589 
3590 : Dimension ID, from a previous call to NF90\_INQ\_DIMID
3591  or NF90\_DEF\_DIM.
3592 
3593  `name`
3594 
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.
3598 
3599  `len`
3600 
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.
3604 
3605 Errors {.heading}
3606 ------
3607 
3608 These functions return the value NF90\_NOERR if no errors occurred.
3609 Otherwise, the returned status indicates an error. Possible causes of
3610 errors include:
3611 
3612 - The dimension ID is invalid for the specified netCDF dataset.
3613 - The specified netCDF ID does not refer to an open netCDF dataset.
3614 
3615 Example {.heading}
3616 -------
3617 
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:
3621 
3622 +--------------------------------------+--------------------------------------+
3623 |   | ``` {.example} |
3624 | | use netcdf |
3625 | | implicit none |
3626 | | integer :: ncid, status, LatDimID, |
3627 | | RecordDimID |
3628 | | integer :: nLats, nRecords |
3629 | | character(len = nf90_max_name) :: R |
3630 | | ecordDimName |
3631 | | ... |
3632 | | status = nf90_open("foo.nc", nf90_n |
3633 | | owrite, ncid) |
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) |
3641 | | ... |
3642 | | status = nf90_inq_dimid(ncid, "Lat" |
3643 | | , LatDimID) |
3644 | | if (status /= nf90_noerr) call hand |
3645 | | le_err(status) |
3646 | | ! How many values of "lat" are ther |
3647 | | e? |
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 |
3654 | | re? |
3655 | | status = nf90_inquire_dimension(nci |
3656 | | d, RecordDimID, & |
3657 | | nam |
3658 | | e = RecordDimName, len = Records) |
3659 | | if (status /= nf90_noerr) call hand |
3660 | | le_err(status) |
3661 | | ``` |
3662 +--------------------------------------+--------------------------------------+
3663 
3664 ------------------------------------------------------------------------
3665 
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  --------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ --------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3669 
3670 4.5 NF90\_RENAME\_DIM {.section}
3671 ---------------------
3672 
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.
3677 
3678 Usage {.heading}
3679 -----
3680 
3681 +--------------------------------------+--------------------------------------+
3682 |   | ``` {.example} |
3683 | | function nf90_rename_dim(ncid, dimi |
3684 | | d, name) |
3685 | | integer, intent( in) |
3686 | | :: ncid |
3687 | | character (len = *), intent( in) |
3688 | | :: name |
3689 | | integer, intent( in) |
3690 | | :: dimid |
3691 | | integer |
3692 | | :: nf90_rename_dim |
3693 | | ``` |
3694 +--------------------------------------+--------------------------------------+
3695 
3696  `ncid`
3697 
3698 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
3699 
3700  `dimid`
3701 
3702 : Dimension ID, from a previous call to NF90\_INQ\_DIMID
3703  or NF90\_DEF\_DIM.
3704 
3705  `name`
3706 
3707 : New dimension name.
3708 
3709 Errors {.heading}
3710 ------
3711 
3712 NF90\_RENAME\_DIM returns the value NF90\_NOERR if no errors occurred.
3713 Otherwise, the returned status indicates an error. Possible causes of
3714 errors include:
3715 
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
3720  not in define mode.
3721 
3722 Example {.heading}
3723 -------
3724 
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:
3727 
3728 +--------------------------------------+--------------------------------------+
3729 |   | ``` {.example} |
3730 | | use netcdf |
3731 | | implicit none |
3732 | | integer :: ncid, status, LatDimID |
3733 | | ... |
3734 | | status = nf90_open("foo.nc", nf90_w |
3735 | | rite, ncid) |
3736 | | if (status /= nf90_noerr) call hand |
3737 | | le_err(status) |
3738 | | ... |
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" |
3746 | | , LatDimID) |
3747 | | if (status /= nf90_noerr) call hand |
3748 | | le_err(status) |
3749 | | ! ... and change the name to "Latit |
3750 | | ude". |
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) |
3759 | | ``` |
3760 +--------------------------------------+--------------------------------------+
3761 
3762 ------------------------------------------------------------------------
3763 
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  -------------------------------------------------------------------------- ----------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3767 
3768 5. User Defined Data Types {.chapter}
3769 ==========================
3770 
3771  ------------------------ ------------------------ ------------------------
3772  [5.1 User Defined Types   
3773  Introduction](#User-Defi
3774  ned-Types)
3775 
3776  [5.2 Learn the IDs of   
3777  All Types in Group:
3778  NF90\_INQ\_TYPEIDS](#NF9
3779  0_005fINQ_005fTYPEIDS)
3780 
3781  [5.3 Find a Typeid from   
3782  Group and Name:
3783  nf90\_inq\_typeid](#nf90
3784  _005finq_005ftypeid)
3785 
3786  [5.4 Learn About a User   
3787  Defined Type:
3788  NF90\_INQ\_TYPE](#NF90_0
3789  05fINQ_005fTYPE)
3790 
3791  [5.5 Learn About a User   
3792  Defined Type:
3793  NF90\_INQ\_USER\_TYPE](#
3794  NF90_005fINQ_005fUSER_00
3795  5fTYPE)
3796 
3797  [5.6 Compound Types   
3798  Introduction](#Compound-
3799  Types)
3800 
3801  [5.7 Variable Length   
3802  Array
3803  Introduction](#Variable-
3804  Length-Array)
3805 
3806  [5.8 Opaque Type   
3807  Introduction](#Opaque-Ty
3808  pe)
3809 
3810  [5.9 Enum Type   
3811  Introduction](#Enum-Type
3812  )
3813  ------------------------ ------------------------ ------------------------
3814 
3815 ------------------------------------------------------------------------
3816 
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  -------------------------------------------------------------------------- ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3820 
3821 5.1 User Defined Types Introduction {.section}
3822 -----------------------------------
3823 
3824 NetCDF-4 has added support for four different user defined data types.
3825 
3826  `compound type`
3827 
3828 : Like a C struct, a compound type is a collection of types, including
3829  other user defined types, in one package.
3830 
3831  `variable length array type`
3832 
3833 : The variable length array may be used to store ragged arrays.
3834 
3835  `opaque type`
3836 
3837 : This type has only a size per element, and no other
3838  type information.
3839 
3840  `enum type`
3841 
3842 : Like an enumeration in C, this type lets you assign text values to
3843  integer values, and store the integer values.
3844 
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.
3848 
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)).
3856 
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)).
3861 
3862 ------------------------------------------------------------------------
3863 
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  --------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3867 
3868 5.2 Learn the IDs of All Types in Group: NF90\_INQ\_TYPEIDS {.section}
3869 -----------------------------------------------------------
3870 
3871 Learn the number of types defined in a group, and their IDs.
3872 
3873 Usage {.heading}
3874 -----
3875 
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 |
3884 | | ``` |
3885 +--------------------------------------+--------------------------------------+
3886 
3887  `NCID`
3888 
3889 : The group id.
3890 
3891  `NTYPES`
3892 
3893 : A pointer to int which will get the number of types defined in
3894  the group. If NULL, ignored.
3895 
3896  `TYPEIDS`
3897 
3898 : A pointer to an int array which will get the typeids. If
3899  NULL, ignored.
3900 
3901 Errors {.heading}
3902 ------
3903 
3904  `NF90_NOERR`
3905 
3906 : No error.
3907 
3908  `NF90_BADID`
3909 
3910 : Bad ncid.
3911 
3912 Example {.heading}
3913 -------
3914 
3915 ------------------------------------------------------------------------
3916 
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  --------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3920 
3921 5.3 Find a Typeid from Group and Name: nf90\_inq\_typeid {.section}
3922 --------------------------------------------------------
3923 
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.
3927 
3928 Usage {.heading}
3929 -----
3930 
3931 +--------------------------------------+--------------------------------------+
3932 |   | ``` {.example} |
3933 | | int nf90_inq_typeid(int ncid, char * |
3934 | | name, nf90_type *typeidp); |
3935 | | ``` |
3936 +--------------------------------------+--------------------------------------+
3937 
3938  `ncid`
3939 
3940 : The group id.
3941 
3942  `name`
3943 
3944 : The name of a type.
3945 
3946  `typeidp`
3947 
3948 : The typeid, if found.
3949 
3950 Errors {.heading}
3951 ------
3952 
3953  `NF90_NOERR`
3954 
3955 : No error.
3956 
3957  `NF90_EBADID`
3958 
3959 : Bad ncid.
3960 
3961  `NF90_EBADTYPE`
3962 
3963 : Can’t find type.
3964 
3965 Example {.heading}
3966 -------
3967 
3968 ------------------------------------------------------------------------
3969 
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  -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
3973 
3974 5.4 Learn About a User Defined Type: NF90\_INQ\_TYPE {.section}
3975 ----------------------------------------------------
3976 
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.
3980 
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).
3983 
3984 Usage {.heading}
3985 -----
3986 
3987 +--------------------------------------+--------------------------------------+
3988 |   | ``` {.example} |
3989 | | function nf90_inq_type(ncid, xtype |
3990 | | , name, size) |
3991 | | integer, intent(in) :: ncid |
3992 | | integer, intent(in) :: xtype |
3993 | | character (len = *), intent(out) |
3994 | | :: name |
3995 | | integer, intent(out) :: size |
3996 | | integer :: nf90_inq_type |
3997 | | ``` |
3998 +--------------------------------------+--------------------------------------+
3999 
4000  `NCID`
4001 
4002 : The ncid for the group containing the type (ignored for
4003  atomic types).
4004 
4005  `XTYPE`
4006 
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.).
4011 
4012  `NAME`
4013 
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
4016  CDL will be given.
4017 
4018  `SIZEP`
4019 
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.
4023 
4024 Return Codes {.heading}
4025 ------------
4026 
4027  `NF90_NOERR`
4028 
4029 : No error.
4030 
4031  `NF90_EBADTYPEID`
4032 
4033 : Bad typeid.
4034 
4035  `NF90_ENOTNC4`
4036 
4037 : Seeking a user-defined type in a netCDF-3 file.
4038 
4039  `NF90_ESTRICTNC3`
4040 
4041 : Seeking a user-defined type in a netCDF-4 file for which classic
4042  model has been turned on.
4043 
4044  `NF90_EBADGRPID`
4045 
4046 : Bad group ID in ncid.
4047 
4048  `NF90_EBADID`
4049 
4050 : Type ID not found.
4051 
4052  `NF90_EHDFERR`
4053 
4054 : An error was reported by the HDF5 layer.
4055 
4056 Example {.heading}
4057 -------
4058 
4059 ------------------------------------------------------------------------
4060 
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  ------------------------------------------------------------------------ -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4064 
4065 5.5 Learn About a User Defined Type: NF90\_INQ\_USER\_TYPE {.section}
4066 ----------------------------------------------------------
4067 
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.
4071 
4072 Usage {.heading}
4073 -----
4074 
4075 +--------------------------------------+--------------------------------------+
4076 |   | ``` {.example} |
4077 | | function nf90_inq_user_type(ncid, |
4078 | | xtype, name, size, base_typeid, nfie |
4079 | | lds, class) |
4080 | | integer, intent(in) :: ncid |
4081 | | integer, intent(in) :: xtype |
4082 | | character (len = *), intent(out) |
4083 | | :: name |
4084 | | integer, intent(out) :: size |
4085 | | integer, intent(out) :: base_typ |
4086 | | eid |
4087 | | integer, intent(out) :: nfields |
4088 | | integer, intent(out) :: class |
4089 | | integer :: nf90_inq_user_type |
4090 | | ``` |
4091 +--------------------------------------+--------------------------------------+
4092 
4093  `NCID`
4094 
4095 : The ncid for the group containing the user defined type.
4096 
4097  `XTYPE`
4098 
4099 : The typeid for this type, as returned by NF90\_DEF\_COMPOUND,
4100  NF90\_DEF\_OPAQUE, NF90\_DEF\_ENUM, NF90\_DEF\_VLEN,
4101  or NF90\_INQ\_VAR.
4102 
4103  `NAME`
4104 
4105 : The name of the user defined type will be copied here. It will be
4106  NF90\_MAX\_NAME bytes or less.
4107 
4108  `SIZE`
4109 
4110 : The (in-memory) size of the user defined type will be copied here.
4111 
4112  `BASE_NF90_TYPE`
4113 
4114 : The base typeid will be copied here for vlen and enum types.
4115 
4116  `NFIELDS`
4117 
4118 : The number of fields will be copied here for enum and
4119  compound types.
4120 
4121  `CLASS`
4122 
4123 : The class of the user defined type, NF90\_VLEN, NF90\_OPAQUE,
4124  NF90\_ENUM, or NF90\_COMPOUND, will be copied here.
4125 
4126 Errors {.heading}
4127 ------
4128 
4129  `NF90_NOERR`
4130 
4131 : No error.
4132 
4133  `NF90_EBADTYPEID`
4134 
4135 : Bad typeid.
4136 
4137  `NF90_EBADFIELDID`
4138 
4139 : Bad fieldid.
4140 
4141  `NF90_EHDFERR`
4142 
4143 : An error was reported by the HDF5 layer.
4144 
4145 Example {.heading}
4146 -------
4147 
4148  ------------------------ ------------------------ ------------------------
4149  [5.5.1 Set a Variable   
4150  Length Array with
4151  NF90\_PUT\_VLEN\_ELEMENT
4152  ](#NF90_005fPUT_005fVLEN
4153  _005fELEMENT)
4154 
4155  [5.5.2 Set a Variable   
4156  Length Array with
4157  NF90\_GET\_VLEN\_ELEMENT
4158  ](#NF90_005fGET_005fVLEN
4159  _005fELEMENT)
4160  ------------------------ ------------------------ ------------------------
4161 
4162 ------------------------------------------------------------------------
4163 
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  --------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4167 
4168 ### 5.5.1 Set a Variable Length Array with NF90\_PUT\_VLEN\_ELEMENT {.subsection}
4169 
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.
4172 
4173 Usage {.heading}
4174 -----
4175 
4176 +--------------------------------------+--------------------------------------+
4177 |   | ``` {.example} |
4178 | | INTEGER FUNCTION NF90_PUT_VLEN_ELEME |
4179 | | NT(INTEGER NCID, INTEGER XTYPE, |
4180 | | CHARACTER*(*) VLEN_ELEMENT, |
4181 | | INTEGER LEN, DATA) |
4182 | | ``` |
4183 +--------------------------------------+--------------------------------------+
4184 
4185  `NCID`
4186 
4187 : The ncid of the file that contains the VLEN type.
4188 
4189  `XTYPE`
4190 
4191 : The type of the VLEN.
4192 
4193  `VLEN_ELEMENT`
4194 
4195 : The VLEN element to be set.
4196 
4197  `LEN`
4198 
4199 : The number of entries in this array.
4200 
4201  `DATA`
4202 
4203 : The data to be stored. Must match the base type of this VLEN.
4204 
4205 Errors {.heading}
4206 ------
4207 
4208  `NF90_NOERR`
4209 
4210 : No error.
4211 
4212  `NF90_EBADTYPE`
4213 
4214 : Can’t find the typeid.
4215 
4216  `NF90_EBADID`
4217 
4218 : ncid invalid.
4219 
4220  `NF90_EBADGRPID`
4221 
4222 : Group ID part of ncid was invalid.
4223 
4224 Example {.heading}
4225 -------
4226 
4227 This example is from nf90\_test/ftst\_vars4.F.
4228 
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) |
4239 | | ``` |
4240 +--------------------------------------+--------------------------------------+
4241 
4242 ------------------------------------------------------------------------
4243 
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  ------------------------------------------------------------------------------------ ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ -------------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4247 
4248 ### 5.5.2 Set a Variable Length Array with NF90\_GET\_VLEN\_ELEMENT {.subsection}
4249 
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.
4252 
4253 Usage {.heading}
4254 -----
4255 
4256 +--------------------------------------+--------------------------------------+
4257 |   | ``` {.example} |
4258 | | INTEGER FUNCTION NF90_GET_VLEN_ELEME |
4259 | | NT(INTEGER NCID, INTEGER XTYPE, |
4260 | | CHARACTER*(*) VLEN_ELEMENT, |
4261 | | INTEGER LEN, DATA) |
4262 | | ``` |
4263 +--------------------------------------+--------------------------------------+
4264 
4265  `NCID`
4266 
4267 : The ncid of the file that contains the VLEN type.
4268 
4269  `XTYPE`
4270 
4271 : The type of the VLEN.
4272 
4273  `VLEN_ELEMENT`
4274 
4275 : The VLEN element to be set.
4276 
4277  `LEN`
4278 
4279 : This will be set to the number of entries in this array.
4280 
4281  `DATA`
4282 
4283 : The data will be copied here. Sufficient storage must be available
4284  or bad things will happen to you.
4285 
4286 Errors {.heading}
4287 ------
4288 
4289  `NF90_NOERR`
4290 
4291 : No error.
4292 
4293  `NF90_EBADTYPE`
4294 
4295 : Can’t find the typeid.
4296 
4297  `NF90_EBADID`
4298 
4299 : ncid invalid.
4300 
4301  `NF90_EBADGRPID`
4302 
4303 : Group ID part of ncid was invalid.
4304 
4305 Example {.heading}
4306 -------
4307 
4308 ------------------------------------------------------------------------
4309 
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  ------------------------------------------------------------------------------------ ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4313 
4314 5.6 Compound Types Introduction {.section}
4315 -------------------------------
4316 
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.
4319 
4320 Compound types are not supported in classic or 64-bit offset format
4321 files.
4322 
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.
4327 
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.
4330 
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.
4334 
4335 The use of compound types introduces challenges and portability issues
4336 for Fortran users.
4337 
4338  ------------------------ ------------------------ ------------------------
4339  [5.6.1 Creating a   
4340  Compound Type:
4341  NF90\_DEF\_COMPOUND](#NF
4342  90_005fDEF_005fCOMPOUND)
4343 
4344  [5.6.2 Inserting a Field   
4345  into a Compound Type:
4346  NF90\_INSERT\_COMPOUND](
4347  #NF90_005fINSERT_005fCOM
4348  POUND)
4349 
4350  [5.6.3 Inserting an   
4351  Array Field into a
4352  Compound Type:
4353  NF90\_INSERT\_ARRAY\_COM
4354  POUND](#NF90_005fINSERT_
4355  005fARRAY_005fCOMPOUND)
4356 
4357  [5.6.4 Learn About a   
4358  Compound Type:
4359  NF90\_INQ\_COMPOUND](#NF
4360  90_005fINQ_005fCOMPOUND)
4361 
4362  [5.6.5 Learn About a   
4363  Field of a Compound
4364  Type:
4365  NF90\_INQ\_COMPOUND\_FIE
4366  LD](#NF90_005fINQ_005fCO
4367  MPOUND_005fFIELD)
4368  ------------------------ ------------------------ ------------------------
4369 
4370 ------------------------------------------------------------------------
4371 
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  ----------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4375 
4376 ### 5.6.1 Creating a Compound Type: NF90\_DEF\_COMPOUND {.subsection}
4377 
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.
4380 
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
4385 compound type.
4386 
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
4391 Wyoming.
4392 
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.
4396 
4397 Usage {.heading}
4398 -----
4399 
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) |
4407 | | :: name |
4408 | | integer, intent(out) :: typeid |
4409 | | integer :: nf90_def_compound |
4410 | | ``` |
4411 +--------------------------------------+--------------------------------------+
4412 
4413  `NCID`
4414 
4415 : The groupid where this compound type will be created.
4416 
4417  `SIZE`
4418 
4419 : The size, in bytes, of the compound type.
4420 
4421  `NAME`
4422 
4423 : The name of the new compound type.
4424 
4425  `TYPEIDP`
4426 
4427 : The typeid of the new type will be placed here.
4428 
4429 Errors {.heading}
4430 ------
4431 
4432  `NF90_NOERR`
4433 
4434 : No error.
4435 
4436  `NF90_EBADID`
4437 
4438 : Bad group id.
4439 
4440  `NF90_ENAMEINUSE`
4441 
4442 : That name is in use. Compound type names must be unique in the
4443  data file.
4444 
4445  `NF90_EMAXNAME`
4446 
4447 : Name exceeds max length NF90\_MAX\_NAME.
4448 
4449  `NF90_EBADNAME`
4450 
4451 : Name contains illegal characters.
4452 
4453  `NF90_ENOTNC4`
4454 
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)).
4459 
4460  `NF90_ESTRICTNC3`
4461 
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)).
4465 
4466  `NF90_EHDFERR`
4467 
4468 : An error was reported by the HDF5 layer.
4469 
4470  `NF90_EPERM`
4471 
4472 : Attempt to write to a read-only file.
4473 
4474  `NF90_ENOTINDEFINE`
4475 
4476 : Not in define mode.
4477 
4478 Example {.heading}
4479 -------
4480 
4481 ------------------------------------------------------------------------
4482 
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  ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4486 
4487 ### 5.6.2 Inserting a Field into a Compound Type: NF90\_INSERT\_COMPOUND {.subsection}
4488 
4489 Insert a named field into a compound type.
4490 
4491 Usage {.heading}
4492 -----
4493 
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) |
4501 | | :: name |
4502 | | integer, intent(in) :: offset |
4503 | | integer, intent(in) :: field_typ |
4504 | | eid |
4505 | | integer :: nf90_insert_compound |
4506 | | ``` |
4507 +--------------------------------------+--------------------------------------+
4508 
4509  `TYPEID`
4510 
4511 : The typeid for this compound type, as returned by
4512  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4513 
4514  `NAME`
4515 
4516 : The name of the new field.
4517 
4518  `OFFSET`
4519 
4520 : Offset in byte from the beginning of the compound type for
4521  this field.
4522 
4523  `FIELD_TYPEID`
4524 
4525 : The type of the field to be inserted.
4526 
4527 Errors {.heading}
4528 ------
4529 
4530  `NF90_NOERR`
4531 
4532 : No error.
4533 
4534  `NF90_EBADID`
4535 
4536 : Bad group id.
4537 
4538  `NF90_ENAMEINUSE`
4539 
4540 : That name is in use. Field names must be unique within a
4541  compound type.
4542 
4543  `NF90_EMAXNAME`
4544 
4545 : Name exceed max length NF90\_MAX\_NAME.
4546 
4547  `NF90_EBADNAME`
4548 
4549 : Name contains illegal characters.
4550 
4551  `NF90_ENOTNC4`
4552 
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)).
4557 
4558  `NF90_ESTRICTNC3`
4559 
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)).
4563 
4564  `NF90_EHDFERR`
4565 
4566 : An error was reported by the HDF5 layer.
4567 
4568  `NF90_ENOTINDEFINE`
4569 
4570 : Not in define mode.
4571 
4572 Example {.heading}
4573 -------
4574 
4575 ------------------------------------------------------------------------
4576 
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  ------------------------------------------------------------------------------- ------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4580 
4581 ### 5.6.3 Inserting an Array Field into a Compound Type: NF90\_INSERT\_ARRAY\_COMPOUND {.subsection}
4582 
4583 Insert a named array field into a compound type.
4584 
4585 Usage {.heading}
4586 -----
4587 
4588 +--------------------------------------+--------------------------------------+
4589 |   | ``` {.example} |
4590 | | function nf90_insert_array_compoun |
4591 | | d(ncid, xtype, name, offset, field_t |
4592 | | ypeid, & |
4593 | | ndims, dim_sizes) |
4594 | | integer, intent(in) :: ncid |
4595 | | integer, intent(in) :: xtype |
4596 | | character (len = *), intent(in) |
4597 | | :: name |
4598 | | integer, intent(in) :: offset |
4599 | | integer, intent(in) :: field_typ |
4600 | | eid |
4601 | | integer, intent(in) :: ndims |
4602 | | integer, intent(in) :: dim_sizes |
4603 | | integer :: nf90_insert_array_com |
4604 | | pound |
4605 | | ``` |
4606 +--------------------------------------+--------------------------------------+
4607 
4608  `NCID`
4609 
4610 : The ID of the file that contains the array type and the
4611  compound type.
4612 
4613  `XTYPE`
4614 
4615 : The typeid for this compound type, as returned by
4616  nf90\_def\_compound, or nf90\_inq\_var.
4617 
4618  `NAME`
4619 
4620 : The name of the new field.
4621 
4622  `OFFSET`
4623 
4624 : Offset in byte from the beginning of the compound type for
4625  this field.
4626 
4627  `FIELD_TYPEID`
4628 
4629 : The base type of the array to be inserted.
4630 
4631  `NDIMS`
4632 
4633 : The number of dimensions for the array to be inserted.
4634 
4635  `DIM_SIZES`
4636 
4637 : An array containing the sizes of each dimension.
4638 
4639 Errors {.heading}
4640 ------
4641 
4642  `NF90_NOERR`
4643 
4644 : No error.
4645 
4646  `NF90_EBADID`
4647 
4648 : Bad group id.
4649 
4650  `NF90_ENAMEINUSE`
4651 
4652 : That name is in use. Field names must be unique within a
4653  compound type.
4654 
4655  `NF90_EMAXNAME`
4656 
4657 : Name exceed max length NF90\_MAX\_NAME.
4658 
4659  `NF90_EBADNAME`
4660 
4661 : Name contains illegal characters.
4662 
4663  `NF90_ENOTNC4`
4664 
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)).
4669 
4670  `NF90_ESTRICTNC3`
4671 
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)).
4675 
4676  `NF90_EHDFERR`
4677 
4678 : An error was reported by the HDF5 layer.
4679 
4680  `NF90_ENOTINDEFINE`
4681 
4682 : Not in define mode.
4683 
4684  `NF90_ETYPEDEFINED`
4685 
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.
4690 
4691 Example {.heading}
4692 -------
4693 
4694 ------------------------------------------------------------------------
4695 
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  ----------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4699 
4700 ### 5.6.4 Learn About a Compound Type: NF90\_INQ\_COMPOUND {.subsection}
4701 
4702 Get the number of fields, length in bytes, and name of a compound type.
4703 
4704 In addtion to the NF90\_INQ\_COMPOUND function, three additional
4705 functions are provided which get only the name, size, and number of
4706 fields.
4707 
4708 Usage {.heading}
4709 -----
4710 
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) |
4718 | | :: name |
4719 | | integer, intent(out) :: size |
4720 | | integer, intent(out) :: nfields |
4721 | | integer :: nf90_inq_compound |
4722 | | |
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) |
4728 | | :: name |
4729 | | integer :: nf90_inq_compound_nam |
4730 | | e |
4731 | | |
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 |
4738 | | e |
4739 | | |
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 |
4746 | | elds |
4747 | | ``` |
4748 +--------------------------------------+--------------------------------------+
4749 
4750  `NCID`
4751 
4752 : The ID of any group in the file that contains the compound type.
4753 
4754  `XTYPE`
4755 
4756 : The typeid for this compound type, as returned by
4757  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4758 
4759  `NAME`
4760 
4761 : Character array which will get the name of the compound type. It
4762  will have a maximum length of NF90\_MAX\_NAME.
4763 
4764  `SIZEP`
4765 
4766 : The size of the compound type in bytes will be put here.
4767 
4768  `NFIELDSP`
4769 
4770 : The number of fields in the compound type will be placed here.
4771 
4772 Return Codes {.heading}
4773 ------------
4774 
4775  `NF90_NOERR`
4776 
4777 : No error.
4778 
4779  `NF90_EBADID`
4780 
4781 : Couldn’t find this ncid.
4782 
4783  `NF90_ENOTNC4`
4784 
4785 : Not a netCDF-4/HDF5 file.
4786 
4787  `NF90_ESTRICTNC3`
4788 
4789 : A netCDF-4/HDF5 file, but with CLASSIC\_MODEL. No user defined types
4790  are allowed in the classic model.
4791 
4792  `NF90_EBADTYPE`
4793 
4794 : This type not a compound type.
4795 
4796  `NF90_EBADTYPEID`
4797 
4798 : Bad type id.
4799 
4800  `NF90_EHDFERR`
4801 
4802 : An error was reported by the HDF5 layer.
4803 
4804 Example {.heading}
4805 -------
4806 
4807 ------------------------------------------------------------------------
4808 
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  ---------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ---------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4812 
4813 ### 5.6.5 Learn About a Field of a Compound Type: NF90\_INQ\_COMPOUND\_FIELD {.subsection}
4814 
4815 Get information about one of the fields of a compound type.
4816 
4817 Usage {.heading}
4818 -----
4819 
4820 +--------------------------------------+--------------------------------------+
4821 |   | ``` {.example} |
4822 | | function nf90_inq_compound_field(n |
4823 | | cid, xtype, fieldid, name, offset, & |
4824 | | field_typeid, ndims, dim_size |
4825 | | s) |
4826 | | integer, intent(in) :: ncid |
4827 | | integer, intent(in) :: xtype |
4828 | | integer, intent(in) :: fieldid |
4829 | | character (len = *), intent(out) |
4830 | | :: name |
4831 | | integer, intent(out) :: offset |
4832 | | integer, intent(out) :: field_ty |
4833 | | peid |
4834 | | integer, intent(out) :: ndims |
4835 | | integer, intent(out) :: dim_size |
4836 | | s |
4837 | | integer :: nf90_inq_compound_fie |
4838 | | ld |
4839 | | |
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) |
4846 | | :: name |
4847 | | integer :: nf90_inq_compound_fie |
4848 | | ldname |
4849 | | |
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) |
4855 | | :: name |
4856 | | integer, intent(out) :: fieldid |
4857 | | integer :: nf90_inq_compound_fie |
4858 | | ldindex |
4859 | | |
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 |
4867 | | ldoffset |
4868 | | |
4869 | | function nf90_inq_compound_fieldty |
4870 | | pe(ncid, xtype, fieldid, field_typei |
4871 | | d) |
4872 | | integer, intent(in) :: ncid |
4873 | | integer, intent(in) :: xtype |
4874 | | integer, intent(in) :: fieldid |
4875 | | integer, intent(out) :: field_ty |
4876 | | peid |
4877 | | integer :: nf90_inq_compound_fie |
4878 | | ldtype |
4879 | | |
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 |
4887 | | ldndims |
4888 | | |
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 |
4895 | | s |
4896 | | integer :: nf90_inq_cmp_fielddim |
4897 | | _sizes |
4898 | | ``` |
4899 +--------------------------------------+--------------------------------------+
4900 
4901  `NCID`
4902 
4903 : The groupid where this compound type exists.
4904 
4905  `XTYPE`
4906 
4907 : The typeid for this compound type, as returned by
4908  NF90\_DEF\_COMPOUND, or NF90\_INQ\_VAR.
4909 
4910  `FIELDID`
4911 
4912 : A one-based index number specifying a field in the compound type.
4913 
4914  `NAME`
4915 
4916 : A character array which will get the name of the field. The name
4917  will be NF90\_MAX\_NAME characters, at most.
4918 
4919  `OFFSETP`
4920 
4921 : An integer which will get the offset of the field.
4922 
4923  `FIELD_TYPEID`
4924 
4925 : An integer which will get the typeid of the field.
4926 
4927  `NDIMSP`
4928 
4929 : An integer which will get the number of dimensions of the field.
4930 
4931  `DIM_SIZESP`
4932 
4933 : An integer array which will get the dimension sizes of the field.
4934 
4935 Errors {.heading}
4936 ------
4937 
4938  `NF90_NOERR`
4939 
4940 : No error.
4941 
4942  `NF90_EBADTYPEID`
4943 
4944 : Bad type id.
4945 
4946  `NF90_EHDFERR`
4947 
4948 : An error was reported by the HDF5 layer.
4949 
4950 Example {.heading}
4951 -------
4952 
4953 ------------------------------------------------------------------------
4954 
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  -------------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
4958 
4959 5.7 Variable Length Array Introduction {.section}
4960 --------------------------------------
4961 
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.
4965 
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.
4969 
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
4972 for the platform.
4973 
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.
4978 
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
4982 each VLEN.
4983 
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.
4987 
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
4990 the actual data.
4991 
4992  ------------------------ ------------------------ ------------------------
4993  [5.7.1 Define a Variable   
4994  Length Array (VLEN):
4995  NF90\_DEF\_VLEN](#NF90_0
4996  05fDEF_005fVLEN)
4997 
4998  [5.7.2 Learning about a   
4999  Variable Length Array
5000  (VLEN) Type:
5001  NF90\_INQ\_VLEN](#NF90_0
5002  05fINQ_005fVLEN)
5003 
5004  [5.7.3 Releasing Memory   
5005  for a Variable Length
5006  Array (VLEN) Type:
5007  NF90\_FREE\_VLEN](#NF90_
5008  005fFREE_005fVLEN)
5009  ------------------------ ------------------------ ------------------------
5010 
5011 ------------------------------------------------------------------------
5012 
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  ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5016 
5017 ### 5.7.1 Define a Variable Length Array (VLEN): NF90\_DEF\_VLEN {.subsection}
5018 
5019 Use this function to define a variable length array type.
5020 
5021 Usage {.heading}
5022 -----
5023 
5024 +--------------------------------------+--------------------------------------+
5025 |   | ``` {.example} |
5026 | | function nf90_def_vlen(ncid, name, |
5027 | | base_typeid, xtypeid) |
5028 | | integer, intent(in) :: ncid |
5029 | | character (len = *), intent(in) |
5030 | | :: name |
5031 | | integer, intent(in) :: base_type |
5032 | | id |
5033 | | integer, intent(out) :: xtypeid |
5034 | | integer :: nf90_def_vlen |
5035 | | ``` |
5036 +--------------------------------------+--------------------------------------+
5037 
5038  `NCID`
5039 
5040 : The ncid of the file to create the VLEN type in.
5041 
5042  `NAME`
5043 
5044 : A name for the VLEN type.
5045 
5046  `BASE_TYPEID`
5047 
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
5050  defined type.
5051 
5052  `XTYPEP`
5053 
5054 : The typeid of the new VLEN type will be set here.
5055 
5056 Errors {.heading}
5057 ------
5058 
5059  `NF90_NOERR`
5060 
5061 : No error.
5062 
5063  `NF90_EMAXNAME`
5064 
5065 : NF90\_MAX\_NAME exceeded.
5066 
5067  `NF90_ENAMEINUSE`
5068 
5069 : Name is already in use.
5070 
5071  `NF90_EBADNAME`
5072 
5073 : Attribute or variable name contains illegal characters.
5074 
5075  `NF90_EBADID`
5076 
5077 : ncid invalid.
5078 
5079  `NF90_EBADGRPID`
5080 
5081 : Group ID part of ncid was invalid.
5082 
5083  `NF90_EINVAL`
5084 
5085 : Size is invalid.
5086 
5087  `NF90_ENOMEM`
5088 
5089 : Out of memory.
5090 
5091 Example {.heading}
5092 -------
5093 
5094 ------------------------------------------------------------------------
5095 
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  ------------------------------------------------------------------------ --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5099 
5100 ### 5.7.2 Learning about a Variable Length Array (VLEN) Type: NF90\_INQ\_VLEN {.subsection}
5101 
5102 Use this type to learn about a vlen.
5103 
5104 Usage {.heading}
5105 -----
5106 
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) |
5114 | | :: name |
5115 | | integer, intent(out) :: datum_si |
5116 | | ze |
5117 | | integer, intent(out) :: base_nc_ |
5118 | | type |
5119 | | integer :: nf90_inq_vlen |
5120 | | ``` |
5121 +--------------------------------------+--------------------------------------+
5122 
5123  `NCID`
5124 
5125 : The ncid of the file that contains the VLEN type.
5126 
5127  `XTYPE`
5128 
5129 : The type of the VLEN to inquire about.
5130 
5131  `NAME`
5132 
5133 : The name of the VLEN type. The name will be NF90\_MAX\_NAME
5134  characters or less.
5135 
5136  `DATUM_SIZEP`
5137 
5138 : A pointer to a size\_t, this will get the size of one element of
5139  this vlen.
5140 
5141  `BASE_NF90_TYPEP`
5142 
5143 : An integer that will get the type of the VLEN base type. (In other
5144  words, what type is this a VLEN of?)
5145 
5146 Errors {.heading}
5147 ------
5148 
5149  `NF90_NOERR`
5150 
5151 : No error.
5152 
5153  `NF90_EBADTYPE`
5154 
5155 : Can’t find the typeid.
5156 
5157  `NF90_EBADID`
5158 
5159 : ncid invalid.
5160 
5161  `NF90_EBADGRPID`
5162 
5163 : Group ID part of ncid was invalid.
5164 
5165 Example {.heading}
5166 -------
5167 
5168 ------------------------------------------------------------------------
5169 
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  ------------------------------------------------------------------------ ---------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5173 
5174 ### 5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type: NF90\_FREE\_VLEN {.subsection}
5175 
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.
5180 
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.
5185 
5186 Usage {.heading}
5187 -----
5188 
5189 +--------------------------------------+--------------------------------------+
5190 |   | ``` {.example} |
5191 | | function nf90_free_vlen(vl) |
5192 | | character (len = *), intent(in) |
5193 | | :: vlen |
5194 | | integer :: nf90_free_vlen |
5195 | | end function nf90_free_vlen |
5196 | | ``` |
5197 +--------------------------------------+--------------------------------------+
5198 
5199  `VL`
5200 
5201 : The variable length array structure which is to be freed.
5202 
5203 Errors {.heading}
5204 ------
5205 
5206  `NF90_NOERR`
5207 
5208 : No error.
5209 
5210  `NF90_EBADTYPE`
5211 
5212 : Can’t find the typeid.
5213 
5214 Example {.heading}
5215 -------
5216 
5217 ------------------------------------------------------------------------
5218 
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  ------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5222 
5223 5.8 Opaque Type Introduction {.section}
5224 ----------------------------
5225 
5226 NetCDF-4 added support for the opaque type. This is not supported in
5227 classic or 64-bit offset files.
5228 
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.
5233 
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.
5238 
5239  ------------------------ ------------------------ ------------------------
5240  [5.8.1 Creating Opaque   
5241  Types:
5242  NF90\_DEF\_OPAQUE](#NF90
5243  _005fDEF_005fOPAQUE)
5244 
5245  [5.8.2 Learn About an   
5246  Opaque Type:
5247  NF90\_INQ\_OPAQUE](#NF90
5248  _005fINQ_005fOPAQUE)
5249  ------------------------ ------------------------ ------------------------
5250 
5251 ------------------------------------------------------------------------
5252 
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  -------------------------------------------------------------- ---------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5256 
5257 ### 5.8.1 Creating Opaque Types: NF90\_DEF\_OPAQUE {.subsection}
5258 
5259 Create an opaque type. Provide a size and a name.
5260 
5261 Usage {.heading}
5262 -----
5263 
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) |
5271 | | :: name |
5272 | | integer, intent(out) :: xtype |
5273 | | integer :: nf90_def_opaque |
5274 | | ``` |
5275 +--------------------------------------+--------------------------------------+
5276 
5277  `NCID`
5278 
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.
5281 
5282  `NAME`
5283 
5284 : The name for this type. Must be shorter than NF90\_MAX\_NAME.
5285 
5286  `SIZE`
5287 
5288 : The size of each opaque object.
5289 
5290  `TYPEIDP`
5291 
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).
5295 
5296 Errors {.heading}
5297 ------
5298 
5299  `NF90_NOERR`
5300 
5301 : No error.
5302 
5303  `NF90_EBADTYPEID`
5304 
5305 : Bad typeid.
5306 
5307  `NF90_EBADFIELDID`
5308 
5309 : Bad fieldid.
5310 
5311  `NF90_EHDFERR`
5312 
5313 : An error was reported by the HDF5 layer.
5314 
5315 Example {.heading}
5316 -------
5317 
5318  ------------------------ ------------------------ ------------------------
5319  [5.8.2 Learn About an   
5320  Opaque Type:
5321  NF90\_INQ\_OPAQUE](#NF90
5322  _005fINQ_005fOPAQUE)
5323  ------------------------ ------------------------ ------------------------
5324 
5325 ------------------------------------------------------------------------
5326 
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  -------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5330 
5331 ### 5.8.2 Learn About an Opaque Type: NF90\_INQ\_OPAQUE {.subsection}
5332 
5333 Given a typeid, get the information about an opaque type.
5334 
5335 Usage {.heading}
5336 -----
5337 
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) |
5345 | | :: name |
5346 | | integer, intent(out) :: size |
5347 | | integer :: nf90_inq_opaque |
5348 | | ``` |
5349 +--------------------------------------+--------------------------------------+
5350 
5351  `NCID`
5352 
5353 : The ncid for the group containing the opaque type.
5354 
5355  `XTYPE`
5356 
5357 : The typeid for this opaque type, as returned by NF90\_DEF\_COMPOUND,
5358  or NF90\_INQ\_VAR.
5359 
5360  `NAME`
5361 
5362 : The name of the opaque type will be copied here. It will be
5363  NF90\_MAX\_NAME bytes or less.
5364 
5365  `SIZEP`
5366 
5367 : The size of the opaque type will be copied here.
5368 
5369 Errors {.heading}
5370 ------
5371 
5372  `NF90_NOERR`
5373 
5374 : No error.
5375 
5376  `NF90_EBADTYPEID`
5377 
5378 : Bad typeid.
5379 
5380  `NF90_EBADFIELDID`
5381 
5382 : Bad fieldid.
5383 
5384  `NF90_EHDFERR`
5385 
5386 : An error was reported by the HDF5 layer.
5387 
5388 Example {.heading}
5389 -------
5390 
5391 ------------------------------------------------------------------------
5392 
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  -------------------------------------------------------------------------- -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ------------------------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5396 
5397 5.9 Enum Type Introduction {.section}
5398 --------------------------
5399 
5400 NetCDF-4 added support for the enum type. This is not supported in
5401 classic or 64-bit offset files.
5402 
5403  ------------------------ ------------------------ ------------------------
5404  [5.9.1 Creating a Enum   
5405  Type:
5406  NF90\_DEF\_ENUM](#NF90_0
5407  05fDEF_005fENUM)
5408 
5409  [5.9.2 Inserting a Field   
5410  into a Enum Type:
5411  NF90\_INSERT\_ENUM](#NF9
5412  0_005fINSERT_005fENUM)
5413 
5414  [5.9.3 Learn About a   
5415  Enum Type:
5416  NF90\_INQ\_ENUM](#NF90_0
5417  05fINQ_005fENUM)
5418 
5419  [5.9.4 Learn the Name of   
5420  a Enum Type:
5421  nf90\_inq\_enum\_member]
5422  (#NF90_005fINQ_005fENUM_
5423  005fMEMBER)
5424 
5425  [5.9.5 Learn the Name of   
5426  a Enum Type:
5427  NF90\_INQ\_ENUM\_IDENT](
5428  #NF90_005fINQ_005fENUM_0
5429  05fIDENT)
5430  ------------------------ ------------------------ ------------------------
5431 
5432 ------------------------------------------------------------------------
5433 
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  ------------------------------------------------------------ ----------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5437 
5438 ### 5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM {.subsection}
5439 
5440 Create an enum type. Provide an ncid, a name, and a base integer type.
5441 
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.
5446 
5447 Usage {.heading}
5448 -----
5449 
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 |
5456 | | id |
5457 | | character (len = *), intent(in) |
5458 | | :: name |
5459 | | integer, intent(out) :: typeid |
5460 | | integer :: nf90_def_enum |
5461 | | ``` |
5462 +--------------------------------------+--------------------------------------+
5463 
5464  `NCID`
5465 
5466 : The groupid where this compound type will be created.
5467 
5468  `BASE_TYPEID`
5469 
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.
5473 
5474  `NAME`
5475 
5476 : The name of the new enum type.
5477 
5478  `TYPEIDP`
5479 
5480 : The typeid of the new type will be placed here.
5481 
5482 Errors {.heading}
5483 ------
5484 
5485  `NF90_NOERR`
5486 
5487 : No error.
5488 
5489  `NF90_EBADID`
5490 
5491 : Bad group id.
5492 
5493  `NF90_ENAMEINUSE`
5494 
5495 : That name is in use. Compound type names must be unique in the
5496  data file.
5497 
5498  `NF90_EMAXNAME`
5499 
5500 : Name exceeds max length NF90\_MAX\_NAME.
5501 
5502  `NF90_EBADNAME`
5503 
5504 : Name contains illegal characters.
5505 
5506  `NF90_ENOTNC4`
5507 
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)).
5512 
5513  `NF90_ESTRICTNC3`
5514 
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)).
5518 
5519  `NF90_EHDFERR`
5520 
5521 : An error was reported by the HDF5 layer.
5522 
5523  `NF90_EPERM`
5524 
5525 : Attempt to write to a read-only file.
5526 
5527  `NF90_ENOTINDEFINE`
5528 
5529 : Not in define mode.
5530 
5531 Example {.heading}
5532 -------
5533 
5534 ------------------------------------------------------------------------
5535 
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  ------------------------------------------------------------------------ -------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5539 
5540 ### 5.9.2 Inserting a Field into a Enum Type: NF90\_INSERT\_ENUM {.subsection}
5541 
5542 Insert a named member into a enum type.
5543 
5544 Usage {.heading}
5545 -----
5546 
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) |
5554 | | :: name |
5555 | | integer, intent(in) :: value |
5556 | | integer :: nf90_insert_enum |
5557 | | ``` |
5558 +--------------------------------------+--------------------------------------+
5559 
5560  `NCID`
5561 
5562 : The ncid of the group which contains the type.
5563 
5564  `TYPEID`
5565 
5566 : The typeid for this enum type, as returned by nf90\_def\_enum,
5567  or nf90\_inq\_var.
5568 
5569  `IDENTIFIER`
5570 
5571 : The identifier of the new member.
5572 
5573  `VALUE`
5574 
5575 : The value that is to be associated with this member.
5576 
5577 Errors {.heading}
5578 ------
5579 
5580  `NF90_NOERR`
5581 
5582 : No error.
5583 
5584  `NF90_EBADID`
5585 
5586 : Bad group id.
5587 
5588  `NF90_ENAMEINUSE`
5589 
5590 : That name is in use. Field names must be unique within a enum type.
5591 
5592  `NF90_EMAXNAME`
5593 
5594 : Name exceed max length NF90\_MAX\_NAME.
5595 
5596  `NF90_EBADNAME`
5597 
5598 : Name contains illegal characters.
5599 
5600  `NF90_ENOTNC4`
5601 
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)).
5606 
5607  `NF90_ESTRICTNC3`
5608 
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)).
5612 
5613  `NF90_EHDFERR`
5614 
5615 : An error was reported by the HDF5 layer.
5616 
5617  `NF90_ENOTINDEFINE`
5618 
5619 : Not in define mode.
5620 
5621 Example {.heading}
5622 -------
5623 
5624 ------------------------------------------------------------------------
5625 
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  --------------------------------------------------------------------------- ------------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5629 
5630 ### 5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM {.subsection}
5631 
5632 Get information about a user-defined enumeration type.
5633 
5634 Usage {.heading}
5635 -----
5636 
5637 +--------------------------------------+--------------------------------------+
5638 |   | ``` {.example} |
5639 | | function nf90_inq_enum(ncid, xtype |
5640 | | , name, base_nc_type, base_size, num |
5641 | | _members) |
5642 | | integer, intent(in) :: ncid |
5643 | | integer, intent(in) :: xtype |
5644 | | character (len = *), intent(out) |
5645 | | :: name |
5646 | | integer, intent(out) :: base_nc_ |
5647 | | type |
5648 | | integer, intent(out) :: base_siz |
5649 | | e |
5650 | | integer, intent(out) :: num_memb |
5651 | | ers |
5652 | | integer :: nf90_inq_enum |
5653 | | ``` |
5654 +--------------------------------------+--------------------------------------+
5655 
5656  `NCID`
5657 
5658 : The group ID of the group which holds the enum type.
5659 
5660  `XTYPE`
5661 
5662 : The typeid for this enum type, as returned by NF90\_DEF\_ENUM,
5663  or NF90\_INQ\_VAR.
5664 
5665  `NAME`
5666 
5667 : Character array which will get the name. It will have a maximum
5668  length of NF90\_MAX\_NAME.
5669 
5670  `BASE_NF90_TYPE`
5671 
5672 : An integer which will get the base integer type of this enum.
5673 
5674  `BASE_SIZE`
5675 
5676 : An integer which will get the size (in bytes) of the base integer
5677  type of this enum.
5678 
5679  `NUM_MEMBERS`
5680 
5681 : An integer which will get the number of members defined for this
5682  enumeration type.
5683 
5684 Errors {.heading}
5685 ------
5686 
5687  `NF90_NOERR`
5688 
5689 : No error.
5690 
5691  `NF90_EBADTYPEID`
5692 
5693 : Bad type id.
5694 
5695  `NF90_EHDFERR`
5696 
5697 : An error was reported by the HDF5 layer.
5698 
5699 Example {.heading}
5700 -------
5701 
5702 ------------------------------------------------------------------------
5703 
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  ------------------------------------------------------------------------ ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5707 
5708 ### 5.9.4 Learn the Name of a Enum Type: nf90\_inq\_enum\_member {.subsection}
5709 
5710 Get information about a member of an enum type.
5711 
5712 Usage {.heading}
5713 -----
5714 
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) |
5723 | | :: name |
5724 | | integer, intent(in) :: value |
5725 | | integer :: nf90_inq_enum_member |
5726 | | ``` |
5727 +--------------------------------------+--------------------------------------+
5728 
5729  `NCID`
5730 
5731 : The groupid where this enum type exists.
5732 
5733  `XTYPE`
5734 
5735 : The typeid for this enum type.
5736 
5737  `IDX`
5738 
5739 : The one-based index number for the member of interest.
5740 
5741  `NAME`
5742 
5743 : A character array which will get the name of the member. It will
5744  have a maximum length of NF90\_MAX\_NAME.
5745 
5746  `VALUE`
5747 
5748 : An integer that will get the value associated with this member.
5749 
5750 Errors {.heading}
5751 ------
5752 
5753  `NF90_NOERR`
5754 
5755 : No error.
5756 
5757  `NF90_EBADTYPEID`
5758 
5759 : Bad type id.
5760 
5761  `NF90_EHDFERR`
5762 
5763 : An error was reported by the HDF5 layer.
5764 
5765 Example {.heading}
5766 -------
5767 
5768 ------------------------------------------------------------------------
5769 
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  ----------------------------------------------------------------------------------- -------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------------- ------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5773 
5774 ### 5.9.5 Learn the Name of a Enum Type: NF90\_INQ\_ENUM\_IDENT {.subsection}
5775 
5776 Get the name which is associated with an enum member value.
5777 
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.
5780 
5781 Usage {.heading}
5782 -----
5783 
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 |
5793 | | ``` |
5794 +--------------------------------------+--------------------------------------+
5795 
5796  `NCID`
5797 
5798 : The groupid where this enum type exists.
5799 
5800  `XTYPE`
5801 
5802 : The typeid for this enum type.
5803 
5804  `VALUE`
5805 
5806 : The value for which an identifier is sought.
5807 
5808  `IDENTIFIER`
5809 
5810 : A character array that will get the identifier. It will have a
5811  maximum length of NF90\_MAX\_NAME.
5812 
5813 Return Code {.heading}
5814 -----------
5815 
5816  `NF90_NOERR`
5817 
5818 : No error.
5819 
5820  `NF90_EBADTYPEID`
5821 
5822 : Bad type id, or not an enum type.
5823 
5824  `NF90_EHDFERR`
5825 
5826 : An error was reported by the HDF5 layer.
5827 
5828  `NF90_EINVAL`
5829 
5830 : The value was not found in the enum.
5831 
5832 Example {.heading}
5833 -------
5834 
5835 ------------------------------------------------------------------------
5836 
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  ---------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------ ----------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5840 
5841 6. Variables {.chapter}
5842 ============
5843 
5844  ------------------------ ------------------------ ------------------------
5845  [6.1 Variables   
5846  Introduction](#Variables
5847  -Introduction)
5848 
5849  [6.2 Language Types   
5850  Corresponding to netCDF
5851  external data
5852  types](#Language_002dTyp
5853  es)
5854 
5855  [6.3 Create a Variable:    Create a Variable
5856  `NF90_DEF_VAR`](#NF90_00
5857  5fDEF_005fVAR)
5858 
5859  [6.4 Define Fill   
5860  Parameters for a
5861  Variable:
5862  `nf90_def_var_fill`](#NF
5863  90_005fDEF_005fVAR_005fF
5864  ILL)
5865 
5866  [6.5 Learn About Fill   
5867  Parameters for a
5868  Variable:
5869  `NF90_INQ_VAR_FILL`](#NF
5870  90_005fINQ_005fVAR_005fF
5871  ILL)
5872 
5873  [6.6 Get Information    Get Var Metadata
5874  about a Variable from
5875  Its ID:
5876  NF90\_INQUIRE\_VARIABLE]
5877  (#NF90_005fINQUIRE_005fV
5878  ARIABLE)
5879 
5880  [6.7 Get the ID of a   
5881  variable from the name:
5882  NF90\_INQ\_VARID](#NF90_
5883  005fINQ_005fVARID)
5884 
5885  [6.8 Writing Data    Write data
5886  Values:
5887  NF90\_PUT\_VAR](#NF90_00
5888  5fPUT_005fVAR)
5889 
5890  [6.9 Reading Data    Read data
5891  Values:
5892  NF90\_GET\_VAR](#NF90_00
5893  5fGET_005fVAR)
5894 
5895  [6.10 Reading and   
5896  Writing Character String
5897  Values](#Reading-and-Wri
5898  ting-Character-String-Va
5899  lues)
5900 
5901  [6.11 Fill    What’s Written Where
5902  Values](#Fill-Values) there’s No Data?
5903 
5904  [6.12   
5905  NF90\_RENAME\_VAR](#NF90
5906  _005fRENAME_005fVAR)
5907 
5908  [6.13 Change between   
5909  Collective and
5910  Independent Parallel
5911  Access:
5912  NF90\_VAR\_PAR\_ACCESS](
5913  #NF90_005fVAR_005fPAR_00
5914  5fACCESS)
5915  ------------------------ ------------------------ ------------------------
5916 
5917 ------------------------------------------------------------------------
5918 
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  ------------------------------------------------------------ ----------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5922 
5923 6.1 Variables Introduction {.section}
5924 --------------------------
5925 
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.
5931 
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.
5936 
5937 A netCDF variable in an open netCDF dataset is referred to by a small
5938 integer called a variable ID.
5939 
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.
5944 
5945 Attributes (see [Attributes](#Attributes)) may be associated with a
5946 variable to specify such properties as units.
5947 
5948 Operations supported on variables are:
5949 
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
5953  from its ID.
5954 - Put a data value into a variable, given variable ID, indices,
5955  and value.
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.
5968 
5969 ------------------------------------------------------------------------
5970 
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  ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
5974 
5975 6.2 Language Types Corresponding to netCDF external data types {.section}
5976 --------------------------------------------------------------
5977 
5978 The following table gives the netCDF external data types and the
5979 corresponding type constants for defining variables in the FORTRAN
5980 interface:
5981 
5982  -------- ---------------------- ------
5983  Type FORTRAN API Mnemonic Bits
5984  byte NF90\_BYTE 8
5985  char NF90\_CHAR 8
5986  short NF90\_SHORT 16
5987  int NF90\_INT 32
5988  float NF90\_FLOAT 32
5989  double NF90\_DOUBLE 64
5990  -------- ---------------------- ------
5991 
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
5997 corresponding type.
5998 
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
6001 library.
6002 
6003 ------------------------------------------------------------------------
6004 
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  --------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6008 
6009 6.3 Create a Variable: `NF90_DEF_VAR` {.section}
6010 -------------------------------------
6011 
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.
6016 
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.
6022 
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
6028 are reduced.
6029 
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.
6033 
6034 Usage {.heading}
6035 -----
6036 
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) : |
6047 | | : name |
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) :: |
6053 | | contiguous |
6054 | | integer, optional, dimension(:), |
6055 | | intent(in) :: chunksizes |
6056 | | integer, optional, intent(in) :: |
6057 | | deflate_level |
6058 | | logical, optional, intent(in) :: |
6059 | | shuffle, fletcher32 |
6060 | | integer, optional, intent(in) :: |
6061 | | endianness |
6062 | | integer, optional, intent(in) :: |
6063 | | cache_size, cache_nelems, cache_pre |
6064 | | emption |
6065 | | integer |
6066 | | :: nf90_def_var |
6067 | | ``` |
6068 +--------------------------------------+--------------------------------------+
6069 
6070  `ncid`
6071 
6072 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6073 
6074  `name`
6075 
6076 : Variable name.
6077 
6078  `xtype`
6079 
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.
6087 
6088  `dimids`
6089 
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.
6093 
6094  If an integer is passed for this parameter, a 1-D variable
6095  is created.
6096 
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.
6099 
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.
6104 
6105  This argument is optional, and if absent specifies a scalar with
6106  no dimensions.
6107 
6108  `varid`
6109 
6110 : Returned variable ID.
6111 
6112  `storage`
6113 
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
6117  contiguous storage.
6118 
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
6122  not called.
6123 
6124  By default contiguous storage is used for fix-sized variables when
6125  conpression, chunking, shuffle, and checksums are not used.
6126 
6127  `chunksizes`
6128 
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.
6132 
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.)
6137 
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.
6142 
6143  `shuffle`
6144 
6145 : If non-zero, turn on the shuffle filter.
6146 
6147  `deflate_level`
6148 
6149 : If the deflate parameter is non-zero, set the deflate level to
6150  this value. Must be between 1 and 9.
6151 
6152  `fletcher32`
6153 
6154 : Set to true to turn on fletcher32 checksums for this variable.
6155 
6156  `endianness`
6157 
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.
6161 
6162  `cache_size`
6163 
6164 : The size of the per-variable cache in MegaBytes.
6165 
6166  `cache_nelems`
6167 
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).
6170 
6171  `cache_preemption`
6172 
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.
6179 
6180 Return Codes {.heading}
6181 ------------
6182 
6183 NF90\_DEF\_VAR returns the value NF90\_NOERR if no errors occurred.
6184 Otherwise, the returned status indicates an error.
6185 
6186 - NF90\_EBADNAME The specified variable name is the name of another
6187  existing variable.
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
6201  netCDF dataset.
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
6213  or write.)
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.
6220 
6221 Example {.heading}
6222 -------
6223 
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:
6227 
6228 +--------------------------------------+--------------------------------------+
6229 |   | ``` {.example} |
6230 | | use netcdf |
6231 | | implicit none |
6232 | | integer :: status, ncid |
6233 | | integer :: LonDimId, LatDimId, Time |
6234 | | DimId |
6235 | | integer :: RhVarId |
6236 | | ... |
6237 | | status = nf90_create("foo.nc", nf90 |
6238 | | _NoClobber, ncid) |
6239 | | if(status /= nf90_NoErr) call handl |
6240 | | e_error(status) |
6241 | | ... |
6242 | | ! Define the dimensions |
6243 | | status = nf90_def_dim(ncid, "lat", |
6244 | | 5, LatDimId) |
6245 | | if(status /= nf90_NoErr) call handl |
6246 | | e_error(status) |
6247 | | status = nf90_def_dim(ncid, "lon", |
6248 | | 10, LonDimId) |
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) |
6255 | | ... |
6256 | | ! Define the variable |
6257 | | status = nf90_def_var(ncid, "rh", n |
6258 | | f90_double, & |
6259 | | (/ LonDimId, |
6260 | | LatDimID, TimeDimID /), RhVarId) |
6261 | | if(status /= nf90_NoErr) call handl |
6262 | | e_error(status) |
6263 | | ``` |
6264 +--------------------------------------+--------------------------------------+
6265 
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.
6268 
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)) |
6276 | | |
6277 | | ! Define the dimensions. |
6278 | | call check(nf90_def_dim(ncid, "x", |
6279 | | NX, x_dimid)) |
6280 | | call check(nf90_def_dim(ncid, "y", |
6281 | | NY, y_dimid)) |
6282 | | dimids = (/ y_dimid, x_dimid /) |
6283 | | |
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.)) |
6300 | | ``` |
6301 +--------------------------------------+--------------------------------------+
6302 
6303 ------------------------------------------------------------------------
6304 
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  ----------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6308 
6309 6.4 Define Fill Parameters for a Variable: `nf90_def_var_fill` {.section}
6310 --------------------------------------------------------------
6311 
6312 The function NF90\_DEF\_VAR\_FILL sets the fill parameters for a
6313 variable in a netCDF-4 file.
6314 
6315 This function must be called after the variable is defined, but before
6316 NF90\_ENDDEF is called.
6317 
6318 Usage {.heading}
6319 -----
6320 
6321 +--------------------------------------+--------------------------------------+
6322 |   | ``` {.example} |
6323 | | NF90_DEF_VAR_FILL(INTEGER NCID, INTE |
6324 | | GER VARID, INTEGER NO_FILL, FILL_VAL |
6325 | | UE); |
6326 | | ``` |
6327 +--------------------------------------+--------------------------------------+
6328 
6329  `NCID`
6330 
6331 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6332 
6333  `VARID`
6334 
6335 : Variable ID.
6336 
6337  `NO_FILL`
6338 
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
6346  any time.
6347 
6348  `FILL_VALUE`
6349 
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.
6354 
6355 Return Codes {.heading}
6356 ------------
6357 
6358  `NF90_NOERR`
6359 
6360 : No error.
6361 
6362  `NF90_BADID`
6363 
6364 : Bad ncid.
6365 
6366  `NF90_ENOTNC4`
6367 
6368 : Not a netCDF-4 file.
6369 
6370  `NF90_ENOTVAR`
6371 
6372 : Can’t find this variable.
6373 
6374  `NF90_ELATEDEF`
6375 
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.
6380 
6381  `NF90_ENOTINDEFINE`
6382 
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)).
6387 
6388  `NF90_EPERM`
6389 
6390 : Attempt to create object in read-only file.
6391 
6392 Example {.heading}
6393 -------
6394 
6395 ------------------------------------------------------------------------
6396 
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  -------------------------------------------------------------------------------- ---------------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6400 
6401 6.5 Learn About Fill Parameters for a Variable: `NF90_INQ_VAR_FILL` {.section}
6402 -------------------------------------------------------------------
6403 
6404 The function NF90\_INQ\_VAR\_FILL returns the fill settings for a
6405 variable in a netCDF-4 file.
6406 
6407 Usage {.heading}
6408 -----
6409 
6410 +--------------------------------------+--------------------------------------+
6411 |   | ``` {.example} |
6412 | | NF90_INQ_VAR_FILL(INTEGER NCID, INTE |
6413 | | GER VARID, INTEGER NO_FILL, FILL_VAL |
6414 | | UE) |
6415 | | ``` |
6416 +--------------------------------------+--------------------------------------+
6417 
6418  `NCID`
6419 
6420 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6421 
6422  `VARID`
6423 
6424 : Variable ID.
6425 
6426  `NO_FILL`
6427 
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
6430 
6431  `FILL_VALUE`
6432 
6433 : This will get the fill value for this variable. This parameter will
6434  be ignored if it is NULL.
6435 
6436 Return Codes {.heading}
6437 ------------
6438 
6439  `NF90_NOERR`
6440 
6441 : No error.
6442 
6443  `NF90_BADID`
6444 
6445 : Bad ncid.
6446 
6447  `NF90_ENOTNC4`
6448 
6449 : Not a netCDF-4 file.
6450 
6451  `NF90_ENOTVAR`
6452 
6453 : Can’t find this variable.
6454 
6455 Example {.heading}
6456 -------
6457 
6458 ------------------------------------------------------------------------
6459 
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  -------------------------------------------------------------------------------- --------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6463 
6464 6.6 Get Information about a Variable from Its ID: NF90\_INQUIRE\_VARIABLE {.section}
6465 -------------------------------------------------------------------------
6466 
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.
6472 
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
6475 netCDF-4/HDF5 file.
6476 
6477 Usage {.heading}
6478 -----
6479 
6480 +--------------------------------------+--------------------------------------+
6481 |   | ``` {.example} |
6482 | | function nf90_inquire_variable(nci |
6483 | | d, varid, name, xtype, ndims, dimids |
6484 | | , nAtts, & |
6485 | | contiguous, chunksizes, defla |
6486 | | te_level, shuffle, fletcher32, endia |
6487 | | nness) |
6488 | | integer, intent(in) :: ncid, var |
6489 | | id |
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) : |
6497 | | : nAtts |
6498 | | logical, optional, intent(out) : |
6499 | | : contiguous |
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) : |
6507 | | : endianness |
6508 | | integer :: nf90_inquire_variable |
6509 | | ``` |
6510 +--------------------------------------+--------------------------------------+
6511 
6512  `ncid`
6513 
6514 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6515 
6516  `varid`
6517 
6518 : Variable ID.
6519 
6520  `name`
6521 
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.
6525 
6526  `xtype`
6527 
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.
6531 
6532  `ndims`
6533 
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.
6537 
6538  `dimids`
6539 
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.
6545 
6546  `natts`
6547 
6548 : Returned number of variable attributes assigned to this variable.
6549 
6550  `contiguous`
6551 
6552 : On return, set to NF90\_CONTIGUOUS if this variable uses contiguous
6553  storage, NF90\_CHUNKED if it uses chunked storage.
6554 
6555  `chunksizes`
6556 
6557 : An array of chunk sizes. The array must have the one element for
6558  each dimension in the variable.
6559 
6560  `shuffle`
6561 
6562 : True if the shuffle filter is turned on for this variable.
6563 
6564  `deflate_level`
6565 
6566 : The deflate\_level from 0 to 9. A value of zero indicates no
6567  deflation is in use.
6568 
6569  `fletcher32`
6570 
6571 : Set to true if the fletcher32 checksum filter is turned on for
6572  this variable.
6573 
6574  `endianness`
6575 
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.
6580 
6581 These functions return the value NF90\_NOERR if no errors occurred.
6582 Otherwise, the returned status indicates an error. Possible causes of
6583 errors include:
6584 
6585 - The variable ID is invalid for the specified netCDF dataset.
6586 - The specified netCDF ID does not refer to an open netCDF dataset.
6587 
6588 Example {.heading}
6589 -------
6590 
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:
6593 
6594 +--------------------------------------+--------------------------------------+
6595 |   | ``` {.example} |
6596 | | use netcdf |
6597 | | implicit none |
6598 | | integer |
6599 | | :: status, ncid, & |
6600 | | |
6601 | | RhVarId & |
6602 | | |
6603 | | numDims, numAtts |
6604 | | integer, dimension(nf90_max_var_dim |
6605 | | s) :: rhDimIds |
6606 | | ... |
6607 | | status = nf90_open("foo.nc", nf90_N |
6608 | | oWrite, ncid) |
6609 | | if(status /= nf90_NoErr) call handl |
6610 | | e_error(status) |
6611 | | ... |
6612 | | status = nf90_inq_varid(ncid, "rh", |
6613 | | RhVarId) |
6614 | | if(status /= nf90_NoErr) call handl |
6615 | | e_err(status) |
6616 | | status = nf90_inquire_variable(ncid |
6617 | | , RhVarId, ndims = numDims, natts = |
6618 | | numAtts) |
6619 | | if(status /= nf90_NoErr) call handl |
6620 | | e_err(status) |
6621 | | status = nf90_inquire_variable(ncid |
6622 | | , RhVarId, dimids = rhDimIds(:numDim |
6623 | | s)) |
6624 | | if(status /= nf90_NoErr) call handl |
6625 | | e_err(status) |
6626 | | ``` |
6627 +--------------------------------------+--------------------------------------+
6628 
6629 ------------------------------------------------------------------------
6630 
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  -------------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6634 
6635 6.7 Get the ID of a variable from the name: NF90\_INQ\_VARID {.section}
6636 ------------------------------------------------------------
6637 
6638 Given the name of a varaible, nf90\_inq\_varid finds the variable ID.
6639 
6640 Usage {.heading}
6641 -----
6642 
6643 +--------------------------------------+--------------------------------------+
6644 |   | ``` {.example} |
6645 | | function nf90_inq_varid(ncid, name |
6646 | | , varid) |
6647 | | integer, intent(in) :: ncid |
6648 | | character (len = *), intent( in) |
6649 | | :: name |
6650 | | integer, intent(out) :: varid |
6651 | | integer :: nf90_inq_varid |
6652 | | ``` |
6653 +--------------------------------------+--------------------------------------+
6654 
6655  `ncid`
6656 
6657 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6658 
6659  `name`
6660 
6661 : The variable name. The maximum possible length, in characters, of a
6662  variable name is given by the predefined constant NF90\_MAX\_NAME.
6663 
6664  `varid`
6665 
6666 : Variable ID.
6667 
6668 These functions return the value NF90\_NOERR if no errors occurred.
6669 Otherwise, the returned status indicates an error. Possible causes of
6670 errors include:
6671 
6672 - Variable not found.
6673 - The specified netCDF ID does not refer to an open netCDF dataset.
6674 
6675 Example {.heading}
6676 -------
6677 
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:
6680 
6681 +--------------------------------------+--------------------------------------+
6682 |   | ``` {.example} |
6683 | | use netcdf |
6684 | | implicit none |
6685 | | integer |
6686 | | :: status, ncid, & |
6687 | | |
6688 | | RhVarId & |
6689 | | |
6690 | | numDims, numAtts |
6691 | | integer, dimension(nf90_max_var_dim |
6692 | | s) :: rhDimIds |
6693 | | ... |
6694 | | status = nf90_open("foo.nc", nf90_N |
6695 | | oWrite, ncid) |
6696 | | if(status /= nf90_NoErr) call handl |
6697 | | e_error(status) |
6698 | | ... |
6699 | | status = nf90_inq_varid(ncid, "rh", |
6700 | | RhVarId) |
6701 | | if(status /= nf90_NoErr) call handl |
6702 | | e_err(status) |
6703 | | status = nf90_inquire_variable(ncid |
6704 | | , RhVarId, ndims = numDims, natts = |
6705 | | numAtts) |
6706 | | if(status /= nf90_NoErr) call handl |
6707 | | e_err(status) |
6708 | | status = nf90_inquire_variable(ncid |
6709 | | , RhVarId, dimids = rhDimIds(:numDim |
6710 | | s)) |
6711 | | if(status /= nf90_NoErr) call handl |
6712 | | e_err(status) |
6713 | | ``` |
6714 +--------------------------------------+--------------------------------------+
6715 
6716 ------------------------------------------------------------------------
6717 
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  ------------------------------------------------------------------------- ------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
6721 
6722 6.8 Writing Data Values: NF90\_PUT\_VAR {.section}
6723 ---------------------------------------
6724 
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.
6736 
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
6747 dimension.
6748 
6749 Usage {.heading}
6750 -----
6751 
6752 +--------------------------------------+--------------------------------------+
6753 |   | ``` {.example} |
6754 | | function nf90_put_var(ncid, varid, |
6755 | | values, start, count, stride, map) |
6756 | | integer, |
6757 | | intent( in) :: ncid, varid |
6758 | | any valid type, scalar or array o |
6759 | | f any rank, & |
6760 | | |
6761 | | intent( in) :: values |
6762 | | integer, dimension(:), optional, |
6763 | | intent( in) :: start, count, stride, |
6764 | | map |
6765 | | integer |
6766 | | :: nf90_put_var |
6767 | | ``` |
6768 +--------------------------------------+--------------------------------------+
6769 
6770  `ncid`
6771 
6772 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
6773 
6774  `varid`
6775 
6776 : Variable ID.
6777 
6778  `values`
6779 
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.
6787 
6788  `start`
6789 
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.
6797 
6798  By default, start(:) = 1.
6799 
6800  `count`
6801 
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.
6808 
6809  By default, count(:numDims) = shape(values) and count(numDims + 1:)
6810  = 1, where numDims = size(shape(values)).
6811 
6812  `stride`
6813 
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.).
6822 
6823  By default, stride(:) = 1.
6824 
6825  `imap`
6826 
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
6834  of elements.
6835 
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.
6839 
6840  Use of Fortran 90 intrinsic functions (including reshape, transpose,
6841  and spread) may let you avoid using this argument.
6842 
6843 Errors {.heading}
6844 ------
6845 
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:
6849 
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
6854  an error.
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.
6859 
6860 Example {.heading}
6861 -------
6862 
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
6868 second time value:
6869 
6870 +--------------------------------------+--------------------------------------+
6871 |   | ``` {.example} |
6872 | | use netcdf |
6873 | | implicit none |
6874 | | integer :: ncId, rhVarId, status |
6875 | | ... |
6876 | | status = nf90_open("foo.nc", nf90_W |
6877 | | rite, ncid) |
6878 | | if(status /= nf90_NoErr) call handl |
6879 | | e_err(status) |
6880 | | ... |
6881 | | status = nf90_inq_varid(ncid, "rh", |
6882 | | rhVarId) |
6883 | | if(status /= nf90_NoErr) call handl |
6884 | | e_err(status) |
6885 | | status = nf90_put_var(ncid, rhVarId |
6886 | | , 0.5, start = (/ 4, 3, 2 /) ) |
6887 | | if(status /= nf90_NoErr) call handl |
6888 | | e_err(status) |
6889 | | ``` |
6890 +--------------------------------------+--------------------------------------+
6891 
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
6898 variable.
6899 
6900 +--------------------------------------+--------------------------------------+
6901 |   | ``` {.example} |
6902 | | use netcdf |
6903 | | implicit none |
6904 | | integer |
6905 | | :: ncId, rhVarId,status, |
6906 | | & |
6907 | | |
6908 | | lonDimID, latDimId, timeDimId, |
6909 | | & |
6910 | | |
6911 | | numLons, numLats, numTimes, |
6912 | | & |
6913 | | |
6914 | | i |
6915 | | integer, dimension(nf90_max_var_dim |
6916 | | s) :: dimIDs |
6917 | | ... |
6918 | | status = nf90_open("foo.nc", nf90_W |
6919 | | rite, ncid) |
6920 | | if(status /= nf90_NoErr) call handl |
6921 | | e_err(status) |
6922 | | ... |
6923 | | status = nf90_inq_varid(ncid, "rh", |
6924 | | rhVarId) |
6925 | | if(status /= nf90_NoErr) call handl |
6926 | | e_err(status) |
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 |
6933 | | e_err(status) |
6934 | | status = nf90_inquire_dimension(nci |
6935 | | d, dimIDs(1), len = numLons) |
6936 | | if(status /= nf90_NoErr) call handl |
6937 | | e_err(status) |
6938 | | status = nf90_inquire_dimension(nci |
6939 | | d, dimIDs(2), len = numLats) |
6940 | | if(status /= nf90_NoErr) call handl |
6941 | | e_err(status) |
6942 | | status = nf90_inquire_dimension(nci |
6943 | | d, dimIDs(3), len = numTimes) |
6944 | | if(status /= nf90_NoErr) call handl |
6945 | | e_err(status) |
6946 | | ... |
6947 | | ! Make a temporary array the same s |
6948 | | hape as the netCDF variable. |
6949 | | status = nf90_put_var(ncid, rhVarId |
6950 | | , & |
6951 | | reshape( & |
6952 | | (/ (0.5, i |
6953 | | = 1, numLons * numLats * numTimes) / |
6954 | | ) , & |
6955 | | shape = (/ n |
6956 | | umLons, numLats, numTimes /) ) |
6957 | | if(status /= nf90_NoErr) call handl |
6958 | | e_err(status) |
6959 | | ``` |
6960 +--------------------------------------+--------------------------------------+
6961 
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.
6968 
6969 +--------------------------------------+--------------------------------------+
6970 |   | ``` {.example} |
6971 | | use netcdf |
6972 | | implicit none |
6973 | | integer :: ncId, rhVarId |
6974 | | , status |
6975 | | integer, parameter :: numLons = 10, |
6976 | | numLats = 5, numTimes = 3 |
6977 | | real, dimension(numLons, numLats) & |
6978 | | :: rhValues |
6979 | | ... |
6980 | | status = nf90_open("foo.nc", nf90_W |
6981 | | rite, ncid) |
6982 | | if(status /= nf90_NoErr) call handl |
6983 | | e_err(status) |
6984 | | ... |
6985 | | status = nf90_inq_varid(ncid, "rh", |
6986 | | rhVarId) |
6987 | | if(status /= nf90_NoErr) call handl |
6988 | | e_err(status) |
6989 | | ! Fill in all values at the last ti |
6990 | | me |
6991 | | rhValues(:, :) = 0.5 |
6992 | | status = nf90_put_var(ncid, rhVarId |
6993 | | ,rhvalues, & |
6994 | | start = (/ 1, |
6995 | | 1, numTimes /), & |
6996 | | count = (/ nu |
6997 | | mLats, numLons, 1 /)) |
6998 | | if(status /= nf90_NoErr) call handl |
6999 | | e_err(status) |
7000 | | ``` |
7001 +--------------------------------------+--------------------------------------+
7002 
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).
7005 
7006 +--------------------------------------+--------------------------------------+
7007 |   | ``` {.example} |
7008 | | use netcdf |
7009 | | implicit none |
7010 | | integer :: ncId, rhVarId |
7011 | | , status |
7012 | | integer, parameter :: numLons = 6, |
7013 | | numLats = 4 |
7014 | | real, dimension(numLons, numLats) & |
7015 | | :: rhValues = 0. |
7016 | | 5 |
7017 | | ... |
7018 | | status = nf90_open("foo.nc", nf90_W |
7019 | | rite, ncid) |
7020 | | if(status /= nf90_NoErr) call handl |
7021 | | e_err(status) |
7022 | | ... |
7023 | | status = nf90_inq_varid(ncid, "rh", |
7024 | | rhVarId) |
7025 | | if(status /= nf90_NoErr) call handl |
7026 | | e_err(status) |
7027 | | ... |
7028 | | ! Fill in every other value using a |
7029 | | n array section |
7030 | | status = nf90_put_var(ncid, rhVarId |
7031 | | , rhValues(::2, ::2), & |
7032 | | stride = (/ 2 |
7033 | | , 2 /)) |
7034 | | if(status /= nf90_NoErr) call handl |
7035 | | e_err(status) |
7036 | | ``` |
7037 +--------------------------------------+--------------------------------------+
7038 
7039 The following map vector shows the default mapping between a 2x3x4
7040 netCDF variable and an internal array of the same shape:
7041 
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 |
7053 | | varying 1 |
7054 | | ! intermediate |
7055 | | 2 (= map(1)*2) |
7056 | | ! most slowly v |
7057 | | arying 6 (= map(2)*3) |
7058 | | ``` |
7059 +--------------------------------------+--------------------------------------+
7060 
7061 Using the map vector above obtains the same result as simply not passing
7062 a map vector at all.
7063 
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:
7066 
7067 +--------------------------------------+--------------------------------------+
7068 |   | ``` {.example} |
7069 | | use netcdf |
7070 | | implicit none |
7071 | | integer : |
7072 | | : ncId, rhVarId, status |
7073 | | integer, parameter : |
7074 | | : numLons = 6, numLats = 4 |
7075 | | real, dimension(numLons, numLats) : |
7076 | | : rhValues |
7077 | | ! netCDF variable has dimensions (n |
7078 | | umLats, numLons) |
7079 | | ... |
7080 | | status = nf90_open("foo.nc", nf90_W |
7081 | | rite, ncid) |
7082 | | if(status /= nf90_NoErr) call handl |
7083 | | e_err(status) |
7084 | | ... |
7085 | | status = nf90_inq_varid(ncid, "rh", |
7086 | | rhVarId) |
7087 | | if(status /= nf90_NoErr) call handl |
7088 | | e_err(status) |
7089 | | ... |
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 |
7096 | | e_err(status) |
7097 | | ``` |
7098 +--------------------------------------+--------------------------------------+
7099 
7100 The same effect can be obtained more simply using Fortran 90 intrinsic
7101 functions:
7102 
7103 +--------------------------------------+--------------------------------------+
7104 |   | ``` {.example} |
7105 | | use netcdf |
7106 | | implicit none |
7107 | | integer : |
7108 | | : ncId, rhVarId, status |
7109 | | integer, parameter : |
7110 | | : numLons = 6, numLats = 4 |
7111 | | real, dimension(numLons, numLats) : |
7112 | | : rhValues |
7113 | | ! netCDF variable has dimensions (n |
7114 | | umLats, numLons) |
7115 | | ... |
7116 | | status = nf90_open("foo.nc", nf90_W |
7117 | | rite, ncid) |
7118 | | if(status /= nf90_NoErr) call handl |
7119 | | e_err(status) |
7120 | | ... |
7121 | | status = nf90_inq_varid(ncid, "rh", |
7122 | | rhVarId) |
7123 | | if(status /= nf90_NoErr) call handl |
7124 | | e_err(status) |
7125 | | ... |
7126 | | status = nf90_put_var(ncid, rhVarId |
7127 | | , transpose(rhValues)) |
7128 | | if(status /= nf90_NoErr) call handl |
7129 | | e_err(status) |
7130 | | ``` |
7131 +--------------------------------------+--------------------------------------+
7132 
7133 ------------------------------------------------------------------------
7134 
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  ----------------------------------------------------------------------- ------------------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7138 
7139 6.9 Reading Data Values: NF90\_GET\_VAR {.section}
7140 ---------------------------------------
7141 
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.
7154 
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.
7163 
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
7169 
7170 Usage {.heading}
7171 -----
7172 
7173 +--------------------------------------+--------------------------------------+
7174 |   | ``` {.example} |
7175 | | function nf90_get_var(ncid, varid, |
7176 | | values, start, count, stride, map) |
7177 | | integer, |
7178 | | intent( in) :: ncid, varid |
7179 | | any valid type, scalar or array o |
7180 | | f any rank, & |
7181 | | |
7182 | | intent(out) :: values |
7183 | | integer, dimension(:), optional, |
7184 | | intent( in) :: start, count, stride, |
7185 | | map |
7186 | | integer |
7187 | | :: nf90_get_var |
7188 | | ``` |
7189 +--------------------------------------+--------------------------------------+
7190 
7191  `ncid`
7192 
7193 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
7194 
7195  `varid`
7196 
7197 : Variable ID.
7198 
7199  `values`
7200 
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.
7208 
7209  `start`
7210 
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.
7218 
7219  By default, start(:) = 1.
7220 
7221  `count`
7222 
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.
7229 
7230  By default, count(:numDims) = shape(values) and count(numDims + 1:)
7231  = 1, where numDims = size(shape(values)).
7232 
7233  `stride`
7234 
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.).
7243 
7244  By default, stride(:) = 1.
7245 
7246  `map`
7247 
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
7255  of elements.
7256 
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.
7260 
7261  Use of Fortran 90 intrinsic functions (including reshape, transpose,
7262  and spread) may let you avoid using this argument.
7263 
7264 Errors {.heading}
7265 ------
7266 
7267 NF90\_GET\_VAR returns the value NF90\_NOERR if no errors occurred.
7268 Otherwise, the returned status indicates an error. Possible causes of
7269 errors include:
7270 
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
7274  the map vector.
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.
7279 
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!)
7284 
7285 Example {.heading}
7286 -------
7287 
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
7293 second time value:
7294 
7295 +--------------------------------------+--------------------------------------+
7296 |   | ``` {.example} |
7297 | | use netcdf |
7298 | | implicit none |
7299 | | integer :: ncId, rhVarId, status |
7300 | | real :: rhValue |
7301 | | ... |
7302 | | status = nf90_open("foo.nc", nf90_N |
7303 | | oWrite, ncid) |
7304 | | if(status /= nf90_NoErr) call handl |
7305 | | e_err(status) |
7306 | | - |
7307 | | status = nf90_inq_varid(ncid, "rh", |
7308 | | rhVarId) |
7309 | | if(status /= nf90_NoErr) call handl |
7310 | | e_err(status) |
7311 | | status = nf90_get_var(ncid, rhVarId |
7312 | | , rhValue, start = (/ 4, 3, 2 /) ) |
7313 | | if(status /= nf90_NoErr) call handl |
7314 | | e_err(status) |
7315 | | ``` |
7316 +--------------------------------------+--------------------------------------+
7317 
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
7323 netCDF variable.
7324 
7325 +--------------------------------------+--------------------------------------+
7326 |   | ``` {.example} |
7327 | | use netcdf |
7328 | | implicit none |
7329 | | integer |
7330 | | :: ncId, rhVarId, & |
7331 | | |
7332 | | lonDimID, latDimId, timeDimId, |
7333 | | & |
7334 | | |
7335 | | numLons, numLats, numTimes, |
7336 | | & |
7337 | | |
7338 | | status |
7339 | | integer, dimension(nf90_max_var_dim |
7340 | | s) :: dimIDs |
7341 | | real, dimension(:, :, :), allocatab |
7342 | | le :: rhValues |
7343 | | ... |
7344 | | status = nf90_open("foo.nc", nf90_N |
7345 | | oWrite, ncid) |
7346 | | if(status /= nf90_NoErr) call handl |
7347 | | e_err(status) |
7348 | | ... |
7349 | | status = nf90_inq_varid(ncid, "rh", |
7350 | | rhVarId) |
7351 | | if(status /= nf90_NoErr) call handl |
7352 | | e_err(status) |
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 |
7359 | | e_err(status) |
7360 | | status = nf90_inquire_dimension(nci |
7361 | | d, dimIDs(1), len = numLons) |
7362 | | if(status /= nf90_NoErr) call handl |
7363 | | e_err(status) |
7364 | | status = nf90_inquire_dimension(nci |
7365 | | d, dimIDs(2), len = numLats) |
7366 | | if(status /= nf90_NoErr) call handl |
7367 | | e_err(status) |
7368 | | status = nf90_inquire_dimension(nci |
7369 | | d, dimIDs(3), len = numTimes) |
7370 | | if(status /= nf90_NoErr) call handl |
7371 | | e_err(status) |
7372 | | allocate(rhValues(numLons, numLats, |
7373 | | numTimes)) |
7374 | | ... |
7375 | | status = nf90_get_var(ncid, rhVarId |
7376 | | , rhValues) |
7377 | | if(status /= nf90_NoErr) call handl |
7378 | | e_err(status) |
7379 | | ``` |
7380 +--------------------------------------+--------------------------------------+
7381 
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.
7388 
7389 +--------------------------------------+--------------------------------------+
7390 |   | ``` {.example} |
7391 | | use netcdf |
7392 | | implicit none |
7393 | | integer :: ncId, rhVarId |
7394 | | , status |
7395 | | integer, parameter :: numLons = 10, |
7396 | | numLats = 5, numTimes = 3 |
7397 | | real, dimension(numLons, numLats, n |
7398 | | umTimes) & |
7399 | | :: rhValues |
7400 | | ... |
7401 | | status = nf90_open("foo.nc", nf90_N |
7402 | | oWrite, ncid) |
7403 | | if(status /= nf90_NoErr) call handl |
7404 | | e_err(status) |
7405 | | ... |
7406 | | status = nf90_inq_varid(ncid, "rh", |
7407 | | rhVarId) |
7408 | | if(status /= nf90_NoErr) call handl |
7409 | | e_err(status) |
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), & |
7414 | | start = (/ 1, |
7415 | | 1, numTimes /), & |
7416 | | count = (/ nu |
7417 | | mLons, numLats, 1 /)) |
7418 | | if(status /= nf90_NoErr) call handl |
7419 | | e_err(status) |
7420 | | ``` |
7421 +--------------------------------------+--------------------------------------+
7422 
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).
7425 
7426 +--------------------------------------+--------------------------------------+
7427 |   | ``` {.example} |
7428 | | use netcdf |
7429 | | implicit none |
7430 | | integer :: ncId, rhVarId |
7431 | | , status |
7432 | | integer, parameter :: numLons = 6, |
7433 | | numLats = 4 |
7434 | | real, dimension(numLons, numLats) & |
7435 | | :: rhValues |
7436 | | ... |
7437 | | status = nf90_open("foo.nc", nf90_N |
7438 | | oWrite, ncid) |
7439 | | if(status /= nf90_NoErr) call handl |
7440 | | e_err(status) |
7441 | | ... |
7442 | | status = nf90_inq_varid(ncid, "rh", |
7443 | | rhVarId) |
7444 | | if(status /= nf90_NoErr) call handl |
7445 | | e_err(status) |
7446 | | ... |
7447 | | ! Read every other value into an ar |
7448 | | ray section |
7449 | | status = nf90_get_var(ncid, rhVarId |
7450 | | , rhValues(::2, ::2) & |
7451 | | stride = (/ 2 |
7452 | | , 2 /)) |
7453 | | if(status /= nf90_NoErr) call handl |
7454 | | e_err(status) |
7455 | | ``` |
7456 +--------------------------------------+--------------------------------------+
7457 
7458 The following map vector shows the default mapping between a 2x3x4
7459 netCDF variable and an internal array of the same shape:
7460 
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 |
7472 | | varying 1 |
7473 | | ! intermediate |
7474 | | 2 (= map(1)*2) |
7475 | | ! most slowly v |
7476 | | arying 6 (= map(2)*3) |
7477 | | ``` |
7478 +--------------------------------------+--------------------------------------+
7479 
7480 Using the map vector above obtains the same result as simply not passing
7481 a map vector at all.
7482 
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:
7485 
7486 +--------------------------------------+--------------------------------------+
7487 |   | ``` {.example} |
7488 | | use netcdf |
7489 | | implicit none |
7490 | | integer : |
7491 | | : ncId, rhVarId, status |
7492 | | integer, parameter : |
7493 | | : numLons = 6, numLats = 4 |
7494 | | real, dimension(numLons, numLats) : |
7495 | | : rhValues |
7496 | | ! netCDF variable has dimensions (n |
7497 | | umLats, numLons) |
7498 | | ... |
7499 | | status = nf90_open("foo.nc", nf90_N |
7500 | | oWrite, ncid) |
7501 | | if(status /= nf90_NoErr) call handl |
7502 | | e_err(status) |
7503 | | ... |
7504 | | status = nf90_inq_varid(ncid, "rh", |
7505 | | rhVarId) |
7506 | | if(status /= nf90_NoErr) call handl |
7507 | | e_err(status) |
7508 | | ... |
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 |
7515 | | e_err(status) |
7516 | | ``` |
7517 +--------------------------------------+--------------------------------------+
7518 
7519 The same effect can be obtained more simply, though using more memory,
7520 using Fortran 90 intrinsic functions:
7521 
7522 +--------------------------------------+--------------------------------------+
7523 |   | ``` {.example} |
7524 | | use netcdf |
7525 | | implicit none |
7526 | | integer : |
7527 | | : ncId, rhVarId, status |
7528 | | integer, parameter : |
7529 | | : numLons = 6, numLats = 4 |
7530 | | real, dimension(numLons, numLats) : |
7531 | | : rhValues |
7532 | | ! netCDF variable has dimensions (n |
7533 | | umLats, numLons) |
7534 | | real, dimension(numLons, numLats) : |
7535 | | : tempValues |
7536 | | ... |
7537 | | status = nf90_open("foo.nc", nf90_N |
7538 | | oWrite, ncid) |
7539 | | if(status /= nf90_NoErr) call handl |
7540 | | e_err(status) |
7541 | | ... |
7542 | | status = nf90_inq_varid(ncid, "rh", |
7543 | | rhVarId) |
7544 | | if(status /= nf90_NoErr) call handl |
7545 | | e_err(status) |
7546 | | ... |
7547 | | status = nf90_get_var(ncid, rhVarId |
7548 | | , tempValues)) |
7549 | | if(status /= nf90_NoErr) call handl |
7550 | | e_err(status) |
7551 | | rhValues(:, :) = transpose(tempValu |
7552 | | es) |
7553 | | ``` |
7554 +--------------------------------------+--------------------------------------+
7555 
7556 ------------------------------------------------------------------------
7557 
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  ----------------------------------------------------------------------- ---------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7561 
7562 6.10 Reading and Writing Character String Values {.section}
7563 ------------------------------------------------
7564 
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
7577 netCDF variables.
7578 
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.
7584 
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
7594 shapes.
7595 
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).
7603 
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.
7610 
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.
7621 
7622 Here is an example illustrating this way of writing strings to character
7623 array variables:
7624 
7625 +--------------------------------------+--------------------------------------+
7626 |   | ``` {.example} |
7627 | | use netcdf |
7628 | | implicit none |
7629 | | integer status |
7630 | | integer : |
7631 | | : ncid, oceanStrLenID, oceanId |
7632 | | integer, parameter : |
7633 | | : MaxOceanNameLen = 20 |
7634 | | character, (len = MaxOceanNameLen): |
7635 | | : ocean |
7636 | | ... |
7637 | | status = nf90_create("foo.nc", nf90 |
7638 | | _NoClobber, ncid) |
7639 | | if(status /= nf90_NoErr) call handl |
7640 | | e_err(status) |
7641 | | ... |
7642 | | status = nf90_def_dim(ncid, "oceanS |
7643 | | trLen", MaxOceanNameLen, oceanStrLen |
7644 | | Id) |
7645 | | if(status /= nf90_NoErr) call handl |
7646 | | e_err(status) |
7647 | | ... |
7648 | | status = nf90_def_var(ncid, "ocean" |
7649 | | , nf90_char, (/ oceanStrLenId /), oc |
7650 | | eanId) |
7651 | | if(status /= nf90_NoErr) call handl |
7652 | | e_err(status) |
7653 | | ... |
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) |
7659 | | ... |
7660 | | ! Note that this assignment adds bl |
7661 | | ank fill |
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 |
7670 | | e_err(status) |
7671 | | ``` |
7672 +--------------------------------------+--------------------------------------+
7673 
7674 ------------------------------------------------------------------------
7675 
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  ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7679 
7680 6.11 Fill Values {.section}
7681 ----------------
7682 
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.
7693 
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.
7700 
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
7706 NF90\_FILL\_DOUBLE
7707 
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
7714 variables.
7715 
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.
7722 
7723 ------------------------------------------------------------------------
7724 
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  -------------------------------------------------------------- ------------------------------------------------------------------------------ --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7728 
7729 6.12 NF90\_RENAME\_VAR {.section}
7730 ----------------------
7731 
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.
7736 
7737 Usage {.heading}
7738 -----
7739 
7740 +--------------------------------------+--------------------------------------+
7741 |   | ``` {.example} |
7742 | | function nf90_rename_var(ncid, vari |
7743 | | d, newname) |
7744 | | integer, intent( in) |
7745 | | :: ncid, varid |
7746 | | character (len = *), intent( in) |
7747 | | :: newname |
7748 | | integer |
7749 | | :: nf90_rename_var |
7750 | | ``` |
7751 +--------------------------------------+--------------------------------------+
7752 
7753  `ncid`
7754 
7755 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
7756 
7757  `varid`
7758 
7759 : Variable ID.
7760 
7761  `newname`
7762 
7763 : New name for the specified variable.
7764 
7765 Errors {.heading}
7766 ------
7767 
7768 NF90\_RENAME\_VAR returns the value NF90\_NOERR if no errors occurred.
7769 Otherwise, the returned status indicates an error. Possible causes of
7770 errors include:
7771 
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.
7775 
7776 Example {.heading}
7777 -------
7778 
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:
7781 
7782 +--------------------------------------+--------------------------------------+
7783 |   | ``` {.example} |
7784 | | use netcdf |
7785 | | implicit none |
7786 | | integer :: ncId, rhVarId, status |
7787 | | ... |
7788 | | status = nf90_open("foo.nc", nf90_W |
7789 | | rite, ncid) |
7790 | | if(status /= nf90_NoErr) call handl |
7791 | | e_err(status) |
7792 | | ... |
7793 | | status = nf90_inq_varid(ncid, "rh", |
7794 | | rhVarId) |
7795 | | if(status /= nf90_NoErr) call handl |
7796 | | e_err(status) |
7797 | | status = nf90_redef(ncid) ! Enter |
7798 | | define mode to change variable name |
7799 | | if(status /= nf90_NoErr) call handl |
7800 | | e_err(status) |
7801 | | status = nf90_rename_var(ncid, rhVa |
7802 | | rId, "rel_hum") |
7803 | | if(status /= nf90_NoErr) call handl |
7804 | | e_err(status) |
7805 | | status = nf90_enddef(ncid) ! Leave |
7806 | | define mode |
7807 | | if(status /= nf90_NoErr) call handl |
7808 | | e_err(status) |
7809 | | ``` |
7810 +--------------------------------------+--------------------------------------+
7811 
7812 ------------------------------------------------------------------------
7813 
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  -------------------------------------------------------------------------- --------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------------- -------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7817 
7818 6.13 Change between Collective and Independent Parallel Access: NF90\_VAR\_PAR\_ACCESS {.section}
7819 --------------------------------------------------------------------------------------
7820 
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.
7826 
7827 This function is only available if the netCDF library was built with
7828 parallel I/O enabled.
7829 
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
7835 open.
7836 
7837 The variable can be changed from collective to independent, and back, as
7838 often as desired.
7839 
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
7845 the file.
7846 
7847 Usage {.heading}
7848 -----
7849 
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 |
7859 | | ``` |
7860 +--------------------------------------+--------------------------------------+
7861 
7862  `ncid`
7863 
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)).
7867 
7868  `varid`
7869 
7870 : Variable ID.
7871 
7872  `access`
7873 
7874 : NF90\_INDEPENDENT to set this variable to independent operations.
7875  NF90\_COLLECTIVE to set it to collective operations.
7876 
7877 Return Values {.heading}
7878 -------------
7879 
7880  `NF90_NOERR`
7881 
7882 : No error.
7883 
7884  `NF90_ENOTVAR`
7885 
7886 : No variable found.
7887 
7888  `NF90_NOPAR`
7889 
7890 : File not opened for parallel access.
7891 
7892 Example {.heading}
7893 -------
7894 
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
7898 netcdf.
7899 
7900 +--------------------------------------+--------------------------------------+
7901 |   | ``` {.example} |
7902 | | ! Reopen the file. |
7903 | | call handle_err(nf90_open(FILE_NAM |
7904 | | E, nf90_nowrite, ncid, comm = MPI_CO |
7905 | | MM_WORLD, & |
7906 | | info = MPI_INFO_NULL)) |
7907 | | |
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)) |
7914 | | |
7915 | | ! Read this processor's data. |
7916 | | call handle_err(nf90_get_var(ncid, |
7917 | | varid, data_in, start = start, coun |
7918 | | t = count)) |
7919 | | ``` |
7920 +--------------------------------------+--------------------------------------+
7921 
7922 ------------------------------------------------------------------------
7923 
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  ---------------------------------------------------------------------------------- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------------- ----------------------------- ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7927 
7928 7. Attributes {.chapter}
7929 =============
7930 
7931  ------------------------ ------------------------ ------------------------
7932  [7.1 Attributes   
7933  Introduction](#Attribute
7934  s-Introduction)
7935 
7936  [7.2 Create an   
7937  Attribute:
7938  NF90\_PUT\_ATT](#NF90_00
7939  5fPUT_005fATT)
7940 
7941  [7.3 Get Information   
7942  about an Attribute:
7943  NF90\_INQUIRE\_ATTRIBUTE
7944  and
7945  NF90\_INQ\_ATTNAME](#NF9
7946  0_005fINQUIRE_005fATTRIB
7947  UTE)
7948 
7949  [7.4 Get Attribute’s   
7950  Values:
7951  NF90\_GET\_ATT](#NF90_00
7952  5fGET_005fATT)
7953 
7954  [7.5 Copy Attribute from   
7955  One NetCDF to Another:
7956  NF90\_COPY\_ATT](#NF90_0
7957  05fCOPY_005fATT)
7958 
7959  [7.6 Rename an   
7960  Attribute:
7961  NF90\_RENAME\_ATT](#NF90
7962  _005fRENAME_005fATT)
7963 
7964  [7.7   
7965  NF90\_DEL\_ATT](#NF90_00
7966  5fDEL_005fATT)
7967  ------------------------ ------------------------ ------------------------
7968 
7969 ------------------------------------------------------------------------
7970 
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  ------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
7974 
7975 7.1 Attributes Introduction {.section}
7976 ---------------------------
7977 
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
7988 NF90\_INQ\_ATTNAME.
7989 
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.
7995 
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.
8001 
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.
8006 
8007 Operations supported on attributes are:
8008 
8009 - Create an attribute, given its variable ID, name, data type, length,
8010  and value.
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.
8017 
8018 ------------------------------------------------------------------------
8019 
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  -------------------------------------------------------------------------- ----------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8023 
8024 7.2 Create an Attribute: NF90\_PUT\_ATT {.section}
8025 ---------------------------------------
8026 
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.
8031 
8032 Usage {.heading}
8033 -----
8034 
8035 Although it’s possible to create attributes of all types, text and
8036 double attributes are adequate for most purposes.
8037 
8038 +--------------------------------------+--------------------------------------+
8039 |   | ``` {.example} |
8040 | | function nf90_put_att(ncid, varid, |
8041 | | name, values) |
8042 | | integer, intent( in) : |
8043 | | : ncid, varid |
8044 | | character(len = *), intent( in) : |
8045 | | : name |
8046 | | scalar character string or any nu |
8047 | | meric type, scalar, or array of rank |
8048 | | 1, & |
8049 | | intent( in) : |
8050 | | : values |
8051 | | integer : |
8052 | | : nf90_put_att |
8053 | | ``` |
8054 +--------------------------------------+--------------------------------------+
8055 
8056  `ncid`
8057 
8058 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8059 
8060  `varid`
8061 
8062 : Variable ID of the variable to which the attribute will be assigned
8063  or NF90\_GLOBAL for a global attribute.
8064 
8065  `name`
8066 
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.
8072 
8073  `values`
8074 
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
8080  desired type.
8081 
8082 Errors {.heading}
8083 ------
8084 
8085 NF90\_PUT\_ATT returns the value NF90\_NOERR if no errors occurred.
8086 Otherwise, the returned status indicates an error. Possible causes of
8087 errors include:
8088 
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.
8098 
8099 Example {.heading}
8100 -------
8101 
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:
8105 
8106 +--------------------------------------+--------------------------------------+
8107 |   | ``` {.example} |
8108 | | use netcdf |
8109 | | implicit none |
8110 | | integer :: ncid, status, RHVarID |
8111 | | ... |
8112 | | status = nf90_open("foo.nc", nf90_w |
8113 | | rite, ncid) |
8114 | | if (status /= nf90_noerr) call hand |
8115 | | le_err(status) |
8116 | | ... |
8117 | | ! Enter define mode so we can add t |
8118 | | he attribute |
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", |
8124 | | RHVarID) |
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") |
8136 | | ) |
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) |
8143 | | ``` |
8144 +--------------------------------------+--------------------------------------+
8145 
8146 ------------------------------------------------------------------------
8147 
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  ----------------------------------------------------------------------- ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8151 
8152 7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and NF90\_INQ\_ATTNAME {.section}
8153 ---------------------------------------------------------------------------------------
8154 
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.
8159 
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
8167 an attribute ID.
8168 
8169 Usage {.heading}
8170 -----
8171 
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) |
8179 | | :: name |
8180 | | integer, intent(out), |
8181 | | optional :: xtype, len, attnum |
8182 | | integer |
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) |
8189 | | :: name |
8190 | | integer |
8191 | | :: nf90_inq_attname |
8192 | | ``` |
8193 +--------------------------------------+--------------------------------------+
8194 
8195  `ncid`
8196 
8197 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8198 
8199  `varid`
8200 
8201 : Variable ID of the attribute’s variable, or NF90\_GLOBAL for a
8202  global attribute.
8203 
8204  `name`
8205 
8206 : Attribute name. For NF90\_INQ\_ATTNAME, this is a pointer to the
8207  location for the returned attribute name.
8208 
8209  `xtype`
8210 
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,
8214  and NF90\_DOUBLE.
8215 
8216  `len`
8217 
8218 : Returned number of values currently stored in the attribute. For a
8219  string-valued attribute, this is the number of characters in
8220  the string.
8221 
8222  `attnum`
8223 
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.
8229 
8230  (If you already know an attribute name, knowing its number is not
8231  very useful, because accessing information about an attribute
8232  requires its name.)
8233 
8234 Errors {.heading}
8235 ------
8236 
8237 Each function returns the value NF90\_NOERR if no errors occurred.
8238 Otherwise, the returned status indicates an error. Possible causes of
8239 errors include:
8240 
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
8246  specified variable.
8247 
8248 Example {.heading}
8249 -------
8250 
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
8254 named foo.nc:
8255 
8256 +--------------------------------------+--------------------------------------+
8257 |   | ``` {.example} |
8258 | | use netcdf |
8259 | | implicit none |
8260 | | integer :: ncid, status |
8261 | | integer :: RHVarID |
8262 | | ! Variable ID |
8263 | | integer :: validRangeLength, titleL |
8264 | | ength ! Attribute lengths |
8265 | | ... |
8266 | | status = nf90_open("foo.nc", nf90_n |
8267 | | owrite, ncid) |
8268 | | if (status /= nf90_noerr) call hand |
8269 | | le_err(status) |
8270 | | ... |
8271 | | ! Get the variable ID for "rh"... |
8272 | | status = nf90_inq_varid(ncid, "rh", |
8273 | | RHVarID) |
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", & |
8280 | | len = val |
8281 | | idRangeLength) |
8282 | | if (status /= nf90_noerr) call hand |
8283 | | le_err(status) |
8284 | | ! ... and the global title attribut |
8285 | | e. |
8286 | | status = nf90_inquire_attribute(nci |
8287 | | d, nf90_global, "title", len = title |
8288 | | Length) |
8289 | | if (status /= nf90_noerr) call hand |
8290 | | le_err(status) |
8291 | | ``` |
8292 +--------------------------------------+--------------------------------------+
8293 
8294 ------------------------------------------------------------------------
8295 
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  --------------------------------------------------------------------------------- -------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8299 
8300 7.4 Get Attribute’s Values: NF90\_GET\_ATT {.section}
8301 ------------------------------------------
8302 
8303 Function nf90\_get\_att gets the value(s) of a netCDF attribute, given
8304 its variable ID and name.
8305 
8306 Usage {.heading}
8307 -----
8308 
8309 +--------------------------------------+--------------------------------------+
8310 |   | ``` {.example} |
8311 | | function nf90_get_att(ncid, varid, |
8312 | | name, values) |
8313 | | integer, intent( in) : |
8314 | | : ncid, varid |
8315 | | character(len = *), intent( in) : |
8316 | | : name |
8317 | | any valid type, scalar or array o |
8318 | | f rank 1, & |
8319 | | intent(out) : |
8320 | | : values |
8321 | | integer : |
8322 | | : nf90_get_att |
8323 | | ``` |
8324 +--------------------------------------+--------------------------------------+
8325 
8326  `ncid`
8327 
8328 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8329 
8330  `varid`
8331 
8332 : Variable ID of the attribute’s variable, or NF90\_GLOBAL for a
8333  global attribute.
8334 
8335  `name`
8336 
8337 : Attribute name.
8338 
8339  `values`
8340 
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.
8354 
8355 Errors {.heading}
8356 ------
8357 
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:
8361 
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.
8367 
8368 Example {.heading}
8369 -------
8370 
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:
8377 
8378 +--------------------------------------+--------------------------------------+
8379 |   | ``` {.example} |
8380 | | use netcdf |
8381 | | implicit none |
8382 | | integer :: ncid, statu |
8383 | | s |
8384 | | integer :: RHVarID |
8385 | | ! Variable ID |
8386 | | integer :: validRangeL |
8387 | | ength, titleLength ! Attribute lengt |
8388 | | hs |
8389 | | real, dimension(:), allocatable, & |
8390 | | :: validRange |
8391 | | character (len = 80) :: title |
8392 | | |
8393 | | ... |
8394 | | status = nf90_open("foo.nc", nf90_n |
8395 | | owrite, ncid) |
8396 | | if (status /= nf90_noerr) call hand |
8397 | | le_err(status) |
8398 | | ... |
8399 | | ! Find the lengths of the attribute |
8400 | | s |
8401 | | status = nf90_inq_varid(ncid, "rh", |
8402 | | RHVarID) |
8403 | | if (status /= nf90_noerr) call hand |
8404 | | le_err(status) |
8405 | | status = nf90_inquire_attribute(nci |
8406 | | d, RHVarID, "valid_range", & |
8407 | | len = val |
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 |
8413 | | Length) |
8414 | | if (status /= nf90_noerr) call hand |
8415 | | le_err(status) |
8416 | | ... |
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 |
8422 | | tleLength) |
8423 | | print *, "Not enough space to put |
8424 | | attribute values." |
8425 | | exit |
8426 | | end if |
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) |
8436 | | ``` |
8437 +--------------------------------------+--------------------------------------+
8438 
8439 ------------------------------------------------------------------------
8440 
8441  ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8442  \[[&lt;](#NF90_005fGET_005fATT "Previous section in reading order")\] \[[&gt;](#NF90_005fRENAME_005fATT "Next section in reading order")\]   \[[&lt;&lt;](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[&gt;&gt;](#Summary-of-Fortran-90-Interface "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8443  ----------------------------------------------------------------------- ---------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8444 
8445 7.5 Copy Attribute from One NetCDF to Another: NF90\_COPY\_ATT {.section}
8446 --------------------------------------------------------------
8447 
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.
8451 
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
8457 attempted.)
8458 
8459 Usage {.heading}
8460 -----
8461 
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) |
8469 | | :: name |
8470 | | integer, intent( in) |
8471 | | :: ncid_out, varid_out |
8472 | | integer |
8473 | | :: nf90_copy_att |
8474 | | ``` |
8475 +--------------------------------------+--------------------------------------+
8476 
8477  `ncid_in`
8478 
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.
8481 
8482  `varid_in`
8483 
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.
8486 
8487  `name`
8488 
8489 : Name of the attribute in the input netCDF dataset to be copied.
8490 
8491  `ncid_out`
8492 
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.
8499 
8500  `varid_out`
8501 
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
8504  global attribute.
8505 
8506 Errors {.heading}
8507 ------
8508 
8509 NF90\_COPY\_ATT returns the value NF90\_NOERR if no errors occurred.
8510 Otherwise, the returned status indicates an error. Possible causes of
8511 errors include:
8512 
8513 - The input or output variable ID is invalid for the specified
8514  netCDF dataset.
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
8519  netCDF dataset.
8520 
8521 Example {.heading}
8522 -------
8523 
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
8528 units attribute:
8529 
8530 +--------------------------------------+--------------------------------------+
8531 |   | ``` {.example} |
8532 | | use netcdf |
8533 | | implicit none |
8534 | | integer :: ncid1, ncid2, status |
8535 | | integer :: RHVarID, avgRHVarID ! |
8536 | | Variable ID |
8537 | | ... |
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 |
8543 | | rite, ncid2) |
8544 | | if (status /= nf90_noerr) call hand |
8545 | | le_err(status) |
8546 | | ... |
8547 | | ! Find the IDs of the variables |
8548 | | status = nf90_inq_varid(ncid1, "rh" |
8549 | | , RHVarID) |
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) |
8556 | | ... |
8557 | | status = nf90_redef(ncid2) ! Ente |
8558 | | r define mode |
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) |
8570 | | ``` |
8571 +--------------------------------------+--------------------------------------+
8572 
8573 ------------------------------------------------------------------------
8574 
8575  ------------------------------------------------------------------------ ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8576  \[[&lt;](#NF90_005fCOPY_005fATT "Previous section in reading order")\] \[[&gt;](#NF90_005fDEL_005fATT "Next section in reading order")\]   \[[&lt;&lt;](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[&gt;&gt;](#Summary-of-Fortran-90-Interface "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8577  ------------------------------------------------------------------------ ------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8578 
8579 7.6 Rename an Attribute: NF90\_RENAME\_ATT {.section}
8580 ------------------------------------------
8581 
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.
8586 
8587 Usage {.heading}
8588 -----
8589 
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 |
8598 | | integer |
8599 | | :: nf90_rename_att |
8600 | | ``` |
8601 +--------------------------------------+--------------------------------------+
8602 
8603  `ncid`
8604 
8605 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE
8606 
8607  `varid`
8608 
8609 : ID of the attribute’s variable, or NF90\_GLOBAL for a global
8610  attribute
8611 
8612  `curname`
8613 
8614 : The current attribute name.
8615 
8616  `newname`
8617 
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
8620  define mode.
8621 
8622 Errors {.heading}
8623 ------
8624 
8625 NF90\_RENAME\_ATT returns the value NF90\_NOERR if no errors occurred.
8626 Otherwise, the returned status indicates an error. Possible causes of
8627 errors include:
8628 
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.
8636 
8637 Example {.heading}
8638 -------
8639 
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
8642 named foo.nc:
8643 
8644 +--------------------------------------+--------------------------------------+
8645 |   | ``` {.example} |
8646 | | use netcdf |
8647 | | implicit none |
8648 | | integer :: ncid1, status |
8649 | | integer :: RHVarID ! Variab |
8650 | | le ID |
8651 | | ... |
8652 | | status = nf90_open("foo.nc", nf90_n |
8653 | | owrite, ncid) |
8654 | | if (status /= nf90_noerr) call hand |
8655 | | le_err(status) |
8656 | | ... |
8657 | | ! Find the IDs of the variables |
8658 | | status = nf90_inq_varid(ncid, "rh", |
8659 | | RHVarID) |
8660 | | if (status /= nf90_noerr) call hand |
8661 | | le_err(status) |
8662 | | ... |
8663 | | status = nf90_rename_att(ncid, RHVa |
8664 | | rID, "units", "Units") |
8665 | | if (status /= nf90_noerr) call hand |
8666 | | le_err(status) |
8667 | | ``` |
8668 +--------------------------------------+--------------------------------------+
8669 
8670 ------------------------------------------------------------------------
8671 
8672  -------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8673  \[[&lt;](#NF90_005fRENAME_005fATT "Previous section in reading order")\] \[[&gt;](#Summary-of-Fortran-90-Interface "Next section in reading order")\]   \[[&lt;&lt;](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Attributes "Up section")\] \[[&gt;&gt;](#Summary-of-Fortran-90-Interface "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
8674  -------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ----------------------------------------------------------------------------- ------------------------------------ ----------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8675 
8676 7.7 NF90\_DEL\_ATT {.section}
8677 ------------------
8678 
8679 The function NF90\_DEL\_ATT deletes a netCDF attribute from an open
8680 netCDF dataset. The netCDF dataset must be in define mode.
8681 
8682 Usage {.heading}
8683 -----
8684 
8685 +--------------------------------------+--------------------------------------+
8686 |   | ``` {.example} |
8687 | | function nf90_del_att(ncid, varid, |
8688 | | name) |
8689 | | integer, intent( in) |
8690 | | :: ncid, varid |
8691 | | character (len = *), intent( in) |
8692 | | :: name |
8693 | | integer |
8694 | | :: nf90_del_att |
8695 | | ``` |
8696 +--------------------------------------+--------------------------------------+
8697 
8698  `ncid`
8699 
8700 : NetCDF ID, from a previous call to NF90\_OPEN or NF90\_CREATE.
8701 
8702  `varid`
8703 
8704 : ID of the attribute’s variable, or NF90\_GLOBAL for a
8705  global attribute.
8706 
8707  `name`
8708 
8709 : The name of the attribute to be deleted.
8710 
8711 Errors {.heading}
8712 ------
8713 
8714 NF90\_DEL\_ATT returns the value NF90\_NOERR if no errors occurred.
8715 Otherwise, the returned status indicates an error. Possible causes of
8716 errors include:
8717 
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.
8722 
8723 Example {.heading}
8724 -------
8725 
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:
8728 
8729 +--------------------------------------+--------------------------------------+
8730 |   | ``` {.example} |
8731 | | use netcdf |
8732 | | implicit none |
8733 | | integer :: ncid1, status |
8734 | | integer :: RHVarID ! Variab |
8735 | | le ID |
8736 | | ... |
8737 | | status = nf90_open("foo.nc", nf90_n |
8738 | | owrite, ncid) |
8739 | | if (status /= nf90_noerr) call hand |
8740 | | le_err(status) |
8741 | | ... |
8742 | | ! Find the IDs of the variables |
8743 | | status = nf90_inq_varid(ncid, "rh", |
8744 | | RHVarID) |
8745 | | if (status /= nf90_noerr) call hand |
8746 | | le_err(status) |
8747 | | ... |
8748 | | status = nf90_redef(ncid) ! Enter |
8749 | | define mode |
8750 | | if (status /= nf90_noerr) call hand |
8751 | | le_err(status) |
8752 | | status = nf90_del_att(ncid, RHVarID |
8753 | | , "Units") |
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) |
8759 | | ``` |
8760 +--------------------------------------+--------------------------------------+
8761 
8762 ------------------------------------------------------------------------
8763 
8764  ----------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8765  \[[&lt;](#NF90_005fDEL_005fATT "Previous section in reading order")\] \[[&gt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Next section in reading order")\]   \[[&lt;&lt;](#Attributes "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[&gt;&gt;](#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  ----------------------------------------------------------------------- ---------------------------------------------------------------------------------------- --- ----------------------------------------------------------------------------- ----------------------------- --------------------------------------------------------------------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
8767 
8768 A. Appendix A - Summary of Fortran 90 Interface {.appendix}
8769 ===============================================
8770 
8771 Dataset Functions
8772 
8773 +--------------------------------------+--------------------------------------+
8774 |   | ``` {.example} |
8775 | | function nf90_inq_libvers() |
8776 | | character(len = 80) :: nf90_inq_l |
8777 | | ibvers |
8778 | | function nf90_strerror(ncerr) |
8779 | | integer, intent( in) :: ncerr |
8780 | | character(len = 80) :: nf90_stre |
8781 | | rror |
8782 | | function nf90_create(path, cmode, n |
8783 | | cid) |
8784 | | character (len = *), intent(in |
8785 | | ) :: path |
8786 | | integer, intent(in |
8787 | | ) :: cmode |
8788 | | integer, optional, intent(in |
8789 | | ) :: initialsize |
8790 | | integer, optional, intent(inout |
8791 | | ) :: chunksize |
8792 | | integer, intent( out |
8793 | | ) :: ncid |
8794 | | integer |
8795 | | :: nf90_create |
8796 | | function nf90_open(path, mode, ncid |
8797 | | , chunksize) |
8798 | | character (len = *), intent(in |
8799 | | ) :: path |
8800 | | integer, intent(in |
8801 | | ) :: mode |
8802 | | integer, intent( out |
8803 | | ) :: ncid |
8804 | | integer, optional, intent(inout |
8805 | | ) :: chunksize |
8806 | | integer |
8807 | | :: nf90_open |
8808 | | function nf90_set_fill(ncid, fillmo |
8809 | | de, old_mode) |
8810 | | integer, intent( in) :: ncid, fil |
8811 | | lmode |
8812 | | integer, intent(out) :: old_mode |
8813 | | integer :: nf90_set_ |
8814 | | fill |
8815 | | function nf90_redef(ncid) |
8816 | | integer, intent( in) :: ncid |
8817 | | integer :: nf90_rede |
8818 | | f |
8819 | | function nf90_enddef(ncid, h_minfre |
8820 | | e, v_align, v_minfree, r_align) |
8821 | | integer, intent( in) :: |
8822 | | ncid |
8823 | | integer, optional, intent( in) :: |
8824 | | h_minfree, v_align, v_minfree, r_al |
8825 | | ign |
8826 | | integer :: |
8827 | | nf90_enddef |
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 |
8834 | | t |
8835 | | function nf90_close(ncid) |
8836 | | integer, intent( in) :: ncid |
8837 | | integer :: nf90_clos |
8838 | | e |
8839 | | function nf90_Inquire(ncid, nDimens |
8840 | | ions, nVariables, nAttributes, & |
8841 | | unlimitedDimId |
8842 | | ) |
8843 | | integer, intent( in) :: |
8844 | | ncid |
8845 | | integer, optional, intent(out) :: |
8846 | | nDimensions, nVariables, nAttribute |
8847 | | s, & |
8848 | | unlim |
8849 | | itedDimId |
8850 | | integer :: |
8851 | | nf90_Inquire |
8852 | | ``` |
8853 +--------------------------------------+--------------------------------------+
8854 
8855 Dimension functions
8856 
8857 +--------------------------------------+--------------------------------------+
8858 |   | ``` {.example} |
8859 | | function nf90_def_dim(ncid, name, l |
8860 | | en, dimid) |
8861 | | integer, intent( in) |
8862 | | :: ncid |
8863 | | character (len = *), intent( in) |
8864 | | :: name |
8865 | | integer, intent( in) |
8866 | | :: len |
8867 | | integer, intent(out) |
8868 | | :: dimid |
8869 | | integer |
8870 | | :: nf90_def_dim |
8871 | | function nf90_inq_dimid(ncid, name, |
8872 | | dimid) |
8873 | | integer, intent( in) |
8874 | | :: ncid |
8875 | | character (len = *), intent( in) |
8876 | | :: name |
8877 | | integer, intent(out) |
8878 | | :: dimid |
8879 | | integer |
8880 | | :: nf90_inq_dimid |
8881 | | function nf90_inquire_dimension(nci |
8882 | | d, dimid, name, len) |
8883 | | integer, in |
8884 | | tent( in) :: ncid, dimid |
8885 | | character (len = *), optional, in |
8886 | | tent(out) :: name |
8887 | | integer, optional, in |
8888 | | tent(out) :: len |
8889 | | integer |
8890 | | :: nf90_inquire_dimension |
8891 | | function nf90_rename_dim(ncid, dimi |
8892 | | d, name) |
8893 | | integer, intent( in) |
8894 | | :: ncid |
8895 | | character (len = *), intent( in) |
8896 | | :: name |
8897 | | integer, intent( in) |
8898 | | :: dimid |
8899 | | integer |
8900 | | :: nf90_rename_dim |
8901 | | ``` |
8902 +--------------------------------------+--------------------------------------+
8903 
8904 Variable functions
8905 
8906 +--------------------------------------+--------------------------------------+
8907 |   | ``` {.example} |
8908 | | function nf90_def_var(ncid, name, x |
8909 | | type, dimids, varid) |
8910 | | integer, intent( in |
8911 | | ) :: ncid |
8912 | | character (len = *), intent( in |
8913 | | ) :: name |
8914 | | integer, intent( in |
8915 | | ) :: xtype |
8916 | | integer, dimension(:), intent( in |
8917 | | ) :: dimids ! May be omitted, scalar |
8918 | | , |
8919 | | |
8920 | | ! vector |
8921 | | integer |
8922 | | :: nf90_def_var |
8923 | | function nf90_inq_varid(ncid, name, |
8924 | | varid) |
8925 | | integer, intent( in) |
8926 | | :: ncid |
8927 | | character (len = *), intent( in) |
8928 | | :: name |
8929 | | integer, intent(out) |
8930 | | :: varid |
8931 | | integer |
8932 | | :: nf90_inq_varid |
8933 | | function nf90_inquire_variable(ncid |
8934 | | , varid, name, xtype, ndims, & |
8935 | | dimi |
8936 | | ds, nAtts) |
8937 | | integer, |
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 |
8947 | | integer |
8948 | | :: nf90_inquire_variable |
8949 | | function nf90_put_var(ncid, varid, |
8950 | | values, start, stride, map) |
8951 | | integer, |
8952 | | intent( in) :: ncid, varid |
8953 | | any valid type, scalar or array o |
8954 | | f any rank, & |
8955 | | |
8956 | | intent( in) :: values |
8957 | | integer, dimension(:), optional, |
8958 | | intent( in) :: start, count, stride, |
8959 | | map |
8960 | | integer |
8961 | | :: nf90_put_var |
8962 | | function nf90_get_var(ncid, varid, |
8963 | | values, start, stride, map) |
8964 | | integer, |
8965 | | intent( in) :: ncid, varid |
8966 | | any valid type, scalar or array o |
8967 | | f any rank, & |
8968 | | |
8969 | | intent(out) :: values |
8970 | | integer, dimension(:), optional, |
8971 | | intent( in) :: start, count, stride, |
8972 | | map |
8973 | | integer |
8974 | | :: nf90_get_var |
8975 | | function nf90_rename_var(ncid, vari |
8976 | | d, newname) |
8977 | | integer, intent( in) |
8978 | | :: ncid, varid |
8979 | | character (len = *), intent( in) |
8980 | | :: newname |
8981 | | integer |
8982 | | :: nf90_rename_var |
8983 | | ``` |
8984 +--------------------------------------+--------------------------------------+
8985 
8986 Attribute functions
8987 
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) |
8995 | | :: name |
8996 | | integer, intent(out), |
8997 | | optional :: xtype, len, attnum |
8998 | | integer |
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) |
9005 | | :: name |
9006 | | integer |
9007 | | :: nf90_inq_attname |
9008 | | function nf90_put_att(ncid, varid, |
9009 | | name, values) |
9010 | | integer, intent( in) : |
9011 | | : ncid, varid |
9012 | | character(len = *), intent( in) : |
9013 | | : name |
9014 | | scalar character string or any nu |
9015 | | meric type, scalar, or array of rank |
9016 | | 1, & |
9017 | | intent( in) : |
9018 | | : values |
9019 | | integer : |
9020 | | : nf90_put_att |
9021 | | function nf90_get_att(ncid, varid, |
9022 | | name, values) |
9023 | | integer, intent( in) : |
9024 | | : ncid, varid |
9025 | | character(len = *), intent( in) : |
9026 | | : name |
9027 | | any valid type, scalar or array o |
9028 | | f rank 1, & |
9029 | | intent(out) : |
9030 | | : values |
9031 | | integer |
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) |
9038 | | :: name |
9039 | | integer, intent( in) |
9040 | | :: ncid_out, varid_out |
9041 | | integer |
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 |
9049 | | integer |
9050 | | :: nf90_rename_att |
9051 | | function nf90_del_att(ncid, varid, |
9052 | | name) |
9053 | | integer, intent( in) |
9054 | | :: ncid, varid |
9055 | | character (len = *), intent( in) |
9056 | | :: name |
9057 | | integer |
9058 | | :: nf90_del_att |
9059 | | ``` |
9060 +--------------------------------------+--------------------------------------+
9061 
9062 ------------------------------------------------------------------------
9063 
9064  ---------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------------- ----------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9065  \[[&lt;](#Summary-of-Fortran-90-Interface "Previous section in reading order")\] \[[&gt;](#The-new-Fortran-90-interface "Next section in reading order")\]   \[[&lt;&lt;](#Summary-of-Fortran-90-Interface "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[[&gt;&gt;](#Combined-Index "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9066  ---------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- -------------------------------------------------------------------------------------------------- ----------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9067 
9068 B. Appendix B - FORTRAN 77 to Fortran 90 Transition Guide {.appendix}
9069 =========================================================
9070 
9071 ------------------------------------------------------------------------
9072 
9073  -------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9074  \[[&lt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Previous section in reading order")\] \[[&gt;](#Changes-to-Inquiry-functions "Next section in reading order")\]   \[[&lt;&lt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[&gt;&gt;](#Combined-Index "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9075  -------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9076 
9077 The new Fortran 90 interface {.unnumberedsec}
9078 ----------------------------
9079 
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.
9086 
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.
9094 
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.
9099 
9100 ------------------------------------------------------------------------
9101 
9102  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9103  \[[&lt;](#The-new-Fortran-90-interface "Previous section in reading order")\] \[[&gt;](#Changes-to-put-and-get-function "Next section in reading order")\]   \[[&lt;&lt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[&gt;&gt;](#Combined-Index "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9104  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------ --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9105 
9106 Changes to Inquiry functions {.unnumberedsec}
9107 ----------------------------
9108 
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
9114 interface.
9115 
9116 As an example, compare the attribute inquiry functions in the Fortran 90
9117 interface
9118 
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) |
9126 | | :: name |
9127 | | integer, intent(out), |
9128 | | optional :: xtype, len, attnum |
9129 | | integer |
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) |
9136 | | :: name |
9137 | | integer |
9138 | | :: nf90_inq_attname |
9139 | | ``` |
9140 +--------------------------------------+--------------------------------------+
9141 
9142 with those in the FORTRAN interface
9143 
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) |
9156 | | ``` |
9157 +--------------------------------------+--------------------------------------+
9158 
9159 ------------------------------------------------------------------------
9160 
9161  ------------------------------------------------------------------------------- ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9162  \[[&lt;](#Changes-to-Inquiry-functions "Previous section in reading order")\] \[[&gt;](#Combined-Index "Next section in reading order")\]   \[[&lt;&lt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#FORTRAN-77-to-Fortran-90-Transition-Guide "Up section")\] \[[&gt;&gt;](#Combined-Index "Next chapter")\]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9163  ------------------------------------------------------------------------------- ------------------------------------------------------------- --- ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- ------------------------------------------------ --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9164 
9165 Changes to put and get function {.unnumberedsec}
9166 -------------------------------
9167 
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
9174 representation.
9175 
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.
9182 
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).
9187 
9188 ------------------------------------------------------------------------
9189 
9190  ---------------------------------------------------------------------------------- ------------ --- ------------------------------------------------------------------------------------------------------------ ----------------------------- ---------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9191  \[[&lt;](#Changes-to-put-and-get-function "Previous section in reading order")\] \[ &gt; \]   \[[&lt;&lt;](#FORTRAN-77-to-Fortran-90-Transition-Guide "Beginning of this chapter or previous chapter")\] \[[Up](#Top "Up section")\] \[ &gt;&gt; \]         \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9192  ---------------------------------------------------------------------------------- ------------ --- ------------------------------------------------------------------------------------------------------------ ----------------------------- ---------------- --- --- --- --- ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9193 
9194 Index {.unnumbered}
9195 =====
9196 
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  ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9200 
9201 Index Entry
9202 
9203 Section
9204 
9205 ------------------------------------------------------------------------
9206 
9207 A
9208 
9209 [attributes, adding](#index-attributes_002c-adding)
9210 
9211 [1.5 Adding New Dimensions, Variables,
9212 Attributes](#Adding-New-Dimensions)
9213 
9214 ------------------------------------------------------------------------
9215 
9216 C
9217 
9218 [common netcdf commands](#index-common-netcdf-commands)
9219 
9220 [1. Use of the NetCDF Library](#Use-of-the-NetCDF-Library)
9221 
9222 [compiling with netCDF library](#index-compiling-with-netCDF-library)
9223 
9224 [1.7 Compiling and Linking with the NetCDF
9225 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9226 
9227 [compound types, overview](#index-compound-types_002c-overview)
9228 
9229 [5.6 Compound Types Introduction](#Compound-Types)
9230 
9231 ------------------------------------------------------------------------
9232 
9233 D
9234 
9235 [dataset, creating](#index-dataset_002c-creating)
9236 
9237 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9238 
9239 [datasets, overview](#index-datasets_002c-overview)
9240 
9241 [2.1 Datasets Introduction](#Datasets-Introduction)
9242 
9243 [dimensions, adding](#index-dimensions_002c-adding)
9244 
9245 [1.5 Adding New Dimensions, Variables,
9246 Attributes](#Adding-New-Dimensions)
9247 
9248 ------------------------------------------------------------------------
9249 
9250 E
9251 
9252 [enum type](#index-enum-type)
9253 
9254 [5.9 Enum Type Introduction](#Enum-Type)
9255 
9256 [error handling](#index-error-handling)
9257 
9258 [1.6 Error Handling](#Error-Handling)
9259 
9260 ------------------------------------------------------------------------
9261 
9262 F
9263 
9264 [fill](#index-fill)
9265 
9266 [6.4 Define Fill Parameters for a Variable:
9267 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9268 
9269 ------------------------------------------------------------------------
9270 
9271 G
9272 
9273 [groups, overview](#index-groups_002c-overview)
9274 
9275 [3. Groups](#Groups)
9276 
9277 ------------------------------------------------------------------------
9278 
9279 I
9280 
9281 [interface descriptions](#index-interface-descriptions)
9282 
9283 [2.2 NetCDF Library Interface
9284 Descriptions](#NetCDF-Library-Interface-Descriptions)
9285 
9286 ------------------------------------------------------------------------
9287 
9288 L
9289 
9290 [linking to netCDF library](#index-linking-to-netCDF-library)
9291 
9292 [1.7 Compiling and Linking with the NetCDF
9293 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9294 
9295 ------------------------------------------------------------------------
9296 
9297 N
9298 
9299 [nf-config](#index-nf_002dconfig)
9300 
9301 [1.7 Compiling and Linking with the NetCDF
9302 Library](#Compiling-and-Linking-with-the-NetCDF-Library)
9303 
9304 [NF90\_ABORT](#index-NF90_005fABORT)
9305 
9306 [2.12 NF90\_ABORT](#NF90_005fABORT)
9307 
9308 [NF90\_ABORT , example](#index-NF90_005fABORT-_002c-example)
9309 
9310 [2.12 NF90\_ABORT](#NF90_005fABORT)
9311 
9312 [NF90\_CLOSE](#index-NF90_005fCLOSE)
9313 
9314 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
9315 
9316 [NF90\_CLOSE , example](#index-NF90_005fCLOSE-_002c-example)
9317 
9318 [2.9 NF90\_CLOSE](#NF90_005fCLOSE)
9319 
9320 [NF90\_CLOSE, typical use](#index-NF90_005fCLOSE_002c-typical-use)
9321 
9322 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9323 
9324 [NF90\_COPY\_ATT](#index-NF90_005fCOPY_005fATT)
9325 
9326 [7.5 Copy Attribute from One NetCDF to Another:
9327 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
9328 
9329 [NF90\_COPY\_ATT, example](#index-NF90_005fCOPY_005fATT_002c-example)
9330 
9331 [7.5 Copy Attribute from One NetCDF to Another:
9332 NF90\_COPY\_ATT](#NF90_005fCOPY_005fATT)
9333 
9334 [NF90\_CREATE](#index-NF90_005fCREATE)
9335 
9336 [2.5 NF90\_CREATE](#NF90_005fCREATE)
9337 
9338 [NF90\_CREATE , example](#index-NF90_005fCREATE-_002c-example)
9339 
9340 [2.5 NF90\_CREATE](#NF90_005fCREATE)
9341 
9342 [NF90\_CREATE, typical use](#index-NF90_005fCREATE_002c-typical-use)
9343 
9344 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9345 
9346 [NF90\_DEF\_COMPOUND](#index-NF90_005fDEF_005fCOMPOUND)
9347 
9348 [5.6.1 Creating a Compound Type:
9349 NF90\_DEF\_COMPOUND](#NF90_005fDEF_005fCOMPOUND)
9350 
9351 [NF90\_DEF\_DIM](#index-NF90_005fDEF_005fDIM)
9352 
9353 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
9354 
9355 [NF90\_DEF\_DIM, example](#index-NF90_005fDEF_005fDIM_002c-example)
9356 
9357 [4.2 NF90\_DEF\_DIM](#NF90_005fDEF_005fDIM)
9358 
9359 [NF90\_DEF\_DIM, typical
9360 use](#index-NF90_005fDEF_005fDIM_002c-typical-use)
9361 
9362 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9363 
9364 [NF90\_DEF\_ENUM](#index-NF90_005fDEF_005fENUM)
9365 
9366 [5.9.1 Creating a Enum Type: NF90\_DEF\_ENUM](#NF90_005fDEF_005fENUM)
9367 
9368 [NF90\_DEF\_GRP](#index-NF90_005fDEF_005fGRP)
9369 
9370 [3.11 Create a New Group: NF90\_DEF\_GRP](#NF90_005fDEF_005fGRP)
9371 
9372 [NF90\_DEF\_OPAQUE](#index-NF90_005fDEF_005fOPAQUE)
9373 
9374 [5.8.1 Creating Opaque Types:
9375 NF90\_DEF\_OPAQUE](#NF90_005fDEF_005fOPAQUE)
9376 
9377 [NF90\_DEF\_VAR](#index-NF90_005fDEF_005fVAR)
9378 
9379 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
9380 
9381 [NF90\_DEF\_VAR, example](#index-NF90_005fDEF_005fVAR_002c-example)
9382 
9383 [6.3 Create a Variable: `NF90_DEF_VAR`](#NF90_005fDEF_005fVAR)
9384 
9385 [NF90\_DEF\_VAR, typical
9386 use](#index-NF90_005fDEF_005fVAR_002c-typical-use)
9387 
9388 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9389 
9390 [NF90\_DEF\_VAR\_FILL](#index-NF90_005fDEF_005fVAR_005fFILL)
9391 
9392 [6.4 Define Fill Parameters for a Variable:
9393 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9394 
9395 [NF90\_DEF\_VLEN](#index-NF90_005fDEF_005fVLEN)
9396 
9397 [5.7.1 Define a Variable Length Array (VLEN):
9398 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
9399 
9400 [NF90\_DEL\_ATT](#index-NF90_005fDEL_005fATT)
9401 
9402 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
9403 
9404 [NF90\_DEL\_ATT , example](#index-NF90_005fDEL_005fATT-_002c-example)
9405 
9406 [7.7 NF90\_DEL\_ATT](#NF90_005fDEL_005fATT)
9407 
9408 [NF90\_ENDDEF](#index-NF90_005fENDDEF)
9409 
9410 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
9411 
9412 [NF90\_ENDDEF , example](#index-NF90_005fENDDEF-_002c-example)
9413 
9414 [2.8 NF90\_ENDDEF](#NF90_005fENDDEF)
9415 
9416 [NF90\_ENDDEF, typical use](#index-NF90_005fENDDEF_002c-typical-use)
9417 
9418 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9419 
9420 [NF90\_FREE\_VLEN](#index-NF90_005fFREE_005fVLEN)
9421 
9422 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
9423 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
9424 
9425 [NF90\_GET\_ATT](#index-NF90_005fGET_005fATT)
9426 
9427 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
9428 
9429 [NF90\_GET\_ATT, example](#index-NF90_005fGET_005fATT_002c-example)
9430 
9431 [7.4 Get Attribute’s Values: NF90\_GET\_ATT](#NF90_005fGET_005fATT)
9432 
9433 [NF90\_GET\_ATT, typical
9434 use](#index-NF90_005fGET_005fATT_002c-typical-use)
9435 
9436 [1.2 Reading a NetCDF Dataset with Known
9437 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9438 
9439 [NF90\_GET\_ATT, typical
9440 use](#index-NF90_005fGET_005fATT_002c-typical-use-1)
9441 
9442 [1.3 Reading a netCDF Dataset with Unknown
9443 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9444 
9445 [NF90\_GET\_VAR](#index-NF90_005fGET_005fVAR)
9446 
9447 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
9448 
9449 [NF90\_GET\_VAR, example](#index-NF90_005fGET_005fVAR_002c-example)
9450 
9451 [6.9 Reading Data Values: NF90\_GET\_VAR](#NF90_005fGET_005fVAR)
9452 
9453 [NF90\_GET\_VAR, typical
9454 use](#index-NF90_005fGET_005fVAR_002c-typical-use)
9455 
9456 [1.2 Reading a NetCDF Dataset with Known
9457 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9458 
9459 [NF90\_GET\_VLEN\_ELEMENT](#index-NF90_005fGET_005fVLEN_005fELEMENT)
9460 
9461 [5.5.2 Set a Variable Length Array with
9462 NF90\_GET\_VLEN\_ELEMENT](#NF90_005fGET_005fVLEN_005fELEMENT)
9463 
9464 [NF90\_INQUIRE, typical use](#index-NF90_005fINQUIRE_002c-typical-use)
9465 
9466 [1.3 Reading a netCDF Dataset with Unknown
9467 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9468 
9469 [NF90\_INQUIRE\_ATTRIBUTE](#index-NF90_005fINQUIRE_005fATTRIBUTE)
9470 
9471 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9472 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9473 
9474 [NF90\_INQUIRE\_ATTRIBUTE,
9475 example](#index-NF90_005fINQUIRE_005fATTRIBUTE_002c-example)
9476 
9477 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9478 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9479 
9480 [NF90\_INQUIRE\_ATTRIBUTE, typical
9481 use](#index-NF90_005fINQUIRE_005fATTRIBUTE_002c-typical-use)
9482 
9483 [1.3 Reading a netCDF Dataset with Unknown
9484 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9485 
9486 [NF90\_INQUIRE\_DIMENSION](#index-NF90_005fINQUIRE_005fDIMENSION)
9487 
9488 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
9489 
9490 [NF90\_INQUIRE\_DIMENSION ,
9491 example](#index-NF90_005fINQUIRE_005fDIMENSION-_002c-example)
9492 
9493 [4.4 NF90\_INQUIRE\_DIMENSION](#NF90_005fINQUIRE_005fDIMENSION)
9494 
9495 [NF90\_INQUIRE\_DIMENSION, typical
9496 use](#index-NF90_005fINQUIRE_005fDIMENSION_002c-typical-use)
9497 
9498 [1.3 Reading a netCDF Dataset with Unknown
9499 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9500 
9501 [NF90\_INQUIRE\_VARIABLE](#index-NF90_005fINQUIRE_005fVARIABLE)
9502 
9503 [6.6 Get Information about a Variable from Its ID:
9504 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
9505 
9506 [NF90\_INQUIRE\_VARIABLE ,
9507 example](#index-NF90_005fINQUIRE_005fVARIABLE-_002c-example)
9508 
9509 [6.6 Get Information about a Variable from Its ID:
9510 NF90\_INQUIRE\_VARIABLE](#NF90_005fINQUIRE_005fVARIABLE)
9511 
9512 [NF90\_INQUIRE\_VARIABLE, typical
9513 use](#index-NF90_005fINQUIRE_005fVARIABLE_002c-typical-use)
9514 
9515 [1.3 Reading a netCDF Dataset with Unknown
9516 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9517 
9518 [NF90\_INQ\_ATTNAME](#index-NF90_005fINQ_005fATTNAME)
9519 
9520 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9521 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9522 
9523 [NF90\_INQ\_ATTNAME,
9524 example](#index-NF90_005fINQ_005fATTNAME_002c-example)
9525 
9526 [7.3 Get Information about an Attribute: NF90\_INQUIRE\_ATTRIBUTE and
9527 NF90\_INQ\_ATTNAME](#NF90_005fINQUIRE_005fATTRIBUTE)
9528 
9529 [NF90\_INQ\_ATTNAME, typical
9530 use](#index-NF90_005fINQ_005fATTNAME_002c-typical-use)
9531 
9532 [1.3 Reading a netCDF Dataset with Unknown
9533 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9534 
9535 [NF90\_INQ\_CMP\_FIELDDIM\_SIZES](#index-NF90_005fINQ_005fCMP_005fFIELDDIM_005fSIZES)
9536 
9537 [5.6.5 Learn About a Field of a Compound Type:
9538 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9539 
9540 [NF90\_INQ\_COMPOUND](#index-NF90_005fINQ_005fCOMPOUND)
9541 
9542 [5.6.4 Learn About a Compound Type:
9543 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9544 
9545 [NF90\_INQ\_COMPOUND\_FIELD](#index-NF90_005fINQ_005fCOMPOUND_005fFIELD)
9546 
9547 [5.6.5 Learn About a Field of a Compound Type:
9548 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9549 
9550 [NF90\_INQ\_COMPOUND\_FIELDINDEX](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDINDEX)
9551 
9552 [5.6.5 Learn About a Field of a Compound Type:
9553 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9554 
9555 [NF90\_INQ\_COMPOUND\_FIELDNAME](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDNAME)
9556 
9557 [5.6.5 Learn About a Field of a Compound Type:
9558 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9559 
9560 [NF90\_INQ\_COMPOUND\_FIELDNDIMS](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDNDIMS)
9561 
9562 [5.6.5 Learn About a Field of a Compound Type:
9563 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9564 
9565 [NF90\_INQ\_COMPOUND\_FIELDOFFSET](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDOFFSET)
9566 
9567 [5.6.5 Learn About a Field of a Compound Type:
9568 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9569 
9570 [NF90\_INQ\_COMPOUND\_FIELDTYPE](#index-NF90_005fINQ_005fCOMPOUND_005fFIELDTYPE)
9571 
9572 [5.6.5 Learn About a Field of a Compound Type:
9573 NF90\_INQ\_COMPOUND\_FIELD](#NF90_005fINQ_005fCOMPOUND_005fFIELD)
9574 
9575 [NF90\_INQ\_COMPOUND\_NAME](#index-NF90_005fINQ_005fCOMPOUND_005fNAME)
9576 
9577 [5.6.4 Learn About a Compound Type:
9578 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9579 
9580 [NF90\_INQ\_COMPOUND\_NFIELDS](#index-NF90_005fINQ_005fCOMPOUND_005fNFIELDS)
9581 
9582 [5.6.4 Learn About a Compound Type:
9583 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9584 
9585 [NF90\_INQ\_COMPOUND\_SIZE](#index-NF90_005fINQ_005fCOMPOUND_005fSIZE)
9586 
9587 [5.6.4 Learn About a Compound Type:
9588 NF90\_INQ\_COMPOUND](#NF90_005fINQ_005fCOMPOUND)
9589 
9590 [NF90\_INQ\_DIMID](#index-NF90_005fINQ_005fDIMID)
9591 
9592 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
9593 
9594 [NF90\_INQ\_DIMID ,
9595 example](#index-NF90_005fINQ_005fDIMID-_002c-example)
9596 
9597 [4.3 NF90\_INQ\_DIMID](#NF90_005fINQ_005fDIMID)
9598 
9599 [NF90\_INQ\_DIMID, typical
9600 use](#index-NF90_005fINQ_005fDIMID_002c-typical-use)
9601 
9602 [1.2 Reading a NetCDF Dataset with Known
9603 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9604 
9605 [NF90\_INQ\_DIMIDS](#index-NF90_005fINQ_005fDIMIDS)
9606 
9607 [3.4 Find all Dimensions Visible in a Group:
9608 NF90\_INQ\_DIMIDS](#NF90_005fINQ_005fDIMIDS)
9609 
9610 [NF90\_INQ\_ENUM](#index-NF90_005fINQ_005fENUM)
9611 
9612 [5.9.3 Learn About a Enum Type: NF90\_INQ\_ENUM](#NF90_005fINQ_005fENUM)
9613 
9614 [NF90\_INQ\_ENUM\_IDENT](#index-NF90_005fINQ_005fENUM_005fIDENT)
9615 
9616 [5.9.5 Learn the Name of a Enum Type:
9617 NF90\_INQ\_ENUM\_IDENT](#NF90_005fINQ_005fENUM_005fIDENT)
9618 
9619 [nf90\_inq\_enum\_member](#index-nf90_005finq_005fenum_005fmember)
9620 
9621 [5.9.4 Learn the Name of a Enum Type:
9622 nf90\_inq\_enum\_member](#NF90_005fINQ_005fENUM_005fMEMBER)
9623 
9624 [NF90\_INQ\_GRPNAME](#index-NF90_005fINQ_005fGRPNAME)
9625 
9626 [3.6 Find a Group’s Name: NF90\_INQ\_GRPNAME](#NF90_005fINQ_005fGRPNAME)
9627 
9628 [NF90\_INQ\_GRPNAME\_FULL](#index-NF90_005fINQ_005fGRPNAME_005fFULL)
9629 
9630 [3.7 Find a Group’s Full Name:
9631 NF90\_INQ\_GRPNAME\_FULL](#NF90_005fINQ_005fGRPNAME_005fFULL)
9632 
9633 [NF90\_INQ\_GRPNAME\_LEN](#index-NF90_005fINQ_005fGRPNAME_005fLEN)
9634 
9635 [3.5 Find the Length of a Group’s Full Name:
9636 NF90\_INQ\_GRPNAME\_LEN](#NF90_005fINQ_005fGRPNAME_005fLEN)
9637 
9638 [NF90\_INQ\_GRPS](#index-NF90_005fINQ_005fGRPS)
9639 
9640 [3.2 Get a List of Groups in a Group:
9641 NF90\_INQ\_GRPS](#NF90_005fINQ_005fGRPS)
9642 
9643 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT)
9644 
9645 [3.8 Find a Group’s Parent:
9646 NF90\_INQ\_GRP\_PARENT](#NF90_005fINQ_005fGRP_005fPARENT)
9647 
9648 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT-1)
9649 
9650 [3.9 Find a Group by Name:
9651 NF90\_INQ\_GRP\_NCID](#NF90_005fINQ_005fGRP_005fNCID)
9652 
9653 [NF90\_INQ\_GRP\_PARENT](#index-NF90_005fINQ_005fGRP_005fPARENT-2)
9654 
9655 [3.10 Find a Group by its Fully-qualified Name:
9656 NF90\_INQ\_GRP\_FULL\_NCID](#NF90_005fINQ_005fGRP_005fFULL_005fNCID)
9657 
9658 [NF90\_INQ\_LIBVERS](#index-NF90_005fINQ_005fLIBVERS)
9659 
9660 [2.4 Get netCDF library version:
9661 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
9662 
9663 [NF90\_INQ\_LIBVERS,
9664 example](#index-NF90_005fINQ_005fLIBVERS_002c-example)
9665 
9666 [2.4 Get netCDF library version:
9667 NF90\_INQ\_LIBVERS](#NF90_005fINQ_005fLIBVERS)
9668 
9669 [NF90\_INQ\_NCID](#index-NF90_005fINQ_005fNCID)
9670 
9671 [3.1 Find a Group ID: NF90\_INQ\_NCID](#NF90_005fINQ_005fNCID)
9672 
9673 [NF90\_INQ\_OPAQUE](#index-NF90_005fINQ_005fOPAQUE)
9674 
9675 [5.8.2 Learn About an Opaque Type:
9676 NF90\_INQ\_OPAQUE](#NF90_005fINQ_005fOPAQUE)
9677 
9678 [NF90\_INQ\_TYPE](#index-NF90_005fINQ_005fTYPE)
9679 
9680 [5.4 Learn About a User Defined Type:
9681 NF90\_INQ\_TYPE](#NF90_005fINQ_005fTYPE)
9682 
9683 [nf90\_inq\_typeid](#index-nf90_005finq_005ftypeid)
9684 
9685 [5.3 Find a Typeid from Group and Name:
9686 nf90\_inq\_typeid](#nf90_005finq_005ftypeid)
9687 
9688 [NF90\_INQ\_TYPEIDS](#index-NF90_005fINQ_005fTYPEIDS)
9689 
9690 [5.2 Learn the IDs of All Types in Group:
9691 NF90\_INQ\_TYPEIDS](#NF90_005fINQ_005fTYPEIDS)
9692 
9693 [NF90\_INQ\_USER\_TYPE](#index-NF90_005fINQ_005fUSER_005fTYPE)
9694 
9695 [5.5 Learn About a User Defined Type:
9696 NF90\_INQ\_USER\_TYPE](#NF90_005fINQ_005fUSER_005fTYPE)
9697 
9698 [NF90\_INQ\_VARID](#index-NF90_005fINQ_005fVARID)
9699 
9700 [6.7 Get the ID of a variable from the name:
9701 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
9702 
9703 [NF90\_INQ\_VARID, example](#index-NF90_005fINQ_005fVARID_002c-example)
9704 
9705 [6.7 Get the ID of a variable from the name:
9706 NF90\_INQ\_VARID](#NF90_005fINQ_005fVARID)
9707 
9708 [NF90\_INQ\_VARID, typical
9709 use](#index-NF90_005fINQ_005fVARID_002c-typical-use)
9710 
9711 [1.2 Reading a NetCDF Dataset with Known
9712 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9713 
9714 [NF90\_INQ\_VARID, typical
9715 use](#index-NF90_005fINQ_005fVARID_002c-typical-use-1)
9716 
9717 [1.4 Writing Data in an Existing NetCDF
9718 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9719 
9720 [NF90\_INQ\_VARIDS](#index-NF90_005fINQ_005fVARIDS)
9721 
9722 [3.3 Find all the Variables in a Group:
9723 NF90\_INQ\_VARIDS](#NF90_005fINQ_005fVARIDS)
9724 
9725 [NF90\_INQ\_VAR\_FILL](#index-NF90_005fINQ_005fVAR_005fFILL)
9726 
9727 [6.5 Learn About Fill Parameters for a Variable:
9728 `NF90_INQ_VAR_FILL`](#NF90_005fINQ_005fVAR_005fFILL)
9729 
9730 [NF90\_INQ\_VLEN](#index-NF90_005fINQ_005fVLEN)
9731 
9732 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
9733 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
9734 
9735 [NF90\_INSERT\_ARRAY\_COMPOUND](#index-NF90_005fINSERT_005fARRAY_005fCOMPOUND)
9736 
9737 [5.6.3 Inserting an Array Field into a Compound Type:
9738 NF90\_INSERT\_ARRAY\_COMPOUND](#NF90_005fINSERT_005fARRAY_005fCOMPOUND)
9739 
9740 [NF90\_INSERT\_COMPOUND](#index-NF90_005fINSERT_005fCOMPOUND)
9741 
9742 [5.6.2 Inserting a Field into a Compound Type:
9743 NF90\_INSERT\_COMPOUND](#NF90_005fINSERT_005fCOMPOUND)
9744 
9745 [NF90\_INSERT\_ENUM](#index-NF90_005fINSERT_005fENUM)
9746 
9747 [5.9.2 Inserting a Field into a Enum Type:
9748 NF90\_INSERT\_ENUM](#NF90_005fINSERT_005fENUM)
9749 
9750 [NF90\_OPEN](#index-NF90_005fOPEN)
9751 
9752 [2.6 NF90\_OPEN](#NF90_005fOPEN)
9753 
9754 [NF90\_OPEN , example](#index-NF90_005fOPEN-_002c-example)
9755 
9756 [2.6 NF90\_OPEN](#NF90_005fOPEN)
9757 
9758 [NF90\_OPEN, typical use](#index-NF90_005fOPEN_002c-typical-use)
9759 
9760 [1.2 Reading a NetCDF Dataset with Known
9761 Names](#Reading-a-NetCDF-Dataset-with-Known-Names)
9762 
9763 [NF90\_PUT\_ATT](#index-NF90_005fPUT_005fATT)
9764 
9765 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
9766 
9767 [NF90\_PUT\_ATT, example](#index-NF90_005fPUT_005fATT_002c-example)
9768 
9769 [7.2 Create an Attribute: NF90\_PUT\_ATT](#NF90_005fPUT_005fATT)
9770 
9771 [NF90\_PUT\_ATT, typical
9772 use](#index-NF90_005fPUT_005fATT_002c-typical-use)
9773 
9774 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9775 
9776 [NF90\_PUT\_ATT, typical
9777 use](#index-NF90_005fPUT_005fATT_002c-typical-use-1)
9778 
9779 [1.4 Writing Data in an Existing NetCDF
9780 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9781 
9782 [NF90\_PUT\_VAR](#index-NF90_005fPUT_005fVAR)
9783 
9784 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
9785 
9786 [NF90\_PUT\_VAR, example](#index-NF90_005fPUT_005fVAR_002c-example)
9787 
9788 [6.8 Writing Data Values: NF90\_PUT\_VAR](#NF90_005fPUT_005fVAR)
9789 
9790 [NF90\_PUT\_VAR, typical
9791 use](#index-NF90_005fPUT_005fVAR_002c-typical-use)
9792 
9793 [1.1 Creating a NetCDF Dataset](#Creating-a-NetCDF-Dataset)
9794 
9795 [NF90\_PUT\_VAR, typical
9796 use](#index-NF90_005fPUT_005fVAR_002c-typical-use-1)
9797 
9798 [1.4 Writing Data in an Existing NetCDF
9799 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9800 
9801 [NF90\_PUT\_VLEN\_ELEMENT](#index-NF90_005fPUT_005fVLEN_005fELEMENT)
9802 
9803 [5.5.1 Set a Variable Length Array with
9804 NF90\_PUT\_VLEN\_ELEMENT](#NF90_005fPUT_005fVLEN_005fELEMENT)
9805 
9806 [NF90\_REDEF](#index-NF90_005fREDEF)
9807 
9808 [2.7 NF90\_REDEF](#NF90_005fREDEF)
9809 
9810 [NF90\_REDEF , example](#index-NF90_005fREDEF-_002c-example)
9811 
9812 [2.7 NF90\_REDEF](#NF90_005fREDEF)
9813 
9814 [NF90\_REDEF, typical use](#index-NF90_005fREDEF_002c-typical-use)
9815 
9816 [1.5 Adding New Dimensions, Variables,
9817 Attributes](#Adding-New-Dimensions)
9818 
9819 [NF90\_RENAME\_ATT](#index-NF90_005fRENAME_005fATT)
9820 
9821 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
9822 
9823 [NF90\_RENAME\_ATT,
9824 example](#index-NF90_005fRENAME_005fATT_002c-example)
9825 
9826 [7.6 Rename an Attribute: NF90\_RENAME\_ATT](#NF90_005fRENAME_005fATT)
9827 
9828 [NF90\_RENAME\_DIM](#index-NF90_005fRENAME_005fDIM)
9829 
9830 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
9831 
9832 [NF90\_RENAME\_DIM ,
9833 example](#index-NF90_005fRENAME_005fDIM-_002c-example)
9834 
9835 [4.5 NF90\_RENAME\_DIM](#NF90_005fRENAME_005fDIM)
9836 
9837 [NF90\_RENAME\_VAR](#index-NF90_005fRENAME_005fVAR)
9838 
9839 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
9840 
9841 [NF90\_RENAME\_VAR ,
9842 example](#index-NF90_005fRENAME_005fVAR-_002c-example)
9843 
9844 [6.12 NF90\_RENAME\_VAR](#NF90_005fRENAME_005fVAR)
9845 
9846 [NF90\_SET\_FILL](#index-NF90_005fSET_005fFILL)
9847 
9848 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
9849 
9850 [NF90\_SET\_FILL , example](#index-NF90_005fSET_005fFILL-_002c-example)
9851 
9852 [2.13 NF90\_SET\_FILL](#NF90_005fSET_005fFILL)
9853 
9854 [NF90\_STRERROR](#index-NF90_005fSTRERROR)
9855 
9856 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
9857 
9858 [NF90\_STRERROR, example](#index-NF90_005fSTRERROR_002c-example)
9859 
9860 [2.3 NF90\_STRERROR](#NF90_005fSTRERROR)
9861 
9862 [NF90\_STRERROR,
9863 introduction](#index-NF90_005fSTRERROR_002c-introduction)
9864 
9865 [1.6 Error Handling](#Error-Handling)
9866 
9867 [NF90\_SYNC](#index-NF90_005fSYNC)
9868 
9869 [2.11 NF90\_SYNC](#NF90_005fSYNC)
9870 
9871 [NF90\_SYNC , example](#index-NF90_005fSYNC-_002c-example)
9872 
9873 [2.11 NF90\_SYNC](#NF90_005fSYNC)
9874 
9875 [NF90\_VAR\_PAR\_ACCESS](#index-NF90_005fVAR_005fPAR_005fACCESS)
9876 
9877 [6.13 Change between Collective and Independent Parallel Access:
9878 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
9879 
9880 [NF90\_VAR\_PAR\_ACCESS,
9881 example](#index-NF90_005fVAR_005fPAR_005fACCESS_002c-example)
9882 
9883 [6.13 Change between Collective and Independent Parallel Access:
9884 NF90\_VAR\_PAR\_ACCESS](#NF90_005fVAR_005fPAR_005fACCESS)
9885 
9886 ------------------------------------------------------------------------
9887 
9888 O
9889 
9890 [opaque type](#index-opaque-type)
9891 
9892 [5.8 Opaque Type Introduction](#Opaque-Type)
9893 
9894 ------------------------------------------------------------------------
9895 
9896 R
9897 
9898 [reading dataset with unknown
9899 names](#index-reading-dataset-with-unknown-names)
9900 
9901 [1.3 Reading a netCDF Dataset with Unknown
9902 Names](#Reading-a-netCDF-Dataset-with-Unknown-Names)
9903 
9904 ------------------------------------------------------------------------
9905 
9906 U
9907 
9908 [user defined types](#index-user-defined-types)
9909 
9910 [5. User Defined Data Types](#User-Defined-Data-Types)
9911 
9912 [user defined types, overview](#index-user-defined-types_002c-overview)
9913 
9914 [5.1 User Defined Types Introduction](#User-Defined-Types)
9915 
9916 [users’ guide, netcdf](#index-users_0027-guide_002c-netcdf)
9917 
9918 [1. Use of the NetCDF Library](#Use-of-the-NetCDF-Library)
9919 
9920 ------------------------------------------------------------------------
9921 
9922 V
9923 
9924 [variable length array type,
9925 overview](#index-variable-length-array-type_002c-overview)
9926 
9927 [5. User Defined Data Types](#User-Defined-Data-Types)
9928 
9929 [variable length arrays](#index-variable-length-arrays)
9930 
9931 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
9932 
9933 [variables, adding](#index-variables_002c-adding)
9934 
9935 [1.5 Adding New Dimensions, Variables,
9936 Attributes](#Adding-New-Dimensions)
9937 
9938 [variables, fill](#index-variables_002c-fill)
9939 
9940 [6.4 Define Fill Parameters for a Variable:
9941 `nf90_def_var_fill`](#NF90_005fDEF_005fVAR_005fFILL)
9942 
9943 [VLEN](#index-VLEN)
9944 
9945 [5.7 Variable Length Array Introduction](#Variable-Length-Array)
9946 
9947 [VLEN, defining](#index-VLEN_002c-defining)
9948 
9949 [5.7.1 Define a Variable Length Array (VLEN):
9950 NF90\_DEF\_VLEN](#NF90_005fDEF_005fVLEN)
9951 
9952 [VLEN, defining](#index-VLEN_002c-defining-1)
9953 
9954 [5.7.2 Learning about a Variable Length Array (VLEN) Type:
9955 NF90\_INQ\_VLEN](#NF90_005fINQ_005fVLEN)
9956 
9957 [VLEN, defining](#index-VLEN_002c-defining-2)
9958 
9959 [5.7.3 Releasing Memory for a Variable Length Array (VLEN) Type:
9960 NF90\_FREE\_VLEN](#NF90_005fFREE_005fVLEN)
9961 
9962 ------------------------------------------------------------------------
9963 
9964 W
9965 
9966 [writing to existing dataset](#index-writing-to-existing-dataset)
9967 
9968 [1.4 Writing Data in an Existing NetCDF
9969 Dataset](#Writing-Data-in-an-Existing-NetCDF-Dataset)
9970 
9971 ------------------------------------------------------------------------
9972 
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  ------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9976 
9977 ------------------------------------------------------------------------
9978 
9979  ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9980  \[[Top](#Top "Cover (top) of document")\] \[Contents\] \[[Index](#Combined-Index "Index")\] \[[?](#SEC_About "About (help)")\]
9981  ------------------------------------------- -------------- -------------------------------------- ------------------------------------
9982 
9983 About This Document
9984 ===================
9985 
9986 This document was generated by *Ward Fisher* on *July 14, 2015* using
9987 [*texi2html 1.82*](http://www.nongnu.org/texi2html/).
9988 
9989 The buttons in the navigation panels have the following meaning:
9990 
9991  Button Name Go to From 1.2.3 go to
9992  ---------------- ------------- ----------------------------------------------- ------------------
9993  \[ &lt; \] Back Previous section in reading order 1.2.2
9994  \[ &gt; \] Forward Next section in reading order 1.2.4
9995  \[ &lt;&lt; \] FastBack Beginning of this chapter or previous chapter 1
9996  \[ Up \] Up Up section 1.2
9997  \[ &gt;&gt; \] 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)  
10002 
10003 where the **Example** assumes that the current position is at
10004 **Subsubsection One-Two-Three** of a document of the following
10005 structure:
10006 
10007 - 1\. Section One
10008  - 1.1 Subsection One-One
10009  - ...
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     **&lt;== Current
10014  Position**
10015  - 1.2.4 Subsubsection One-Two-Four
10016  - 1.3 Subsection One-Three
10017  - ...
10018  - 1.4 Subsection One-Four
10019 
10020 ------------------------------------------------------------------------
10021 
10022 This document was generated by *Ward Fisher* on *July 14, 2015* using
10023 [*texi2html 1.82*](http://www.nongnu.org/texi2html/).\
10024 

Return to the Main Unidata NetCDF page.
Generated on Fri Jan 22 2016 10:52:16 for NetCDF-Fortran. NetCDF is a Unidata library.