NetCDF
4.8.1
|
#include "config.h"
#include "ncdispatch.h"
#include "nc_logging.h"
#include "nclist.h"
Go to the source code of this file.
Functions | |
static int | NC_compare_nc_types (int ncid1, int typeid1, int ncid2, int typeid2, int *equalp) |
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. More... | |
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. More... | |
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 another, assuming dimensions in the output file are already defined and have same dimension IDs and length. More... | |
static int | NC_find_equal_type (int ncid1, nc_type xtype1, int ncid2, nc_type *xtype2) |
static int | NC_rec_find_nc_type (int ncid1, nc_type tid1, int ncid2, nc_type *tid2) |
static int | searchgroup (int ncid1, int tid1, int grp, int *tid2) |
static int | searchgrouptree (int ncid1, int tid1, int grp, int *tid2) |
Copyright 2018 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for more info.
This file has the var and att copy functions.
Definition in file dcopy.c.
|
static |
Copy an attribute from one open file to another.
This is called by nc_copy_att().
ncid_in | File ID to copy from. |
varid_in | Variable ID to copy from. |
name | Name of attribute to copy. |
ncid_out | File ID to copy to. |
varid_out | Variable ID to copy to. |
USE_NETCDF4
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.
Special programming challenge: this function must work even if one of the other of the files is a netcdf version 1.0 file (i.e. not HDF5). So only use top level netcdf api functions.
From the netcdf-3 docs: The output netCDF dataset should be in define mode if the attribute to be copied does not already exist for the target variable, or if it would cause an existing target attribute to grow.
ncid_in | File ID to copy from. |
varid_in | Variable ID to copy from. |
name | Name of attribute to copy. |
ncid_out | File ID to copy to. |
varid_out | Variable ID to copy to. |
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 another, assuming dimensions in the output file are already defined and have same dimension IDs and length.
However it doesn't work for copying netCDF-4 variables of type string or a user-defined type.
This function works even if the files are different formats, (for example, one netcdf classic, the other netcdf-4).
If you're copying into a classic-model file, from a netcdf-4 file, you must be copying a variable of one of the six classic-model types, and similarly for the attributes.
For large netCDF-3 files, this can be a very inefficient way to copy data from one file to another, because adding a new variable to the target file may require more space in the header and thus result in moving data for other variables in the target file. This is not a problem for netCDF-4 files, which support efficient addition of variables without moving data for other variables.
ncid_in | File ID to copy from. |
varid_in | Variable ID to copy. |
ncid_out | File ID to copy to. |