File: netcdf-cxx.texi

package info (click to toggle)
netcdf 1%3A4.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,340 kB
  • sloc: ansic: 200,241; sh: 10,808; yacc: 2,522; makefile: 1,234; lex: 1,153; xml: 173; awk: 2
file content (1238 lines) | stat: -rw-r--r-- 42,464 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
\input texinfo   @c -*-texinfo-*-
@comment This is part of the netCDF documentation. See COPYRIGHT file
@comment $Id: netcdf-cxx.texi,v 1.3 2008/08/06 17:01:13 dmh Exp $
@comment %**start of header
@setfilename netcdf-cxx.info
@settitle NetCDF C++ Interface Guide
@setchapternewpage odd
@setcontentsaftertitlepage
@c Combine the variable and function indices.
@synindex vr cp
@synindex fn cp
@c %**end of header

@c version.texi is automatically generated by automake and contains
@c defined variables VERSION, UPDATED, UPDATED-MONTH.
@include version-cxx.texi
@include defines.texi

@ifinfo
@dircategory netCDF scientific data format
@direntry
* netcdf-cxx: (netcdf-cxx).         @value{cxx-man}
@end direntry
@end ifinfo

@titlepage
@title @value{cxx-man}
@subtitle Class Documentation
@subtitle Version @value{VERSION}
@subtitle @value{UPDATED}
@author Russ Rew
@author Unidata Program Center
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@ifnottex
@node Top, Introduction, (dir), (dir)
@top @value{cxx-man}

This document describes the netCDF C++ API. It applies to netCDF
version @value{VERSION} release of the software, but the C++ interface
still only supports the ``classic'' data model from the netCDF-3
release. This document was last updated in @value{UPDATED}.

The netCDF library provides an application- and machine-independent
interface to self-describing, array-oriented data.  It supports an
abstract view of such data as a collection of named variables and
their attributes, and provides high-level access to data that is
faithful to the abstraction.  This on-line document describes the C++
interface to netCDF.  This C++ interface is still based on the classic
data model supported by netCDF-3 software; it has not yet been updated
to the enhanced data model supported by netCDF-4.

The first part of this master menu lists the major nodes in this Info
document.  The rest of the menu lists all the lower level nodes in the
document.

For a complete description of the netCDF format and utilities see 
@ref{Top,, , netcdf, @value{n-man}}.

@end ifnottex

@menu
* Introduction::                
* NetCDF Classes::              
* Auxiliary Classes::           
* Combined Index::              

@detailmenu
 --- The Detailed Node Listing ---

Introduction

* Class Hierarchy::             
* Auxiliary Types and Constants::  

NetCDF Classes

* Class NcFile::                Files
* Class NcDim::                 Dimensions
* Class NcTypedComponent::      Operations common to variables and attributes
* Class NcVar::                 Variables
* Class NcAtt::                 Attributes

Auxiliary Classes

* Class NcValues::              
* Class NcError::               

@end detailmenu
@end menu

@node Introduction, NetCDF Classes, Top, Top
@unnumbered Introduction
@cindex requirements of C++ interface

The main requirements for the design of the C++ interface are:

@itemize @bullet
@item
to provide the functionality of the C interface;
@item
to provide type safety by eliminating all use of @code{void*} pointers; and
@item
to provide an interface that is simpler to use than the C interface.
@end itemize

Some of the features of the C++ interface are:

@itemize @bullet
@item
No IDs needed for netCDF's variables, dimensions, or attributes.
@item
No explicit open or close calls needed for netCDF files; a constructor
opens and a destructor closes a file.
@item
No need to specify types for creating attributes; they will have the
type of the value provided.
@item
No use of @code{void*}: values are type-checked.
@item
Less indirection is needed for dimensions and dimension sizes than with
the C interface.  A variable's dimensions can be provided as arguments 
when defining a variable.
@item
Code for data types is isolated to make the addition of new
types easier.
@item
No explicit @code{ncredef} or @code{ncendef} calls are needed for
switching between define and data modes.  Whenever a mode switch is
required, it happens implicitly.
@end itemize

The header file @file{netcdfcpp.h} must be included in source code files
using this interface.

This release provides some of the functionality of netCDF version 4,
but not for the enhanced data model introduced with netCDF-4.

This manual assumes familiarity with the netCDF User's Guide, where
the concepts of netCDF dimensions, variables, and attributes are
discussed.

@menu
* Class Hierarchy::             
* Auxiliary Types and Constants::  
@end menu

@node Class Hierarchy, Auxiliary Types and Constants, Introduction, Introduction
@unnumberedsec Class Hierarchy
@cindex class hierarchy

The class for netCDF file objects is @code{NcFile}.

The components of a netCDF file are dimensions, variables, and
attributes.  There is a class for each of these kinds of objects;
@code{NcDim}, @code{NcVar}, and @code{NcAtt}.  Variables and attributes
share some common characteristics that are factored out in the
abstract base class @code{NcTypedComponent}.

An auxiliary class, @code{NcValues}, provides a type for arrays of values
that are read from or written to netCDF files.  Another auxiliary class,
@code{NcError}, provides facilities for handling errors.

@example
@group
@code{NcFile}                     netCDF file

