From ed204b1cc9adc9935bfcf72fab22a13b53bebb39 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 12 Jul 2011 15:37:24 +0000 Subject: [PATCH] more doxygen variable stuff --- Doxyfile | 3 +- include/netcdf.h | 12 +- libdispatch/attinq.c | 10 +- libdispatch/nc4.c | 195 +-------- libdispatch/var.c | 74 +++- libdispatch/varget.c | 711 +++++++++++++++++++------------- libdispatch/varinq.c | 346 ++++++++++++++-- libdispatch/varput.c | 950 +++++++++++++++++++++++++------------------ man4/notes.doc | 38 ++ 9 files changed, 1431 insertions(+), 908 deletions(-) diff --git a/Doxyfile b/Doxyfile index bf2e634e4..896dc2086 100644 --- a/Doxyfile +++ b/Doxyfile @@ -582,6 +582,7 @@ libdispatch/var.c \ libdispatch/varinq.c \ libdispatch/varput.c libdispatch/varget.c \ libdispatch/error.c \ +libdispatch/nc4.c \ libsrc4/nc4file.c \ man4/mainpage.doc man4/tutorial.doc COPYRIGHT man4/install.doc man4/dispatch.doc \ man4/guide.doc man4/types.doc man4/notes.doc @@ -1280,7 +1281,7 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = USE_NETCDF4 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/include/netcdf.h b/include/netcdf.h index 7e89cf7c9..3c2cf7fdc 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -204,12 +204,14 @@ As a rule, NC_MAX_VAR_DIMS <= NC_MAX_DIMS. #define NC_CONTIGUOUS 1 /**@}*/ -/* 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. */ +/** 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 @@ -761,7 +763,7 @@ 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_value); +nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep); /* Define the endianness of a variable. */ EXTERNL int diff --git a/libdispatch/attinq.c b/libdispatch/attinq.c index b04806c11..aba056b96 100644 --- a/libdispatch/attinq.c +++ b/libdispatch/attinq.c @@ -26,17 +26,17 @@ nc_create(). for a global attribute. \param name Pointer to the location for the returned attribute \ref -object_name. Ignored if NULL. +object_name. \ref ignored_if_null. \param xtypep Pointer to location for returned attribute \ref -data_type. Ignored if NULL. +data_type. \ref ignored_if_null. \param lenp Pointer to location for returned number of values currently stored in the attribute. For attributes of type ::NC_CHAR, you should not assume that this includes a trailing zero byte; it doesn't if the attribute was stored without a trailing zero byte, for example from a FORTRAN program. Before using the value as a C string, -make sure it is null-terminated. Ignored if NULL. +make sure it is null-terminated. \ref ignored_if_null. \section Example @@ -139,7 +139,7 @@ Find number of global attributes. nc_create(). \param nattsp Pointer where number of global attributes will be -written. Ignored if NULL. +written. \ref ignored_if_null. */ int nc_inq_natts(int ncid, int *nattsp) @@ -188,7 +188,7 @@ for a global attribute. \param lenp Pointer to location for returned number of values currently stored in the attribute. Before using the value as a C -string, make sure it is null-terminated. Ignored if NULL. +string, make sure it is null-terminated. \ref ignored_if_null. */ int nc_inq_attlen(int ncid, int varid, const char *name, size_t *lenp) diff --git a/libdispatch/nc4.c b/libdispatch/nc4.c index 503954ed6..b8a97908d 100644 --- a/libdispatch/nc4.c +++ b/libdispatch/nc4.c @@ -1,18 +1,24 @@ -/* - Copyright 2010 University Corporation for Atmospheric - Research/Unidata. See COPYRIGHT file for more info. +/*! \file +Functions for netCDF-4 features. - This file defines the netcdf-4 functions. - - "$Id: nc4.c,v 1.1 2010/06/01 15:46:50 ed Exp $" -*/ +Copyright 2010 University Corporation for Atmospheric +Research/Unidata. See \ref COPYRIGHT file for more info. */ #include "ncdispatch.h" -/* When you read 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. */ +/** \ingroup variables +Free string space allocated by the library. + +When you read 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. + +\param len The number of character arrays in the array. +\param data The pointer to the data array. + +\returns ::NC_NOERR No error. +*/ int nc_free_string(size_t len, char **data) { @@ -48,155 +54,6 @@ nc_free_vlens(size_t len, nc_vlen_t vlens[]) return NC_NOERR; } -/* Wrappers for nc_inq_var_all */ - -int -nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all( - ncid, varid, - NULL, /*name*/ - NULL, /*xtypep*/ - NULL, /*ndimsp*/ - NULL, /*dimidsp*/ - NULL, /*nattsp*/ - shufflep, /*shufflep*/ - deflatep, /*deflatep*/ - deflate_levelp, /*deflatelevelp*/ - NULL, /*fletcher32p*/ - NULL, /*contiguousp*/ - NULL, /*chunksizep*/ - NULL, /*nofillp*/ - NULL, /*fillvaluep*/ - NULL, /*endianp*/ - NULL, /*optionsmaskp*/ - NULL /*pixelsp*/ - ); -} - -int -nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all( - ncid, varid, - NULL, /*name*/ - NULL, /*xtypep*/ - NULL, /*ndimsp*/ - NULL, /*dimidsp*/ - NULL, /*nattsp*/ - NULL, /*shufflep*/ - NULL, /*deflatep*/ - NULL, /*deflatelevelp*/ - NULL, /*fletcher32p*/ - NULL, /*contiguousp*/ - NULL, /*chunksizep*/ - NULL, /*nofillp*/ - NULL, /*fillvaluep*/ - NULL, /*endianp*/ - options_maskp, /*optionsmaskp*/ - pixels_per_blockp /*pixelsp*/ - ); -} - -int -nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all( - ncid, varid, - NULL, /*name*/ - NULL, /*xtypep*/ - NULL, /*ndimsp*/ - NULL, /*dimidsp*/ - NULL, /*nattsp*/ - NULL, /*shufflep*/ - NULL, /*deflatep*/ - NULL, /*deflatelevelp*/ - fletcher32p, /*fletcher32p*/ - NULL, /*contiguousp*/ - NULL, /*chunksizep*/ - NULL, /*nofillp*/ - NULL, /*fillvaluep*/ - NULL, /*endianp*/ - NULL, /*optionsmaskp*/ - NULL /*pixelsp*/ - ); -} - -int -nc_inq_var_chunking(int ncid, int varid, int *contiguousp, size_t *chunksizesp) -{ - NC *ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, contiguousp, - chunksizesp, NULL, NULL, NULL, NULL, NULL); -} - -int -nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_value) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all( - ncid, varid, - NULL, /*name*/ - NULL, /*xtypep*/ - NULL, /*ndimsp*/ - NULL, /*dimidsp*/ - NULL, /*nattsp*/ - NULL, /*shufflep*/ - NULL, /*deflatep*/ - NULL, /*deflatelevelp*/ - NULL, /*fletcher32p*/ - NULL, /*contiguousp*/ - NULL, /*chunksizep*/ - no_fill, /*nofillp*/ - fill_value, /*fillvaluep*/ - NULL, /*endianp*/ - NULL, /*optionsmaskp*/ - NULL /*pixelsp*/ - ); -} - -int -nc_inq_var_endian(int ncid, int varid, int *endianp) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->inq_var_all( - ncid, varid, - NULL, /*name*/ - NULL, /*xtypep*/ - NULL, /*ndimsp*/ - NULL, /*dimidsp*/ - NULL, /*nattsp*/ - NULL, /*shufflep*/ - NULL, /*deflatep*/ - NULL, /*deflatelevelp*/ - NULL, /*fletcher32p*/ - NULL, /*contiguousp*/ - NULL, /*chunksizep*/ - NULL, /*nofillp*/ - NULL, /*fillvaluep*/ - endianp, /*endianp*/ - NULL, /*optionsmaskp*/ - NULL /*pixelsp*/ - ); -} - - int nc_inq_ncid(int ncid, const char *name, int *grp_ncid) { @@ -600,24 +457,6 @@ nc_def_var_endian(int ncid, int varid, int endian) return ncp->dispatch->def_var_endian(ncid,varid,endian); } -int -nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, float preemption) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->set_var_chunk_cache(ncid,varid,size,nelems,preemption); -} - -int -nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp, float *preemptionp) -{ - NC* ncp; - int stat = NC_check_id(ncid,&ncp); - if(stat != NC_NOERR) return stat; - return ncp->dispatch->get_var_chunk_cache(ncid,varid,sizep,nelemsp,preemptionp); -} - int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp) { diff --git a/libdispatch/var.c b/libdispatch/var.c index a5cced742..fa712f08a 100644 --- a/libdispatch/var.c +++ b/libdispatch/var.c @@ -163,7 +163,7 @@ element of the dimids array. \returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. \returns ::NC_EMAXVARS NC_MAX_VARS exceeded \returns ::NC_EBADTYPE Bad type. -\returns ::NC_EINVAL Number of dimensions to large. +\returns ::NC_EINVAL Invalid input. \returns ::NC_ENAMEINUSE Name already in use. \returns ::NC_EPERM Attempt to create object in read-only file. @@ -436,4 +436,76 @@ NC_getshape(int ncid, int varid, int ndims, size_t* shape) return status; } +#ifdef USE_NETCDF4 +/** \ingroup variables +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param size The total size of the raw data chunk cache, in bytes. + +\param nelems The number of chunk slots in the raw data chunk cache. + +\param preemption The preemption, a value between 0 and 1 inclusive +that indicates how much chunks that have been fully read are favored +for preemption. A value of zero means fully read chunks are treated no +differently than other chunks (the preemption is strictly LRU) while a +value of one means fully read chunks are always preempted before other +chunks. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. +\returns ::NC_EINVAL Invalid input + */ +int +nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, + float preemption) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->set_var_chunk_cache(ncid, varid, size, + nelems, preemption); +} + +/** \ingroup variables + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param sizep The total size of the raw data chunk cache, in bytes, +will be put here. \ref ignored_if_null. + +\param nelemsp The number of chunk slots in the raw data chunk cache +hash table will be put here. \ref ignored_if_null. + +\param preemptionp The preemption will be put here. The preemtion +value is between 0 and 1 inclusive and indicates how much chunks that +have been fully read are favored for preemption. A value of zero means +fully read chunks are treated no differently than other chunks (the +preemption is strictly LRU) while a value of one means fully read +chunks are always preempted before other chunks. \ref ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. +\returns ::NC_EINVAL Invalid input +*/ +int +nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp, + float *preemptionp) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->get_var_chunk_cache(ncid, varid, sizep, + nelemsp, preemptionp); +} +#endif /* USE_NETCDF4 */ diff --git a/libdispatch/varget.c b/libdispatch/varget.c index e025a3411..60ff64057 100644 --- a/libdispatch/varget.c +++ b/libdispatch/varget.c @@ -2,8 +2,7 @@ Functions for getting data from variables. Copyright 2011 University Corporation for Atmospheric -Research/Unidata. See COPYRIGHT file for more info. -*/ +Research/Unidata. See \ref COPYRIGHT file for more info. */ #include "ncdispatch.h" @@ -511,7 +510,7 @@ nc_get_vara_int(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,NC_INT); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_INT); } int @@ -521,7 +520,7 @@ nc_get_vara_long(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_long); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_long); } int @@ -531,7 +530,7 @@ nc_get_vara_float(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_float); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_float); } @@ -542,7 +541,7 @@ nc_get_vara_double(int ncid, int varid, const size_t *startp, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_double); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_double); } int @@ -552,7 +551,7 @@ nc_get_vara_ubyte(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_ubyte); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ubyte); } int @@ -562,7 +561,7 @@ nc_get_vara_ushort(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_ushort); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ushort); } int @@ -572,7 +571,7 @@ nc_get_vara_uint(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_uint); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_uint); } int @@ -582,7 +581,7 @@ nc_get_vara_longlong(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,T_longlong); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_longlong); } int @@ -592,7 +591,7 @@ nc_get_vara_ulonglong(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,NC_UINT64); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_UINT64); } #ifdef USE_NETCDF4 @@ -603,44 +602,11 @@ nc_get_vara_string(int ncid, int varid, NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vara(ncid,varid,startp,countp,(void*)ip,NC_STRING); + return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_STRING); } #endif /*USE_NETCDF4*/ /**@}*/ -int -nc_get_var(int ncid, int varid, void *value) -{ - return NC_get_var(ncid, varid, value, NC_NAT); -} - -int -nc_get_varm(int ncid, int varid, const size_t * startp, - const size_t * countp, const ptrdiff_t * stride, - const ptrdiff_t * imapp, void *value) -{ - NC* ncp; - int stat; - - if ((stat = NC_check_id(ncid, &ncp))) - return stat; - return ncp->dispatch->get_varm(ncid, varid, startp, countp, stride, imapp, - value, NC_NAT); -} - -int -nc_get_vars (int ncid, int varid, const size_t * startp, - const size_t * countp, const ptrdiff_t * stride, - void *value) -{ - NC* ncp; - int stat; - - if ((stat = NC_check_id(ncid, &ncp))) - return stat; - return ncp->dispatch->get_vars(ncid, varid, startp, countp, stride, - value, NC_NAT); -} /** \ingroup variables Read a single datum from a variable. @@ -688,7 +654,7 @@ nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip) int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; INITCOORD1; - return NC_get_var1(ncid, varid, indexp, (void*)ip, NC_CHAR); + return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_CHAR); } int @@ -698,7 +664,7 @@ nc_get_var1_schar(int ncid, int varid, const size_t *indexp, signed char *ip) int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; INITCOORD1; - return NC_get_var1(ncid, varid, indexp, (void*)ip, NC_BYTE); + return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_BYTE); } int @@ -708,7 +674,7 @@ nc_get_var1_uchar(int ncid, int varid, const size_t *indexp, unsigned char *ip) int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; INITCOORD1; - return NC_get_var1(ncid, varid, indexp, (void*)ip, NC_UBYTE); + return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE); } int @@ -718,7 +684,7 @@ nc_get_var1_short(int ncid, int varid, const size_t *indexp, short *ip) int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; INITCOORD1; - return NC_get_var1(ncid, varid, indexp, (void*)ip, NC_SHORT); + return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_SHORT); } int @@ -728,7 +694,7 @@ nc_get_var1_int(int ncid, int varid, const size_t *indexp, int *ip) int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; INITCOORD1; - return NC_get_var1(ncid, varid, indexp, (void*)ip, NC_INT); + return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT); } int @@ -832,31 +798,79 @@ nc_get_var1_string(int ncid, int varid, const size_t *indexp, char* *ip) #endif /*USE_NETCDF4*/ /** \} */ +/** \ingroup variables +Read an entire variable in one call. + +This function will read all the values from a netCDF variable of an +open netCDF dataset. + +This is the simplest interface to use for reading the value of a +scalar variable or when all the values of a multidimensional variable +can be read at once. The values are read into consecutive locations +with the last dimension varying fastest. The netCDF dataset must be in +data mode. + +Take care when using this function with record variables (variables +that use the ::NC_UNLIMITED dimension). If you try to read all the +values of a record variable into an array but there are more records +in the file than you assume, more data will be read than you expect, +which may cause a segmentation violation. To avoid such problems, it +is better to use the nc_get_vara interfaces for variables that use the +::NC_UNLIMITED dimension. + +The functions for types ubyte, ushort, uint, longlong, ulonglong, and +string are only available for netCDF-4/HDF5 files. + +The nc_get_var() function will read a variable of any type, including +user defined type. For this function, the type of the data in memory +must match the type of the variable - no data conversion is done. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param ip Pointer where the data will be copied. Memory must be +allocated by the user before this function is called. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. +*/ +/** \{ */ +int +nc_get_var(int ncid, int varid, void *ip) +{ + return NC_get_var(ncid, varid, ip, NC_NAT); +} + int nc_get_var_text(int ncid, int varid, char *ip) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid, varid, (void*)ip, NC_CHAR); + return NC_get_var(ncid, varid, (void *)ip, NC_CHAR); } int nc_get_var_schar(int ncid, int varid, signed char *ip) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_BYTE); + return NC_get_var(ncid, varid, (void *)ip, NC_BYTE); } int nc_get_var_uchar(int ncid, int varid, unsigned char *ip) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_UBYTE); + return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); } int @@ -865,7 +879,7 @@ nc_get_var_short(int ncid, int varid, short *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_SHORT); + return NC_get_var(ncid, varid, (void *)ip, NC_SHORT); } int @@ -874,7 +888,7 @@ nc_get_var_int(int ncid, int varid, int *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_INT); + return NC_get_var(ncid,varid, (void *)ip, NC_INT); } int @@ -883,7 +897,7 @@ nc_get_var_long(int ncid, int varid, long *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, longtype); + return NC_get_var(ncid,varid, (void *)ip, longtype); } int @@ -892,7 +906,7 @@ nc_get_var_float(int ncid, int varid, float *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_FLOAT); + return NC_get_var(ncid,varid, (void *)ip, NC_FLOAT); } int @@ -901,7 +915,7 @@ nc_get_var_double(int ncid, int varid, double *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_DOUBLE); + return NC_get_var(ncid,varid, (void *)ip, NC_DOUBLE); } int @@ -910,7 +924,7 @@ nc_get_var_ubyte(int ncid, int varid, unsigned char *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_UBYTE); + return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); } int @@ -919,7 +933,7 @@ nc_get_var_ushort(int ncid, int varid, unsigned short *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_USHORT); + return NC_get_var(ncid,varid, (void *)ip, NC_USHORT); } int @@ -928,7 +942,7 @@ nc_get_var_uint(int ncid, int varid, unsigned int *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_UINT); + return NC_get_var(ncid,varid, (void *)ip, NC_UINT); } int @@ -937,7 +951,7 @@ nc_get_var_longlong(int ncid, int varid, long long *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip, NC_INT64); + return NC_get_var(ncid,varid, (void *)ip, NC_INT64); } int @@ -946,7 +960,7 @@ nc_get_var_ulonglong(int ncid, int varid, unsigned long long *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip,NC_UINT64); + return NC_get_var(ncid,varid, (void *)ip,NC_UINT64); } #ifdef USE_NETCDF4 @@ -956,351 +970,472 @@ nc_get_var_string(int ncid, int varid, char* *ip) NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_var(ncid,varid,(void*)ip,NC_STRING); + return NC_get_var(ncid,varid, (void *)ip,NC_STRING); } - #endif /*USE_NETCDF4*/ +/** \} */ +/** \ingroup variables +Read a strided array from a variable. + +This function reads a subsampled (strided) array section of values +from a netCDF variable of an open netCDF dataset. The subsampled array +section is specified by giving a corner, a vector of edge lengths, and +a stride vector. The values are read with the last dimension of the +netCDF variable varying fastest. The netCDF dataset must be in data +mode. + +The nc_get_vars() function will read a variable of any type, including +user defined type. For this function, the type of the data in memory +must match the type of the variable - no data conversion is done. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param startp Start vector with one element for each dimension to \ref +specify_hyperslab. + +\param countp Count vector with one element for each dimension to \ref +specify_hyperslab. + +\param stridep Stride vector with one element for each dimension to +\ref specify_hyperslab. + +\param ip Pointer where the data will be copied. Memory must be +allocated by the user before this function is called. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. +*/ +/** \{ */ int -nc_get_varm_schar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - signed char *ip) +nc_get_vars (int ncid, int varid, const size_t * startp, + const size_t * countp, const ptrdiff_t * stridep, + void *ip) { NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_BYTE); + int stat; + + if ((stat = NC_check_id(ncid, &ncp))) + return stat; + return ncp->dispatch->get_vars(ncid, varid, startp, countp, stridep, + ip, NC_NAT); } int -nc_get_varm_uchar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - unsigned char *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_uchar); -} - -int -nc_get_varm_short(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - short *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_SHORT); -} - -int -nc_get_varm_int(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - int *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_INT); -} - -int -nc_get_varm_long(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - long *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_long); -} - -int -nc_get_varm_float(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - float *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_float); -} - -int -nc_get_varm_double(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - double *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_double); -} - -int -nc_get_varm_ubyte(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - unsigned char *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_ubyte); -} - -int -nc_get_varm_ushort(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - unsigned short *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_ushort); -} - -int -nc_get_varm_uint(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - unsigned int *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_uint); -} - -int -nc_get_varm_longlong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - long long *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,T_longlong); -} - -int -nc_get_varm_ulonglong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - unsigned long long *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_UINT64); -} - -int -nc_get_varm_text(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, +nc_get_vars_text(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, char *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_CHAR); -} - -#ifdef USE_NETCDF4 -int -nc_get_varm_string(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - char* *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_varm(ncid,varid,startp,countp,stride,imapp,(void*)ip,NC_STRING); -} - -#endif /*USE_NETCDF4*/ - -int -nc_get_vars_text(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, - char *ip) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_CHAR); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, NC_CHAR); } int -nc_get_vars_schar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_schar(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, signed char *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_BYTE); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, NC_BYTE); } int -nc_get_vars_uchar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_uchar(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, unsigned char *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_uchar); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, T_uchar); } int -nc_get_vars_short(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_short(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, short *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_SHORT); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, NC_SHORT); } int -nc_get_vars_int(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_int(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, int *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_INT); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, NC_INT); } int -nc_get_vars_long(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_long(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, long *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_long); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, T_long); } int -nc_get_vars_float(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_float(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, float *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_float); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, T_float); } int -nc_get_vars_double(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_double(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, double *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_double); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, T_double); } int -nc_get_vars_ubyte(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, unsigned char *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_ubyte); + return NC_get_vars(ncid,varid, startp, countp, stridep, + (void *)ip, T_ubyte); } int -nc_get_vars_ushort(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_ushort(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, unsigned short *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_ushort); + return NC_get_vars(ncid,varid,startp,countp, stridep, + (void *)ip, T_ushort); } int -nc_get_vars_uint(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_uint(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, unsigned int *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_uint); + return NC_get_vars(ncid,varid,startp, countp, stridep, + (void *)ip, T_uint); } int -nc_get_vars_longlong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_longlong(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, long long *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,T_longlong); + return NC_get_vars(ncid, varid, startp, countp, stridep, + (void *)ip, T_longlong); } int -nc_get_vars_ulonglong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, +nc_get_vars_ulonglong(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t * stridep, unsigned long long *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_UINT64); + return NC_get_vars(ncid, varid, startp, countp, stridep, + (void *)ip, NC_UINT64); } #ifdef USE_NETCDF4 int nc_get_vars_string(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t * stridep, char* *ip) { NC* ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_get_vars(ncid,varid,startp,countp,stride,(void*)ip,NC_STRING); + return NC_get_vars(ncid, varid, startp, countp, stridep, + (void *)ip, NC_STRING); +} +#endif /*USE_NETCDF4*/ +/** \} */ + +/** \ingroup variables +Read a mapped array from a variable. + +The nc_get_varm_ type family of functions reads a mapped array section +of values from a netCDF variable of an open netCDF dataset. The mapped +array section is specified by giving a corner, a vector of edge +lengths, a stride vector, and an index mapping vector. The index +mapping vector is a vector of integers that specifies the mapping +between the dimensions of a netCDF variable and the in-memory +structure of the internal data array. No assumptions are made about +the ordering or length of the dimensions of the data array. The netCDF +dataset must be in data mode. + +The functions for types ubyte, ushort, uint, longlong, ulonglong, and +string are only available for netCDF-4/HDF5 files. + +The nc_get_varm() function will read a variable of any type, including +user defined type. For this function, the type of the data in memory +must match the type of the variable - no data conversion is done. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param startp Start vector with one element for each dimension to \ref +specify_hyperslab. + +\param countp Count vector with one element for each dimension to \ref +specify_hyperslab. + +\param stridep Stride vector with one element for each dimension to +\ref specify_hyperslab. + +\param imapp Mapping vector with one element for each dimension to +\ref specify_hyperslab. + +\param ip Pointer where the data will be copied. Memory must be +allocated by the user before this function is called. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. +*/ +/** \{ */ +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) +{ + NC* ncp; + int stat; + + if ((stat = NC_check_id(ncid, &ncp))) + return stat; + return ncp->dispatch->get_varm(ncid, varid, startp, countp, + stridep, imapp, ip, NC_NAT); } +int +nc_get_varm_schar(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, + const ptrdiff_t *imapp, signed char *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, + stridep, imapp, (void *)ip, NC_BYTE); +} + +int +nc_get_varm_uchar(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + unsigned char *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_uchar); +} + +int +nc_get_varm_short(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t *imapp, short *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_SHORT); +} + +int +nc_get_varm_int(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + int *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_INT); +} + +int +nc_get_varm_long(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + long *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_long); +} + +int +nc_get_varm_float(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + float *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_float); +} + +int +nc_get_varm_double(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + double *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_double); +} + +int +nc_get_varm_ubyte(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + unsigned char *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid,varid,startp,countp,stridep, + imapp, (void *)ip, T_ubyte); +} + +int +nc_get_varm_ushort(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + unsigned short *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, stridep, + imapp, (void *)ip, T_ushort); +} + +int +nc_get_varm_uint(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + unsigned int *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, + stridep, imapp, (void *)ip, T_uint); +} + +int +nc_get_varm_longlong(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t *imapp, long long *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)ip, T_longlong); +} + +int +nc_get_varm_ulonglong(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + unsigned long long *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)ip, NC_UINT64); +} + +int +nc_get_varm_text(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t *imapp, char *ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)ip, NC_CHAR); +} + +#ifdef USE_NETCDF4 +int +nc_get_varm_string(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t *imapp, char **ip) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)ip, NC_STRING); +} +/** \} */ #endif /*USE_NETCDF4*/ + /*! \} */ /* End of named group... */ diff --git a/libdispatch/varinq.c b/libdispatch/varinq.c index 32a21489e..1da3f8508 100644 --- a/libdispatch/varinq.c +++ b/libdispatch/varinq.c @@ -24,10 +24,11 @@ nc_create(). \param name Name of the variable. -\param varidp Pointer to location for returned variable ID. +\param varidp Pointer to location for returned variable ID. \ref +ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. \section Example @@ -65,23 +66,23 @@ nc_create(). \param varid Variable ID \param name Returned variable name. The caller must allocate space for -the returned name. The maximum length is \ref NC_MAX_NAME. Ignored if -NULL. +the returned name. The maximum length is ::NC_MAX_NAME. \ref +ignored_if_null. -\param xtypep Pointer where typeid will be stored. Ignored if NULL. +\param xtypep Pointer where typeid will be stored. \ref ignored_if_null. \param ndimsp Pointer where number of dimensions will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. \param dimidsp Pointer where array of dimension IDs will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. \param nattsp Pointer where number of attributes will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. \section Example @@ -132,12 +133,12 @@ nc_create(). \param varid Variable ID \param name Returned variable name. The caller must allocate space for -the returned name. The maximum length is \ref NC_MAX_NAME. Ignored if +the returned name. The maximum length is ::NC_MAX_NAME. Ignored if NULL. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. */ int nc_inq_varname(int ncid, int varid, char *name) @@ -154,11 +155,11 @@ nc_create(). \param varid Variable ID -\param typep Pointer where typeid will be stored. Ignored if NULL. +\param typep Pointer where typeid will be stored. \ref ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. */ int nc_inq_vartype(int ncid, int varid, nc_type *typep) @@ -176,11 +177,11 @@ nc_create(). \param varid Variable ID \param ndimsp Pointer where number of dimensions will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. */ int nc_inq_varndims(int ncid, int varid, int *ndimsp) @@ -197,11 +198,11 @@ nc_create(). \param varid Variable ID \param dimidsp Pointer where array of dimension IDs will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. */ int nc_inq_vardimid(int ncid, int varid, int *dimidsp) @@ -219,11 +220,11 @@ nc_create(). \param varid Variable ID \param nattsp Pointer where number of attributes will be -stored. Ignored if NULL. +stored. \ref ignored_if_null. -\returns \ref NC_NOERR No error. -\returns \ref NC_EBADID Bad ncid. -\returns \ref NC_ENOTVAR Invalid variable ID. +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. */ int nc_inq_varnatts(int ncid, int varid, int *nattsp) @@ -235,4 +236,285 @@ nc_inq_varnatts(int ncid, int varid, int *nattsp) nattsp); } +#ifdef USE_NETCDF4 +/** \ingroup variables +Learn the storage and deflate settings for a variable. + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param shufflep A 1 will be written here if the shuffle filter is +turned on for this variable, and a 0 otherwise. \ref ignored_if_null. + +\param deflatep If this pointer is non-NULL, the nc_inq_var_deflate +function will write a 1 if the deflate filter is turned on for this +variable, and a 0 otherwise. \ref ignored_if_null. + +\param deflate_levelp If the deflate filter is in use for this +variable, the deflate_level will be writen here. \ref ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, + int *deflate_levelp) +{ + NC* ncp; + int stat = NC_check_id(ncid,&ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all( + ncid, varid, + NULL, /*name*/ + NULL, /*xtypep*/ + NULL, /*ndimsp*/ + NULL, /*dimidsp*/ + NULL, /*nattsp*/ + shufflep, /*shufflep*/ + deflatep, /*deflatep*/ + deflate_levelp, /*deflatelevelp*/ + NULL, /*fletcher32p*/ + NULL, /*contiguousp*/ + NULL, /*chunksizep*/ + NULL, /*nofillp*/ + NULL, /*fillvaluep*/ + NULL, /*endianp*/ + NULL, /*optionsmaskp*/ + NULL /*pixelsp*/ + ); +} + +/** \ingroup variables +Learn the szip settings of a variable. + +This function returns the szip settings for a variable. NetCDF does +not allow variables to be created with szip (due to license problems +with the szip library), but we do enable read-only access of HDF5 +files with szip compression. + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param options_maskp The szip options mask will be copied to this +pointer. \ref ignored_if_null. + +\param pixels_per_blockp The szip pixels per block will be copied +here. \ref ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp) +{ + NC* ncp; + int stat = NC_check_id(ncid,&ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all( + ncid, varid, + NULL, /*name*/ + NULL, /*xtypep*/ + NULL, /*ndimsp*/ + NULL, /*dimidsp*/ + NULL, /*nattsp*/ + NULL, /*shufflep*/ + NULL, /*deflatep*/ + NULL, /*deflatelevelp*/ + NULL, /*fletcher32p*/ + NULL, /*contiguousp*/ + NULL, /*chunksizep*/ + NULL, /*nofillp*/ + NULL, /*fillvaluep*/ + NULL, /*endianp*/ + options_maskp, /*optionsmaskp*/ + pixels_per_blockp /*pixelsp*/ + ); +} + +/** \ingroup variables +Learn the checksum settings for a variable. + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param fletcher32p Will be set to ::NC_FLETCHER32 if the fletcher32 +checksum filter is turned on for this variable, and ::NC_NOCHECKSUM if +it is not. \ref ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p) +{ + NC* ncp; + int stat = NC_check_id(ncid,&ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all( + ncid, varid, + NULL, /*name*/ + NULL, /*xtypep*/ + NULL, /*ndimsp*/ + NULL, /*dimidsp*/ + NULL, /*nattsp*/ + NULL, /*shufflep*/ + NULL, /*deflatep*/ + NULL, /*deflatelevelp*/ + fletcher32p, /*fletcher32p*/ + NULL, /*contiguousp*/ + NULL, /*chunksizep*/ + NULL, /*nofillp*/ + NULL, /*fillvaluep*/ + NULL, /*endianp*/ + NULL, /*optionsmaskp*/ + NULL /*pixelsp*/ + ); +} + +/** \ingroup variables + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param storagep Address of returned storage property, returned as +::NC_CONTIGUOUS if this variable uses contiguous storage, or +::NC_CHUNKED if it uses chunked storage. \ref ignored_if_null. + +\param chunksizesp The chunksizes will be copied here. \ref +ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, storagep, + chunksizesp, NULL, NULL, NULL, NULL, NULL); +} + +/** \ingroup variables +Learn the fill mode of a variable. + +The fill mode of a variable is set by nc_def_var_fill(). + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param no_fill Pointer to an integer which will get a 1 if no_fill +mode is set for this variable. \ref ignored_if_null. + +\param fill_valuep A pointer which will get the fill value for this +variable. \ref ignored_if_null. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep) +{ + NC* ncp; + int stat = NC_check_id(ncid,&ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all( + ncid, varid, + NULL, /*name*/ + NULL, /*xtypep*/ + NULL, /*ndimsp*/ + NULL, /*dimidsp*/ + NULL, /*nattsp*/ + NULL, /*shufflep*/ + NULL, /*deflatep*/ + NULL, /*deflatelevelp*/ + NULL, /*fletcher32p*/ + NULL, /*contiguousp*/ + NULL, /*chunksizep*/ + no_fill, /*nofillp*/ + fill_valuep, /*fillvaluep*/ + NULL, /*endianp*/ + NULL, /*optionsmaskp*/ + NULL /*pixelsp*/ + ); +} + +/** \ingroup variables +Find the endianness of a variable. + +This is a wrapper for nc_inq_var_all(). + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param endianp Storage which will get ::NC_ENDIAN_LITTLE if this +variable is stored in little-endian format, ::NC_ENDIAN_BIG if it is +stored in big-endian format, and ::NC_ENDIAN_NATIVE if the endianness +is not set, and the variable is not created yet. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +*/ +int +nc_inq_var_endian(int ncid, int varid, int *endianp) +{ + NC* ncp; + int stat = NC_check_id(ncid,&ncp); + if(stat != NC_NOERR) return stat; + return ncp->dispatch->inq_var_all( + ncid, varid, + NULL, /*name*/ + NULL, /*xtypep*/ + NULL, /*ndimsp*/ + NULL, /*dimidsp*/ + NULL, /*nattsp*/ + NULL, /*shufflep*/ + NULL, /*deflatep*/ + NULL, /*deflatelevelp*/ + NULL, /*fletcher32p*/ + NULL, /*contiguousp*/ + NULL, /*chunksizep*/ + NULL, /*nofillp*/ + NULL, /*fillvaluep*/ + endianp, /*endianp*/ + NULL, /*optionsmaskp*/ + NULL /*pixelsp*/ + ); +} +#endif /* USE_NETCDF4 */ /*! \} */ /* End of named group ...*/ diff --git a/libdispatch/varput.c b/libdispatch/varput.c index a792c01e9..d75f6b391 100644 --- a/libdispatch/varput.c +++ b/libdispatch/varput.c @@ -556,188 +556,227 @@ nc_put_vara_string(int ncid, int varid, const size_t *startp, #endif /*USE_NETCDF4*/ /**@}*/ +/** \ingroup variables +Write one datum. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param indexp Index vector with one element for each dimension. + +\param op Pointer from where the data will be copied. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_EEDGE Start+count exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. + */ +/**@{*/ +int +nc_put_var1(int ncid, int varid, const size_t *indexp, const void *op) +{ + return NC_put_var1(ncid, varid, indexp, op, NC_NAT); +} + +int +nc_put_var1_text(int ncid, int varid, const size_t *indexp, const char *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_CHAR); +} + +int +nc_put_var1_schar(int ncid, int varid, const size_t *indexp, const signed char *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_BYTE); +} + +int +nc_put_var1_uchar(int ncid, int varid, const size_t *indexp, const unsigned char *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_UBYTE); +} + +int +nc_put_var1_short(int ncid, int varid, const size_t *indexp, const short *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_SHORT); +} + +int +nc_put_var1_int(int ncid, int varid, const size_t *indexp, const int *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_INT); +} + +int +nc_put_var1_long(int ncid, int varid, const size_t *indexp, const long *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void*)op, longtype); +} + +int +nc_put_var1_float(int ncid, int varid, const size_t *indexp, const float *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void*)op, NC_FLOAT); +} + +int +nc_put_var1_double(int ncid, int varid, const size_t *indexp, const double *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_DOUBLE); +} + +int +nc_put_var1_ubyte(int ncid, int varid, const size_t *indexp, const unsigned char *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_UBYTE); +} + +int +nc_put_var1_ushort(int ncid, int varid, const size_t *indexp, const unsigned short *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_USHORT); +} + +int +nc_put_var1_uint(int ncid, int varid, const size_t *indexp, const unsigned int *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_UINT); +} + +int +nc_put_var1_longlong(int ncid, int varid, const size_t *indexp, const long long *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_INT64); +} + +int +nc_put_var1_ulonglong(int ncid, int varid, const size_t *indexp, const unsigned long long *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void *)op, NC_UINT64); +} + +#ifdef USE_NETCDF4 +int +nc_put_var1_string(int ncid, int varid, const size_t *indexp, const char* *op) +{ + NC* ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + INITCOORD1; + return NC_put_var1(ncid, varid, indexp, (void*)op, NC_STRING); +} +#endif /*USE_NETCDF4*/ +/**@}*/ + +/** \ingroup variables +Write an entire variable with one call. + +The nc_put_var_ type family of functions write all the values of a +variable into a netCDF variable of an open netCDF dataset. This is the +simplest interface to use for writing a value in a scalar variable or +whenever all the values of a multidimensional variable can all be +written at once. The values to be written are associated with the +netCDF variable by assuming that the last dimension of the netCDF +variable varies fastest in the C interface. The values are converted +to the external data type of the variable, if necessary. + +Take care when using this function with record variables (variables +that use the ::NC_UNLIMITED dimension). If you try to write all the +values of a record variable into a netCDF file that has no record data +yet (hence has 0 records), nothing will be written. Similarly, if you +try to write all the values of a record variable but there are more +records in the file than you assume, more in-memory data will be +accessed than you supply, which may result in a segmentation +violation. To avoid such problems, it is better to use the nc_put_vara +interfaces for variables that use the ::NC_UNLIMITED dimension. + +The functions for types ubyte, ushort, uint, longlong, ulonglong, and +string are only available for netCDF-4/HDF5 files. + +The nc_put_var() function will write a variable of any type, including +user defined type. For this function, the type of the data in memory +must match the type of the variable - no data conversion is done. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param op Pointer from where the data will be copied. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_EEDGE Start+count exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. + */ +/**@{*/ int nc_put_var(int ncid, int varid, const void *op) { return NC_put_var(ncid, varid, op, NC_NAT); } -int -nc_put_var1(int ncid, int varid, const size_t *coord, const void *op) -{ - return NC_put_var1(ncid, varid, coord, op, NC_NAT); -} - -int -nc_put_varm (int ncid, int varid, const size_t * startp, - const size_t * countp, const ptrdiff_t * stride, - const ptrdiff_t * imapp, const void *op) -{ - NC* ncp; - int stat; - - if ((stat = NC_check_id(ncid, &ncp))) - return stat; - return ncp->dispatch->put_varm(ncid, varid, startp, countp, stride, imapp, - op, NC_NAT); -} - -int -nc_put_vars (int ncid, int varid, const size_t * startp, - const size_t * countp, const ptrdiff_t * stride, - const void *op) -{ - NC* ncp; - int stat; - - if ((stat = NC_check_id(ncid, &ncp))) - return stat; - return ncp->dispatch->put_vars(ncid, varid, startp, countp, stride, - op, NC_NAT); -} -int -nc_put_var1_text(int ncid, int varid, const size_t *coord, const char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_CHAR); -} - -int -nc_put_var1_schar(int ncid, int varid, const size_t *coord, const signed char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_BYTE); -} - -int -nc_put_var1_uchar(int ncid, int varid, const size_t *coord, const unsigned char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_UBYTE); -} - -int -nc_put_var1_short(int ncid, int varid, const size_t *coord, const short *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_SHORT); -} - -int -nc_put_var1_int(int ncid, int varid, const size_t *coord, const int *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_INT); -} - -int -nc_put_var1_long(int ncid, int varid, const size_t *coord, const long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid, varid, coord, (void*)op, longtype); -} - -int -nc_put_var1_float(int ncid, int varid, const size_t *coord, const float *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid, varid, coord, (void*)op, NC_FLOAT); -} - -int -nc_put_var1_double(int ncid, int varid, const size_t *coord, const double *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_DOUBLE); -} - -int -nc_put_var1_ubyte(int ncid, int varid, const size_t *coord, const unsigned char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_UBYTE); -} - -int -nc_put_var1_ushort(int ncid, int varid, const size_t *coord, const unsigned short *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_USHORT); -} - -int -nc_put_var1_uint(int ncid, int varid, const size_t *coord, const unsigned int *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_UINT); -} - -int -nc_put_var1_longlong(int ncid, int varid, const size_t *coord, const long long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_INT64); -} - -int -nc_put_var1_ulonglong(int ncid, int varid, const size_t *coord, const unsigned long long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid,varid,coord,(void*)op, NC_UINT64); -} - -#ifdef USE_NETCDF4 -int -nc_put_var1_string(int ncid, int varid, const size_t *coord, const char* *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - INITCOORD1; - return NC_put_var1(ncid, varid, coord, (void*)op, NC_STRING); -} - -#endif /*USE_NETCDF4*/ - int nc_put_var_text(int ncid, int varid, const char *op) { @@ -864,350 +903,465 @@ nc_put_var_string(int ncid, int varid, const char* *op) if(stat != NC_NOERR) return stat; return NC_put_var(ncid,varid,(void*)op,NC_STRING); } - #endif /*USE_NETCDF4*/ +/**\} */ + +/** \ingroup variables +Write a strided array of values to a variable. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param startp Start vector with one element for each dimension to \ref +specify_hyperslab. + +\param countp Count vector with one element for each dimension to \ref +specify_hyperslab. + +\param stridep Stride vector with one element for each dimension to +\ref specify_hyperslab. + +\param op Pointer where the data will be copied. Memory must be +allocated by the user before this function is called. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_EEDGE Start+count exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. + */ +/**@{*/ +int +nc_put_vars (int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const void *op) +{ + NC *ncp; + int stat; + + if ((stat = NC_check_id(ncid, &ncp))) + return stat; + return ncp->dispatch->put_vars(ncid, varid, startp, countp, + stridep, op, NC_NAT); +} int -nc_put_varm_text(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, +nc_put_vars_text(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, const char *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_CHAR); + return NC_put_vars(ncid, varid, startp, countp, + stridep,(void*)op,NC_CHAR); } int -nc_put_varm_schar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, +nc_put_vars_schar(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, const signed char *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_BYTE); -} - -int -nc_put_varm_uchar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const unsigned char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_uchar); -} - -int -nc_put_varm_short(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const short *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_SHORT); -} - -int -nc_put_varm_int(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const int *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_INT); -} - -int -nc_put_varm_long(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_long); -} - -int -nc_put_varm_float(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const float *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_float); -} - -int -nc_put_varm_double(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const double *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_double); -} - -int -nc_put_varm_ubyte(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const unsigned char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_ubyte); -} - -int -nc_put_varm_ushort(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const unsigned short *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_ushort); -} - -int -nc_put_varm_uint(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const unsigned int *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_uint); -} - -int -nc_put_varm_longlong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const long long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,T_longlong); -} - -int -nc_put_varm_ulonglong(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const unsigned long long *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_UINT64); -} - -#ifdef USE_NETCDF4 -int -nc_put_varm_string(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, const ptrdiff_t * imapp, - const char* *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_varm(ncid,varid,startp,countp,stride,imapp,(void*)op,NC_STRING); -} - -#endif /*USE_NETCDF4*/ - - -int -nc_put_vars_text(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, - const char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_CHAR); -} - -int -nc_put_vars_schar(int ncid, int varid, - const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, - const signed char *op) -{ - NC* ncp; - int stat = NC_check_id(ncid, &ncp); - if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_BYTE); + return NC_put_vars(ncid, varid, startp, countp, + stridep,(void*)op,NC_BYTE); } int nc_put_vars_uchar(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const unsigned char *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_uchar); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_uchar); } int nc_put_vars_short(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const short *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_SHORT); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, NC_SHORT); } int nc_put_vars_int(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const int *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_INT); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, NC_INT); } int nc_put_vars_long(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const long *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_long); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_long); } int nc_put_vars_float(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const float *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_float); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_float); } int nc_put_vars_double(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const double *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_double); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_double); } int nc_put_vars_ubyte(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const unsigned char *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_ubyte); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_ubyte); } int nc_put_vars_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const unsigned short *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_ushort); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_ushort); } int nc_put_vars_uint(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const unsigned int *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_uint); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_uint); } int nc_put_vars_longlong(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const long long *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,T_longlong); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, T_longlong); } int nc_put_vars_ulonglong(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, + const ptrdiff_t *stridep, const unsigned long long *op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_UINT64); + return NC_put_vars(ncid, varid, startp, countp, + stridep, (void *)op, NC_UINT64); } #ifdef USE_NETCDF4 int nc_put_vars_string(int ncid, int varid, const size_t *startp, const size_t *countp, - const ptrdiff_t * stride, - const char* *op) + const ptrdiff_t *stridep, + const char**op) { - NC* ncp; + NC *ncp; int stat = NC_check_id(ncid, &ncp); if(stat != NC_NOERR) return stat; - return NC_put_vars(ncid,varid,startp,countp,stride,(void*)op,NC_STRING); + return NC_put_vars(ncid, varid, startp, countp, stridep, + (void *)op, NC_STRING); +} +#endif /*USE_NETCDF4*/ +/**\} */ + +/** \ingroup variables +Write a mapped array of values to a variable. + +\param ncid NetCDF ID, from a previous call to nc_open() or +nc_create(). + +\param varid Variable ID + +\param startp Start vector with one element for each dimension to \ref +specify_hyperslab. + +\param countp Count vector with one element for each dimension to \ref +specify_hyperslab. + +\param stridep Stride vector with one element for each dimension to +\ref specify_hyperslab. + +\param imapp Mapping vector with one element for each dimension to +\ref specify_hyperslab. + +\param op Pointer where the data will be copied. Memory must be +allocated by the user before this function is called. + +\returns ::NC_NOERR No error. +\returns ::NC_ENOTVAR Variable not found. +\returns ::NC_EINVALCOORDS Index exceeds dimension bound. +\returns ::NC_EEDGE Start+count exceeds dimension bound. +\returns ::NC_ERANGE One or more of the values are out of range. +\returns ::NC_EINDEFINE Operation not allowed in define mode. +\returns ::NC_EBADID Bad ncid. + */ +/**@{*/ +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) +{ + NC *ncp; + int stat; + + if ((stat = NC_check_id(ncid, &ncp))) + return stat; + return ncp->dispatch->put_varm(ncid, varid, startp, countp, + stridep, imapp, op, NC_NAT); } -#endif /*USE_NETCDF4*/ +int +nc_put_varm_text(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t *imapp, const char *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_CHAR); +} + +int +nc_put_varm_schar(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const signed char *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_BYTE); +} + +int +nc_put_varm_uchar(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const unsigned char *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_uchar); +} + +int +nc_put_varm_short(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const short *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_SHORT); +} + +int +nc_put_varm_int(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const int *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_INT); +} + +int +nc_put_varm_long(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const long *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_long); +} + +int +nc_put_varm_float(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const float *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_float); +} + +int +nc_put_varm_double(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const double *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_double); +} + +int +nc_put_varm_ubyte(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const unsigned char *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_ubyte); +} + +int +nc_put_varm_ushort(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const unsigned short *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_ushort); +} + +int +nc_put_varm_uint(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const unsigned int *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_uint); +} + +int +nc_put_varm_longlong(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const long long *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, T_longlong); +} + +int +nc_put_varm_ulonglong(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const unsigned long long *op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_UINT64); +} + +#ifdef USE_NETCDF4 +int +nc_put_varm_string(int ncid, int varid, + const size_t *startp, const size_t *countp, + const ptrdiff_t *stridep, const ptrdiff_t *imapp, + const char**op) +{ + NC *ncp; + int stat = NC_check_id(ncid, &ncp); + if(stat != NC_NOERR) return stat; + return NC_put_varm(ncid, varid, startp, countp, stridep, imapp, + (void *)op, NC_STRING); +} +#endif /*USE_NETCDF4*/ +/**\} */ + + +/*! \} */ /*End of named group... */ -/*! \} */ /* End of named group... */ diff --git a/man4/notes.doc b/man4/notes.doc index 9c1654412..a7fcfc444 100644 --- a/man4/notes.doc +++ b/man4/notes.doc @@ -46,6 +46,11 @@ if (nc_inq(ncid, &ndims, NULL, NULL, NULL)) return SOME_ERROR; \endcode +\section Allocating Storage for the Result + +User must allocate space for the result of an inq function before the +function is called. + \page specify_hyperslab Specify a Hyperslab The NetCDF allows specification of hyperslabs to be read or written @@ -77,4 +82,37 @@ variable's dimensions. Setting any element of the count array to zero causes the function to exit without error, and without doing anything. +\section stride_vector A Vector Specifying Stride for Each Dimension + +A vector of size_t integers specifying the interval between selected +indices. + +A value of 1 accesses adjacent values of the netCDF variable in the +corresponding dimension; a value of 2 accesses every other value of +the netCDF variable in the corresponding dimension; and so on. + +The elements of the stride vector correspond, in order, to the +variable's dimensions. + +A NULL stride argument is treated as (1, 1, ... , 1). + +\section map_vector A Vector Specifying Mapping for Each Dimension + +A vector of integers that specifies the mapping between the dimensions +of a netCDF variable and the in-memory structure of the internal data +array. + +imap[0] gives the distance between elements of the internal array +corresponding to the most slowly varying dimension of the netCDF +variable. imap[n-1] (where n is the rank of the netCDF variable) gives +the distance between elements of the internal array corresponding to +the most rapidly varying dimension of the netCDF variable. Intervening +imap elements correspond to other dimensions of the netCDF variable in +the obvious way. Distances between elements are specified in +type-independent units of elements. + +\note The distance between internal elements that occupy adjacent +memory locations is 1 and not the element's byte-length as in netCDF +2. + */ \ No newline at end of file