mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-31 17:50:26 +08:00
removed NC from open in dispatch table
This commit is contained in:
parent
64f983ee14
commit
170c5b0901
@ -40,7 +40,7 @@ extern "C" {
|
||||
|
||||
extern int
|
||||
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const NC_Dispatch *, NC *);
|
||||
void *parameters, const NC_Dispatch *, int);
|
||||
|
||||
extern int
|
||||
NC_HDF4_abort(int ncid);
|
||||
|
@ -53,7 +53,7 @@ extern "C" {
|
||||
extern int
|
||||
NC3_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const struct NC_Dispatch*, NC* ncp);
|
||||
void* mpidata, const struct NC_Dispatch*, int ncid);
|
||||
|
||||
/* WARNING: this signature differs from external nc_open API*/
|
||||
extern int
|
||||
|
@ -23,12 +23,12 @@ extern "C" {
|
||||
EXTERNL int
|
||||
NC4_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
void* parameters, const NC_Dispatch*, NC*);
|
||||
void* parameters, const NC_Dispatch*, int);
|
||||
|
||||
EXTERNL int
|
||||
NC4_open(const char *path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
void* parameters, const NC_Dispatch*, NC*);
|
||||
void* parameters, const NC_Dispatch*, int);
|
||||
|
||||
EXTERNL int
|
||||
NC4_redef(int ncid);
|
||||
|
@ -25,9 +25,9 @@ struct NC_Dispatch
|
||||
|
||||
int (*create)(const char *path, int cmode, size_t initialsz,
|
||||
int basepe, size_t *chunksizehintp, void *parameters,
|
||||
const struct NC_Dispatch *table, NC *ncp);
|
||||
const struct NC_Dispatch *table, int ncid);
|
||||
int (*open)(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const struct NC_Dispatch *table, NC *ncp);
|
||||
void *parameters, const struct NC_Dispatch *table, int ncid);
|
||||
|
||||
int (*redef)(int);
|
||||
int (*_enddef)(int,size_t,size_t,size_t,size_t);
|
||||
@ -140,7 +140,7 @@ struct NC_Dispatch
|
||||
|
||||
EXTERNL int NC_RO_create(const char *path, int cmode, size_t initialsz, int basepe,
|
||||
size_t *chunksizehintp, void* parameters,
|
||||
const NC_Dispatch*, NC*);
|
||||
const NC_Dispatch*, int);
|
||||
EXTERNL int NC_RO_redef(int ncid);
|
||||
EXTERNL int NC_RO__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
|
||||
size_t r_align);
|
||||
|
@ -63,7 +63,7 @@ static NCerror applyclientparams(NCDAPCOMMON*);
|
||||
static int
|
||||
NCD2_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const struct NC_Dispatch*,NC* ncp);
|
||||
void* mpidata, const struct NC_Dispatch*,int);
|
||||
|
||||
static int NCD2_redef(int ncid);
|
||||
static int NCD2__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align);
|
||||
@ -227,7 +227,7 @@ NCD2_abort(int ncid)
|
||||
static int
|
||||
NCD2_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const NC_Dispatch* dispatch, NC* ncp)
|
||||
void* mpidata, const NC_Dispatch* dispatch, int ncid)
|
||||
{
|
||||
return NC_EPERM;
|
||||
}
|
||||
@ -271,7 +271,7 @@ NCD2_get_vars(int ncid, int varid,
|
||||
/* See ncd2dispatch.c for other version */
|
||||
int
|
||||
NCD2_open(const char* path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const NC_Dispatch* dispatch, NC* drno1)
|
||||
void* mpidata, const NC_Dispatch* dispatch, int ncid)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
OCerror ocstat = OC_NOERR;
|
||||
@ -281,7 +281,7 @@ NCD2_open(const char* path, int mode, int basepe, size_t *chunksizehintp,
|
||||
int nc3id = -1;
|
||||
|
||||
/* Find pointer to NC struct for this file. */
|
||||
ncstat = NC_check_id(drno1->ext_ncid,&drno);
|
||||
ncstat = NC_check_id(ncid,&drno);
|
||||
if(ncstat != NC_NOERR) {goto done;}
|
||||
|
||||
if(path == NULL)
|
||||
|
@ -46,7 +46,7 @@ extern "C" {
|
||||
extern int
|
||||
NCD2_open(const char *path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const struct NC_Dispatch* dispatch, NC* ncp);
|
||||
void* mpidata, const struct NC_Dispatch* dispatch, int ncid);
|
||||
|
||||
extern int
|
||||
NCD2_close(int ncid,void*);
|
||||
|
@ -38,7 +38,7 @@ static const char* checkseps = "+,:;";
|
||||
int
|
||||
NCD4_open(const char * path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
void *mpidata, const NC_Dispatch *dispatch, NC *nc1)
|
||||
void *mpidata, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
int ret = NC_NOERR;
|
||||
NCD4INFO* d4info = NULL;
|
||||
@ -52,7 +52,7 @@ NCD4_open(const char * path, int mode,
|
||||
assert(dispatch != NULL);
|
||||
|
||||
/* Find pointer to NC struct for this file. */
|
||||
ret = NC_check_id(nc1->ext_ncid,&nc);
|
||||
ret = NC_check_id(ncid,&nc);
|
||||
if(ret != NC_NOERR) {goto done;}
|
||||
|
||||
/* Setup our NC and NCDAPCOMMON state*/
|
||||
|
@ -85,7 +85,7 @@ NCD4_sync(int ncid)
|
||||
static int
|
||||
NCD4_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
void* mpidata, const NC_Dispatch *dispatch, NC *ncp)
|
||||
void* mpidata, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
return THROW(NC_EPERM);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ extern "C" {
|
||||
extern int
|
||||
NCD4_open(const char *path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
void *mpidata, const struct NC_Dispatch *dispatch, NC *ncp);
|
||||
void *mpidata, const struct NC_Dispatch *dispatch, int ncid);
|
||||
|
||||
extern int
|
||||
NCD4_close(int ncid,void*);
|
||||
|
@ -1901,7 +1901,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
|
||||
|
||||
/* Assume create will fill in remaining ncp fields */
|
||||
if ((stat = dispatcher->create(ncp->path, cmode, initialsz, basepe, chunksizehintp,
|
||||
parameters, dispatcher, ncp))) {
|
||||
parameters, dispatcher, ncp->ext_ncid))) {
|
||||
del_from_NCList(ncp); /* oh well */
|
||||
free_NC(ncp);
|
||||
} else {
|
||||
@ -2090,12 +2090,12 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp,
|
||||
/* Create the NC* instance and insert its dispatcher */
|
||||
if((stat = new_NC(dispatcher,path,omode,&model,&ncp))) goto done;
|
||||
|
||||
/* Add to list of known open files */
|
||||
/* Add to list of known open files. This assignes 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);
|
||||
parameters, dispatcher, ncp->ext_ncid);
|
||||
if(stat == NC_NOERR) {
|
||||
if(ncidp) *ncidp = ncp->ext_ncid;
|
||||
} else {
|
||||
|
@ -245,7 +245,7 @@ NC_RO_sync(int ncid)
|
||||
* @param use_parallel Ignored.
|
||||
* @param parameters Ignored.
|
||||
* @param dispatch Ignored.
|
||||
* @param nc_file Ignored.
|
||||
* @param ncid Ignored.
|
||||
*
|
||||
* @return ::NC_EPERM Cannot create files.
|
||||
* @author Ed Hartnett
|
||||
@ -253,7 +253,7 @@ NC_RO_sync(int ncid)
|
||||
int
|
||||
NC_RO_create(const char* path, int cmode, size_t initialsz, int basepe,
|
||||
size_t *chunksizehintp, void *parameters,
|
||||
const NC_Dispatch *dispatch, NC *nc_file)
|
||||
const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
return NC_EPERM;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ hdf4_read_var(NC_FILE_INFO_T *h5, int v)
|
||||
*/
|
||||
int
|
||||
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
|
||||
void *parameters, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_HDF4_FILE_INFO_T *hdf4_file;
|
||||
@ -608,12 +608,12 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
int retval;
|
||||
|
||||
/* Check inputs. */
|
||||
assert(nc_file && path);
|
||||
assert(path);
|
||||
|
||||
LOG((1, "%s: path %s mode %d params %x", __func__, path, mode, parameters));
|
||||
|
||||
/* Find pointer to NC. */
|
||||
if ((retval = NC_check_id(nc_file->ext_ncid, &nc1)))
|
||||
if ((retval = NC_check_id(ncid, &nc1)))
|
||||
return retval;
|
||||
|
||||
/* Check the mode for validity */
|
||||
|
@ -262,7 +262,8 @@ exit: /*failure exit*/
|
||||
* @param parameters pointer to struct holding extra data (e.g. for
|
||||
* parallel I/O) layer. Ignored if NULL.
|
||||
* @param dispatch Pointer to the dispatch table for this file.
|
||||
* @param nc_file Pointer to an instance of NC.
|
||||
* @param ncid The ncid that has been assigned by the dispatch layer
|
||||
* (aka ext_ncid).
|
||||
*
|
||||
* @return ::NC_NOERR No error.
|
||||
* @return ::NC_EINVAL Invalid input (check cmode).
|
||||
@ -272,11 +273,12 @@ exit: /*failure exit*/
|
||||
int
|
||||
NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
|
||||
size_t *chunksizehintp, void *parameters,
|
||||
const NC_Dispatch *dispatch, NC *nc_file)
|
||||
const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
NC *nc_file;
|
||||
int res;
|
||||
|
||||
assert(nc_file && path);
|
||||
assert(path);
|
||||
|
||||
LOG((1, "%s: path %s cmode 0x%x parameters %p",
|
||||
__func__, path, cmode, parameters));
|
||||
@ -293,9 +295,14 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
|
||||
|
||||
/* Check the cmode for validity. Checking parallel against
|
||||
* NC_DISKLESS already done in NC_create(). */
|
||||
if((cmode & ILLEGAL_CREATE_FLAGS) != 0)
|
||||
if (cmode & ILLEGAL_CREATE_FLAGS)
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Find pointer to NC. */
|
||||
if ((res = NC_check_id(ncid, &nc_file)))
|
||||
return res;
|
||||
assert(nc_file);
|
||||
|
||||
/* Create the netCDF-4/HDF5 file. */
|
||||
res = nc4_create_file(path, cmode, initialsz, parameters, nc_file);
|
||||
|
||||
|
@ -622,7 +622,7 @@ check_for_classic_model(NC_GRP_INFO_T *root_grp, int *is_classic)
|
||||
* @param path The file name of the new file.
|
||||
* @param mode The open mode flag.
|
||||
* @param parameters File parameters.
|
||||
* @param nc Pointer to NC file info.
|
||||
* @param ncid The ncid that has been assigned to this file.
|
||||
*
|
||||
* @return ::NC_NOERR No error.
|
||||
* @return ::NC_ENOMEM Out of memory.
|
||||
@ -634,11 +634,11 @@ check_for_classic_model(NC_GRP_INFO_T *root_grp, int *is_classic)
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
static int
|
||||
nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
|
||||
nc4_open_file(const char *path, int mode, void* parameters, int ncid)
|
||||
{
|
||||
NC_FILE_INFO_T *nc4_info = NULL;
|
||||
NC_HDF5_FILE_INFO_T *h5 = NULL;
|
||||
NC *nc1;
|
||||
NC *nc;
|
||||
hid_t fapl_id = H5P_DEFAULT;
|
||||
unsigned flags;
|
||||
int is_classic;
|
||||
@ -650,12 +650,12 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
|
||||
int retval;
|
||||
|
||||
LOG((3, "%s: path %s mode %d", __func__, path, mode));
|
||||
assert(path && nc);
|
||||
assert(path);
|
||||
|
||||
/* Find pointer to NC. */
|
||||
if ((retval = NC_check_id(nc->ext_ncid, &nc1)))
|
||||
if ((retval = NC_check_id(ncid, &nc)))
|
||||
return retval;
|
||||
assert(nc1);
|
||||
assert(nc && nc->model->impl == NC_FORMATX_NC4);
|
||||
|
||||
/* Determine the HDF5 open flag to use. */
|
||||
flags = (mode & NC_WRITE) ? H5F_ACC_RDWR : H5F_ACC_RDONLY;
|
||||
@ -868,10 +868,9 @@ exit:
|
||||
*/
|
||||
int
|
||||
NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
|
||||
void *parameters, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
assert(nc_file && path && dispatch && nc_file &&
|
||||
nc_file->model->impl == NC_FORMATX_NC4);
|
||||
assert(path && dispatch);
|
||||
|
||||
LOG((1, "%s: path %s mode %d params %x",
|
||||
__func__, path, mode, parameters));
|
||||
@ -894,7 +893,7 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
#endif /* LOGGING */
|
||||
|
||||
/* Open the file. */
|
||||
return nc4_open_file(path, mode, parameters, nc_file);
|
||||
return nc4_open_file(path, mode, parameters, ncid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1039,7 +1039,7 @@ int NC3_new_nc(NC3_INFO** ncpp)
|
||||
int
|
||||
NC3_create(const char *path, int ioflags, size_t initialsz, int basepe,
|
||||
size_t *chunksizehintp, void *parameters,
|
||||
const NC_Dispatch *dispatch, NC *nc1)
|
||||
const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
int status = NC_NOERR;
|
||||
void *xp = NULL;
|
||||
@ -1048,7 +1048,7 @@ NC3_create(const char *path, int ioflags, size_t initialsz, int basepe,
|
||||
NC3_INFO* nc3 = NULL;
|
||||
|
||||
/* Find NC struct for this file. */
|
||||
if ((status = NC_check_id(nc1->ext_ncid, &nc)))
|
||||
if ((status = NC_check_id(ncid, &nc)))
|
||||
return status;
|
||||
|
||||
/* Create our specific NC3_INFO instance */
|
||||
@ -1176,14 +1176,14 @@ nc_set_default_format(int format, int *old_formatp)
|
||||
|
||||
int
|
||||
NC3_open(const char *path, int ioflags, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const NC_Dispatch *dispatch, NC *nc1)
|
||||
void *parameters, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
int status;
|
||||
NC3_INFO* nc3 = NULL;
|
||||
NC *nc;
|
||||
|
||||
/* Find NC struct for this file. */
|
||||
if ((status = NC_check_id(nc1->ext_ncid, &nc)))
|
||||
if ((status = NC_check_id(ncid, &nc)))
|
||||
return status;
|
||||
|
||||
/* Create our specific NC3_INFO instance */
|
||||
|
@ -45,14 +45,14 @@ NCP_create(const char *path,
|
||||
size_t *chunksizehintp,
|
||||
void *mpidata,
|
||||
const struct NC_Dispatch *table,
|
||||
NC *nc1)
|
||||
int ncid)
|
||||
{
|
||||
int status;
|
||||
NCP_INFO *nc5;
|
||||
NC *nc;
|
||||
|
||||
/* Find pointer to NC for this file. */
|
||||
status = NC_check_id(nc1->ext_ncid, &nc);
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if (status != NC_NOERR) return status;
|
||||
|
||||
/* Check the cmode for only valid flags */
|
||||
@ -87,14 +87,14 @@ NCP_open(const char *path,
|
||||
size_t *chunksizehintp,
|
||||
void *mpidata,
|
||||
const struct NC_Dispatch *table,
|
||||
NC *nc1)
|
||||
int ncid)
|
||||
{
|
||||
int status;
|
||||
NCP_INFO *nc5;
|
||||
NC *nc;
|
||||
|
||||
/* Find pointer to NC for this file. */
|
||||
status = NC_check_id(nc1->ext_ncid, &nc);
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if (status != NC_NOERR) return status;
|
||||
|
||||
/* Check the omode for only valid flags */
|
||||
|
@ -26,7 +26,7 @@ NC4_show_metadata(int ncid)
|
||||
|
||||
int
|
||||
tst_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
|
||||
void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
|
||||
void *parameters, const NC_Dispatch *dispatch, int ncid)
|
||||
{
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user