@code{NcDim}                      dimension

@code{NcTypedComponent}           abstract base class
        @code{NcVar}                variable
        @code{NcAtt}                attribute

@code{NcValues}                   abstract base class for array
        @code{NcValues_ncbyte}      array of bytes
        @code{NcValues_char}        array of characters
        @code{NcValues_short}       array of shorts
        @code{NcValues_int}         array of ints
        @code{NcValues_long}        array of longs
        @code{NcValues_float}       array of floats
        @code{NcValues_double}      array of doubles

@code{NcError}                    for error handling
@end group
@end example

@node Auxiliary Types and Constants,  , Class Hierarchy, Introduction
@unnumberedsec Auxiliary Types and Constants
@cindex auxiliary types and constants

The netCDF classes use several auxiliary types for arguments and return
types from member functions: @code{NcToken}, @code{NcType},
@code{NcBool}, and @code{ncbyte}.

@table @code
@vindex NcToken
@item NcToken
Used for names for netCDF objects, in particular variable names, dimension
names, and attribute names.  Currently this is just a typedef for
@code{const char*}.

@vindex NcType
@item NcType
Used for specifying netCDF external value types.  Currently this is an
enumerated type with the following legitimate values: @code{ncByte},
@code{ncChar}, @code{ncShort}, @code{ncInt}, @code{ncLong} (deprecated),
@code{ncFloat}, and @code{ncDouble}.

@vindex NcBool
@item NcBool
Used for the return type of some member functions.  If the member
function fails, 0 is returned, otherwise some non-zero value.  Currently
this is just a typedef for @code{unsigned int}.  It will be changed to
@code{bool} when all C++ compilers support the new @code{bool} type.

@vindex ncbyte
@item ncbyte
Used to declare values of type @code{ncByte}, for 8-bit integer data.
(This is currently a typedef for @code{unsigned char}, but it may be
changed to a typedef for @code{signed char}, so don't depend on the
underlying representation.)
@end table

@node NetCDF Classes, Auxiliary Classes, Introduction, Top
@unnumbered     NetCDF Classes

@menu
* Class NcFile::                Files
* Class NcDim::                 Dimensions
* Class NcTypedComponent::      Operations common to variables and attributes
* Class NcVar::                 Variables
* Class NcAtt::                 Attributes
@end menu

@vindex NcFile
@node Class NcFile, Class NcDim, NetCDF Classes, NetCDF Classes
@unnumberedsec Class NcFile

@code{NcFile} is the class for netCDF files,
providing methods for netCDF file operations.

Some member functions return pointers to dimensions (@code{NcDim}) or
variables (@code{NcVar}).  These objects are owned by the @code{NcFile}
they are associated with, and will be deleted automatically by the
@code{NcFile} destructor (or by the @code{close} member function, if
this is called earlier than the destructor), so users should not delete
these.  Member functions that return pointers to attributes
(@code{NcAtt}) pass ownership to the calling function; users
should delete attributes when they are finished with them.  

Member functions that return @code{NcBool} yield @code{TRUE} on success
and @code{FALSE} on failure.  Member functions that return a pointer
value return a @code{NULL} pointer on failure.

This class interface hides the distinction in the C and Fortran
interfaces between @dfn{define mode} (when dimensions, variables, or
attributes are being defined or renamed), and @dfn{data mode} (when data
values are being accessed), by automatically switching between the modes
when necessary.  Be aware that switching from accessing data to adding
or renaming dimensions, variables and attributes can be expensive, since
it may entail a copy of the data.

@unnumberedsubsec Public Member Functions

@table @code
@findex NcFile
@findex NcFile::NcFile
@item NcFile( const char * path, FileMode = ReadOnly, size_t *chunksizeptr = NULL, size_t initialsize = 0, FileFormat = Classic)

The constructor creates a new netCDF file or opens an existing netCDF
file.  
The path argument may be an OPenDAP DAP URL if DAP support is enabled.

The @code{FileMode} argument can be any of @code{ReadOnly} (the
default) to open an existing file for reading, @code{Write} to open an
existing file for reading or writing, @code{Replace} to create a new
empty file even if the named file already exists, or
@code{New} to create a new file only if the named file does not already
exist.

The optional @code{FileFormat} argument can be any of @code{Classic}
(the default), @code{Offset64Bits}, @code{Netcdf4}, or
@code{Netcdf4Classic}.

The optional @code{chunksizeptr} and @code{initialsize} tuning
parameters are as described in the corresponding @code{nc__create()}
function in the C interface.

The constructor will not fail, but in the case of a bad path name,
improper permissions, or if the file already exists and you have
specified @code{FileMode} as @code{New}, no netCDF file will be created
or opened.  If the constructor fails to create or open a netCDF file, a
subsequent call to the @code{is_valid()} member function will return
@code{False}.

@findex ~NcFile
@findex NcFile::~NcFile
@item ~NcFile( void )
Destructor.  The file is closed and all resources associated with it are
released, including the associated @code{NcVar} and @code{NcDim}
objects.  If you wish to close the file earlier, you may explicitly call
the @code{close} member function; a subsequent destructor call will work
properly.

@findex close
@findex NcFile::close
@item NcBool close( void )
Close netCDF file earlier than it would be closed by the @code{NcFile}
destructor.

