11 #include "netcdf_filter.h"
12 #include "ncdispatch.h"
13 #include "nc4internal.h"
15 #include "nc4internal.h"
213 int ndims,
const int *dimidsp,
int *varidp)
218 if ((stat = NC_check_id(ncid, &ncp)))
221 return ncp->dispatch->def_var(ncid, name, xtype, ndims,
307 int stat = NC_check_id(ncid,&ncp);
316 return ncp->dispatch->def_var_fill(ncid,varid,no_fill,fill_value);
422 int stat = NC_check_id(ncid,&ncp);
424 return ncp->dispatch->def_var_deflate(ncid,varid,shuffle,deflate,deflate_level);
468 int stat = NC_check_id(ncid,&ncp);
470 return ncp->dispatch->def_var_fletcher32(ncid,varid,fletcher32);
588 int stat = NC_check_id(ncid, &ncp);
590 return ncp->dispatch->def_var_chunking(ncid, varid, storage,
666 int stat = NC_check_id(ncid,&ncp);
668 return ncp->dispatch->def_var_endian(ncid,varid,endian);
726 unsigned int params[2];
727 params[0] = options_mask;
728 params[1] = pixels_per_block;
729 if ((ret = nc_def_var_filter(ncid, varid, HDF5_FILTER_SZIP, 2, params)))
805 int stat = NC_check_id(ncid, &ncp);
808 return ncp->dispatch->rename_var(ncid, varid, name);
822 NC_is_recvar(
int ncid,
int varid,
size_t* nrecs)
833 if(ndims == 0)
return 0;
836 status =
nc_inq_dim(ncid,dimset[0],NULL,nrecs);
838 return (dimset[0] == unlimid ? 1: 0);
867 NC_inq_recvar(
int ncid,
int varid,
int* nrecdimsp,
int *is_recdim)
877 if(status !=
NC_NOERR)
return status;
879 for(dim = 0; dim < nvardims; dim++)
882 if(status !=
NC_NOERR)
return status;
883 if(unlimid == -1)
return status;
890 if(status !=
NC_NOERR)
return status;
891 if(nunlimdims == 0)
return status;
893 if (!(unlimids = malloc(nunlimdims *
sizeof(
int))))
905 for (dim = 0; dim < nvardims; dim++) {
906 for(recdim = 0; recdim < nunlimdims; recdim++) {
907 if(dimset[dim] == unlimids[recdim]) {
917 if(status !=
NC_NOERR)
return status;
918 if(dimset[0] == unlimid) {
923 if(nrecdimsp) *nrecdimsp = nrecdims;
949 return ((
int)
sizeof(
char));
951 return ((
int)
sizeof(
signed char));
953 return ((
int)
sizeof(
short));
955 return ((
int)
sizeof(
int));
957 return ((
int)
sizeof(
float));
959 return ((
int)
sizeof(
double));
963 return ((
int)
sizeof(
unsigned char));
965 return ((
int)(
sizeof(
unsigned short)));
967 return ((
int)
sizeof(
unsigned int));
969 return ((
int)
sizeof(
signed long long));
971 return ((
int)
sizeof(
unsigned long long));
974 return ((
int)
sizeof(
char*));
991 NC_atomictypelen(
nc_type xtype)
995 case NC_NAT: sz = 0;
break;
996 case NC_BYTE: sz =
sizeof(
signed char);
break;
997 case NC_CHAR: sz =
sizeof(char);
break;
998 case NC_SHORT: sz =
sizeof(short);
break;
999 case NC_INT: sz =
sizeof(int);
break;
1000 case NC_FLOAT: sz =
sizeof(float);
break;
1001 case NC_DOUBLE: sz =
sizeof(double);
break;
1002 case NC_INT64: sz =
sizeof(
signed long long);
break;
1003 case NC_UBYTE: sz =
sizeof(
unsigned char);
break;
1004 case NC_USHORT: sz =
sizeof(
unsigned short);
break;
1005 case NC_UINT: sz =
sizeof(
unsigned int);
break;
1006 case NC_UINT64: sz =
sizeof(
unsigned long long);
break;
1008 case NC_STRING: sz =
sizeof(
char*);
break;
1024 NC_atomictypename(
nc_type xtype)
1028 case NC_NAT: nm =
"undefined";
break;
1029 case NC_BYTE: nm =
"byte";
break;
1030 case NC_CHAR: nm =
"char";
break;
1031 case NC_SHORT: nm =
"short";
break;
1032 case NC_INT: nm =
"int";
break;
1033 case NC_FLOAT: nm =
"float";
break;
1035 case NC_INT64: nm =
"int64";
break;
1036 case NC_UBYTE: nm =
"ubyte";
break;
1038 case NC_UINT: nm =
"uint";
break;
1066 NC_getshape(
int ncid,
int varid,
int ndims,
size_t* shape)
1074 for(i = 0; i < ndims; i++)
1106 NC_check_nulls(
int ncid,
int varid,
const size_t *start,
size_t **count,
1116 if (!start && varndims)
1122 if (!(*count = malloc(varndims *
sizeof(
size_t))))
1124 if ((stat = NC_getshape(ncid, varid, varndims, *count)))
1134 if (stride && !*stride)
1138 if (!(*stride = malloc(varndims *
sizeof(ptrdiff_t))))
1140 for (i = 0; i < varndims; i++)
1172 for (i = 0; i < len; i++)
1251 int stat = NC_check_id(ncid, &ncp);
1253 return ncp->dispatch->set_var_chunk_cache(ncid, varid, size,
1254 nelems, preemption);
1292 int stat = NC_check_id(ncid, &ncp);
1294 return ncp->dispatch->get_var_chunk_cache(ncid, varid, sizep,
1295 nelemsp, preemptionp);
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define NC_CHAR
ISO/ASCII character.
int nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp, float *preemptionp)
Get the per-variable chunk cache settings from the HDF5 layer.
EXTERNL int nc_inq_vardimid(int ncid, int varid, int *dimidsp)
Learn the dimension IDs associated with a variable.
int nc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
Define a new variable.
#define NC_UBYTE
unsigned 1 byte int
#define NC_MAX_VAR_DIMS
max per variable dimensions
int nc_def_var_szip(int ncid, int varid, int options_mask, int pixels_per_block)
Set szip compression settings on a variable.
#define NC_UINT
unsigned 4-byte int
#define NC_EINVALCOORDS
Index exceeds dimension bound.
int nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_level)
Set the zlib compression settings for a netCDF-4/HDF5 variable.
Main header file for the C API.
#define NC_INT64
signed 8-byte int
#define NC_DOUBLE
double precision floating point number
EXTERNL int nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
Find the name and length of a dimension.
EXTERNL int nc_inq_varndims(int ncid, int varid, int *ndimsp)
Learn how many dimensions are associated with a variable.
int nc_type
The nc_type type is just an int.
#define NC_BYTE
signed 1 byte integer
int nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, float preemption)
Change the cache settings for a chunked variable.
int nc_rename_var(int ncid, int varid, const char *name)
Rename a variable.
EXTERNL int nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
Find the length of a dimension.
#define NC_EGLOBAL
Action prohibited on NC_GLOBAL varid.
#define NC_INT
signed 4 byte integer
int nc_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp)
Define storage and, if chunked storage is used, chunking parameters for a variable.
#define NC_NAT
Not A Type.
int nc_free_string(size_t len, char **data)
Free string space allocated by the library.
#define NC_USHORT
unsigned 2-byte int
int nc_def_var_endian(int ncid, int varid, int endian)
Define endianness of a variable.
EXTERNL int nc_inq_unlimdim(int ncid, int *unlimdimidp)
Find the ID of the unlimited dimension.
#define NC_SHORT
signed 2 byte integer
EXTERNL int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
#define NC_NOERR
No Error.
int nc_def_var_fill(int ncid, int varid, int no_fill, const void *fill_value)
Set the fill value for a variable.
#define NC_GLOBAL
Attribute id to put/get a global attribute.
#define NC_FLOAT
single precision floating point number
#define NC_UINT64
unsigned 8-byte int
int nc_def_var_fletcher32(int ncid, int varid, int fletcher32)
Set checksum for a var.