Loading...
Searching...
No Matches
dfile.c
Go to the documentation of this file.
#include "config.h"
#include <stdlib.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* lseek() */
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#include "ncdispatch.h"
#include "netcdf_mem.h"
#include "ncpathmgr.h"
#include "fbits.h"
#undef DEBUG
#ifndef nulldup
#define nulldup(s) ((s)?strdup(s):NULL)
#endif
/* User-defined formats. */
NC_Dispatch *UDF0_dispatch_table = NULL;
char UDF0_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1] = "";
NC_Dispatch *UDF1_dispatch_table = NULL;
char UDF1_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1] = "";
/**************************************************/
int
nc_def_user_format(int mode_flag, NC_Dispatch *dispatch_table, char *magic_number)
{
/* Check inputs. */
if (!dispatch_table)
return NC_EINVAL;
if (magic_number && strlen(magic_number) > NC_MAX_MAGIC_NUMBER_LEN)
return NC_EINVAL;
/* Check the version of the dispatch table provided. */
if (dispatch_table->dispatch_version != NC_DISPATCH_VERSION)
return NC_EINVAL;
/* user defined magic numbers not allowed with netcdf3 modes */
if (magic_number && (fIsSet(mode_flag, NC_64BIT_OFFSET) ||
fIsSet(mode_flag, NC_64BIT_DATA) ||
(fIsSet(mode_flag, NC_CLASSIC_MODEL) &&
!fIsSet(mode_flag, NC_NETCDF4))))
return NC_EINVAL;
/* Retain a pointer to the dispatch_table and a copy of the magic
* number, if one was provided. */
if (fIsSet(mode_flag,NC_UDF0))
{
UDF0_dispatch_table = dispatch_table;
if (magic_number)
strncpy(UDF0_magic_number, magic_number, NC_MAX_MAGIC_NUMBER_LEN);
}
else if(fIsSet(mode_flag, NC_UDF1))
{
UDF1_dispatch_table = dispatch_table;
if (magic_number)
strncpy(UDF1_magic_number, magic_number, NC_MAX_MAGIC_NUMBER_LEN);
}
else
{
return NC_EINVAL;
}
return NC_NOERR;
}
int
nc_inq_user_format(int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
{
/* Check inputs. */
if (fIsSet(mode_flag,NC_UDF0))
{
if (dispatch_table)
*dispatch_table = UDF0_dispatch_table;
if (magic_number)
strncpy(magic_number, UDF0_magic_number, NC_MAX_MAGIC_NUMBER_LEN);
}
else if(fIsSet(mode_flag,NC_UDF1))
{
if (dispatch_table)
*dispatch_table = UDF1_dispatch_table;
if (magic_number)
strncpy(magic_number, UDF1_magic_number, NC_MAX_MAGIC_NUMBER_LEN);
}
else
{
return NC_EINVAL;
}
return NC_NOERR;
}
int
nc_create(const char *path, int cmode, int *ncidp)
{
return nc__create(path,cmode,NC_SIZEHINT_DEFAULT,NULL,ncidp);
}
int
nc__create(const char *path, int cmode, size_t initialsz,
size_t *chunksizehintp, int *ncidp)
{
return NC_create(path, cmode, initialsz, 0,
chunksizehintp, 0, NULL, ncidp);
}
int
nc_create_mem(const char* path, int mode, size_t initialsize, int* ncidp)
{
if(mode & NC_MMAP) return NC_EINVAL;
mode |= NC_INMEMORY; /* Specifically, do not set NC_DISKLESS */
return NC_create(path, mode, initialsize, 0, NULL, 0, NULL, ncidp);
}
int
nc__create_mp(const char *path, int cmode, size_t initialsz,
int basepe, size_t *chunksizehintp, int *ncidp)
{
return NC_create(path, cmode, initialsz, basepe,
chunksizehintp, 0, NULL, ncidp);
}
int
nc_open(const char *path, int omode, int *ncidp)
{
return NC_open(path, omode, 0, NULL, 0, NULL, ncidp);
}
int
nc__open(const char *path, int omode,
size_t *chunksizehintp, int *ncidp)
{
/* this API is for non-parallel access.
* Note nc_open_par() also calls NC_open().
*/
return NC_open(path, omode, 0, chunksizehintp, 0, NULL, ncidp);
}
int
nc_open_mem(const char* path, int omode, size_t size, void* memory, int* ncidp)
{
NC_memio meminfo;
/* Sanity checks */
if(memory == NULL || size < MAGIC_NUMBER_LEN || path == NULL)
return NC_EINVAL;
if(omode & (NC_WRITE|NC_MMAP))
return NC_EINVAL;
omode |= (NC_INMEMORY); /* Note: NC_INMEMORY and NC_DISKLESS are mutually exclusive*/
meminfo.size = size;
meminfo.memory = memory;
meminfo.flags = NC_MEMIO_LOCKED;
return NC_open(path, omode, 0, NULL, 0, &meminfo, ncidp);
}
int
nc_open_memio(const char* path, int omode, NC_memio* params, int* ncidp)
{
/* Sanity checks */
if(path == NULL || params == NULL)
return NC_EINVAL;
if(params->memory == NULL || params->size < MAGIC_NUMBER_LEN)
return NC_EINVAL;
if(omode & NC_MMAP)
return NC_EINVAL;
omode |= (NC_INMEMORY);
return NC_open(path, omode, 0, NULL, 0, params, ncidp);
}
int
nc__open_mp(const char *path, int omode, int basepe,
size_t *chunksizehintp, int *ncidp)
{
return NC_open(path, omode, basepe, chunksizehintp, 0, NULL, ncidp);
}
int
nc_inq_path(int ncid, size_t *pathlen, char *path)
{
NC* ncp;
int stat = NC_NOERR;
if ((stat = NC_check_id(ncid, &ncp)))
return stat;
if(ncp->path == NULL) {
if(pathlen) *pathlen = 0;
if(path) path[0] = '\0';
} else {
if (pathlen) *pathlen = strlen(ncp->path);
if (path) strcpy(path, ncp->path);
}
return stat;
}
int
nc_redef(int ncid)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->redef(ncid);
}
int
nc_enddef(int ncid)
{
int status = NC_NOERR;
NC *ncp;
status = NC_check_id(ncid, &ncp);
if(status != NC_NOERR) return status;
return ncp->dispatch->_enddef(ncid,0,1,0,1);
}
int
nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
size_t r_align)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->_enddef(ncid,h_minfree,v_align,v_minfree,r_align);
}
int
nc_sync(int ncid)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->sync(ncid);
}
int
nc_abort(int ncid)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
stat = ncp->dispatch->abort(ncid);
del_from_NCList(ncp);
free_NC(ncp);
return stat;
}
int
nc_close(int ncid)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
stat = ncp->dispatch->close(ncid,NULL);
/* Remove from the nc list */
if (!stat)
{
del_from_NCList(ncp);
free_NC(ncp);
}
return stat;
}
int
nc_close_memio(int ncid, NC_memio* memio)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
stat = ncp->dispatch->close(ncid,memio);
/* Remove from the nc list */
if (!stat)
{
del_from_NCList(ncp);
free_NC(ncp);
}
return stat;
}
int
nc_set_fill(int ncid, int fillmode, int *old_modep)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->set_fill(ncid,fillmode,old_modep);
}
int
nc_inq_base_pe(int ncid, int *pe)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
if (pe) *pe = 0;
return NC_NOERR;
}
int
nc_set_base_pe(int ncid, int pe)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return NC_NOERR;
}
int
nc_inq_format(int ncid, int *formatp)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->inq_format(ncid,formatp);
}
int
nc_inq_format_extended(int ncid, int *formatp, int *modep)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->inq_format_extended(ncid,formatp,modep);
}
int
nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->inq(ncid,ndimsp,nvarsp,nattsp,unlimdimidp);
}
int
nc_inq_nvars(int ncid, int *nvarsp)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->inq(ncid, NULL, nvarsp, NULL, NULL);
}
int
nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
{
NC* ncp;
int stat;
/* Do a quick triage on xtype */
if(xtype <= NC_NAT) return NC_EBADTYPE;
/* For compatibility, we need to allow inq about
atomic types, even if ncid is ill-defined */
if(xtype <= ATOMICTYPEMAX4) {
if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
if(size) *size = NC_atomictypelen(xtype);
return NC_NOERR;
}
/* Apparently asking about a user defined type, so we need
a valid ncid */
stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) /* bad ncid */
return NC_EBADTYPE;
/* have good ncid */
return ncp->dispatch->inq_type(ncid,xtype,name,size);
}
static int
check_create_mode(int mode)
{
int mode_format;
int use_mmap = 0;
int inmemory = 0;
int diskless = 0;
/* This is a clever check to see if more than one format bit is
* set. */
mode_format = (mode & NC_NETCDF4) | (mode & NC_64BIT_OFFSET) |
(mode & NC_CDF5);
if (mode_format && (mode_format & (mode_format - 1)))
return NC_EINVAL;
use_mmap = ((mode & NC_MMAP) == NC_MMAP);
inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY);
diskless = ((mode & NC_DISKLESS) == NC_DISKLESS);
/* NC_INMEMORY and NC_DISKLESS and NC_MMAP are all mutually exclusive */
if(diskless && inmemory) return NC_EDISKLESS;
if(diskless && use_mmap) return NC_EDISKLESS;
if(inmemory && use_mmap) return NC_EINMEMORY;
/* mmap is not allowed for netcdf-4 */
if(use_mmap && (mode & NC_NETCDF4)) return NC_EINVAL;
#ifndef USE_NETCDF4
/* If the user asks for a netCDF-4 file, and the library was built
* without netCDF-4, then return an error.*/
if (mode & NC_NETCDF4)
return NC_ENOTBUILT;
#endif /* USE_NETCDF4 undefined */
/* Well I guess there is some sanity in the world after all. */
return NC_NOERR;
}
int
NC_create(const char *path0, int cmode, size_t initialsz,
int basepe, size_t *chunksizehintp, int useparallel,
void* parameters, int *ncidp)
{
int stat = NC_NOERR;
NC* ncp = NULL;
const NC_Dispatch* dispatcher = NULL;
char* path = NULL;
NCmodel model;
char* newpath = NULL;
TRACE(nc_create);
if(path0 == NULL)
{stat = NC_EINVAL; goto done;}
/* Check mode flag for sanity. */
if ((stat = check_create_mode(cmode))) goto done;
/* Initialize the library. The available dispatch tables
* will depend on how netCDF was built
* (with/without netCDF-4, DAP, CDMREMOTE). */
if(!NC_initialized) {
if ((stat = nc_initialize())) goto done;
}
{
/* Skip past any leading whitespace in path */
const unsigned char* p;
for(p=(const unsigned char*)path0;*p;p++) {if(*p > ' ') break;}
path = nulldup((const char*)p);
}
memset(&model,0,sizeof(model));
newpath = NULL;
if((stat = NC_infermodel(path,&cmode,1,useparallel,NULL,&model,&newpath))) goto done;
if(newpath) {
nullfree(path);
path = newpath;
newpath = NULL;
}
assert(model.format != 0 && model.impl != 0);
/* Now, check for NC_ENOTBUILT cases limited to create (so e.g. HDF4 is not listed) */
#ifndef USE_HDF5
if (model.impl == NC_FORMATX_NC4)
{stat = NC_ENOTBUILT; goto done;}
#endif
#ifndef USE_PNETCDF
if (model.impl == NC_FORMATX_PNETCDF)
{stat = NC_ENOTBUILT; goto done;}
#endif
#ifndef NETCDF_ENABLE_CDF5
if (model.impl == NC_FORMATX_NC3 && (cmode & NC_64BIT_DATA))
{stat = NC_ENOTBUILT; goto done;}
#endif
/* Figure out what dispatcher to use */
switch (model.impl) {
#ifdef USE_HDF5
case NC_FORMATX_NC4:
dispatcher = HDF5_dispatch_table;
break;
#endif
#ifdef USE_PNETCDF
case NC_FORMATX_PNETCDF:
dispatcher = NCP_dispatch_table;
break;
#endif
#ifdef USE_NETCDF4
case NC_FORMATX_UDF0:
dispatcher = UDF0_dispatch_table;
break;
case NC_FORMATX_UDF1:
dispatcher = UDF1_dispatch_table;
break;
#endif /* USE_NETCDF4 */
#ifdef NETCDF_ENABLE_NCZARR
case NC_FORMATX_NCZARR:
dispatcher = NCZ_dispatch_table;
break;
#endif
case NC_FORMATX_NC3:
dispatcher = NC3_dispatch_table;
break;
default:
{stat = NC_ENOTNC; goto done;}
}
/* Create the NC* instance and insert its dispatcher and model */
if((stat = new_NC(dispatcher,path,cmode,&ncp))) goto done;
/* Add to list of known open files and define ext_ncid */
add_to_NCList(ncp);
/* Assume create will fill in remaining ncp fields */
if ((stat = dispatcher->create(ncp->path, cmode, initialsz, basepe, chunksizehintp,
parameters, dispatcher, ncp->ext_ncid))) {
del_from_NCList(ncp); /* oh well */
free_NC(ncp);
} else {
if(ncidp)*ncidp = ncp->ext_ncid;
}
done:
nullfree(path);
nullfree(newpath);
return stat;
}
int
NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp,
int useparallel, void* parameters, int *ncidp)
{
int stat = NC_NOERR;
NC* ncp = NULL;
const NC_Dispatch* dispatcher = NULL;
int inmemory = 0;
int diskless = 0;
int use_mmap = 0;
char* path = NULL;
NCmodel model;
char* newpath = NULL;
TRACE(nc_open);
if(!NC_initialized) {
stat = nc_initialize();
if(stat) goto done;
}
/* Check inputs. */
if (!path0)
{stat = NC_EINVAL; goto done;}
/* Capture the inmemory related flags */
use_mmap = ((omode & NC_MMAP) == NC_MMAP);
diskless = ((omode & NC_DISKLESS) == NC_DISKLESS);
inmemory = ((omode & NC_INMEMORY) == NC_INMEMORY);
/* NC_INMEMORY and NC_DISKLESS and NC_MMAP are all mutually exclusive */
if(diskless && inmemory) {stat = NC_EDISKLESS; goto done;}
if(diskless && use_mmap) {stat = NC_EDISKLESS; goto done;}
if(inmemory && use_mmap) {stat = NC_EINMEMORY; goto done;}
/* mmap is not allowed for netcdf-4 */
if(use_mmap && (omode & NC_NETCDF4)) {stat = NC_EINVAL; goto done;}
/* Attempt to do file path conversion: note that this will do
nothing if path is a 'file:...' url, so it will need to be
repeated in protocol code (e.g. libdap2, libdap4, etc).
*/
{
/* Skip past any leading whitespace in path */
const char* p;
for(p=(const char*)path0;*p;p++) {if(*p < 0 || *p > ' ') break;}
path = nulldup(p);
}
memset(&model,0,sizeof(model));
/* Infer model implementation and format, possibly by reading the file */
if((stat = NC_infermodel(path,&omode,0,useparallel,parameters,&model,&newpath)))
goto done;
if(newpath) {
nullfree(path);
path = newpath;
newpath = NULL;
}
/* Still no implementation, give up */
if(model.impl == 0) {
#ifdef DEBUG
fprintf(stderr,"implementation == 0\n");
#endif
{stat = NC_ENOTNC; goto done;}
}
/* Suppress unsupported formats */
#if 0
/* (should be more compact, table-driven, way to do this) */
{
int hdf5built = 0;
int hdf4built = 0;
int cdf5built = 0;
int udf0built = 0;
int udf1built = 0;
int nczarrbuilt = 0;
#ifdef USE_NETCDF4
hdf5built = 1;
#endif
#ifdef USE_HDF4
hdf4built = 1;
#endif
#ifdef NETCDF_ENABLE_CDF5
cdf5built = 1;
#endif
#ifdef NETCDF_ENABLE_NCZARR
nczarrbuilt = 1;
#endif
if(UDF0_dispatch_table != NULL)
udf0built = 1;
if(UDF1_dispatch_table != NULL)
udf1built = 1;
if(!hdf5built && model.impl == NC_FORMATX_NC4)
{stat = NC_ENOTBUILT; goto done;}
if(!hdf4built && model.impl == NC_FORMATX_NC_HDF4)
{stat = NC_ENOTBUILT; goto done;}
if(!cdf5built && model.impl == NC_FORMATX_NC3 && model.format == NC_FORMAT_CDF5)
{stat = NC_ENOTBUILT; goto done;}
if(!nczarrbuilt && model.impl == NC_FORMATX_NCZARR)
{stat = NC_ENOTBUILT; goto done;}
if(!udf0built && model.impl == NC_FORMATX_UDF0)
{stat = NC_ENOTBUILT; goto done;}
if(!udf1built && model.impl == NC_FORMATX_UDF1)
{stat = NC_ENOTBUILT; goto done;}
}
#else
{
unsigned built = 0 /* leave off the trailing semicolon so we can build constant */
| (1<<NC_FORMATX_NC3) /* NC3 always supported */
#ifdef USE_HDF5
| (1<<NC_FORMATX_NC_HDF5)
#endif
#ifdef USE_HDF4
| (1<<NC_FORMATX_NC_HDF4)
#endif
#ifdef NETCDF_ENABLE_NCZARR
| (1<<NC_FORMATX_NCZARR)
#endif
#ifdef NETCDF_ENABLE_DAP
| (1<<NC_FORMATX_DAP2)
#endif
#ifdef NETCDF_ENABLE_DAP4
| (1<<NC_FORMATX_DAP4)
#endif
#ifdef USE_PNETCDF
| (1<<NC_FORMATX_PNETCDF)
#endif
; /* end of the built flags */
if(UDF0_dispatch_table != NULL)
built |= (1<<NC_FORMATX_UDF0);
if(UDF1_dispatch_table != NULL)
built |= (1<<NC_FORMATX_UDF1);
/* Verify */
if((built & (1 << model.impl)) == 0)
{stat = NC_ENOTBUILT; goto done;}
#ifndef NETCDF_ENABLE_CDF5
/* Special case because there is no separate CDF5 dispatcher */
if(model.impl == NC_FORMATX_NC3 && (omode & NC_64BIT_DATA))
{stat = NC_ENOTBUILT; goto done;}
#endif
}
#endif
/* Figure out what dispatcher to use */
if (!dispatcher) {
switch (model.impl) {
#ifdef NETCDF_ENABLE_DAP
case NC_FORMATX_DAP2:
dispatcher = NCD2_dispatch_table;
break;
#endif
#ifdef NETCDF_ENABLE_DAP4
case NC_FORMATX_DAP4:
dispatcher = NCD4_dispatch_table;
break;
#endif
#ifdef NETCDF_ENABLE_NCZARR
case NC_FORMATX_NCZARR:
dispatcher = NCZ_dispatch_table;
break;
#endif
#ifdef USE_PNETCDF
case NC_FORMATX_PNETCDF:
dispatcher = NCP_dispatch_table;
break;
#endif
#ifdef USE_HDF5
case NC_FORMATX_NC4:
dispatcher = HDF5_dispatch_table;
break;
#endif
#ifdef USE_HDF4
case NC_FORMATX_NC_HDF4:
dispatcher = HDF4_dispatch_table;
break;
#endif
#ifdef USE_NETCDF4
case NC_FORMATX_UDF0:
dispatcher = UDF0_dispatch_table;
break;
case NC_FORMATX_UDF1:
dispatcher = UDF1_dispatch_table;
break;
#endif /* USE_NETCDF4 */
case NC_FORMATX_NC3:
dispatcher = NC3_dispatch_table;
break;
default:
stat = NC_ENOTNC;
goto done;
}
}
/* If we can't figure out what dispatch table to use, give up. */
if (!dispatcher) {stat = NC_ENOTNC; goto done;}
/* Create the NC* instance and insert its dispatcher */
if((stat = new_NC(dispatcher,path,omode,&ncp))) goto done;
/* Add to list of known open files. This assigns an ext_ncid. */
add_to_NCList(ncp);
/* Assume open will fill in remaining ncp fields */
stat = dispatcher->open(ncp->path, omode, basepe, chunksizehintp,
parameters, dispatcher, ncp->ext_ncid);
if(stat == NC_NOERR) {
if(ncidp) *ncidp = ncp->ext_ncid;
} else {
del_from_NCList(ncp);
free_NC(ncp);
}
done:
nullfree(path);
nullfree(newpath);
return stat;
}
/*Provide an internal function for generating pseudo file descriptors
for systems that are not file based (e.g. dap, memio).
*/
static int pseudofd = 0;
int
nc__pseudofd(void)
{
if(pseudofd == 0) {
#ifdef HAVE_GETRLIMIT
int maxfd = 32767; /* default */
struct rlimit rl;
if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
if(rl.rlim_max != RLIM_INFINITY)
maxfd = (int)rl.rlim_max;
if(rl.rlim_cur != RLIM_INFINITY)
maxfd = (int)rl.rlim_cur;
}
pseudofd = maxfd+1;
#endif
}
return pseudofd++;
}
nc_inq_nvars
int nc_inq_nvars(int ncid, int *nvarsp)
Learn the number of variables in a file or group.
Definition dfile.c:1654
nc_inq_user_format
int nc_inq_user_format(int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
Inquire about user-defined format.
Definition dfile.c:179
nc__create
int nc__create(const char *path, int cmode, size_t initialsz, size_t *chunksizehintp, int *ncidp)
Create a netCDF file with some extra parameters controlling classic file caching.
Definition dfile.c:470
nc_close
int nc_close(int ncid)
Close an open netCDF dataset.
Definition dfile.c:1300
nc_abort
int nc_abort(int ncid)
No longer necessary for user to invoke manually.
Definition dfile.c:1247
nc_create
int nc_create(const char *path, int cmode, int *ncidp)
Create a new netCDF file.
Definition dfile.c:398
nc_inq
int nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
Inquire about a file or group.
Definition dfile.c:1635
nc_inq_format_extended
int nc_inq_format_extended(int ncid, int *formatp, int *modep)
Obtain more detailed (vis-a-vis nc_inq_format) format information about an open dataset.
Definition dfile.c:1582
nc_close_memio
int nc_close_memio(int ncid, NC_memio *memio)
Do a normal close (see nc_close()) on an in-memory dataset, then return a copy of the final memory co...
Definition dfile.c:1359
nc__enddef
int nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
Leave define mode with performance tuning.
Definition dfile.c:1118
nc_set_fill
int nc_set_fill(int ncid, int fillmode, int *old_modep)
Change the fill-value mode to improve write performance.
Definition dfile.c:1474
nc_create_mem
int nc_create_mem(const char *path, int mode, size_t initialsize, int *ncidp)
Create a netCDF file with the contents stored in memory.
Definition dfile.c:516
nc__open
int nc__open(const char *path, int omode, size_t *chunksizehintp, int *ncidp)
Open a netCDF file with extra performance parameters for the classic library.
Definition dfile.c:721
nc_inq_path
int nc_inq_path(int ncid, size_t *pathlen, char *path)
Get the file pathname (or the opendap URL) which was used to open/create the ncid's file.
Definition dfile.c:898
nc_open_mem
int nc_open_mem(const char *path, int omode, size_t size, void *memory, int *ncidp)
Open a netCDF file with the contents taken from a block of memory.
Definition dfile.c:776
nc_def_user_format
int nc_def_user_format(int mode_flag, NC_Dispatch *dispatch_table, char *magic_number)
Add handling of user-defined format.
Definition dfile.c:123
nc_inq_type
int nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
Inquire about a type.
Definition dfile.c:1728
nc_enddef
int nc_enddef(int ncid)
Leave define mode.
Definition dfile.c:1027
nc_redef
int nc_redef(int ncid)
Put open netcdf dataset into define mode.
Definition dfile.c:963
nc_open
int nc_open(const char *path, int omode, int *ncidp)
Open an existing netCDF file.
Definition dfile.c:664
nc_open_memio
int nc_open_memio(const char *path, int omode, NC_memio *params, int *ncidp)
Open a netCDF file with the contents taken from a block of memory.
Definition dfile.c:841
nc_inq_format
int nc_inq_format(int ncid, int *formatp)
Inquire about the binary format of a netCDF file as presented by the API.
Definition dfile.c:1547
nc_sync
int nc_sync(int ncid)
Synchronize an open netcdf dataset to disk.
Definition dfile.c:1195
check_create_mode
static int check_create_mode(int mode)
Check the create mode parameter for sanity.
Definition dfile.c:1775
NC_MAX_MAGIC_NUMBER_LEN
#define NC_MAX_MAGIC_NUMBER_LEN
Max len of user-defined format magic number.
Definition netcdf.h:178
NC_NETCDF4
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
Definition netcdf.h:162
NC_UDF0
#define NC_UDF0
User-defined format 0.
Definition netcdf.h:146
NC_EDISKLESS
#define NC_EDISKLESS
Error in using diskless access.
Definition netcdf.h:519
NC_SIZEHINT_DEFAULT
#define NC_SIZEHINT_DEFAULT
Let nc__create() or nc__open() figure out a suitable buffer size.
Definition netcdf.h:255
NC_EBADTYPE
#define NC_EBADTYPE
Not a netcdf data type.
Definition netcdf.h:420
NC_MMAP
#define NC_MMAP
Definition netcdf.h:141
NC_INMEMORY
#define NC_INMEMORY
Read from memory.
Definition netcdf.h:172
NC_CDF5
#define NC_CDF5
Alias NC_CDF5 to NC_64BIT_DATA.
Definition netcdf.h:144
NC_FORMATX_NC3
#define NC_FORMATX_NC3
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:225
NC_FORMATX_NCZARR
#define NC_FORMATX_NCZARR
Added in version 4.8.0.
Definition netcdf.h:234
NC_ENOTNC
#define NC_ENOTNC
Not a netcdf file.
Definition netcdf.h:434
NC_NAT
#define NC_NAT
Not A Type.
Definition netcdf.h:34
NC_64BIT_OFFSET
#define NC_64BIT_OFFSET
Use large (64-bit) file offsets.
Definition netcdf.h:150
NC_EINMEMORY
#define NC_EINMEMORY
In-memory file error.
Definition netcdf.h:526
NC_FORMATX_UDF1
#define NC_FORMATX_UDF1
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:233
NC_FORMATX_PNETCDF
#define NC_FORMATX_PNETCDF
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:229
NC_FORMAT_CDF5
#define NC_FORMAT_CDF5
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition netcdf.h:200
NC_FORMATX_NC_HDF4
#define NC_FORMATX_NC_HDF4
netCDF-4 subset of HDF4
Definition netcdf.h:228
NC_WRITE
#define NC_WRITE
Set read-write access for nc_open().
Definition netcdf.h:136
NC_FORMATX_NC_HDF5
#define NC_FORMATX_NC_HDF5
netCDF-4 subset of HDF5
Definition netcdf.h:226
NC_FORMATX_DAP4
#define NC_FORMATX_DAP4
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:231
NC_FORMATX_UDF0
#define NC_FORMATX_UDF0
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:232
NC_DISKLESS
#define NC_DISKLESS
Use diskless file.
Definition netcdf.h:140
NC_FORMATX_DAP2
#define NC_FORMATX_DAP2
Extended format specifier returned by nc_inq_format_extended() Added in version 4....
Definition netcdf.h:230
NC_EINVAL
#define NC_EINVAL
Invalid Argument.
Definition netcdf.h:388
NC_CLASSIC_MODEL
#define NC_CLASSIC_MODEL
Enforce classic model on netCDF-4.
Definition netcdf.h:149
NC_MAX_NAME
#define NC_MAX_NAME
Maximum for classic library.
Definition netcdf.h:291
NC_NOERR
#define NC_NOERR
No Error.
Definition netcdf.h:378
NC_64BIT_DATA
#define NC_64BIT_DATA
CDF-5 format: classic model but 64 bit dimensions and sizes.
Definition netcdf.h:143
NC_ENOTBUILT
#define NC_ENOTBUILT
Attempt to use feature that was not turned on when netCDF was built.
Definition netcdf.h:518
NC_UDF1
#define NC_UDF1
User-defined format 1.
Definition netcdf.h:147
nc_type
int nc_type
The nc_type type is just an int.
Definition netcdf.h:25
NC_FORMATX_NC4
#define NC_FORMATX_NC4
alias
Definition netcdf.h:227
netcdf_mem.h
Main header file for in-memory (diskless) functionality.
NC_memio
Definition netcdf_mem.h:22