@findex is_valid
@findex NcFile::is_valid
@item NcBool is_valid( void ) const
Returns @code{TRUE} if valid netCDF file, @code{FALSE} otherwise (e.g.
if constructor could not open file).

@findex num_dims
@findex NcFile::num_dims
@item int num_dims( void ) const
Returns the number of dimensions in the netCDF file.

@findex num_vars
@findex NcFile::num_vars
@item int num_vars( void ) const
Returns the number of variables in the netCDF file.

@findex num_atts
@findex NcFile::num_atts
@item int num_atts( void ) const
Returns the number of global attributes in the netCDF file.

@findex get_dim
@findex NcFile::get_dim
@item NcDim* get_dim(NcToken name) const
Get a dimension by name.

@findex get_var
@findex NcFile::get_var
@item NcVar* get_var(NcToken name) const
Get a variable by name.

@findex get_att
@findex NcFile::get_att
@item NcAtt* get_att(NcToken name) const
Get a global attribute by name.

@findex get_dim
@findex NcFile::get_dim
@item NcDim* get_dim(int n) const
Get the @var{n}th dimension (beginning with the 0th).

@findex get_var
@findex NcFile::get_var
@item NcVar* get_var(int n) const
Get the @var{n}th variable (beginning with the 0th).

@findex get_att
@findex NcFile::get_att
@item NcAtt* get_att(int n) const
Get the @var{n}th global attribute (beginning with the 0th).

@findex rec_dim
@findex NcFile::rec_dim
@item NcDim* rec_dim( void ) const
Get the unlimited dimension, if any.
@end table

The following @code{add_} member functions put the file in @dfn{define
mode}, so could be expensive.  To avoid copying of data, invoke
these before writing data to variables.

@table @code
@findex add_dim
@findex NcFile::add_dim
@item NcDim* add_dim(NcToken dimname)
Add an unlimited dimension named @code{dimname} to the netCDF file.

@findex add_dim
@findex NcFile::add_dim
@item NcDim* add_dim(NcToken dimname, long dimsize)
Add a dimension named @code{dimname} of size @code{dimsize}.

@findex add_var
@findex NcFile::add_var
@item NcVar* add_var(NcToken varname, NcType type, const NcDim*, @dots{})
Add a variable named @code{varname} of the specified type
(@code{ncByte}, @code{ncChar}, @code{ncShort}, @code{ncInt},
@code{ncFloat}, @code{ncDouble}) to the open netCDF file.  The variable
is defined with a shape that depends on how many
dimension arguments are provided.  A scalar variable would have 0
dimensions, a vector would have 1 dimension, and so on.  Supply as many
dimensions as needed, up to 5.  If more than 5 dimensions are required,
use the n-dimensional version of this member function instead.

@findex add_var
@findex NcFile::add_var
@item NcVar* add_var(NcToken varname, NcType type, int ndims, const NcDim** dims)
Add a variable named @code{varname} of @code{ndims} dimensions and of
the specified type.  This method must be used when dealing with
variables of more than 5 dimensions.

@findex add_att
@findex NcFile::add_att
@item  NcBool add_att(NcToken name, ncbyte val)
@itemx NcBool add_att(NcToken name, char val)
@itemx NcBool add_att(NcToken name, short val)
@itemx NcBool add_att(NcToken name, int val)
@itemx NcBool add_att(NcToken name, float val)
@itemx NcBool add_att(NcToken name, double val)
Add global scalar attributes of the specified name and with the
supplied value.

@item NcBool add_att(NcToken name, const char* val)
Add global string-valued attribute with the specified name and C string
value (terminated with a @code{\0} character).

@findex add_att
@findex NcFile::add_att
@item  NcBool add_att(NcToken name, int n, const ncbyte* val)
@itemx NcBool add_att(NcToken name, int n, const char* val)
@itemx NcBool add_att(NcToken name, int n, const short* val)
@itemx NcBool add_att(NcToken name, int n, const int* val)
@itemx NcBool add_att(NcToken name, int n, const float* val)
@itemx NcBool add_att(NcToken name, int n, const double* val)
Add global vector attributes with the specified name, length, and values.

@findex set_fill
@findex NcFile::set_fill
@item NcBool set_fill(FillMode mode = Fill)
Sets fill-mode to either @code{NcFile::Fill} or @code{NcFile::NoFill}.
Default is @code{Fill}, in which case unwritten values are pre-written
with appropriate type-specific or variable-specific fill values.

@findex get_fill
@findex NcFile::get_fill
@item enum NcFile::FillMode get_fill( void ) const
Returns fill mode of the file, either @code{NcFile::Fill} or
@code{NcFile::NoFill}.

@findex get_format
@findex NcFile::get_format
@item enum NcFile::FileFormat get_format( void ) const
Returns format version of the file, either @code{NcFile::Classic},
@code{NcFile:Offset64Bits}, @code{NcFile:Netcdf4}, or 
@code{NcFile::Netcdf4Classic}.

@findex sync
@findex NcFile::sync
@item NcBool sync( void )
Synchronizes file to disk.  This flushes buffers so that readers
of the file will see recent changes.

