-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathnetcdf.h
2129 lines (1652 loc) · 71.5 KB
/
netcdf.h
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
/*! \file
Main header file for the C API.
Copyright 2018, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
2015, 2016, 2017, 2018, 2019
University Corporation for Atmospheric Research/Unidata.
See \ref copyright file for more info.
*/
#ifndef _NETCDF_
#define _NETCDF_
#include <stddef.h> /* size_t, ptrdiff_t */
#include <errno.h> /* netcdf functions sometimes return system errors */
/* Required for alloca on Windows */
#if defined(_WIN32) || defined(_WIN64)
#include <malloc.h>
#endif
/*! The nc_type type is just an int. */
typedef int nc_type;
#if defined(__cplusplus)
extern "C" {
#endif
/*
* The netcdf external data types
*/
#define NC_NAT 0 /**< Not A Type */
#define NC_BYTE 1 /**< signed 1 byte integer */
#define NC_CHAR 2 /**< ISO/ASCII character */
#define NC_SHORT 3 /**< signed 2 byte integer */
#define NC_INT 4 /**< signed 4 byte integer */
#define NC_LONG NC_INT /**< \deprecated required for backward compatibility. */
#define NC_FLOAT 5 /**< single precision floating point number */
#define NC_DOUBLE 6 /**< double precision floating point number */
#define NC_UBYTE 7 /**< unsigned 1 byte int */
#define NC_USHORT 8 /**< unsigned 2-byte int */
#define NC_UINT 9 /**< unsigned 4-byte int */
#define NC_INT64 10 /**< signed 8-byte int */
#define NC_UINT64 11 /**< unsigned 8-byte int */
#define NC_STRING 12 /**< string */
#define NC_MAX_ATOMIC_TYPE NC_STRING /**< @internal Largest atomic type. */
/* The following are use internally in support of user-defines
* types. They are also the class returned by nc_inq_user_type. */
#define NC_VLEN 13 /**< vlen (variable-length) types */
#define NC_OPAQUE 14 /**< opaque types */
#define NC_ENUM 15 /**< enum types */
#define NC_COMPOUND 16 /**< compound types */
/** @internal Define the first user defined type id (leave some
* room) */
#define NC_FIRSTUSERTYPEID 32
/** Default fill value. This is used unless _FillValue attribute
* is set. These values are stuffed into newly allocated space as
* appropriate. The hope is that one might use these to notice that a
* particular datum has not been set. */
/**@{*/
#define NC_FILL_BYTE ((signed char)-127)
#define NC_FILL_CHAR ((char)0)
#define NC_FILL_SHORT ((short)-32767)
#define NC_FILL_INT (-2147483647)
#define NC_FILL_FLOAT (9.9692099683868690e+36f) /* near 15 * 2^119 */
#define NC_FILL_DOUBLE (9.9692099683868690e+36)
#define NC_FILL_UBYTE (255)
#define NC_FILL_USHORT (65535)
#define NC_FILL_UINT (4294967295U)
#define NC_FILL_INT64 ((long long)-9223372036854775806LL)
#define NC_FILL_UINT64 ((unsigned long long)18446744073709551614ULL)
#define NC_FILL_STRING ((char *)"")
/**@}*/
/*! Max or min values for a type. Nothing greater/smaller can be
* stored in a netCDF file for their associated types. Recall that a C
* compiler may define int to be any length it wants, but a NC_INT is
* *always* a 4 byte signed int. On a platform with 64 bit ints,
* there will be many ints which are outside the range supported by
* NC_INT. But since NC_INT is an external format, it has to mean the
* same thing everywhere. */
/**@{*/
#define NC_MAX_BYTE 127
#define NC_MIN_BYTE (-NC_MAX_BYTE-1)
#define NC_MAX_CHAR 255
#define NC_MAX_SHORT 32767
#define NC_MIN_SHORT (-NC_MAX_SHORT - 1)
#define NC_MAX_INT 2147483647
#define NC_MIN_INT (-NC_MAX_INT - 1)
#define NC_MAX_FLOAT 3.402823466e+38f
#define NC_MIN_FLOAT (-NC_MAX_FLOAT)
#define NC_MAX_DOUBLE 1.7976931348623157e+308
#define NC_MIN_DOUBLE (-NC_MAX_DOUBLE)
#define NC_MAX_UBYTE NC_MAX_CHAR
#define NC_MAX_USHORT 65535U
#define NC_MAX_UINT 4294967295U
#define NC_MAX_INT64 (9223372036854775807LL)
#define NC_MIN_INT64 (-9223372036854775807LL-1)
#define NC_MAX_UINT64 (18446744073709551615ULL)
/**@}*/
/** Name of fill value attribute. If you wish a variable to use a
* different value than the above defaults, create an attribute with
* the same type as the variable and this reserved name. The value you
* give the attribute will be used as the fill value for that
* variable. */
#define _FillValue "_FillValue"
#define NC_FILL 0 /**< Argument to nc_set_fill() to clear NC_NOFILL */
#define NC_NOFILL 0x100 /**< Argument to nc_set_fill() to turn off filling of data. */
/* Define the ioflags bits for nc_create and nc_open.
Currently unused in lower 16 bits:
0x0002
All upper 16 bits are unused except
0x20000
*/
/* Lower 16 bits */
#define NC_NOWRITE 0x0000 /**< Set read-only access for nc_open(). */
#define NC_WRITE 0x0001 /**< Set read-write access for nc_open(). */
#define NC_CLOBBER 0x0000 /**< Destroy existing file. Mode flag for nc_create(). */
#define NC_NOCLOBBER 0x0004 /**< Don't destroy existing file. Mode flag for nc_create(). */
#define NC_DISKLESS 0x0008 /**< Use diskless file. Mode flag for nc_open() or nc_create(). */
#define NC_MMAP 0x0010 /**< \deprecated Use diskless file with mmap. Mode flag for nc_open() or nc_create()*/
#define NC_64BIT_DATA 0x0020 /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
#define NC_CDF5 NC_64BIT_DATA /**< Alias NC_CDF5 to NC_64BIT_DATA */
#define NC_UDF0 0x0040 /**< User-defined format 0. */
#define NC_UDF1 0x0080 /**< User-defined format 1. */
#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
#define NC_64BIT_OFFSET 0x0200 /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
/** \deprecated The following flag currently is ignored, but use in
* nc_open() or nc_create() may someday support use of advisory
* locking to prevent multiple writers from clobbering a file
*/
#define NC_LOCK 0x0400
/** Share updates, limit caching.
Use this in mode flags for both nc_create() and nc_open(). */
#define NC_SHARE 0x0800
#define NC_NETCDF4 0x1000 /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
/** The following 3 flags are deprecated as of 4.6.2. Parallel I/O is now
* initiated by calling nc_create_par and nc_open_par, no longer by flags.
*/
#define NC_MPIIO 0x2000 /**< \deprecated */
#define NC_MPIPOSIX NC_MPIIO /**< \deprecated */
#define NC_PNETCDF (NC_MPIIO) /**< \deprecated */
#define NC_PERSIST 0x4000 /**< Save diskless contents to disk. Mode flag for nc_open() or nc_create() */
#define NC_INMEMORY 0x8000 /**< Read from memory. Mode flag for nc_open() or nc_create() */
/* Upper 16 bits */
#define NC_NOATTCREORD 0x20000 /**< Disable the netcdf-4 (hdf5) attribute creation order tracking */
#define NC_NODIMSCALE_ATTACH 0x40000 /**< Disable the netcdf-4 (hdf5) attaching of dimscales to variables (#2128) */
#define NC_MAX_MAGIC_NUMBER_LEN 8 /**< Max len of user-defined format magic number. */
/** Format specifier for nc_set_default_format() and returned
* by nc_inq_format. This returns the format as provided by
* the API. See nc_inq_format_extended to see the true file format.
* Starting with version 3.6, there are different format netCDF files.
* 4.0 introduces the third one. \see netcdf_format
*/
/**@{*/
#define NC_FORMAT_CLASSIC (1)
/* After adding CDF5 support, the NC_FORMAT_64BIT
flag is somewhat confusing. So, it is renamed.
Note that the name in the contributed code
NC_FORMAT_64BIT was renamed to NC_FORMAT_CDF2
*/
#define NC_FORMAT_64BIT_OFFSET (2)
#define NC_FORMAT_64BIT (NC_FORMAT_64BIT_OFFSET) /**< \deprecated Saved for compatibility. Use NC_FORMAT_64BIT_OFFSET or NC_FORMAT_64BIT_DATA, from netCDF 4.4.0 onwards. */
#define NC_FORMAT_NETCDF4 (3)
#define NC_FORMAT_NETCDF4_CLASSIC (4)
#define NC_FORMAT_64BIT_DATA (5)
/* Alias */
#define NC_FORMAT_CDF5 NC_FORMAT_64BIT_DATA
/* Define a mask covering format flags only */
#define NC_FORMAT_ALL (NC_64BIT_OFFSET|NC_64BIT_DATA|NC_CLASSIC_MODEL|NC_NETCDF4|NC_UDF0|NC_UDF1)
/**@}*/
/** Extended format specifier returned by nc_inq_format_extended()
* Added in version 4.3.1. This returns the true format of the
* underlying data.
* The function returns two values
* 1. a small integer indicating the underlying source type
* of the data. Note that this may differ from what the user
* sees from nc_inq_format() because this latter function
* returns what the user can expect to see thru the API.
* 2. A mode value indicating what mode flags are effectively
* set for this dataset. This usually will be a superset
* of the mode flags used as the argument to nc_open
* or nc_create.
* More or less, the #1 values track the set of dispatch tables.
* The #1 values are as follows.
* Note that CDF-5 returns NC_FORMAT_NC3, but sets the mode flag properly.
*/
/**@{*/
#define NC_FORMATX_NC3 (1)
#define NC_FORMATX_NC_HDF5 (2) /**< netCDF-4 subset of HDF5 */
#define NC_FORMATX_NC4 NC_FORMATX_NC_HDF5 /**< alias */
#define NC_FORMATX_NC_HDF4 (3) /**< netCDF-4 subset of HDF4 */
#define NC_FORMATX_PNETCDF (4)
#define NC_FORMATX_DAP2 (5)
#define NC_FORMATX_DAP4 (6)
#define NC_FORMATX_UDF0 (8)
#define NC_FORMATX_UDF1 (9)
#define NC_FORMATX_NCZARR (10)
#define NC_FORMATX_UNDEFINED (0)
/* To avoid breaking compatibility (such as in the python library),
we need to retain the NC_FORMAT_xxx format as well. This may come
out eventually, as the NC_FORMATX is more clear that it's an extended
format specifier.*/
#define NC_FORMAT_NC3 NC_FORMATX_NC3 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC3 */
#define NC_FORMAT_NC_HDF5 NC_FORMATX_NC_HDF5 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC_HDF5 */
#define NC_FORMAT_NC4 NC_FORMATX_NC4 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC4 */
#define NC_FORMAT_NC_HDF4 NC_FORMATX_NC_HDF4 /**< \deprecated As of 4.4.0, use NC_FORMATX_HDF4 */
#define NC_FORMAT_PNETCDF NC_FORMATX_PNETCDF /**< \deprecated As of 4.4.0, use NC_FORMATX_PNETCDF */
#define NC_FORMAT_DAP2 NC_FORMATX_DAP2 /**< \deprecated As of 4.4.0, use NC_FORMATX_DAP2 */
#define NC_FORMAT_DAP4 NC_FORMATX_DAP4 /**< \deprecated As of 4.4.0, use NC_FORMATX_DAP4 */
#define NC_FORMAT_UNDEFINED NC_FORMATX_UNDEFINED /**< \deprecated As of 4.4.0, use NC_FORMATX_UNDEFINED */
/**@}*/
/** Let nc__create() or nc__open() figure out a suitable buffer size. */
#define NC_SIZEHINT_DEFAULT 0
/** In nc__enddef(), align to the buffer size. */
#define NC_ALIGN_CHUNK ((size_t)(-1))
/** Size argument to nc_def_dim() for an unlimited dimension. */
#define NC_UNLIMITED 0L
/** Attribute id to put/get a global attribute. */
#define NC_GLOBAL -1
/**
Maximum for classic library.
In the classic netCDF model there are maximum values for the number of
dimensions in the file (\ref NC_MAX_DIMS), the number of global or per
variable attributes (\ref NC_MAX_ATTRS), the number of variables in
the file (\ref NC_MAX_VARS), and the length of a name (\ref
NC_MAX_NAME).
These maximums are enforced by the interface, to facilitate writing
applications and utilities. However, nothing is statically allocated
to these sizes internally.
These maximums are not used for netCDF-4/HDF5 files unless they were
created with the ::NC_CLASSIC_MODEL flag.
As a rule, NC_MAX_VAR_DIMS <= NC_MAX_DIMS.
NOTE: The NC_MAX_DIMS, NC_MAX_ATTRS, and NC_MAX_VARS limits
are *not* enforced after version 4.5.0
*/
/**@{*/
#define NC_MAX_DIMS 1024 /* not enforced after 4.5.0 */
#define NC_MAX_ATTRS 8192 /* not enforced after 4.5.0 */
#define NC_MAX_VARS 8192 /* not enforced after 4.5.0 */
#define NC_MAX_NAME 256
#define NC_MAX_VAR_DIMS 1024 /**< max per variable dimensions */
/**@}*/
/** The max size of an SD dataset name in HDF4 (from HDF4
* documentation) is 64. But in in the wild we have encountered longer
* names. As long as the HDF4 name is not greater than NC_MAX_NAME,
* our code will be OK. */
#define NC_MAX_HDF4_NAME NC_MAX_NAME
/** In HDF5 files you can set the endianness of variables with
nc_def_var_endian(). This define is used there. */
/**@{*/
#define NC_ENDIAN_NATIVE 0
#define NC_ENDIAN_LITTLE 1
#define NC_ENDIAN_BIG 2
/**@}*/
/** In HDF5 files you can set storage for each variable to be either
* contiguous or chunked, with nc_def_var_chunking(). This define is
* used there. Unknown storage is used for further extensions of HDF5
* storage models, which should be handled transparently by netcdf */
/**@{*/
#define NC_CHUNKED 0
#define NC_CONTIGUOUS 1
#define NC_COMPACT 2
#define NC_UNKNOWN_STORAGE 3
#define NC_VIRTUAL 4
/**@}*/
/** In HDF5 files you can set check-summing for each variable.
Currently the only checksum available is Fletcher-32, which can be set
with the function nc_def_var_fletcher32. These defines are used
there. */
/**@{*/
#define NC_NOCHECKSUM 0
#define NC_FLETCHER32 1
/**@}*/
/**@{*/
/** Control the HDF5 shuffle filter. In HDF5 files you can specify
* that a shuffle filter should be used on each chunk of a variable to
* improve compression for that variable. This per-variable shuffle
* property can be set with the function nc_def_var_deflate(). */
#define NC_NOSHUFFLE 0
#define NC_SHUFFLE 1
/**@}*/
#define NC_MIN_DEFLATE_LEVEL 0 /**< Minimum deflate level. */
#define NC_MAX_DEFLATE_LEVEL 9 /**< Maximum deflate level. */
#define NC_SZIP_NN 32 /**< SZIP NN option mask. */
#define NC_SZIP_EC 4 /**< SZIP EC option mask. */
#define NC_NOQUANTIZE 0 /**< No quantization in use. */
#define NC_QUANTIZE_BITGROOM 1 /**< Use BitGroom quantization. */
#define NC_QUANTIZE_GRANULARBR 2 /**< Use Granular BitRound quantization. */
#define NC_QUANTIZE_BITROUND 3 /**< Use BitRound quantization. */
/**@{*/
/** When quantization is used for a variable, an attribute of the
* appropriate name is added. */
#define NC_QUANTIZE_BITGROOM_ATT_NAME "_QuantizeBitGroomNumberOfSignificantDigits"
#define NC_QUANTIZE_GRANULARBR_ATT_NAME "_QuantizeGranularBitRoundNumberOfSignificantDigits"
#define NC_QUANTIZE_BITROUND_ATT_NAME "_QuantizeBitRoundNumberOfSignificantBits"
/**@}*/
/**@{*/
/** For quantization, the allowed value of number of significant
* decimal and binary digits, respectively, for float. */
#define NC_QUANTIZE_MAX_FLOAT_NSD (7)
#define NC_QUANTIZE_MAX_FLOAT_NSB (23)
/**@}*/
/**@{*/
/** For quantization, the allowed value of number of significant
* decimal and binary digits, respectively, for double. */
#define NC_QUANTIZE_MAX_DOUBLE_NSD (15)
#define NC_QUANTIZE_MAX_DOUBLE_NSB (52)
/**@}*/
/** The netcdf version 3 functions all return integer error status.
* These are the possible values, in addition to certain values from
* the system errno.h.
*/
#define NC_ISSYSERR(err) ((err) > 0)
#define NC_NOERR 0 /**< No Error */
#define NC2_ERR (-1) /**< Returned for all errors in the v2 API. */
/** Not a netcdf id.
The specified netCDF ID does not refer to an
open netCDF dataset. */
#define NC_EBADID (-33)
#define NC_ENFILE (-34) /**< Too many netcdfs open */
#define NC_EEXIST (-35) /**< netcdf file exists && NC_NOCLOBBER */
#define NC_EINVAL (-36) /**< Invalid Argument */
#define NC_EPERM (-37) /**< Write to read only */
/** Operation not allowed in data mode. This is returned for netCDF
classic or 64-bit offset files, or for netCDF-4 files, when they were
been created with ::NC_CLASSIC_MODEL flag in nc_create(). */
#define NC_ENOTINDEFINE (-38)
/** Operation not allowed in define mode.
The specified netCDF is in define mode rather than data mode.
With netCDF-4/HDF5 files, this error will not occur, unless
::NC_CLASSIC_MODEL was used in nc_create().
*/
#define NC_EINDEFINE (-39)
/** Index exceeds dimension bound.
The specified corner indices were out of range for the rank of the
specified variable. For example, a negative index or an index that is
larger than the corresponding dimension length will cause an error. */
#define NC_EINVALCOORDS (-40)
/** NC_MAX_DIMS exceeded. Max number of dimensions exceeded in a
classic or 64-bit offset file, or an netCDF-4 file with
::NC_CLASSIC_MODEL on. */
#define NC_EMAXDIMS (-41) /* not enforced after 4.5.0 */
#define NC_ENAMEINUSE (-42) /**< String match to name in use */
#define NC_ENOTATT (-43) /**< Attribute not found */
#define NC_EMAXATTS (-44) /**< NC_MAX_ATTRS exceeded - not enforced after 4.5.0 */
#define NC_EBADTYPE (-45) /**< Not a netcdf data type */
#define NC_EBADDIM (-46) /**< Invalid dimension id or name */
#define NC_EUNLIMPOS (-47) /**< NC_UNLIMITED in the wrong index */
/** NC_MAX_VARS exceeded. Max number of variables exceeded in a
classic or 64-bit offset file, or an netCDF-4 file with
::NC_CLASSIC_MODEL on. */
#define NC_EMAXVARS (-48) /* not enforced after 4.5.0 */
/** Variable not found.
The variable ID is invalid for the specified netCDF dataset. */
#define NC_ENOTVAR (-49)
#define NC_EGLOBAL (-50) /**< Action prohibited on NC_GLOBAL varid */
#define NC_ENOTNC (-51) /**< Not a netcdf file */
#define NC_ESTS (-52) /**< In Fortran, string too short */
#define NC_EMAXNAME (-53) /**< NC_MAX_NAME exceeded */
#define NC_EUNLIMIT (-54) /**< NC_UNLIMITED size already in use */
#define NC_ENORECVARS (-55) /**< nc_rec op when there are no record vars */
#define NC_ECHAR (-56) /**< Attempt to convert between text & numbers */
/** Start+count exceeds dimension bound.
The specified edge lengths added to the specified corner would have
referenced data out of range for the rank of the specified
variable. For example, an edge length that is larger than the
corresponding dimension length minus the corner index will cause an
error. */
#define NC_EEDGE (-57) /**< Start+count exceeds dimension bound. */
#define NC_ESTRIDE (-58) /**< Illegal stride */
#define NC_EBADNAME (-59) /**< Attribute or variable name contains illegal characters */
/* N.B. following must match value in ncx.h */
/** Math result not representable.
One or more of the values are out of the range of values representable
by the desired type. */
#define NC_ERANGE (-60)
#define NC_ENOMEM (-61) /**< Memory allocation (malloc) failure */
#define NC_EVARSIZE (-62) /**< One or more variable sizes violate format constraints */
#define NC_EDIMSIZE (-63) /**< Invalid dimension size */
#define NC_ETRUNC (-64) /**< File likely truncated or possibly corrupted */
#define NC_EAXISTYPE (-65) /**< Unknown axis type. */
/* Following errors are added for DAP */
#define NC_EDAP (-66) /**< Generic DAP error */
#define NC_ECURL (-67) /**< Generic libcurl error */
#define NC_EIO (-68) /**< Generic IO error */
#define NC_ENODATA (-69) /**< Attempt to access variable with no data */
#define NC_EDAPSVC (-70) /**< DAP server error */
#define NC_EDAS (-71) /**< Malformed or inaccessible DAS */
#define NC_EDDS (-72) /**< Malformed or inaccessible DDS */
#define NC_EDMR NC_EDDS /**< Dap4 alias */
#define NC_EDATADDS (-73) /**< Malformed or inaccessible DATADDS */
#define NC_EDATADAP NC_EDATADDS /**< Dap4 alias */
#define NC_EDAPURL (-74) /**< Malformed DAP URL */
#define NC_EDAPCONSTRAINT (-75) /**< Malformed DAP Constraint*/
#define NC_ETRANSLATION (-76) /**< Untranslatable construct */
#define NC_EACCESS (-77) /**< Access Failure */
#define NC_EAUTH (-78) /**< Authorization Failure */
/* Misc. additional errors */
#define NC_ENOTFOUND (-90) /**< No such file */
#define NC_ECANTREMOVE (-91) /**< Can't remove file */
#define NC_EINTERNAL (-92) /**< NetCDF Library Internal Error */
#define NC_EPNETCDF (-93) /**< Error at PnetCDF layer */
/* The following was added in support of netcdf-4. Make all netcdf-4
error codes < -100 so that errors can be added to netcdf-3 if
needed. */
#define NC4_FIRST_ERROR (-100) /**< @internal All HDF5 errors < this. */
#define NC_EHDFERR (-101) /**< Error at HDF5 layer. */
#define NC_ECANTREAD (-102) /**< Can't read. */
#define NC_ECANTWRITE (-103) /**< Can't write. */
#define NC_ECANTCREATE (-104) /**< Can't create. */
#define NC_EFILEMETA (-105) /**< Problem with file metadata. */
#define NC_EDIMMETA (-106) /**< Problem with dimension metadata. */
#define NC_EATTMETA (-107) /**< Problem with attribute metadata. */
#define NC_EVARMETA (-108) /**< Problem with variable metadata. */
#define NC_ENOCOMPOUND (-109) /**< Not a compound type. */
#define NC_EATTEXISTS (-110) /**< Attribute already exists. */
#define NC_ENOTNC4 (-111) /**< Attempting netcdf-4 operation on netcdf-3 file. */
#define NC_ESTRICTNC3 (-112) /**< Attempting netcdf-4 operation on strict nc3 netcdf-4 file. */
#define NC_ENOTNC3 (-113) /**< Attempting netcdf-3 operation on netcdf-4 file. */
#define NC_ENOPAR (-114) /**< Parallel operation on file opened for non-parallel access. */
#define NC_EPARINIT (-115) /**< Error initializing for parallel access. */
#define NC_EBADGRPID (-116) /**< Bad group ID. */
#define NC_EBADTYPID (-117) /**< Bad type ID. */
#define NC_ETYPDEFINED (-118) /**< Type has already been defined and may not be edited. */
#define NC_EBADFIELD (-119) /**< Bad field ID. */
#define NC_EBADCLASS (-120) /**< Bad class. */
#define NC_EMAPTYPE (-121) /**< Mapped access for atomic types only. */
#define NC_ELATEFILL (-122) /**< Attempt to define fill value when data already exists. */
#define NC_ELATEDEF (-123) /**< Attempt to define var properties, like deflate, after enddef. */
#define NC_EDIMSCALE (-124) /**< Problem with HDF5 dimscales. */
#define NC_ENOGRP (-125) /**< No group found. */
#define NC_ESTORAGE (-126) /**< Can't specify both contiguous and chunking. */
#define NC_EBADCHUNK (-127) /**< Bad chunksize. */
#define NC_ENOTBUILT (-128) /**< Attempt to use feature that was not turned on when netCDF was built. */
#define NC_EDISKLESS (-129) /**< Error in using diskless access. */
#define NC_ECANTEXTEND (-130) /**< Attempt to extend dataset during ind. I/O operation. */
#define NC_EMPI (-131) /**< MPI operation failed. */
#define NC_EFILTER (-132) /**< Filter operation failed. */
#define NC_ERCFILE (-133) /**< RC file failure */
#define NC_ENULLPAD (-134) /**< Header Bytes not Null-Byte padded */
#define NC_EINMEMORY (-135) /**< In-memory file error */
#define NC_ENOFILTER (-136) /**< Filter not defined on variable. */
#define NC_ENCZARR (-137) /**< Error at NCZarr layer. */
#define NC_ES3 (-138) /**< Generic S3 error */
#define NC_EEMPTY (-139) /**< Attempt to read empty NCZarr map key */
#define NC_EOBJECT (-140) /**< Some object exists when it should not */
#define NC_ENOOBJECT (-141) /**< Some object not found */
#define NC_EPLUGIN (-142) /**< Unclassified failure in accessing a dynamically loaded plugin> */
#define NC4_LAST_ERROR (-142) /**< @internal All netCDF errors > this. */
/* Errors for all remote access methods(e.g. DAP and CDMREMOTE)*/
#define NC_EURL (NC_EDAPURL) /**< Malformed URL */
#define NC_ECONSTRAINT (NC_EDAPCONSTRAINT) /**< Malformed Constraint*/
/** @internal This is used in netCDF-4 files for dimensions without
* coordinate vars. */
#define DIM_WITHOUT_VARIABLE "This is a netCDF dimension but not a netCDF variable."
/** @internal This is here at the request of the NCO team to support
* our mistake of having chunksizes be first ints, then
* size_t. Doh! */
#define NC_HAVE_NEW_CHUNKING_API 1
/*
* The Interface
*/
/* Declaration modifiers for DLL support (MSC et al) */
#if defined(DLL_NETCDF) /* define when library is a DLL */
# if defined(DLL_EXPORT) /* define when building the library */
# define MSC_EXTRA __declspec(dllexport)
# else
# define MSC_EXTRA __declspec(dllimport)
# endif
# include <io.h>
#else
#define MSC_EXTRA /**< Needed for DLL build. */
#endif /* defined(DLL_NETCDF) */
#define EXTERNL MSC_EXTRA extern /**< Needed for DLL build. */
#if defined(DLL_NETCDF) /* define when library is a DLL */
EXTERNL int ncerr;
EXTERNL int ncopts;
#endif
EXTERNL const char *
nc_inq_libvers(void);
EXTERNL const char *
nc_strerror(int ncerr);
/* Set up user-defined format. */
typedef struct NC_Dispatch NC_Dispatch;
EXTERNL int
nc_def_user_format(int mode_flag, NC_Dispatch *dispatch_table, char *magic_number);
EXTERNL int
nc_inq_user_format(int mode_flag, NC_Dispatch **dispatch_table, char *magic_number);
/* Set the global alignment property */
EXTERNL int
nc_set_alignment(int threshold, int alignment);
/* Get the global alignment property */
EXTERNL int
nc_get_alignment(int* thresholdp, int* alignmentp);
EXTERNL int
nc__create(const char *path, int cmode, size_t initialsz,
size_t *chunksizehintp, int *ncidp);
EXTERNL int
nc_create(const char *path, int cmode, int *ncidp);
EXTERNL int
nc__open(const char *path, int mode,
size_t *chunksizehintp, int *ncidp);
EXTERNL int
nc_open(const char *path, int mode, int *ncidp);
/* Learn the path used to open/create the file. */
EXTERNL int
nc_inq_path(int ncid, size_t *pathlen, char *path);
/* Given an ncid and group name (NULL gets root group), return
* locid. */
EXTERNL int
nc_inq_ncid(int ncid, const char *name, int *grp_ncid);
/* Given a location id, return the number of groups it contains, and
* an array of their locids. */
EXTERNL int
nc_inq_grps(int ncid, int *numgrps, int *ncids);
/* Given locid, find name of group. (Root group is named "/".) */
EXTERNL int
nc_inq_grpname(int ncid, char *name);
/* Given ncid, find full name and len of full name. (Root group is
* named "/", with length 1.) */
EXTERNL int
nc_inq_grpname_full(int ncid, size_t *lenp, char *full_name);
/* Given ncid, find len of full name. */
EXTERNL int
nc_inq_grpname_len(int ncid, size_t *lenp);
/* Given an ncid, find the ncid of its parent group. */
EXTERNL int
nc_inq_grp_parent(int ncid, int *parent_ncid);
/* Given a name and parent ncid, find group ncid. */
EXTERNL int
nc_inq_grp_ncid(int ncid, const char *grp_name, int *grp_ncid);
/* Given a full name and ncid, find group ncid. */
EXTERNL int
nc_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid);
/* Get a list of ids for all the variables in a group. */
EXTERNL int
nc_inq_varids(int ncid, int *nvars, int *varids);
/* Find all dimids for a location. This finds all dimensions in a
* group, or any of its parents. */
EXTERNL int
nc_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents);
/* Find all user-defined types for a location. This finds all
* user-defined types in a group. */
EXTERNL int
nc_inq_typeids(int ncid, int *ntypes, int *typeids);
/* Are two types equal? */
EXTERNL int
nc_inq_type_equal(int ncid1, nc_type typeid1, int ncid2,
nc_type typeid2, int *equal);
/* Create a group. its ncid is returned in the new_ncid pointer. */
EXTERNL int
nc_def_grp(int parent_ncid, const char *name, int *new_ncid);
/* Rename a group */
EXTERNL int
nc_rename_grp(int grpid, const char *name);
/* Here are functions for dealing with compound types. */
/* Create a compound type. */
EXTERNL int
nc_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp);
/* Insert a named field into a compound type. */
EXTERNL int
nc_insert_compound(int ncid, nc_type xtype, const char *name,
size_t offset, nc_type field_typeid);
/* Insert a named array into a compound type. */
EXTERNL int
nc_insert_array_compound(int ncid, nc_type xtype, const char *name,
size_t offset, nc_type field_typeid,
int ndims, const int *dim_sizes);
/* Get the name and size of a type. */
EXTERNL int
nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size);
/* Get the id of a type from the name, which might be a fully qualified name */
EXTERNL int
nc_inq_typeid(int ncid, const char *name, nc_type *typeidp);
/* Get the name, size, and number of fields in a compound type. */
EXTERNL int
nc_inq_compound(int ncid, nc_type xtype, char *name, size_t *sizep,
size_t *nfieldsp);
/* Get the name of a compound type. */
EXTERNL int
nc_inq_compound_name(int ncid, nc_type xtype, char *name);
/* Get the size of a compound type. */
EXTERNL int
nc_inq_compound_size(int ncid, nc_type xtype, size_t *sizep);
/* Get the number of fields in this compound type. */
EXTERNL int
nc_inq_compound_nfields(int ncid, nc_type xtype, size_t *nfieldsp);
/* Given the xtype and the fieldid, get all info about it. */
EXTERNL int
nc_inq_compound_field(int ncid, nc_type xtype, int fieldid, char *name,
size_t *offsetp, nc_type *field_typeidp, int *ndimsp,
int *dim_sizesp);
/* Given the typeid and the fieldid, get the name. */
EXTERNL int
nc_inq_compound_fieldname(int ncid, nc_type xtype, int fieldid,
char *name);
/* Given the xtype and the name, get the fieldid. */
EXTERNL int
nc_inq_compound_fieldindex(int ncid, nc_type xtype, const char *name,
int *fieldidp);
/* Given the xtype and fieldid, get the offset. */
EXTERNL int
nc_inq_compound_fieldoffset(int ncid, nc_type xtype, int fieldid,
size_t *offsetp);
/* Given the xtype and the fieldid, get the type of that field. */
EXTERNL int
nc_inq_compound_fieldtype(int ncid, nc_type xtype, int fieldid,
nc_type *field_typeidp);
/* Given the xtype and the fieldid, get the number of dimensions for
* that field (scalars are 0). */
EXTERNL int
nc_inq_compound_fieldndims(int ncid, nc_type xtype, int fieldid,
int *ndimsp);
/* Given the xtype and the fieldid, get the sizes of dimensions for
* that field. User must have allocated storage for the dim_sizes. */
EXTERNL int
nc_inq_compound_fielddim_sizes(int ncid, nc_type xtype, int fieldid,
int *dim_sizes);
/** This is the type of arrays of vlens. */
typedef struct {
size_t len; /**< Length of VL data (in base type units) */
void *p; /**< Pointer to VL data */
} nc_vlen_t;
/** Calculate an offset for creating a compound type. This calls a
* mysterious C macro which was found carved into one of the blocks of
* the Newgrange passage tomb in County Meath, Ireland. This code has
* been carbon dated to 3200 B.C.E. */
#define NC_COMPOUND_OFFSET(S,M) (offsetof(S,M))
/* Create a variable length type. */
EXTERNL int
nc_def_vlen(int ncid, const char *name, nc_type base_typeid, nc_type *xtypep);
/* Find out about a vlen. */
EXTERNL int
nc_inq_vlen(int ncid, nc_type xtype, char *name, size_t *datum_sizep,
nc_type *base_nc_typep);
/* When you read VLEN type the library will actually allocate the
* storage space for the data. This storage space must be freed, so
* pass the pointer back to this function, when you're done with the
* data, and it will free the vlen memory.
* These two functions are deprecated in favor of the nc_reclaim_data function.
*/
EXTERNL int
nc_free_vlen(nc_vlen_t *vl);
EXTERNL int
nc_free_vlens(size_t len, nc_vlen_t vlens[]);
/* Put or get one element in a vlen array. */
EXTERNL int
nc_put_vlen_element(int ncid, int typeid1, void *vlen_element,
size_t len, const void *data);
EXTERNL int
nc_get_vlen_element(int ncid, int typeid1, const void *vlen_element,
size_t *len, void *data);
/* When you read the string type the library will allocate the storage
* space for the data. This storage space must be freed, so pass the
* pointer back to this function, when you're done with the data, and
* it will free the string memory.
* This function is deprecated in favor of the nc_reclaim_data function.
*/
EXTERNL int
nc_free_string(size_t len, char **data);
/* Find out about a user defined type. */
EXTERNL int
nc_inq_user_type(int ncid, nc_type xtype, char *name, size_t *size,
nc_type *base_nc_typep, size_t *nfieldsp, int *classp);
/* Write an attribute of any type. */
EXTERNL int
nc_put_att(int ncid, int varid, const char *name, nc_type xtype,
size_t len, const void *op);
/* Read an attribute of any type. */
EXTERNL int
nc_get_att(int ncid, int varid, const char *name, void *ip);
/* Enum type. */
/* Create an enum type. Provide a base type and a name. At the moment
* only ints are accepted as base types. */
EXTERNL int
nc_def_enum(int ncid, nc_type base_typeid, const char *name,
nc_type *typeidp);
/* Insert a named value into an enum type. The value must fit within
* the size of the enum type, the name size must be <= NC_MAX_NAME. */
EXTERNL int
nc_insert_enum(int ncid, nc_type xtype, const char *name,
const void *value);
/* Get information about an enum type: its name, base type and the
* number of members defined. */
EXTERNL int
nc_inq_enum(int ncid, nc_type xtype, char *name, nc_type *base_nc_typep,
size_t *base_sizep, size_t *num_membersp);
/* Get information about an enum member: a name and value. Name size
* will be <= NC_MAX_NAME. */
EXTERNL int
nc_inq_enum_member(int ncid, nc_type xtype, int idx, char *name,
void *value);
/* Get enum name from enum value. Name size will be <= NC_MAX_NAME. */
/* If value is zero and there is no matching ident, then return _UNDEFINED */
#define NC_UNDEFINED_ENUM_IDENT "_UNDEFINED"
EXTERNL int
nc_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier);
/* Opaque type. */
/* Create an opaque type. Provide a size and a name. */
EXTERNL int
nc_def_opaque(int ncid, size_t size, const char *name, nc_type *xtypep);
/* Get information about an opaque type. */
EXTERNL int
nc_inq_opaque(int ncid, nc_type xtype, char *name, size_t *sizep);
/* Write entire var of any type. */
EXTERNL int
nc_put_var(int ncid, int varid, const void *op);
/* Read entire var of any type. */
EXTERNL int
nc_get_var(int ncid, int varid, void *ip);
/* Write one value. */
EXTERNL int
nc_put_var1(int ncid, int varid, const size_t *indexp,
const void *op);
/* Read one value. */
EXTERNL int
nc_get_var1(int ncid, int varid, const size_t *indexp, void *ip);
/* Write an array of values. */
EXTERNL int
nc_put_vara(int ncid, int varid, const size_t *startp,
const size_t *countp, const void *op);
/* Read an array of values. */
EXTERNL int
nc_get_vara(int ncid, int varid, const size_t *startp,
const size_t *countp, void *ip);
/* Write slices of an array of values. */
EXTERNL int
nc_put_vars(int ncid, int varid, const size_t *startp,
const size_t *countp, const ptrdiff_t *stridep,
const void *op);
/* Read slices of an array of values. */
EXTERNL int
nc_get_vars(int ncid, int varid, const size_t *startp,
const size_t *countp, const ptrdiff_t *stridep,
void *ip);
/* Write mapped slices of an array of values. */
EXTERNL int
nc_put_varm(int ncid, int varid, const size_t *startp,
const size_t *countp, const ptrdiff_t *stridep,
const ptrdiff_t *imapp, const void *op);
/* Read mapped slices of an array of values. */
EXTERNL int
nc_get_varm(int ncid, int varid, const size_t *startp,
const size_t *countp, const ptrdiff_t *stridep,
const ptrdiff_t *imapp, void *ip);
/* Extra netcdf-4 stuff. */
/* Set quantization settings for a variable. Quantizing data improves
* later compression. Must be called after nc_def_var and before
* nc_enddef. */
EXTERNL int
nc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd);
/* Find out quantization settings of a var. */
EXTERNL int
nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp);
/* Set compression settings for a variable. Lower is faster, higher is
* better. Must be called after nc_def_var and before nc_enddef. */
EXTERNL int
nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
int deflate_level);
/* Find out compression settings of a var. */
EXTERNL int
nc_inq_var_deflate(int ncid, int varid, int *shufflep,
int *deflatep, int *deflate_levelp);
/* Set szip compression for a variable. */
EXTERNL int nc_def_var_szip(int ncid, int varid, int options_mask,
int pixels_per_block);
/* Find out szip settings of a var. */
EXTERNL int
nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp);
/* Set fletcher32 checksum for a var. This must be done after nc_def_var
and before nc_enddef. */
EXTERNL int
nc_def_var_fletcher32(int ncid, int varid, int fletcher32);
/* Inquire about fletcher32 checksum for a var. */
EXTERNL int
nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p);
/* Define chunking for a variable. This must be done after nc_def_var
and before nc_enddef. */
EXTERNL int
nc_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp);
/* Inq chunking stuff for a var. */
EXTERNL int
nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp);
/* Define fill value behavior for a variable. This must be done after
nc_def_var and before nc_enddef. */
EXTERNL int
nc_def_var_fill(int ncid, int varid, int no_fill, const void *fill_value);
/* Inq fill value setting for a var. */
EXTERNL int
nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep);
/* Define the endianness of a variable. */
EXTERNL int
nc_def_var_endian(int ncid, int varid, int endian);
/* Learn about the endianness of a variable. */
EXTERNL int
nc_inq_var_endian(int ncid, int varid, int *endianp);
/* Define a filter for a variable */
EXTERNL int
nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int* parms);
/* Learn about the first filter on a variable */
EXTERNL int
nc_inq_var_filter(int ncid, int varid, unsigned int* idp, size_t* nparams, unsigned int* params);
/* Set the fill mode (classic or 64-bit offset files only). */
EXTERNL int
nc_set_fill(int ncid, int fillmode, int *old_modep);
/* Set the default nc_create format to NC_FORMAT_CLASSIC, NC_FORMAT_64BIT,
* NC_FORMAT_CDF5, NC_FORMAT_NETCDF4, or NC_FORMAT_NETCDF4_CLASSIC */
EXTERNL int
nc_set_default_format(int format, int *old_formatp);
/* Set the cache size, nelems, and preemption policy. */
EXTERNL int
nc_set_chunk_cache(size_t size, size_t nelems, float preemption);
/* Get the cache size, nelems, and preemption policy. */
EXTERNL int
nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp);
/* Set the per-variable cache size, nelems, and preemption policy. */
EXTERNL int
nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems,
float preemption);