NetCDF 4.9.3-rc1
Loading...
Searching...
No Matches
dcopy.c
Go to the documentation of this file.
1
10#include "config.h"
11#include "ncdispatch.h"
12#include "nc_logging.h"
13#include "nclist.h"
14
15static int NC_find_equal_type(int ncid1, nc_type xtype1, int ncid2, nc_type *xtype2);
16
17#ifdef USE_NETCDF4
18
19static int searchgroup(int ncid1, int tid1, int grp, int* tid2);
20static int searchgrouptree(int ncid1, int tid1, int grp, int* tid2);
21
22#endif /*USE_NETCDF4*/
23
24
25#ifdef USE_NETCDF4
40static int
41NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2, int *equalp)
42{
43 int ret = NC_NOERR;
44
45 /* If you don't care about the answer, neither do I! */
46 if(equalp == NULL)
47 return NC_NOERR;
48
49 /* Assume the types are not equal. If we find any inequality, then
50 exit with NC_NOERR and we're done. */
51 *equalp = 0;
52
53 /* Atomic types are so easy! */
54 if (typeid1 <= NC_MAX_ATOMIC_TYPE)
55 {
56 if (typeid2 != typeid1)
57 return NC_NOERR;
58 *equalp = 1;
59 }
60 else
61 {
62 int i, ret, equal1;
63 char name1[NC_MAX_NAME];
64 char name2[NC_MAX_NAME];
65 size_t size1, size2;
66 nc_type base1, base2;
67 size_t nelems1, nelems2;
68 int class1, class2;
69 void* value1 = NULL;
70 void* value2 = NULL;
71 size_t offset1, offset2;
72 nc_type ftype1, ftype2;
73 int ndims1, ndims2;
74 int dimsizes1[NC_MAX_VAR_DIMS];
75 int dimsizes2[NC_MAX_VAR_DIMS];
76
77 /* Find out about the two types. */
78 if ((ret = nc_inq_user_type(ncid1, typeid1, name1, &size1,
79 &base1, &nelems1, &class1)))
80 return ret;
81 if ((ret = nc_inq_user_type(ncid2, typeid2, name2, &size2,
82 &base2, &nelems2, &class2)))
83 return ret;
84
85 /* Check the obvious. */
86 if(size1 != size2 || class1 != class2 || strcmp(name1,name2) != 0)
87 return NC_NOERR;
88
89 /* Check user-defined types in detail. */
90 switch(class1)
91 {
92 case NC_VLEN:
93 if((ret = NC_compare_nc_types(ncid1, base1, ncid2,
94 base1, &equal1)))
95 return ret;
96 if(!equal1)
97 return NC_NOERR;
98 break;
99 case NC_OPAQUE:
100 /* Already checked size above. */
101 break;
102 case NC_ENUM:
103 if(base1 != base2 || nelems1 != nelems2) return NC_NOERR;
104
105 if (!(value1 = malloc(size1)))
106 return NC_ENOMEM;
107 if (!(value2 = malloc(size2))) {
108 free(value1);
109 return NC_ENOMEM;
110 }
111
112 for(i = 0; i < nelems1; i++)
113 {
114 if ((ret = nc_inq_enum_member(ncid1, typeid1, i, name1,
115 value1)) ||
116 (ret = nc_inq_enum_member(ncid2, typeid2, i, name2,
117 value2)) ||
118 strcmp(name1, name2) != 0 || memcmp(value1, value2, size1) != 0)
119 {
120 free(value1);
121 free(value2);
122 return ret;
123 }
124 }
125 free(value1);
126 free(value2);
127 break;
128 case NC_COMPOUND:
129 if(nelems1 != nelems2)
130 return NC_NOERR;
131
132 /* Compare each field. Each must be equal! */
133 for(i = 0; i < nelems1; i++)
134 {
135 int j;
136 if ((ret = nc_inq_compound_field(ncid1, typeid1, i, name1, &offset1,
137 &ftype1, &ndims1, dimsizes1)))
138 return ret;
139 if ((ret = nc_inq_compound_field(ncid2, typeid2, i, name2, &offset2,
140 &ftype2, &ndims2, dimsizes2)))
141 return ret;
142 if(ndims1 != ndims2)
143 return NC_NOERR;
144 for(j = 0; j < ndims1;j++)
145 if(dimsizes1[j] != dimsizes2[j])
146 return NC_NOERR;
147
148 /* Compare user-defined field types. */
149 if((ret = NC_compare_nc_types(ncid1, ftype1, ncid2, ftype2,
150 &equal1)))
151 return ret;
152 if(!equal1)
153 return NC_NOERR;
154 }
155 break;
156 default:
157 return NC_EINVAL;
158 }
159 *equalp = 1;
160 }
161 return ret;
162}
163
183static int
184NC_rec_find_nc_type(int ncid1, nc_type tid1, int ncid2, nc_type* tid2)
185{
186 int ret = NC_NOERR;
187 int parent;
188
189 if((ret = searchgroup(ncid1,tid1,ncid2,tid2)))
190 goto done;
191 if(*tid2 != 0)
192 goto done; /* found */
193
194 /* Look in the parents of ncid2 upto the root */
195 switch (ret = nc_inq_grp_parent(ncid2,&parent)) {
196 case NC_NOERR:
197 /* Recurse up using parent grp */
198 ret = NC_rec_find_nc_type(ncid1, tid1, parent, tid2);
199 break;
200 case NC_ENOGRP:
201 /* do the breadth-first pre-order search of the whole tree */
202 /* ncid2 should be root group */
203 ret = searchgrouptree(ncid1,tid1,ncid2,tid2);
204 break;
205 default: break;
206 }
207
208done:
209 return ret;
210}
211
212#endif /* USE_NETCDF4 */
213
226static int
227NC_find_equal_type(int ncid1, nc_type xtype1, int ncid2, nc_type *xtype2)
228{
229 int ret = NC_NOERR;
230
231 /* Check input */
232 if(xtype1 <= NC_NAT)
233 return NC_EINVAL;
234
235 /* Handle atomic types. */
236 if (xtype1 <= NC_MAX_ATOMIC_TYPE)
237 {
238 if(xtype2)
239 *xtype2 = xtype1;
240 return NC_NOERR;
241 }
242
243#ifdef USE_NETCDF4
244 /* Recursively search group ncid2 and its children
245 to find a type that is equal (using compare_type)
246 to xtype1. */
247 ret = NC_rec_find_nc_type(ncid1, xtype1 , ncid2, xtype2);
248#endif /* USE_NETCDF4 */
249 return ret;
250}
251
280int
281nc_copy_var(int ncid_in, int varid_in, int ncid_out)
282{
283 char name[NC_MAX_NAME + 1];
284 char att_name[NC_MAX_NAME + 1];
285 nc_type xtype;
286 int ndims, dimids_in[NC_MAX_VAR_DIMS], dimids_out[NC_MAX_VAR_DIMS], natts, real_ndims;
287 int varid_out;
288 int a, d;
289 void *data = NULL;
290 size_t *count = NULL, *start = NULL;
291 size_t reclen = 1;
292 size_t *dimlen = NULL;
293 int retval = NC_NOERR;
294 size_t type_size;
295 int src_format, dest_format;
296 char type_name[NC_MAX_NAME+1];
297 char dimname_in[NC_MAX_NAME + 1];
298 int i;
299
300 /* Learn about this var. */
301 if ((retval = nc_inq_var(ncid_in, varid_in, name, &xtype,
302 &ndims, dimids_in, &natts)))
303 return retval;
304 /* find corresponding dimids in the output file */
305 for(i = 0; i < ndims; i++) {
306 dimids_out[i] = dimids_in[i];
307 if ((retval = nc_inq_dimname(ncid_in, dimids_in[i], dimname_in)))
308 return retval;
309 if ((retval = nc_inq_dimid(ncid_out, dimname_in, &dimids_out[i])))
310 return retval;
311 }
312
313 LOG((2, "nc_copy_var: ncid_in 0x%x varid_in %d ncid_out 0x%x",
314 ncid_in, varid_in, ncid_out));
315
316 /* Make sure we are not trying to write into a netcdf-3 file
317 * anything that won't fit in netcdf-3. */
318 if ((retval = nc_inq_format(ncid_in, &src_format)))
319 return retval;
320 if ((retval = nc_inq_format(ncid_out, &dest_format)))
321 return retval;
322 if ((dest_format == NC_FORMAT_CLASSIC
323 || dest_format == NC_FORMAT_64BIT_DATA
324 || dest_format == NC_FORMAT_64BIT_OFFSET) &&
325 src_format == NC_FORMAT_NETCDF4 && xtype > NC_DOUBLE)
326 return NC_ENOTNC4;
327
328 /* Later on, we will need to know the size of this type. */
329 if ((retval = nc_inq_type(ncid_in, xtype, type_name, &type_size)))
330 return retval;
331 LOG((3, "type %s has size %d", type_name, type_size));
332
333 /* Switch back to define mode, and create the output var. */
334 retval = nc_redef(ncid_out);
335 if (retval && retval != NC_EINDEFINE)
336 BAIL(retval);
337 if ((retval = nc_def_var(ncid_out, name, xtype,
338 ndims, dimids_out, &varid_out)))
339 BAIL(retval);
340
341 /* Copy the attributes. */
342 for (a=0; a<natts; a++)
343 {
344 if ((retval = nc_inq_attname(ncid_in, varid_in, a, att_name)))
345 BAIL(retval);
346 if ((retval = nc_copy_att(ncid_in, varid_in, att_name,
347 ncid_out, varid_out)))
348 BAIL(retval);
349 }
350
351 /* End define mode, to write metadata and create file. */
352 nc_enddef(ncid_out);
353 nc_sync(ncid_out);
354
355 /* Allocate memory for our start and count arrays. If ndims = 0
356 this is a scalar, which I will treat as a 1-D array with one
357 element. */
358 real_ndims = ndims ? ndims : 1;
359 if (!(start = malloc((size_t)real_ndims * sizeof(size_t))))
360 BAIL(NC_ENOMEM);
361 if (!(count = malloc((size_t)real_ndims * sizeof(size_t))))
362 BAIL(NC_ENOMEM);
363
364 /* The start array will be all zeros, except the first element,
365 which will be the record number. Count will be the dimension
366 size, except for the first element, which will be one, because
367 we will copy one record at a time. For this we need the var
368 shape. */
369 if (!(dimlen = malloc((size_t)real_ndims * sizeof(size_t))))
370 BAIL(NC_ENOMEM);
371
372 /* Set to 0, to correct for an unlikely dereference
373 error reported by clang/llvm. */
374 dimlen[0] = 0;
375
376 /* Find out how much data. */
377 for (d=0; d<ndims; d++)
378 {
379 if ((retval = nc_inq_dimlen(ncid_in, dimids_in[d], &dimlen[d])))
380 BAIL(retval);
381 LOG((4, "nc_copy_var: there are %d data", dimlen[d]));
382 }
383
384 /* If this is really a scalar, then set the dimlen to 1. */
385 if (ndims == 0)
386 dimlen[0] = 1;
387
388 for (d=0; d<real_ndims; d++)
389 {
390 start[d] = 0;
391 count[d] = d ? dimlen[d] : 1;
392 if (d) reclen *= dimlen[d];
393 }
394
395 /* If there are no records, we're done. */
396 if (!dimlen[0])
397 goto exit;
398
399 /* Allocate memory for one record. */
400 if (!(data = malloc(reclen * type_size))) {
401 if(count) free(count);
402 if(dimlen) free(dimlen);
403 if(start) free(start);
404 return NC_ENOMEM;
405 }
406
407 /* Copy the var data one record at a time. */
408 for (start[0]=0; !retval && start[0]<(size_t)dimlen[0]; start[0]++)
409 {
410 switch (xtype)
411 {
412 case NC_BYTE:
413 retval = nc_get_vara_schar(ncid_in, varid_in, start, count,
414 (signed char *)data);
415 if (!retval)
416 retval = nc_put_vara_schar(ncid_out, varid_out, start, count,
417 (const signed char *)data);
418 break;
419 case NC_CHAR:
420 retval = nc_get_vara_text(ncid_in, varid_in, start, count,
421 (char *)data);
422 if (!retval)
423 retval = nc_put_vara_text(ncid_out, varid_out, start, count,
424 (char *)data);
425 break;
426 case NC_SHORT:
427 retval = nc_get_vara_short(ncid_in, varid_in, start, count,
428 (short *)data);
429 if (!retval)
430 retval = nc_put_vara_short(ncid_out, varid_out, start, count,
431 (short *)data);
432 break;
433 case NC_INT:
434 retval = nc_get_vara_int(ncid_in, varid_in, start, count,
435 (int *)data);
436 if (!retval)
437 retval = nc_put_vara_int(ncid_out, varid_out, start, count,
438 (int *)data);
439 break;
440 case NC_FLOAT:
441 retval = nc_get_vara_float(ncid_in, varid_in, start, count,
442 (float *)data);
443 if (!retval)
444 retval = nc_put_vara_float(ncid_out, varid_out, start, count,
445 (float *)data);
446 break;
447 case NC_DOUBLE:
448 retval = nc_get_vara_double(ncid_in, varid_in, start, count,
449 (double *)data);
450 if (!retval)
451 retval = nc_put_vara_double(ncid_out, varid_out, start, count,
452 (double *)data);
453 break;
454 case NC_UBYTE:
455 retval = nc_get_vara_uchar(ncid_in, varid_in, start, count,
456 (unsigned char *)data);
457 if (!retval)
458 retval = nc_put_vara_uchar(ncid_out, varid_out, start, count,
459 (unsigned char *)data);
460 break;
461 case NC_USHORT:
462 retval = nc_get_vara_ushort(ncid_in, varid_in, start, count,
463 (unsigned short *)data);
464 if (!retval)
465 retval = nc_put_vara_ushort(ncid_out, varid_out, start, count,
466 (unsigned short *)data);
467 break;
468 case NC_UINT:
469 retval = nc_get_vara_uint(ncid_in, varid_in, start, count,
470 (unsigned int *)data);
471 if (!retval)
472 retval = nc_put_vara_uint(ncid_out, varid_out, start, count,
473 (unsigned int *)data);
474 break;
475 case NC_INT64:
476 retval = nc_get_vara_longlong(ncid_in, varid_in, start, count,
477 (long long *)data);
478 if (!retval)
479 retval = nc_put_vara_longlong(ncid_out, varid_out, start, count,
480 (long long *)data);
481 break;
482 case NC_UINT64:
483 retval = nc_get_vara_ulonglong(ncid_in, varid_in, start, count,
484 (unsigned long long *)data);
485 if (!retval)
486 retval = nc_put_vara_ulonglong(ncid_out, varid_out, start, count,
487 (unsigned long long *)data);
488 break;
489 default:
490 retval = NC_EBADTYPE;
491 }
492 }
493
494 exit:
495 if (data) free(data);
496 if (dimlen) free(dimlen);
497 if (start) free(start);
498 if (count) free(count);
499 return retval;
500}
501
515static int
516NC_copy_att(int ncid_in, int varid_in, const char *name,
517 int ncid_out, int varid_out)
518{
519 nc_type xtype;
520 size_t len;
521 void *data=NULL;
522 int res;
523
524 LOG((2, "nc_copy_att: ncid_in 0x%x varid_in %d name %s",
525 ncid_in, varid_in, name));
526
527 /* Find out about the attribute to be copied. */
528 if ((res = nc_inq_att(ncid_in, varid_in, name, &xtype, &len)))
529 return res;
530
531 {
532 /* Copy arbitrary attributes. */
533 int class;
534 size_t size;
535 nc_type xtype_out = NC_NAT;
536
537 if(xtype <= NC_MAX_ATOMIC_TYPE) {
538 xtype_out = xtype;
539 if((res = nc_inq_type(ncid_out,xtype_out,NULL,&size))) return res;
540 } else { /* User defined type */
541 /* Find out if there is an equal type in the output file. */
542 /* Note: original code used a libsrc4 specific internal function
543 which we had to "duplicate" here */
544 if ((res = NC_find_equal_type(ncid_in, xtype, ncid_out, &xtype_out)))
545 return res;
546 if (xtype_out) {
547 /* We found an equal type! */
548 if ((res = nc_inq_user_type(ncid_in, xtype, NULL, &size, NULL, NULL, &class)))
549 return res;
550 }
551 }
552 if((data = malloc(size * len))==NULL) {return NC_ENOMEM;}
553 res = nc_get_att(ncid_in, varid_in, name, data);
554 if(!res)
555 res = nc_put_att(ncid_out, varid_out, name, xtype_out, len, data);
556 (void)nc_reclaim_data_all(ncid_out,xtype_out,data,len);
557 }
558
559 return res;
560}
561
583int
584nc_copy_att(int ncid_in, int varid_in, const char *name,
585 int ncid_out, int varid_out)
586{
587 int format, target_natts, target_attid;
588 char att_name[NC_MAX_NAME + 1];
589 int a, retval;
590
591 /* What is the destination format? */
592 if ((retval = nc_inq_format(ncid_out, &format)))
593 return retval;
594
595 /* Can't copy to same var in same file. */
596 if (ncid_in == ncid_out && varid_in == varid_out)
597 return NC_NOERR;
598
599 /* For classic model netCDF-4 files, order of attributes must be
600 * maintained during copies. We MUST MAINTAIN ORDER! */
601 if (format == NC_FORMAT_NETCDF4_CLASSIC)
602 {
603 /* Does this attribute already exist in the target file? */
604 retval = nc_inq_attid(ncid_out, varid_out, name, &target_attid);
605 if (retval == NC_ENOTATT)
606 {
607 /* Attribute does not exist. No order to be preserved. */
608 return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
609 }
610 else if (retval == NC_NOERR)
611 {
612 /* How many atts for this var? */
613 if ((retval = nc_inq_varnatts(ncid_out, varid_out, &target_natts)))
614 return retval;
615
616 /* If this is the last attribute in the target file, we are
617 * off the hook. */
618 if (target_attid == target_natts - 1)
619 return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
620
621 /* Order MUST BE MAINTAINED! Copy all existing atts in the target
622 * file, stopping at our target att. */
623 for (a = 0; a < target_natts; a++)
624 {
625 if (a == target_attid)
626 {
627 if ((retval = NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out)))
628 return retval;
629 }
630 else
631 {
632 if ((retval = nc_inq_attname(ncid_out, varid_out, a, att_name)))
633 return retval;
634 if ((retval = NC_copy_att(ncid_out, varid_out, att_name,
635 ncid_out, varid_out)))
636 return retval;
637 }
638 }
639 }
640 else
641 return retval; /* Some other error occurred. */
642 }
643 else
644 return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
645
646 return NC_NOERR;
647}
648
649#ifdef USE_NETCDF4
650
651/* Helper function for NC_rec_find_nc_type();
652 search a specified group for matching type.
653*/
654static int
655searchgroup(int ncid1, int tid1, int grp, int* tid2)
656{
657 int i,ret = NC_NOERR;
658 int nids;
659 int* ids = NULL;
660
661 /* Get all types in grp */
662 if(tid2)
663 *tid2 = 0;
664 if ((ret = nc_inq_typeids(grp, &nids, NULL)))
665 goto done;
666 if (nids)
667 {
668 if (!(ids = (int *)malloc((size_t)nids * sizeof(int))))
669 {ret = NC_ENOMEM; goto done;}
670 if ((ret = nc_inq_typeids(grp, &nids, ids)))
671 goto done;
672 for(i = 0; i < nids; i++)
673 {
674 int equal = 0;
675 if ((ret = NC_compare_nc_types(ncid1, tid1, grp, ids[i], &equal)))
676 goto done;
677 if(equal)
678 {
679 if(tid2)
680 *tid2 = ids[i];
681 goto done;
682 }
683 }
684 }
685
686done:
687 nullfree(ids);
688 return ret;
689}
690
691/* Helper function for NC_rec_find_nc_type();
692 search a tree of groups for a matching type
693 using a breadth first queue
694*/
695static int
696searchgrouptree(int ncid1, int tid1, int grp, int* tid2)
697{
698 int i,ret = NC_NOERR;
699 int nids;
700 int* ids = NULL;
701 NClist* queue = nclistnew();
702 int gid;
703 uintptr_t id;
704
705 id = (uintptr_t)grp;
706 nclistpush(queue,(void*)id); /* prime the queue */
707 while(nclistlength(queue) > 0) {
708 id = (uintptr_t)nclistremove(queue,0);
709 gid = (int)id;
710 if((ret = searchgroup(ncid1,tid1,gid,tid2)))
711 goto done;
712 if(*tid2 != 0)
713 goto done; /*we found it*/
714 /* Get subgroups of gid and push onto front of the queue (for breadth first) */
715 if((ret = nc_inq_grps(gid,&nids,NULL)))
716 goto done;
717 if (!(ids = (int *)malloc((size_t)nids * sizeof(int))))
718 {ret = NC_ENOMEM; goto done;}
719 if ((ret = nc_inq_grps(gid, &nids, ids)))
720 goto done;
721 /* push onto the end of the queue */
722 for(i=0;i<nids;i++) {
723 id = (uintptr_t)ids[i];
724 nclistpush(queue,(void*)id);
725 }
726 free(ids); ids = NULL;
727 }
728 /* Not found */
729 ret = NC_EBADTYPE;
730
731done:
732 nclistfree(queue);
733 nullfree(ids);
734 return ret;
735}
736
737#endif /* USE_NETCDF4 */
738
int nc_copy_var(int ncid_in, int varid_in, int ncid_out)
This will copy a variable that is an array of primitive type and its attributes from one file to anot...
Definition dcopy.c:281
int nc_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out, int varid_out)
Copy an attribute from one open file to another.
Definition dcopy.c:584
static int NC_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out, int varid_out)
Copy an attribute from one open file to another.
Definition dcopy.c:516
EXTERNL int nc_put_att(int ncid, int varid, const char *name, nc_type xtype, size_t len, const void *op)
Write an attribute of any type.
Definition dattput.c:222
EXTERNL int nc_get_att(int ncid, int varid, const char *name, void *ip)
Get an attribute of any type.
Definition dattget.c:133
EXTERNL int nc_inq_attid(int ncid, int varid, const char *name, int *idp)
Find an attribute ID.
Definition dattinq.c:164
EXTERNL int nc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp)
Return information about a netCDF attribute.
Definition dattinq.c:86
EXTERNL int nc_inq_attname(int ncid, int varid, int attnum, char *name)
Find the name of an attribute.
Definition dattinq.c:255
EXTERNL int nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
Inquire about a type.
Definition dfile.c:1728
EXTERNL int nc_enddef(int ncid)
Leave define mode.
Definition dfile.c:1027
EXTERNL int nc_redef(int ncid)
Put open netcdf dataset into define mode.
Definition dfile.c:963
EXTERNL int nc_inq_format(int ncid, int *formatp)
Inquire about the binary format of a netCDF file as presented by the API.
Definition dfile.c:1547
EXTERNL int nc_sync(int ncid)
Synchronize an open netcdf dataset to disk.
Definition dfile.c:1195
EXTERNL int nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
Find the length of a dimension.
Definition ddim.c:467
EXTERNL int nc_inq_dimname(int ncid, int dimid, char *name)
Find out the name of a dimension.
Definition ddim.c:409
EXTERNL int nc_inq_dimid(int ncid, const char *name, int *idp)
Find the ID of a dimension from the name.
Definition ddim.c:152
EXTERNL int nc_inq_typeids(int ncid, int *ntypes, int *typeids)
Retrieve a list of types associated with a group.
Definition dgroup.c:223
EXTERNL int nc_inq_grps(int ncid, int *numgrps, int *ncids)
Get a list of groups or subgroups from a file or groupID.
Definition dgroup.c:73
EXTERNL int nc_inq_grp_parent(int ncid, int *parent_ncid)
Get the ID of the parent based on a group ID.
Definition dgroup.c:136
EXTERNL int nc_inq_enum_member(int ncid, nc_type xtype, int idx, char *name, void *value)
Learn about a about a member of an enum type.
Definition denum.c:140
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)
Get information about one of the fields of a compound type.
Definition dcompound.c:287
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)
Learn about a user defined type.
Definition dtype.c:146
EXTERNL int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition dvarinq.c:249
EXTERNL int nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)
Learn about a variable.
Definition dvarinq.c:124
EXTERNL int nc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
Define a new variable.
Definition dvar.c:214
#define NC_FORMAT_64BIT_OFFSET
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:185
#define NC_FORMAT_NETCDF4_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:188
#define NC_EBADTYPE
Not a netcdf data type.
Definition netcdf.h:411
#define NC_UINT
unsigned 4-byte int
Definition netcdf.h:44
#define NC_INT
signed 4 byte integer
Definition netcdf.h:38
#define NC_MAX_VAR_DIMS
max per variable dimensions
Definition netcdf.h:283
#define NC_BYTE
signed 1 byte integer
Definition netcdf.h:35
#define NC_VLEN
vlen (variable-length) types
Definition netcdf.h:53
#define NC_ENOGRP
No group found.
Definition netcdf.h:506
#define NC_NAT
Not A Type.
Definition netcdf.h:34
#define NC_DOUBLE
double precision floating point number
Definition netcdf.h:41
#define NC_UBYTE
unsigned 1 byte int
Definition netcdf.h:42
#define NC_FLOAT
single precision floating point number
Definition netcdf.h:40
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition netcdf.h:492
#define NC_ENOMEM
Memory allocation (malloc) failure.
Definition netcdf.h:449
#define NC_COMPOUND
compound types
Definition netcdf.h:56
#define NC_EINDEFINE
Operation not allowed in define mode.
Definition netcdf.h:394
#define NC_SHORT
signed 2 byte integer
Definition netcdf.h:37
#define NC_ENUM
enum types
Definition netcdf.h:55
#define NC_INT64
signed 8-byte int
Definition netcdf.h:45
#define NC_FORMAT_NETCDF4
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:187
#define NC_UINT64
unsigned 8-byte int
Definition netcdf.h:46
#define NC_ENOTATT
Attribute not found.
Definition netcdf.h:409
#define NC_FORMAT_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:179
#define NC_EINVAL
Invalid Argument.
Definition netcdf.h:379
#define NC_MAX_NAME
Maximum for classic library.
Definition netcdf.h:282
#define NC_NOERR
No Error.
Definition netcdf.h:369
#define NC_USHORT
unsigned 2-byte int
Definition netcdf.h:43
#define NC_OPAQUE
opaque types
Definition netcdf.h:54
#define NC_CHAR
ISO/ASCII character.
Definition netcdf.h:36
#define NC_FORMAT_64BIT_DATA
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:189
int nc_type
The nc_type type is just an int.
Definition netcdf.h:25