@findex abort
@findex NcFile::abort
@item NcBool abort( void )
Either just closes file (if recently it has been in data mode as the
result of accessing data), or backs out of the most recent sequence of
changes to the file schema (dimensions, variables, and attributes).
@end table

@vindex NcDim
@node Class NcDim, Class NcTypedComponent, Class NcFile, NetCDF Classes
@unnumberedsec  Class NcDim

A netCDF dimension has a name and a size.  Dimensions are only created and
destroyed by NcFile member functions, because they cannot exist
independently of an open netCDF file.  Hence there are no public
constructors or destructors.

@unnumberedsubsec Public Member Functions

@table @code
@findex name
@findex NcDim::name
@item NcToken name( void ) const

Returns the name of the dimension if it exists, 0 otherwise.

@findex size
@findex NcDim::size
@item long size( void ) const

Returns the dimension size.

@findex is_valid
@findex NcDim::is_valid
@item NcBool is_valid( void ) const

Returns @code{TRUE} if file and dimension are both valid, @code{FALSE}
otherwise.

@findex is_unlimited
@findex NcDim::is_unlimited
@item NcBool is_unlimited( void ) const

Returns @code{TRUE} if the dimension is the unlimited dimension,
@code{FALSE} if either not a valid netCDF file, or if the dimension is
not the unlimited dimension.

@findex rename
@findex NcDim::rename
@item NcBool rename( NcToken newname )

Renames the dimension to @code{newname}.

@findex sync
@findex NcDim::sync
@item NcBool sync( void )

If the dimension may have been renamed, make sure its name is updated.

@end table

@vindex NcTypedComponent
@node Class NcTypedComponent, Class NcVar, Class NcDim, NetCDF Classes
@unnumberedsec  Class NcTypedComponent

@code{NcTypedComponent} is an abstract base class for @code{NcVar} and
@code{NcAtt} that captures the similarities between netCDF variables and
attributes.  We list here the member functions that variables and
attributes inherit from @code{NcTypedComponent}, but these member
functions are also documented under the @code{NcVar} and @code{NcAtt}
classes for convenience.

@unnumberedsubsec Public Member Functions

@table @code
@findex name
@findex NcTypedComponent::name
@item NcToken name( void ) const

Returns the name of the variable or attribute.

@findex type
@findex NcTypedComponent::type
@item NcType type( void ) const

Returns the type of the variable or attribute.  The type will be one of
@code{ncByte}, @code{ncChar}, @code{ncShort}, @code{ncInt},
@code{ncFloat}, or @code{ncDouble}.

@findex is_valid
@findex NcTypedComponent::is_valid
@item NcBool is_valid( void ) const

Returns @code{TRUE} if the component is valid, @code{FALSE} otherwise.

@findex num_vals
@findex NcTypedComponent::num_vals
@item long num_vals( void ) const

Returns the number of values for an attribute or variable.  For an
attribute, this is just 1 for a scalar attribute, the number of values
for a vector-valued attribute, and the number of characters for a
string-valued attribute.  For a variable, this is the product of the
dimension sizes for all the variable's dimensions.

@findex rename
@findex NcTypedComponent::rename
@item NcBool rename( NcToken newname )

Renames the variable or attribute.

@findex values
@findex NcTypedComponent::values
@item NcValues* values( void ) const

Returns a pointer to the block of all values for the variable or
attribute.  The caller is responsible for deleting this block of values
when no longer needed, as well as the pointer returned by the
@code{values} method.  Note that this is not a good way to read
selected values of a variable; use the @code{get} member function
instead, to get single values or selected cross-sections of values.

@findex as_ncbyte
@findex NcTypedComponent::as_ncbyte
@item ncbyte as_ncbyte( int n ) const
@findex as_char
@findex NcTypedComponent::as_char
@itemx char as_char( int n ) const
@findex as_short
@findex NcTypedComponent::as_short
@itemx short as_short( int n ) const
@findex as_int
@findex NcTypedComponent::as_int
@itemx int as_int( int n ) const
@findex as_nclong
@findex NcTypedComponent::as_nclong
@itemx nclong as_nclong( int n ) const // deprecated
@findex as_long
@findex NcTypedComponent::as_long
@itemx long as_long( int n ) const
@findex as_float
@findex NcTypedComponent::as_float
@itemx float as_float( int n ) const
@findex as_double
@findex NcTypedComponent::as_double
@itemx double as_double( int n ) const
@findex as_string
@findex NcTypedComponent::as_string
@itemx char* as_string( int n ) const

Get the n-th value of the attribute or variable.  These member functions
provide conversions from the value type of the variable or attribute to
the specified type.  If the value is out-of-range, the
fill-value of the appropriate type is returned.
@end table


@vindex NcVar
@node Class NcVar, Class NcAtt, Class NcTypedComponent, NetCDF Classes
@unnumberedsec  Class NcVar

@code{NcVar} is derived from NcTypedComponent, and represents a netCDF
variable.  A netCDF variable has a name, a type, a shape, zero or more
attributes, and a block of values associated with it.  Because variables
are only associated with open netCDF files, there are no public
constructors for this class.  Use member functions of @code{NcFile} to
get variables or add new variables.

@unnumberedsubsec Public Member Functions

