NetCDF  4.8.0
dcopy.c
Go to the documentation of this file.
1 
10 #include "config.h"
11 #include "ncdispatch.h"
12 #include "nc_logging.h"
13 
14 #ifdef USE_NETCDF4
15 
29 static int
30 NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
31  int *equalp)
32 {
33  int ret = NC_NOERR;
34 
35  /* If you don't care about the answer, neither do I! */
36  if(equalp == NULL)
37  return NC_NOERR;
38 
39  /* Assume the types are not equal. If we find any inequality, then
40  exit with NC_NOERR and we're done. */
41  *equalp = 0;
42 
43  /* Atomic types are so easy! */
44  if (typeid1 <= NC_MAX_ATOMIC_TYPE)
45  {
46  if (typeid2 != typeid1)
47  return NC_NOERR;
48  *equalp = 1;
49  }
50  else
51  {
52  int i, ret, equal1;
53  char name1[NC_MAX_NAME];
54  char name2[NC_MAX_NAME];
55  size_t size1, size2;
56  nc_type base1, base2;
57  size_t nelems1, nelems2;
58  int class1, class2;
59  void* value1 = NULL;
60  void* value2 = NULL;
61  size_t offset1, offset2;
62  nc_type ftype1, ftype2;
63  int ndims1, ndims2;
64  int dimsizes1[NC_MAX_VAR_DIMS];
65  int dimsizes2[NC_MAX_VAR_DIMS];
66 
67  /* Find out about the two types. */
68  if ((ret = nc_inq_user_type(ncid1, typeid1, name1, &size1,
69  &base1, &nelems1, &class1)))
70  return ret;
71  if ((ret = nc_inq_user_type(ncid2, typeid2, name2, &size2,
72  &base2, &nelems2, &class2)))
73  return ret;
74 
75  /* Check the obvious. */
76  if(size1 != size2 || class1 != class2 || strcmp(name1,name2))
77  return NC_NOERR;
78 
79  /* Check user-defined types in detail. */
80  switch(class1)
81  {
82  case NC_VLEN:
83  if((ret = NC_compare_nc_types(ncid1, base1, ncid2,
84  base1, &equal1)))
85  return ret;
86  if(!equal1)
87  return NC_NOERR;
88  break;
89  case NC_OPAQUE:
90  /* Already checked size above. */
91  break;
92  case NC_ENUM:
93  if(base1 != base2 || nelems1 != nelems2) return NC_NOERR;
94 
95  if (!(value1 = malloc(size1)))
96  return NC_ENOMEM;
97  if (!(value2 = malloc(size2))) {
98  free(value1);
99  return NC_ENOMEM;
100  }
101 
102  for(i = 0; i < nelems1; i++)
103  {
104  if ((ret = nc_inq_enum_member(ncid1, typeid1, i, name1,
105  value1)) ||
106  (ret = nc_inq_enum_member(ncid2, typeid2, i, name2,
107  value2)) ||
108  strcmp(name1, name2) || memcmp(value1, value2, size1))
109  {
110  free(value1);
111  free(value2);
112  return ret;
113  }
114  }
115  free(value1);
116  free(value2);
117  break;
118  case NC_COMPOUND:
119  if(nelems1 != nelems2)
120  return NC_NOERR;
121 
122  /* Compare each field. Each must be equal! */
123  for(i = 0; i < nelems1; i++)
124  {
125  int j;
126  if ((ret = nc_inq_compound_field(ncid1, typeid1, i, name1, &offset1,
127  &ftype1, &ndims1, dimsizes1)))
128  return ret;
129  if ((ret = nc_inq_compound_field(ncid2, typeid2, i, name2, &offset2,
130  &ftype2, &ndims2, dimsizes2)))
131  return ret;
132  if(ndims1 != ndims2)
133  return NC_NOERR;
134  for(j = 0; j < ndims1;j++)
135  if(dimsizes1[j] != dimsizes2[j])
136  return NC_NOERR;
137 
138  /* Compare user-defined field types. */
139  if((ret = NC_compare_nc_types(ncid1, ftype1, ncid2, ftype2,
140  &equal1)))
141  return ret;
142  if(!equal1)
143  return NC_NOERR;
144  }
145  break;
146  default:
147  return NC_EINVAL;
148  }
149  *equalp = 1;
150  }
151  return ret;
152 }
153 
166 static int
167 NC_rec_find_nc_type(int ncid1, nc_type tid1, int ncid2, nc_type* tid2)
168 {
169  int i,ret = NC_NOERR;
170  int nids;
171  int* ids = NULL;
172 
173  /* Get all types in grp ncid2 */
174  if(tid2)
175  *tid2 = 0;
176  if ((ret = nc_inq_typeids(ncid2, &nids, NULL)))
177  return ret;
178  if (nids)
179  {
180  if (!(ids = (int *)malloc((size_t)nids * sizeof(int))))
181  return NC_ENOMEM;
182  if ((ret = nc_inq_typeids(ncid2, &nids, ids)))
183  return ret;
184  for(i = 0; i < nids; i++)
185  {
186  int equal = 0;
187  if ((ret = NC_compare_nc_types(ncid1, tid1, ncid2, ids[i], &equal)))
188  return ret;
189  if(equal)
190  {
191  if(tid2)
192  *tid2 = ids[i];
193  free(ids);
194  return NC_NOERR;
195  }
196  }
197  free(ids);
198  }
199 
200  /* recurse */
201  if ((ret = nc_inq_grps(ncid1, &nids, NULL)))
202  return ret;
203  if (nids)
204  {
205  if (!(ids = (int *)malloc((size_t)nids * sizeof(int))))
206  return NC_ENOMEM;
207  if ((ret = nc_inq_grps(ncid1, &nids, ids)))
208  {
209  free(ids);
210  return ret;
211  }
212  for (i = 0; i < nids; i++)
213  {
214  ret = NC_rec_find_nc_type(ncid1, tid1, ids[i], tid2);
215  if (ret && ret != NC_EBADTYPE)
216  break;
217  if (tid2 && *tid2 != 0) /* found */
218  {
219  free(ids);
220  return NC_NOERR;
221  }
222  }
223  free(ids);
224  }
225  return NC_EBADTYPE; /* not found */
226 }
227 
240 static int
241 NC_find_equal_type(int ncid1, nc_type xtype1, int ncid2, nc_type *xtype2)
242 {
243  int ret = NC_NOERR;
244 
245  /* Check input */
246  if(xtype1 <= NC_NAT)
247  return NC_EINVAL;
248 
249  /* Handle atomic types. */
250  if (xtype1 <= NC_MAX_ATOMIC_TYPE)
251  {
252  if(xtype2)
253  *xtype2 = xtype1;
254  return NC_NOERR;
255  }
256 
257  /* Recursively search group ncid2 and its children
258  to find a type that is equal (using compare_type)
259  to xtype1. */
260  ret = NC_rec_find_nc_type(ncid1, xtype1 , ncid2, xtype2);
261  return ret;
262 }
263 
264 #endif /* USE_NETCDF4 */
265 
294 int
295 nc_copy_var(int ncid_in, int varid_in, int ncid_out)
296 {
297  char name[NC_MAX_NAME + 1];
298  char att_name[NC_MAX_NAME + 1];
299  nc_type xtype;
300  int ndims, dimids_in[NC_MAX_VAR_DIMS], dimids_out[NC_MAX_VAR_DIMS], natts, real_ndims;
301  int varid_out;
302  int a, d;
303  void *data = NULL;
304  size_t *count = NULL, *start = NULL;
305  size_t reclen = 1;
306  size_t *dimlen = NULL;
307  int retval = NC_NOERR;
308  size_t type_size;
309  int src_format, dest_format;
310  char type_name[NC_MAX_NAME+1];
311  char dimname_in[NC_MAX_NAME + 1];
312  int i;
313 
314  /* Learn about this var. */
315  if ((retval = nc_inq_var(ncid_in, varid_in, name, &xtype,
316  &ndims, dimids_in, &natts)))
317  return retval;
318  /* find corresponding dimids in the output file */
319  for(i = 0; i < ndims; i++) {
320  dimids_out[i] = dimids_in[i];
321  if ((retval = nc_inq_dimname(ncid_in, dimids_in[i], dimname_in)))
322  return retval;
323  if ((retval = nc_inq_dimid(ncid_out, dimname_in, &dimids_out[i])))
324  return retval;
325  }
326 
327  LOG((2, "nc_copy_var: ncid_in 0x%x varid_in %d ncid_out 0x%x",
328  ncid_in, varid_in, ncid_out));
329 
330  /* Make sure we are not trying to write into a netcdf-3 file
331  * anything that won't fit in netcdf-3. */
332  if ((retval = nc_inq_format(ncid_in, &src_format)))
333  return retval;
334  if ((retval = nc_inq_format(ncid_out, &dest_format)))
335  return retval;
336  if ((dest_format == NC_FORMAT_CLASSIC
337  || dest_format == NC_FORMAT_64BIT_DATA
338  || dest_format == NC_FORMAT_64BIT_OFFSET) &&
339  src_format == NC_FORMAT_NETCDF4 && xtype > NC_DOUBLE)
340  return NC_ENOTNC4;
341 
342  /* Later on, we will need to know the size of this type. */
343  if ((retval = nc_inq_type(ncid_in, xtype, type_name, &type_size)))
344  return retval;
345  LOG((3, "type %s has size %d", type_name, type_size));
346 
347  /* Switch back to define mode, and create the output var. */
348  retval = nc_redef(ncid_out);
349  if (retval && retval != NC_EINDEFINE)
350  BAIL(retval);
351  if ((retval = nc_def_var(ncid_out, name, xtype,
352  ndims, dimids_out, &varid_out)))
353  BAIL(retval);
354 
355  /* Copy the attributes. */
356  for (a=0; a<natts; a++)
357  {
358  if ((retval = nc_inq_attname(ncid_in, varid_in, a, att_name)))
359  BAIL(retval);
360  if ((retval = nc_copy_att(ncid_in, varid_in, att_name,
361  ncid_out, varid_out)))
362  BAIL(retval);
363  }
364 
365  /* End define mode, to write metadata and create file. */
366  nc_enddef(ncid_out);
367  nc_sync(ncid_out);
368 
369  /* Allocate memory for our start and count arrays. If ndims = 0
370  this is a scalar, which I will treat as a 1-D array with one
371  element. */
372  real_ndims = ndims ? ndims : 1;
373  if (!(start = malloc((size_t)real_ndims * sizeof(size_t))))
374  BAIL(NC_ENOMEM);
375  if (!(count = malloc((size_t)real_ndims * sizeof(size_t))))
376  BAIL(NC_ENOMEM);
377 
378  /* The start array will be all zeros, except the first element,
379  which will be the record number. Count will be the dimension
380  size, except for the first element, which will be one, because
381  we will copy one record at a time. For this we need the var
382  shape. */
383  if (!(dimlen = malloc((size_t)real_ndims * sizeof(size_t))))
384  BAIL(NC_ENOMEM);
385 
386  /* Set to 0, to correct for an unlikely dereference
387  error reported by clang/llvm. */
388  dimlen[0] = 0;
389 
390  /* Find out how much data. */
391  for (d=0; d<ndims; d++)
392  {
393  if ((retval = nc_inq_dimlen(ncid_in, dimids_in[d], &dimlen[d])))
394  BAIL(retval);
395  LOG((4, "nc_copy_var: there are %d data", dimlen[d]));
396  }
397 
398  /* If this is really a scalar, then set the dimlen to 1. */
399  if (ndims == 0)
400  dimlen[0] = 1;
401 
402  for (d=0; d<real_ndims; d++)
403  {
404  start[d] = 0;
405  count[d] = d ? dimlen[d] : 1;
406  if (d) reclen *= dimlen[d];
407  }
408 
409  /* If there are no records, we're done. */
410  if (!dimlen[0])
411  goto exit;
412 
413  /* Allocate memory for one record. */
414  if (!(data = malloc(reclen * type_size))) {
415  if(count) free(count);
416  if(dimlen) free(dimlen);
417  if(start) free(start);
418  return NC_ENOMEM;
419  }
420 
421  /* Copy the var data one record at a time. */
422  for (start[0]=0; !retval && start[0]<(size_t)dimlen[0]; start[0]++)
423  {
424  switch (xtype)
425  {
426  case NC_BYTE:
427  retval = nc_get_vara_schar(ncid_in, varid_in, start, count,
428  (signed char *)data);
429  if (!retval)
430  retval = nc_put_vara_schar(ncid_out, varid_out, start, count,
431  (const signed char *)data);
432  break;
433  case NC_CHAR:
434  retval = nc_get_vara_text(ncid_in, varid_in, start, count,
435  (char *)data);
436  if (!retval)
437  retval = nc_put_vara_text(ncid_out, varid_out, start, count,
438  (char *)data);
439  break;
440  case NC_SHORT:
441  retval = nc_get_vara_short(ncid_in, varid_in, start, count,
442  (short *)data);
443  if (!retval)
444  retval = nc_put_vara_short(ncid_out, varid_out, start, count,
445  (short *)data);
446  break;
447  case NC_INT:
448  retval = nc_get_vara_int(ncid_in, varid_in, start, count,
449  (int *)data);
450  if (!retval)
451  retval = nc_put_vara_int(ncid_out, varid_out, start, count,
452  (int *)data);
453  break;
454  case NC_FLOAT:
455  retval = nc_get_vara_float(ncid_in, varid_in, start, count,
456  (float *)data);
457  if (!retval)
458  retval = nc_put_vara_float(ncid_out, varid_out, start, count,
459  (float *)data);
460  break;
461  case NC_DOUBLE:
462  retval = nc_get_vara_double(ncid_in, varid_in, start, count,
463  (double *)data);
464  if (!retval)
465  retval = nc_put_vara_double(ncid_out, varid_out, start, count,
466  (double *)data);
467  break;
468  case NC_UBYTE:
469  retval = nc_get_vara_uchar(ncid_in, varid_in, start, count,
470  (unsigned char *)data);
471  if (!retval)
472  retval = nc_put_vara_uchar(ncid_out, varid_out, start, count,
473  (unsigned char *)data);
474  break;
475  case NC_USHORT:
476  retval = nc_get_vara_ushort(ncid_in, varid_in, start, count,
477  (unsigned short *)data);
478  if (!retval)
479  retval = nc_put_vara_ushort(ncid_out, varid_out, start, count,
480  (unsigned short *)data);
481  break;
482  case NC_UINT:
483  retval = nc_get_vara_uint(ncid_in, varid_in, start, count,
484  (unsigned int *)data);
485  if (!retval)
486  retval = nc_put_vara_uint(ncid_out, varid_out, start, count,
487  (unsigned int *)data);
488  break;
489  case NC_INT64:
490  retval = nc_get_vara_longlong(ncid_in, varid_in, start, count,
491  (long long *)data);
492  if (!retval)
493  retval = nc_put_vara_longlong(ncid_out, varid_out, start, count,
494  (long long *)data);
495  break;
496  case NC_UINT64:
497  retval = nc_get_vara_ulonglong(ncid_in, varid_in, start, count,
498  (unsigned long long *)data);
499  if (!retval)
500  retval = nc_put_vara_ulonglong(ncid_out, varid_out, start, count,
501  (unsigned long long *)data);
502  break;
503  default:
504  retval = NC_EBADTYPE;
505  }
506  }
507 
508  exit:
509  if (data) free(data);
510  if (dimlen) free(dimlen);
511  if (start) free(start);
512  if (count) free(count);
513  return retval;
514 }
515 
529 static int
530 NC_copy_att(int ncid_in, int varid_in, const char *name,
531  int ncid_out, int varid_out)
532 {
533  nc_type xtype;
534  size_t len;
535  void *data=NULL;
536  int res;
537 
538  LOG((2, "nc_copy_att: ncid_in 0x%x varid_in %d name %s",
539  ncid_in, varid_in, name));
540 
541  /* Find out about the attribute to be copied. */
542  if ((res = nc_inq_att(ncid_in, varid_in, name, &xtype, &len)))
543  return res;
544 
545  if (xtype < NC_STRING)
546  {
547  /* Handle non-string atomic types. */
548  if (len)
549  {
550  size_t size = NC_atomictypelen(xtype);
551 
552  assert(size > 0);
553  if (!(data = malloc(len * size)))
554  return NC_ENOMEM;
555  }
556 
557  res = nc_get_att(ncid_in, varid_in, name, data);
558  if (!res)
559  res = nc_put_att(ncid_out, varid_out, name, xtype,
560  len, data);
561  if (len)
562  free(data);
563  }
564 #ifdef USE_NETCDF4
565  else if (xtype == NC_STRING)
566  {
567  /* Copy string attributes. */
568  char **str_data;
569  if (!(str_data = malloc(sizeof(char *) * len)))
570  return NC_ENOMEM;
571  res = nc_get_att_string(ncid_in, varid_in, name, str_data);
572  if (!res)
573  res = nc_put_att_string(ncid_out, varid_out, name, len,
574  (const char **)str_data);
575  nc_free_string(len, str_data);
576  free(str_data);
577  }
578  else
579  {
580  /* Copy user-defined type attributes. */
581  int class;
582  size_t size;
583  void *data;
584  nc_type xtype_out = NC_NAT;
585 
586  /* Find out if there is an equal type in the output file. */
587  /* Note: original code used a libsrc4 specific internal function
588  which we had to "duplicate" here */
589  if ((res = NC_find_equal_type(ncid_in, xtype, ncid_out, &xtype_out)))
590  return res;
591  if (xtype_out)
592  {
593  /* We found an equal type! */
594  if ((res = nc_inq_user_type(ncid_in, xtype, NULL, &size,
595  NULL, NULL, &class)))
596  return res;
597  if (class == NC_VLEN) /* VLENs are different... */
598  {
599  nc_vlen_t *vldata;
600  int i;
601  if (!(vldata = malloc(sizeof(nc_vlen_t) * len)))
602  return NC_ENOMEM;
603  if ((res = nc_get_att(ncid_in, varid_in, name, vldata)))
604  return res;
605  if ((res = nc_put_att(ncid_out, varid_out, name, xtype_out,
606  len, vldata)))
607  return res;
608  for (i = 0; i < len; i++)
609  if((res = nc_free_vlen(&vldata[i])))
610  return res;
611  free(vldata);
612  }
613  else /* not VLEN */
614  {
615  if (!(data = malloc(size * len)))
616  return NC_ENOMEM;
617  res = nc_get_att(ncid_in, varid_in, name, data);
618  if (!res)
619  res = nc_put_att(ncid_out, varid_out, name, xtype_out, len, data);
620  free(data);
621  }
622  }
623  }
624 #endif
625  return res;
626 }
627 
649 int
650 nc_copy_att(int ncid_in, int varid_in, const char *name,
651  int ncid_out, int varid_out)
652 {
653  int format, target_natts, target_attid;
654  char att_name[NC_MAX_NAME + 1];
655  int a, retval;
656 
657  /* What is the destination format? */
658  if ((retval = nc_inq_format(ncid_out, &format)))
659  return retval;
660 
661  /* Can't copy to same var in same file. */
662  if (ncid_in == ncid_out && varid_in == varid_out)
663  return NC_NOERR;
664 
665  /* For classic model netCDF-4 files, order of attributes must be
666  * maintained during copies. We MUST MAINTAIN ORDER! */
667  if (format == NC_FORMAT_NETCDF4_CLASSIC)
668  {
669  /* Does this attribute already exist in the target file? */
670  retval = nc_inq_attid(ncid_out, varid_out, name, &target_attid);
671  if (retval == NC_ENOTATT)
672  {
673  /* Attribute does not exist. No order to be preserved. */
674  return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
675  }
676  else if (retval == NC_NOERR)
677  {
678  /* How many atts for this var? */
679  if ((retval = nc_inq_varnatts(ncid_out, varid_out, &target_natts)))
680  return retval;
681 
682  /* If this is the last attribute in the target file, we are
683  * off the hook. */
684  if (target_attid == target_natts - 1)
685  return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
686 
687  /* Order MUST BE MAINTAINED! Copy all existing atts in the target
688  * file, stopping at our target att. */
689  for (a = 0; a < target_natts; a++)
690  {
691  if (a == target_attid)
692  {
693  if ((retval = NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out)))
694  return retval;
695  }
696  else
697  {
698  if ((retval = nc_inq_attname(ncid_out, varid_out, a, att_name)))
699  return retval;
700  if ((retval = NC_copy_att(ncid_out, varid_out, att_name,
701  ncid_out, varid_out)))
702  return retval;
703  }
704  }
705  }
706  else
707  return retval; /* Some other error occurred. */
708  }
709  else
710  return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
711 
712  return NC_NOERR;
713 }
NC_USHORT
#define NC_USHORT
unsigned 2-byte int
Definition: netcdf.h:43
NC_NOERR
#define NC_NOERR
No Error.
Definition: netcdf.h:330
NC_EINVAL
#define NC_EINVAL
Invalid Argument.
Definition: netcdf.h:340
nc_put_vara_uchar
int nc_put_vara_uchar(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned char *op)
Definition: dvarput.c:660
nc_get_vara_double
int nc_get_vara_double(int ncid, int varid, const size_t *startp, const size_t *countp, double *ip)
Definition: dvarget.c:803
nc_inq_attid
EXTERNL int nc_inq_attid(int ncid, int varid, const char *name, int *idp)
Definition: dattinq.c:163
nc_get_vara_uchar
int nc_get_vara_uchar(int ncid, int varid, const size_t *startp, const size_t *countp, unsigned char *ip)
Definition: dvarget.c:768
nc_vlen_t
This is the type of arrays of vlens.
Definition: netcdf.h:698
nc_inq_varnatts
EXTERNL int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition: dvarinq.c:249
nc_put_vara_short
int nc_put_vara_short(int ncid, int varid, const size_t *startp, const size_t *countp, const short *op)
Definition: dvarput.c:668
NC_FLOAT
#define NC_FLOAT
single precision floating point number
Definition: netcdf.h:40
nc_put_vara_uint
int nc_put_vara_uint(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned int *op)
Definition: dvarput.c:724
NC_DOUBLE
#define NC_DOUBLE
double precision floating point number
Definition: netcdf.h:41
nc_put_vara_schar
int nc_put_vara_schar(int ncid, int varid, const size_t *startp, const size_t *countp, const signed char *op)
Definition: dvarput.c:652
nc_get_vara_ushort
int nc_get_vara_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, unsigned short *ip)
Definition: dvarget.c:817
nc_inq_user_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)
Definition: dtype.c:146
NC_copy_att
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:530
nc_get_att_string
EXTERNL int nc_get_att_string(int ncid, int varid, const char *name, char **ip)
Definition: dattget.c:741
nc_redef
EXTERNL int nc_redef(int ncid)
Definition: dfile.c:954
nc_def_var
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:212
NC_BYTE
#define NC_BYTE
signed 1 byte integer
Definition: netcdf.h:35
NC_VLEN
#define NC_VLEN
vlen (variable-length) types
Definition: netcdf.h:53
nc_inq_format
EXTERNL int nc_inq_format(int ncid, int *formatp)
Definition: dfile.c:1538
nc_copy_var
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:295
NC_ENOTNC4
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition: netcdf.h:453
NC_FORMAT_CLASSIC
#define NC_FORMAT_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:173
NC_INT
#define NC_INT
signed 4 byte integer
Definition: netcdf.h:38
NC_FORMAT_64BIT_DATA
#define NC_FORMAT_64BIT_DATA
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:183
NC_MAX_NAME
#define NC_MAX_NAME
Maximum for classic library.
Definition: netcdf.h:276
nc_inq_grps
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
NC_UBYTE
#define NC_UBYTE
unsigned 1 byte int
Definition: netcdf.h:42
nc_get_vara_uint
int nc_get_vara_uint(int ncid, int varid, const size_t *startp, const size_t *countp, unsigned int *ip)
Definition: dvarget.c:824
nc_inq_compound_field
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)
Definition: dcompound.c:287
nc_get_vara_ulonglong
int nc_get_vara_ulonglong(int ncid, int varid, const size_t *startp, const size_t *countp, unsigned long long *ip)
Definition: dvarget.c:838
NC_FORMAT_NETCDF4
#define NC_FORMAT_NETCDF4
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:181
NC_MAX_VAR_DIMS
#define NC_MAX_VAR_DIMS
max per variable dimensions
Definition: netcdf.h:277
nc_inq_dimlen
EXTERNL int nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
Find the length of a dimension.
Definition: ddim.c:467
nc_inq_typeids
EXTERNL int nc_inq_typeids(int ncid, int *ntypes, int *typeids)
Retrieve a list of types associated with a group.
Definition: dgroup.c:223
NC_FORMAT_NETCDF4_CLASSIC
#define NC_FORMAT_NETCDF4_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:182
nc_get_vara_float
int nc_get_vara_float(int ncid, int varid, const size_t *startp, const size_t *countp, float *ip)
Definition: dvarget.c:796
NC_FORMAT_64BIT_OFFSET
#define NC_FORMAT_64BIT_OFFSET
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:179
NC_ENOTATT
#define NC_ENOTATT
Attribute not found.
Definition: netcdf.h:370
nc_put_vara_text
int nc_put_vara_text(int ncid, int varid, const size_t *startp, const size_t *countp, const char *op)
Definition: dvarput.c:644
nc_put_vara_longlong
int nc_put_vara_longlong(int ncid, int varid, const size_t *startp, const size_t *countp, const long long *op)
Definition: dvarput.c:732
nc_inq_dimid
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
NC_COMPOUND
#define NC_COMPOUND
compound types
Definition: netcdf.h:56
nc_put_vara_ulonglong
int nc_put_vara_ulonglong(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned long long *op)
Definition: dvarput.c:740
nc_inq_att
EXTERNL int nc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp)
Definition: dattinq.c:85
nc_get_vara_schar
int nc_get_vara_schar(int ncid, int varid, const size_t *startp, const size_t *countp, signed char *ip)
Definition: dvarget.c:761
nc_inq_type
EXTERNL int nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
Definition: dfile.c:1719
nc_get_vara_text
int nc_get_vara_text(int ncid, int varid, const size_t *startp, const size_t *countp, char *ip)
Definition: dvarget.c:754
NC_SHORT
#define NC_SHORT
signed 2 byte integer
Definition: netcdf.h:37
nc_get_vara_int
int nc_get_vara_int(int ncid, int varid, const size_t *startp, const size_t *countp, int *ip)
Definition: dvarget.c:782
NC_OPAQUE
#define NC_OPAQUE
opaque types
Definition: netcdf.h:54
nc_put_att
EXTERNL int nc_put_att(int ncid, int varid, const char *name, nc_type xtype, size_t len, const void *op)
Definition: dattput.c:222
nc_type
int nc_type
The nc_type type is just an int.
Definition: netcdf.h:25
NC_EBADTYPE
#define NC_EBADTYPE
Not a netcdf data type.
Definition: netcdf.h:372
NC_ENUM
#define NC_ENUM
enum types
Definition: netcdf.h:55
NC_EINDEFINE
#define NC_EINDEFINE
Operation not allowed in define mode.
Definition: netcdf.h:355
nc_get_vara_longlong
int nc_get_vara_longlong(int ncid, int varid, const size_t *startp, const size_t *countp, long long *ip)
Definition: dvarget.c:831
nc_free_vlen
EXTERNL int nc_free_vlen(nc_vlen_t *vl)
Definition: dvlen.c:41
nc_put_vara_int
int nc_put_vara_int(int ncid, int varid, const size_t *startp, const size_t *countp, const int *op)
Definition: dvarput.c:676
nc_get_vara_short
int nc_get_vara_short(int ncid, int varid, const size_t *startp, const size_t *countp, short *ip)
Definition: dvarget.c:775
NC_ENOMEM
#define NC_ENOMEM
Memory allocation (malloc) failure.
Definition: netcdf.h:410
NC_NAT
#define NC_NAT
Not A Type.
Definition: netcdf.h:34
nc_put_vara_ushort
int nc_put_vara_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned short *op)
Definition: dvarput.c:716
NC_UINT64
#define NC_UINT64
unsigned 8-byte int
Definition: netcdf.h:46
nc_copy_att
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:650
NC_UINT
#define NC_UINT
unsigned 4-byte int
Definition: netcdf.h:44
NC_STRING
#define NC_STRING
string
Definition: netcdf.h:47
nc_put_att_string
EXTERNL int nc_put_att_string(int ncid, int varid, const char *name, size_t len, const char **op)
Definition: dattput.c:75
nc_inq_attname
EXTERNL int nc_inq_attname(int ncid, int varid, int attnum, char *name)
Definition: dattinq.c:254
nc_enddef
EXTERNL int nc_enddef(int ncid)
Definition: dfile.c:1018
nc_put_vara_double
int nc_put_vara_double(int ncid, int varid, const size_t *startp, const size_t *countp, const double *op)
Definition: dvarput.c:700
NC_CHAR
#define NC_CHAR
ISO/ASCII character.
Definition: netcdf.h:36
nc_sync
EXTERNL int nc_sync(int ncid)
Definition: dfile.c:1186
nc_inq_var
EXTERNL int nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)
Definition: dvarinq.c:124
nc_put_vara_float
int nc_put_vara_float(int ncid, int varid, const size_t *startp, const size_t *countp, const float *op)
Definition: dvarput.c:692
nc_free_string
EXTERNL int nc_free_string(size_t len, char **data)
Free string space allocated by the library.
Definition: dvar.c:1206
nc_get_att
EXTERNL int nc_get_att(int ncid, int varid, const char *name, void *ip)
Definition: dattget.c:96
nc_inq_enum_member
EXTERNL int nc_inq_enum_member(int ncid, nc_type xtype, int idx, char *name, void *value)
Definition: denum.c:140
NC_INT64
#define NC_INT64
signed 8-byte int
Definition: netcdf.h:45
nc_inq_dimname
EXTERNL int nc_inq_dimname(int ncid, int dimid, char *name)
Find out the name of a dimension.
Definition: ddim.c:409