@table @code
@findex name
@findex NcTypedComponent::name
@item NcToken name( void ) const

Returns the name of the variable.

@findex type
@findex NcTypedComponent::type
@item NcType type( void ) const

Returns the type of the variable.  The type will be one of
@code{ncByte}, @code{ncChar}, @code{ncShort}, @code{ncInt},
@code{ncFloat}, or @code{ncDouble}.

@findex num_dims
@findex NcVar::num_dims
@item int num_dims( void ) const
Returns number of dimensions for this variable.

@findex get_dim
@findex NcVar::get_dim
@item NcDim* get_dim( int n ) const
Returns a pointer to the n-th dimension (starting at 0).  Returns a
NULL-pointer if an invalid dimension is requested.

@findex edges
@findex NcVar::edges
@item long* edges( void ) const
Returns the shape of the variable, in the form of a vector containing
the sizes of the dimensions of the variable.  The caller is responsible
for deleting the returned edge vector when no longer needed.

@findex num_atts
@findex NcVar::num_atts
@item int num_atts( void ) const
Returns the number of attributes attached to the variable.

@findex get_att
@findex NcVar::get_att
@item NcAtt* get_att( NcToken attname ) const
@item NcAtt* get_att( int n ) const
The first member function returns a variable attribute by name.  The
second returns the n-th (starting at 0) attribute of the variable.  In
either case, if no such attribute has been attached to the variable,
zero is returned.  Attributes returned in this way belong to the caller,
and hence should eventually be deleted by the caller to avoid memory
leaks.

@findex is_valid
@findex NcTypedComponent::is_valid
@item NcBool is_valid( void ) const

Returns @code{TRUE} if the variable is valid, @code{FALSE} otherwise.

@findex num_vals
@findex NcTypedComponent::num_vals
@item long num_vals( void ) const

Returns the number of values for a variable.  This is just 1 for a
scalar variable, or the product of the dimension sizes for all the
variable's dimensions.

@findex values
@findex NcTypedComponent::values
@item NcValues* values( void ) const

Returns a pointer to the block of all values for the variable.  
The caller is responsible for deleting this block of values
when no longer needed.
Note that this is not a good way to read selected values of
a variable; use the @code{get} member function instead, to get single
values or selected cross-sections of values.

@findex put
@findex NcVar::put
@item  NcBool put(const ncbyte* vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const char*   vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const short*  vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const int* vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const long* vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const float*  vals, long c0, long c1, long c2, long c3, long c4)
@itemx NcBool put(const double* vals, long c0, long c1, long c2, long c3, long c4)

Write scalar or 1 to 5-dimensional arrays by providing enough arguments.
The @code{vals} argument points to a contiguous block of values in
memory to be written.  This means if you allocate each row of an
array with a ``new'' call for example, you must not write more than one row
at a time, because the rows may not be contiguous in memory.
Other arguments are edge lengths, and their number must not exceed variable's
dimensionality.  Start corner is @code{[0,0,..., 0]} by default, but may
be reset using the @code{set_cur()} member function for this variable.
@code{FALSE} is returned if type of values does not match type for
variable.  For more than 5 dimensions, use the overloaded n-dimensional
form of the @code{put} member function.

@findex put
@findex NcVar::put
@item  NcBool put(const ncbyte* vals, const long* counts)
@itemx NcBool put(const char*   vals, const long* counts)
@itemx NcBool put(const short*  vals, const long* counts)
@itemx NcBool put(const int* vals, const long* counts)
@itemx NcBool put(const long* vals, const long* counts)
@itemx NcBool put(const float*  vals, const long* counts)
@itemx NcBool put(const double* vals, const long* counts)

Write n-dimensional arrays, starting at @code{[0, 0, ..., 0]} by
default, may be reset with @code{set_cur()}.  @code{FALSE} is returned
if type of values does not match type for variable.
The @code{vals} argument points to a contiguous block of values in
memory to be written.  This means if you allocate each row of an
array with a ``new'' call for example, you must not write more than one row
at a time, because the rows may not be contiguous in memory.

@findex get
@findex NcVar::get
@item  NcBool get(ncbyte* vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(char*   vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(short*  vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(int* vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(long* vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(float*  vals, long c0, long c1, long c2, long c3, long c4) const
@itemx NcBool get(double* vals, long c0, long c1, long c2, long c3, long c4) const

Get scalar or 1 to 5 dimensional arrays by providing enough arguments.
The @code{vals} argument points to a contiguous block of values in
memory into which values will be read.  This means if you allocate each row of an
array with a ``new'' call for example, you must not read more than one row
at a time, because the rows may not be contiguous in memory.
Other arguments are edge lengths, and their number must not exceed variable's
dimensionality.  Start corner is @code{[0,0,..., 0]} by default, but may
be reset using the @code{set_cur()} member function.  @code{FALSE} is
returned if type of values does not match type for variable.

@findex get
@findex NcVar::get
@item  NcBool get(ncbyte* vals, const long* counts) const
@itemx NcBool get(char*   vals, const long* counts) const
@itemx NcBool get(short*  vals, const long* counts) const
@itemx NcBool get(int* vals, const long* counts) const
@itemx NcBool get(long* vals, const long* counts) const
@itemx NcBool get(float*  vals, const long* counts) const
@itemx NcBool get(double* vals, const long* counts) const
Get n-dimensional arrays, starting at @code{[0, 0, ..., 0]} by default,
may be reset with @code{set_cur()} member function.  @code{FALSE} is
returned if type of values does not match type for variable.
Get scalar or 1 to 5 dimensional arrays by providing enough arguments.
The @code{vals} argument points to a contiguous block of values in
memory into which values will be read.  This means if you allocate each row of an
array with a ``new'' call for example, you must not read more than one row
at a time, because the rows may not be contiguous in memory.

@findex set_cur
@findex NcVar::set_cur
@item NcBool set_cur(long c0=-1, long c1=-1, long c2=-1, long c3=-1, long c4=-1)
@itemx NcBool set_cur(long* cur)
Resets the starting corner to the values supplied.  The first form works
for a variable of dimensionality from scalar to 5 dimensions.  For more
than five dimensions, use the second form, in which the number of longs
supplied must match the rank of the variable.  The method returns FALSE if
any argument is greater than the size of the corresponding dimension.

@findex NcVar::add_att
@findex add_att
@item  NcBool add_att( NcToken, char )
@item  NcBool add_att( NcToken, ncbyte )
@itemx NcBool add_att( NcToken, short )
@itemx NcBool add_att( NcToken, int )
@itemx NcBool add_att( NcToken, long )
@itemx NcBool add_att( NcToken, float )
@itemx NcBool add_att( NcToken, double )
@itemx NcBool add_att( NcToken, const char* )
@itemx NcBool add_att( NcToken, int, const char* )
@itemx NcBool add_att( NcToken, int, const ncbyte* )
@itemx NcBool add_att( NcToken, int, const short* )
@itemx NcBool add_att( NcToken, int, const int* )
@itemx NcBool add_att( NcToken, int, const long* )
@itemx NcBool add_att( NcToken, int, const float* )
@itemx NcBool add_att( NcToken, int, const double* )

Add scalar or vector attribute of any type to a variable, given the
name, number of values, and the vector of values.  These put file in
define mode, so could be expensive.  To avoid the expense of copying
data, add attributes to variables before writing data.

@findex rename
@findex NcTypedComponent::rename
@item NcBool rename( NcToken newname )

Renames the variable.  If variable is renamed to a longer name, this
puts file in define mode, so could be expensive.

@findex as_ncbyte
@findex NcTypedComponent::as_ncbyte
@item ncbyte as_ncbyte( int n ) const
@findex as_char
@findex NcTypedComponent::as_char
@itemx char as_char( int n ) const
@findex as_short
@findex NcTypedComponent::as_short
@itemx short as_short( int n ) const
@findex as_int
@findex NcTypedComponent::as_int
@itemx int as_int( int n ) const
@findex as_nclong
@findex NcTypedComponent::as_nclong
@itemx nclong as_nclong( int n ) const // deprecated
@findex as_long
@findex NcTypedComponent::as_long
@itemx long as_long( int n ) const
@findex as_float
@findex NcTypedComponent::as_float
@itemx float as_float( int n ) const
@findex as_double
@findex NcTypedComponent::as_double
@itemx double as_double( int n ) const
@findex as_string
@findex NcTypedComponent::as_string
@itemx char* as_string( int n ) const

Get the n-th value of the variable, ignoring its shape.  These member
functions provide conversions from the value type of the variable to the
specified type.  If the requested value is out-of-range, the fill-value of the
appropriate type is returned.

@findex id
@findex NcVar::id
@item int id( void ) const

Return the variable number.  This is not needed in the C++ interface,
but might be needed in calling a C-function that requires that a variable
be identified by number instead of name.

@findex sync
@findex NcVar::sync
@item NcBool sync( void )

If the variable may have been renamed, make sure its name is updated.

@findex ~NcVar
@findex NcVar::~NcVar
@item ~NcVar( void )
Destructor.
@end table

The following member functions are intended for record variables.  They
will also work for non-record variables, if the first dimension is
interpreted as the record dimension.

@table @code
@findex rec_size
@findex NcVar::rec_size
@item long rec_size( void )
@item long rec_size( NcDim* )

Return the number of values per record or the number of values per
dimension slice for the specified dimension.

@findex get_rec
@findex NcVar::get_rec
@item NcValues* get_rec( void )
@itemx NcValues* get_rec( long n )

Get the data for this variable for the current record or for the
@var{n}th record.

@item NcValues* get_rec( NcDim* )
@itemx NcValues* get_rec( NcDim*, long n )

Get the data for this variable for the current dimension slice or for the
@var{n}th dimension slice.

@findex put_rec
@findex NcVar::put_rec
@item  NcBool put_rec( const ncbyte* vals )
@itemx NcBool put_rec( const char* vals )
@itemx NcBool put_rec( const short* vals )
@itemx NcBool put_rec( const int* vals )
@itemx NcBool put_rec( const long* vals )
@itemx NcBool put_rec( const float* vals )
@itemx NcBool put_rec( const double* vals )

Put a record's worth of data for this variable in the current record.

@item  NcBool put_rec( NcDim*, const ncbyte* vals )
@itemx NcBool put_rec( NcDim*, const char* vals )
@itemx NcBool put_rec( NcDim*, const short* vals )
@itemx NcBool put_rec( NcDim*, const int* vals )
@itemx NcBool put_rec( NcDim*, const long* vals )
@itemx NcBool put_rec( NcDim*, const float* vals )
@itemx NcBool put_rec( NcDim*, const double* vals )

Put a dimension slice worth of data for this variable in the current
dimension slice.

@findex put_rec
@findex NcVar::put_rec
@item  NcBool put_rec( const ncbyte* vals, long rec )
@itemx NcBool put_rec( const char* vals, long rec )
@itemx NcBool put_rec( const short* vals, long rec )
@itemx NcBool put_rec( const int* vals, long rec )
@itemx NcBool put_rec( const long* vals, long rec )
@itemx NcBool put_rec( const float* vals, long rec )
@itemx NcBool put_rec( const double* vals, long rec )

Put a record's worth of data for this variable in the specified record.

@item  NcBool put_rec( NcDim*, const ncbyte* vals, long slice )
@itemx NcBool put_rec( NcDim*, const char* vals, long slice )
@itemx NcBool put_rec( NcDim*, const short* vals, long slice )
@itemx NcBool put_rec( NcDim*, const int* vals, long slice )
@itemx NcBool put_rec( NcDim*, const long* vals, long slice )
@itemx NcBool put_rec( NcDim*, const float* vals, long slice )
@itemx NcBool put_rec( NcDim*, const double* vals, long slice )

Put a dimension slice worth of data for this variable in the specified
dimension slice.

@findex get_index
@findex NcVar::get_index
@item  long get_index( const ncbyte* vals )
@itemx long get_index( const char* vals )
@itemx long get_index( const short* vals )
@itemx long get_index( const int* vals )
@itemx long get_index( const long* vals )
@itemx long get_index( const float* vals )
@itemx long get_index( const double* vals )

Get first record index for this variable corresponding to the specified
key value(s).

@item  long get_index( NcDim*, const ncbyte* vals )
@itemx long get_index( NcDim*, const char* vals )
@itemx long get_index( NcDim*, const short* vals )
@itemx long get_index( NcDim*, const int* vals )
@itemx long get_index( NcDim*, const long* vals )
@itemx long get_index( NcDim*, const float* vals )
@itemx long get_index( NcDim*, const double* vals )

Get first index of specified dimension for this variable corresponding
to the specified key value(s).

@findex set_rec
@findex NcVar::set_rec
@item void set_rec ( long rec )

Set the current record for this variable.

@item void set_rec ( NcDim*, long rec )

Set the current dimension slice for the specified dimension for this variable.

@end table

@vindex NcAtt
@node Class NcAtt,  , Class NcVar, NetCDF Classes
@unnumberedsec  Class NcAtt

@code{NcAtt} is derived from @code{NcTypedComponent}, and represents a netCDF
attribute.  A netCDF attribute has a name and a type, and may be either
a scalar attribute or a vector attribute.  Scalar attributes have one
value and vector attributes have multiple values.  In addition, each
attribute is attached to a specific netCDF variable or is global to an
entire netCDF file.  Because attributes are only associated with open
netCDF files, there are no public constructors for this class.  Use
member functions of @code{NcFile} and @code{NcVar} to get netCDF
attributes or add new attributes.  Most of the useful member functions
for @code{NcAtt} are
inherited from class @code{NcTypedComponent}.

@unnumberedsubsec Public Member Functions

@table @code
@findex name
@findex NcTypedComponent::name
@item NcToken name( void ) const

Returns the name of the attribute.

@findex type
@findex NcTypedComponent::type
@item NcType type( void ) const

Returns the type of the attribute.  The type will be one of
@code{ncByte}, @code{ncChar}, @code{ncShort}, @code{ncInt},
@code{ncFloat}, or @code{ncDouble}.

@findex is_valid
@findex NcTypedComponent::is_valid
@item NcBool is_valid( void ) const

Returns @code{TRUE} if the attribute is valid, @code{FALSE} otherwise.

@findex num_vals
@findex NcTypedComponent::num_vals
@item long num_vals( void ) const

Returns the number of values for an attribute.  This is just 1 for a
scalar attribute, the number of values for a vector-valued attribute,
and the number of characters for a string-valued attribute.

@findex rename
@findex NcTypedComponent::rename
@item NcBool rename( NcToken newname )

Renames the attribute.

@findex values
@findex NcTypedComponent::values
@item NcValues* values( void ) const

Returns a pointer to the block of all values for the
attribute.  The caller is responsible for deleting this block of values
when no longer needed.

@findex as_ncbyte
@findex NcTypedComponent::as_ncbyte
@item ncbyte as_ncbyte( int n ) const
@findex as_char
@findex NcTypedComponent::as_char
@itemx char as_char( int n ) const
@findex as_short
@findex NcTypedComponent::as_short
@itemx short as_short( int n ) const

@findex as_int
@findex NcTypedComponent::as_int
@itemx int as_int( int n ) const

@findex as_nclong
@findex NcTypedComponent::as_nclong
@itemx nclong as_nclong( int n ) const // deprecated

@findex as_long
@findex NcTypedComponent::as_long
@itemx long as_long( int n ) const

@findex as_float
@findex NcTypedComponent::as_float
@itemx float as_float( int n ) const
@findex as_double
@findex NcTypedComponent::as_double
@itemx double as_double( int n ) const
@findex as_string
@findex NcTypedComponent::as_string
@itemx char* as_string( int n ) const

Get the n-th value of the attribute.  These member functions provide
conversions from the value type of the attribute to the specified type.
If the value is out-of-range, the fill-value of the appropriate type is
returned.

@findex remove
@findex NcAtt::remove
@item NcBool remove( void )
Deletes the attribute from the file and detaches it from the variable.
Does not call the destructor.  Subsequent calls to @code{is_valid()} will
return @code{FALSE}.

@findex ~NcAtt
@findex NcAtt::~NcAtt
@item ~NcAtt( void )
Destructor.
@end table

@node Auxiliary Classes, Combined Index, NetCDF Classes, Top
@unnumbered  Auxiliary Classes

Auxiliary classes include the abstract base class @code{NcValues}, its
type-specific derived subclasses, and the error-handling class
@code{NcError}.

@menu
* Class NcValues::              
* Class NcError::               
@end menu

@vindex NcValues
@node Class NcValues, Class NcError, Auxiliary Classes, Auxiliary Classes
@unnumberedsec  Class NcValues

@vindex NcValues_ncbyte
@vindex NcValues_char
@vindex NcValues_short
@vindex NcValues_int
@vindex NcValues_nclong
@vindex NcValues_long
@vindex NcValues_float
@vindex NcValues_double
Class @code{NcValues} is an abstract base class for a block of typed
values.  The derived classes are @code{NcValues_ncbyte},
@code{NcValues_char}, @code{NcValues_short}, @code{NcValues_int},
@code{NcValues_nclong} (deprecated), and  @code{NcValues_long},
@code{NcValues_float}, @code{NcValues_double}.
These classes are used as the return type of the
@code{NcTypedComponent::values()} member function, for typed-value
arrays associated with variables and attributes.

@unnumberedsubsec Public Member Functions

@table @code
@findex NcValues
@findex NcValues::NcValues
@item NcValues( void )
Default constructor.

@findex NcValues
@findex NcValues::NcValues
@item NcValues(NcType, long)
Constructor for a value block of the specified type and length.

@findex ~NcValues
@findex NcValues::~NcValues
@item ~NcValues( void )
Destructor.

@findex num
@findex NcValues::num
@item long num( void )
Returns the number of values in the value block.

@findex print
@findex NcValues::print
@item ostream& print(ostream&) const
Used to print the comma-delimited sequence of values of the value block.

@findex base
@findex NcValues::base
@item void* base( void ) const
Returns a bland pointer to the beginning of the value block.

@findex bytes_for_one
@findex NcValues::bytes_for_one
@item int bytes_for_one( void ) const
Returns the number of bytes required for one value.

@findex as_ncbyte
@findex NcValues::as_ncbyte
@item ncbyte as_ncbyte( int n ) const
@findex as_char
@findex NcValues::as_char
@itemx char as_char( int n ) const
@findex as_short
@findex NcValues::as_short
@itemx short as_short( int n ) const

@findex as_int
@findex NcValues::as_int
@itemx int as_int( int n ) const

@findex as_nclong
@findex NcValues::as_nclong
@itemx nclong as_nclong( int n ) const // deprecated

@findex as_long
@findex NcValues::as_long
@itemx long as_long( int n ) const

@findex as_float
@findex NcValues::as_float
@itemx float as_float( int n ) const
@findex as_double
@findex NcValues::as_double
@itemx double as_double( int n ) const
@findex as_string
@findex NcValues::as_string
@itemx char* as_string( int n ) const
Provide conversions for the nth value from the value type to a desired
basic type.  If the value is out of range, the default "fill-value" for
the appropriate type is returned.
@end table

@vindex NcError
@node Class NcError,  , Class NcValues, Auxiliary Classes
@unnumberedsec  Class NcError

This class provides control for netCDF error handling.  Declaring an
@code{NcError} object temporarily changes the error-handling behavior
for all netCDF classes until the @code{NcError} object is destroyed
(typically by going out of scope), at which time the previous
error-handling behavior is restored.

@unnumberedsubsec Public Member Functions

@table @code
@findex NcError
@item NcError( Behavior b = verbose_fatal )
The constructor saves the previous error state for restoration when the
destructor is invoked, and sets a new specified state.  Valid error
states are @code{NcError::silent_nonfatal},
@code{NcError::verbose_nonfatal}, @code{NcError::silent_fatal}, or
@code{NcError::verbose_fatal}, to control whether error messages are
output from the underlying library and whether such messages are fatal
or nonfatal.

@findex ~NcError
@findex NcError::~NcError
@item ~NcError( void )
Destructor, restores previous error state.

@findex get_err
@findex NcError::get_err
@item int get_err( void )
Returns most recent error, as enumerated in @file{netcdf.h}.
@end table

@node Combined Index,  , Auxiliary Classes, Top
@unnumbered Index

@printindex cp

@bye
End: