mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-25 17:40:27 +08:00
Support no-op dispatch functions
re: https://github.com/Unidata/netcdf-c/issues/1693 1. Add functions to libdispatch/dnotnc4.c to support dispatch table operations that should work for any dispatch table, even if they do not do anything. Functions such as nc_inq_var_filter. 2. Modify selected dispatch tables to utilize the noop functions. 3. Extend nc_test/tst_formats.c to test. This is an extension of Ed's work to do this for chunking and deflate and szip. See PRs https://github.com/Unidata/netcdf-c/pull/1697 and https://github.com/Unidata/netcdf-c/pull/1692 As a side effect, elide libdispatch/dnotnc3.c since it is no longer used.
This commit is contained in:
parent
a8732ca1e5
commit
f0cd7f8ec1
@ -180,16 +180,6 @@ extern "C" {
|
||||
EXTERNL int NC_RO_rename_dim(int ncid, int dimid, const char *name);
|
||||
EXTERNL int NC_RO_set_fill(int ncid, int fillmode, int *old_modep);
|
||||
|
||||
/* These functions are for dispatch layers that don't implement
|
||||
* these legacy functions. They return NC_ENOTNC3. */
|
||||
EXTERNL int NC_NOTNC3_put_varm(int ncid, int varid, const size_t * start,
|
||||
const size_t *edges, const ptrdiff_t *stride,
|
||||
const ptrdiff_t *imapp, const void *value0,
|
||||
nc_type memtype);
|
||||
EXTERNL int NC_NOTNC3_get_varm(int ncid, int varid, const size_t *start,
|
||||
const size_t *edges, const ptrdiff_t *stride,
|
||||
const ptrdiff_t *imapp, void *value0, nc_type memtype);
|
||||
|
||||
/* These functions are for dispatch layers that don't implement
|
||||
* the enhanced model. They return NC_ENOTNC4. */
|
||||
EXTERNL int NC_NOTNC4_def_var_filter(int, int, unsigned int, size_t,
|
||||
@ -230,9 +220,16 @@ extern "C" {
|
||||
EXTERNL int NC_NOTNC4_inq_typeids(int, int *, int *);
|
||||
EXTERNL int NC_NOTNC4_inq_user_type(int, nc_type, char *, size_t *,
|
||||
nc_type *, size_t *, int *);
|
||||
EXTERNL int NC_NOTNC4_inq_typeid(int, const char *, nc_type *);
|
||||
EXTERNL int NC_NOTNC4_filter_actions(int, int, int, struct NC_Filterobject*);
|
||||
|
||||
/* These functions are for dispatch layers that don't implement
|
||||
* the enhanced model, but want to succeed anyway.
|
||||
* They return NC_NOERR plus properly set the out parameters.
|
||||
* In some cases (filter actions), some cases may succeed and some
|
||||
* will fail.
|
||||
*/
|
||||
EXTERNL int NC_NOOP_filter_actions(int, int, int, struct NC_Filterobject*);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -175,7 +175,7 @@ NCD2_def_var_filter,
|
||||
NCD2_set_var_chunk_cache,
|
||||
NCD2_get_var_chunk_cache,
|
||||
|
||||
NC_NOTNC4_filter_actions,
|
||||
NC_NOOP_filter_actions,
|
||||
|
||||
};
|
||||
|
||||
|
@ -241,14 +241,6 @@ NCD4_set_var_chunk_cache(int ncid, int p2, size_t p3, size_t p4, float p5)
|
||||
return (NC_EPERM);
|
||||
}
|
||||
|
||||
struct NC_FILTER_ACTION;
|
||||
|
||||
static int
|
||||
NCD4_filter_actions(int ncid, int varid, int action, struct NC_Filterobject* spec)
|
||||
{
|
||||
return (NC_EPERM);
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/*
|
||||
Following functions basically return the netcdf-4 value WRT to the nc4id.
|
||||
@ -870,7 +862,7 @@ NCD4_def_var_filter,
|
||||
NCD4_set_var_chunk_cache,
|
||||
NCD4_get_var_chunk_cache,
|
||||
|
||||
NCD4_filter_actions,
|
||||
NC_NOOP_filter_actions,
|
||||
};
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ libdispatch_la_SOURCES = dparallel.c dcopy.c dfile.c ddim.c datt.c \
|
||||
dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c \
|
||||
dvarinq.c dinternal.c ddispatch.c dutf8.c nclog.c dstring.c ncuri.c \
|
||||
nclist.c ncbytes.c nchashmap.c nctime.c nc.c nclistmgr.c \
|
||||
dauth.c doffsets.c dwinpath.c dutil.c dreadonly.c dnotnc4.c dnotnc3.c \
|
||||
dauth.c doffsets.c dwinpath.c dutil.c dreadonly.c dnotnc4.c \
|
||||
crc32.c crc32.h daux.c dinfermodel.c
|
||||
|
||||
# Add the utf8 codebase
|
||||
|
@ -2,10 +2,15 @@
|
||||
* and redistribution conditions.*/
|
||||
/**
|
||||
* @file
|
||||
* @internal This file contains functions that return NC_ENOTNC4, for
|
||||
* dispatch layers that only implement the classic model.
|
||||
* @internal This file contains functions that
|
||||
* can be used in dispatch tables to handle
|
||||
* such things as unimplemented functions.
|
||||
* As a rule, these functions will return NC_ENOTNC4.
|
||||
* In some cases, the function may succeed and set
|
||||
* appropriate output parameter values. These are indicated
|
||||
* by the NC_NOOP prefix to the function name.
|
||||
*
|
||||
* @author Ed Hartnett
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
|
||||
#include "netcdf.h"
|
||||
@ -14,7 +19,7 @@
|
||||
#include "nc4internal.h"
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented in some dispatch tables
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
@ -22,7 +27,7 @@
|
||||
* @param nparams Ignored.
|
||||
* @param parms Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -40,7 +45,7 @@ NC_NOTNC4_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams,
|
||||
* @param name Ignored.
|
||||
* @param new_ncid Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -50,12 +55,12 @@ NC_NOTNC4_def_grp(int parent_ncid, const char *name, int *new_ncid)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param grpid Ignored.
|
||||
* @param name Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -65,14 +70,14 @@ NC_NOTNC4_rename_grp(int grpid, const char *name)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param size Ignored.
|
||||
* @param name Ignored.
|
||||
* @param typeidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -82,7 +87,7 @@ NC_NOTNC4_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -90,7 +95,7 @@ NC_NOTNC4_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp
|
||||
* @param offset Ignored.
|
||||
* @param field Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -101,7 +106,7 @@ NC_NOTNC4_insert_compound(int ncid, nc_type typeid1, const char *name, size_t of
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -111,7 +116,7 @@ NC_NOTNC4_insert_compound(int ncid, nc_type typeid1, const char *name, size_t of
|
||||
* @param ndims Ignored.
|
||||
* @param dim Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
extern int
|
||||
@ -123,7 +128,7 @@ NC_NOTNC4_insert_array_compound(int ncid, int typeid1, const char *name,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -134,7 +139,7 @@ NC_NOTNC4_insert_array_compound(int ncid, int typeid1, const char *name,
|
||||
* @param ndimsp Ignored.
|
||||
* @param dim Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -146,14 +151,14 @@ NC_NOTNC4_inq_compound_field(int ncid, nc_type typeid1, int fieldid, char *name,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
* @param name Ignored.
|
||||
* @param fieldidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -165,14 +170,14 @@ NC_NOTNC4_inq_compound_fieldindex(int ncid, nc_type typeid1, const char *name, i
|
||||
/* Opaque type. */
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param datum Ignored.
|
||||
* @param name Ignored.
|
||||
* @param typeidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -183,14 +188,14 @@ NC_NOTNC4_def_opaque(int ncid, size_t datum_size, const char *name,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param name Ignored.
|
||||
* @param base_typeid Ignored.
|
||||
* @param typeidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -201,14 +206,14 @@ NC_NOTNC4_def_vlen(int ncid, const char *name, nc_type base_typeid,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param base_typeid Ignored.
|
||||
* @param name Ignored.
|
||||
* @param typeidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -220,14 +225,14 @@ NC_NOTNC4_def_enum(int ncid, nc_type base_typeid, const char *name,
|
||||
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param xtype Ignored.
|
||||
* @param value Ignored.
|
||||
* @param identifier Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -237,7 +242,7 @@ NC_NOTNC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identif
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -245,7 +250,7 @@ NC_NOTNC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identif
|
||||
* @param identifier Ignored.
|
||||
* @param value Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -256,14 +261,14 @@ NC_NOTNC4_inq_enum_member(int ncid, nc_type typeid1, int idx, char *identifier,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
* @param identifier Ignored.
|
||||
* @param value Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -274,7 +279,7 @@ NC_NOTNC4_insert_enum(int ncid, nc_type typeid1, const char *identifier,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -293,7 +298,7 @@ NC_NOTNC4_put_vlen_element(int ncid, int typeid1, void *vlen_element,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -301,7 +306,7 @@ NC_NOTNC4_put_vlen_element(int ncid, int typeid1, void *vlen_element,
|
||||
* @param len Ignored.
|
||||
* @param data Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -312,7 +317,7 @@ NC_NOTNC4_get_vlen_element(int ncid, int typeid1, const void *vlen_element,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
@ -320,7 +325,7 @@ NC_NOTNC4_get_vlen_element(int ncid, int typeid1, const void *vlen_element,
|
||||
* @param nelems Ignored.
|
||||
* @param preemption Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -331,7 +336,7 @@ NC_NOTNC4_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
@ -339,7 +344,7 @@ NC_NOTNC4_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems,
|
||||
* @param nelemsp Ignored.
|
||||
* @param preemptionp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -350,7 +355,7 @@ NC_NOTNC4_get_var_chunk_cache(int ncid, int varid, size_t *sizep,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
@ -358,7 +363,7 @@ NC_NOTNC4_get_var_chunk_cache(int ncid, int varid, size_t *sizep,
|
||||
* @param deflate Ignored.
|
||||
* @param deflate_level Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
int
|
||||
@ -369,13 +374,13 @@ NC_NOTNC4_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
* @param fletcher32 Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
int
|
||||
@ -385,14 +390,14 @@ NC_NOTNC4_def_var_fletcher32(int ncid, int varid, int fletcher32)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
* @param contiguous Ignored.
|
||||
* @param chunksizesp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
int
|
||||
@ -403,13 +408,13 @@ NC_NOTNC4_def_var_chunking(int ncid, int varid, int contiguous, const size_t *ch
|
||||
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
* @param endianness Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -419,13 +424,13 @@ NC_NOTNC4_def_var_endian(int ncid, int varid, int endianness)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param varid Ignored.
|
||||
* @param par_access Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
int
|
||||
@ -435,13 +440,13 @@ NC_NOTNC4_var_par_access(int ncid, int varid, int par_access)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param name Ignored.
|
||||
* @param grp_ncid Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -451,13 +456,13 @@ NC_NOTNC4_inq_ncid(int ncid, const char *name, int *grp_ncid)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param numgrps Ignored.
|
||||
* @param ncids Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -467,12 +472,12 @@ NC_NOTNC4_inq_grps(int ncid, int *numgrps, int *ncids)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param name Ignored.
|
||||
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -482,13 +487,13 @@ NC_NOTNC4_inq_grpname(int ncid, char *name)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param lenp Ignored.
|
||||
* @param full_name Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -498,12 +503,12 @@ NC_NOTNC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param parent_ncid Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -513,13 +518,13 @@ NC_NOTNC4_inq_grp_parent(int ncid, int *parent_ncid)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param full_name Ignored.
|
||||
* @param grp_ncid Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -529,13 +534,13 @@ NC_NOTNC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param nvars Ignored.
|
||||
* @param varids Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -545,14 +550,14 @@ NC_NOTNC4_inq_varids(int ncid, int *nvars, int *varids)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param ndims Ignored.
|
||||
* @param dimids Ignored.
|
||||
* @param include_parents Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -562,13 +567,13 @@ NC_NOTNC4_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param ntypes Ignored.
|
||||
* @param typeids Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -578,7 +583,7 @@ NC_NOTNC4_inq_typeids(int ncid, int *ntypes, int *typeids)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not allowed for classic model.
|
||||
* @internal Not implemented for a dispatch table.
|
||||
*
|
||||
* @param ncid Ignored.
|
||||
* @param typeid1 Ignored.
|
||||
@ -588,7 +593,7 @@ NC_NOTNC4_inq_typeids(int ncid, int *ntypes, int *typeids)
|
||||
* @param nfieldsp Ignored.
|
||||
* @param classp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -605,11 +610,28 @@ NC_NOTNC4_inq_user_type(int ncid, nc_type typeid1, char *name, size_t *size,
|
||||
* @param name Ignored.
|
||||
* @param typeidp Ignored.
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
NC_NOTNC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
|
||||
{
|
||||
/* Note that this should actually work for atomic types */
|
||||
return NC_ENOTNC4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Carry out one of several filter actions
|
||||
*
|
||||
* @param ncid Containing group id
|
||||
* @param varid Containing variable id
|
||||
* @param action Action to perform
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not implemented for a dispatch table.
|
||||
* @author D. Heimbigner
|
||||
*/
|
||||
int
|
||||
NC_NOTNC4_filter_actions(int ncid, int varid, int action, struct NC_Filterobject* spec)
|
||||
{
|
||||
return NC_ENOTNC4;
|
||||
}
|
||||
@ -621,11 +643,23 @@ NC_NOTNC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
|
||||
* @param varid Containing variable id
|
||||
* @param action Action to perform
|
||||
*
|
||||
* @return ::NC_ENOTNC4 Not allowed for classic model.
|
||||
* @return ::NC_NOERR Implemented as a no-op.
|
||||
* @return ::NC_ENOTNC4 Not implemented
|
||||
* @return ::NC_ENOFILTER No filter defined
|
||||
* @author D. Heimbigner
|
||||
*/
|
||||
int
|
||||
NC_NOTNC4_filter_actions(int ncid, int varid, int action, struct NC_Filterobject* spec)
|
||||
NC_NOOP_filter_actions(int ncid, int varid, int action, struct NC_Filterobject* args)
|
||||
{
|
||||
return NC_ENOTNC4;
|
||||
NC_FILTER_OBJ_HDF5* obj = (NC_FILTER_OBJ_HDF5*)args;
|
||||
switch (action) {
|
||||
case NCFILTER_FILTERIDS:
|
||||
obj->u.ids.nfilters = 0;
|
||||
return NC_NOERR;
|
||||
case NCFILTER_INQ: /* fall thrue */
|
||||
case NCFILTER_INFO:
|
||||
return NC_ENOFILTER;
|
||||
default:
|
||||
return NC_ENOTNC4;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ static const NC_Dispatch HDF4_dispatcher = {
|
||||
NC_NOTNC4_set_var_chunk_cache,
|
||||
NC_NOTNC4_get_var_chunk_cache,
|
||||
|
||||
NC_NOTNC4_filter_actions,
|
||||
NC_NOOP_filter_actions,
|
||||
};
|
||||
|
||||
const NC_Dispatch *HDF4_dispatch_table = NULL;
|
||||
|
@ -164,7 +164,7 @@ NC3_def_var_filter,
|
||||
NC3_set_var_chunk_cache,
|
||||
NC3_get_var_chunk_cache,
|
||||
|
||||
NC_NOTNC4_filter_actions,
|
||||
NC_NOOP_filter_actions,
|
||||
};
|
||||
|
||||
const NC_Dispatch* NC3_dispatch_table = NULL; /*!< NC3 Dispatch table, moved here from ddispatch.c */
|
||||
|
@ -1461,7 +1461,7 @@ NC_NOTNC4_def_var_filter,
|
||||
NC_NOTNC4_set_var_chunk_cache,
|
||||
NC_NOTNC4_get_var_chunk_cache,
|
||||
|
||||
NC_NOTNC4_filter_actions,
|
||||
NC_NOOP_filter_actions,
|
||||
};
|
||||
|
||||
const NC_Dispatch *NCP_dispatch_table = NULL; /* moved here from ddispatch.c */
|
||||
|
@ -24,226 +24,249 @@
|
||||
void
|
||||
determine_test_formats(int *num_formats, int *format)
|
||||
{
|
||||
int ind = 0;
|
||||
int num;
|
||||
int ind = 0;
|
||||
int num;
|
||||
|
||||
/* Check inputs. */
|
||||
assert(num_formats && format);
|
||||
/* Check inputs. */
|
||||
assert(num_formats && format);
|
||||
|
||||
/* We always have classic and 64-bit offset */
|
||||
num = 2;
|
||||
format[ind++] = NC_FORMAT_CLASSIC;
|
||||
format[ind++] = NC_FORMAT_64BIT_OFFSET;
|
||||
/* We always have classic and 64-bit offset */
|
||||
num = 2;
|
||||
format[ind++] = NC_FORMAT_CLASSIC;
|
||||
format[ind++] = NC_FORMAT_64BIT_OFFSET;
|
||||
|
||||
/* Do we have netCDF-4 and netCDF-4 classic? */
|
||||
/* Do we have netCDF-4 and netCDF-4 classic? */
|
||||
#ifdef USE_HDF5
|
||||
num += 2;
|
||||
format[ind++] = NC_FORMAT_NETCDF4;
|
||||
format[ind++] = NC_FORMAT_NETCDF4_CLASSIC;
|
||||
num += 2;
|
||||
format[ind++] = NC_FORMAT_NETCDF4;
|
||||
format[ind++] = NC_FORMAT_NETCDF4_CLASSIC;
|
||||
#endif /* USE_HDF5 */
|
||||
|
||||
/* Do we have CDF5? */
|
||||
/* Do we have CDF5? */
|
||||
#ifdef ENABLE_CDF5
|
||||
num++;
|
||||
format[ind++] = NC_FORMAT_CDF5;
|
||||
num++;
|
||||
format[ind++] = NC_FORMAT_CDF5;
|
||||
#endif /* ENABLE_CDF5 */
|
||||
|
||||
*num_formats = num;
|
||||
*num_formats = num;
|
||||
}
|
||||
|
||||
/* Function to test nc_inq_format(). */
|
||||
int
|
||||
check_inq_format(int ncid, int expected_format, int expected_extended_format, int expected_mode)
|
||||
{
|
||||
int format;
|
||||
int extended_format;
|
||||
int mode;
|
||||
int format;
|
||||
int extended_format;
|
||||
int mode;
|
||||
|
||||
if (nc_inq_format(ncid + 66000, NULL) != NC_EBADID) ERR;
|
||||
if (nc_inq_format(ncid, NULL)) ERR;
|
||||
if (nc_inq_format(ncid, &format)) ERR;
|
||||
if (format != expected_format) {
|
||||
printf("format %d expected_format %d\n", format, expected_format);
|
||||
ERR;
|
||||
}
|
||||
if (nc_inq_format_extended(ncid + 66000, &extended_format, &mode) != NC_EBADID) ERR;
|
||||
{
|
||||
int mode;
|
||||
if (nc_inq_format_extended(ncid, NULL, &mode)) ERR;
|
||||
if (mode != expected_mode) {
|
||||
printf("expected_mode %x mode %x\n", expected_mode, mode);
|
||||
/*ERR;*/
|
||||
}
|
||||
}
|
||||
{
|
||||
int extended_format;
|
||||
if (nc_inq_format_extended(ncid, &extended_format, NULL)) ERR;
|
||||
if (extended_format != expected_extended_format) ERR;
|
||||
}
|
||||
if (nc_inq_format(ncid + 66000, NULL) != NC_EBADID) ERR;
|
||||
if (nc_inq_format(ncid, NULL)) ERR;
|
||||
if (nc_inq_format(ncid, &format)) ERR;
|
||||
if (format != expected_format) {
|
||||
printf("format %d expected_format %d\n", format, expected_format);
|
||||
ERR;
|
||||
}
|
||||
if (nc_inq_format_extended(ncid + 66000, &extended_format, &mode) != NC_EBADID) ERR;
|
||||
{
|
||||
int mode;
|
||||
if (nc_inq_format_extended(ncid, NULL, &mode)) ERR;
|
||||
if (mode != expected_mode) {
|
||||
printf("expected_mode %x mode %x\n", expected_mode, mode);
|
||||
/*ERR;*/
|
||||
}
|
||||
}
|
||||
{
|
||||
int extended_format;
|
||||
if (nc_inq_format_extended(ncid, &extended_format, NULL)) ERR;
|
||||
if (extended_format != expected_extended_format) ERR;
|
||||
}
|
||||
|
||||
if (nc_inq_format_extended(ncid, &extended_format, &mode)) ERR;
|
||||
if (mode != expected_mode) ERR;
|
||||
if (extended_format != expected_extended_format) ERR;
|
||||
if (nc_inq_format_extended(ncid, &extended_format, &mode)) ERR;
|
||||
if (mode != expected_mode) ERR;
|
||||
if (extended_format != expected_extended_format) ERR;
|
||||
|
||||
/* Nothing to do with inq_format, but let's check the base_pe
|
||||
* functions. */
|
||||
if (nc_set_base_pe(ncid, 0)) ERR;
|
||||
if (nc_inq_base_pe(ncid, NULL)) ERR;
|
||||
/* Nothing to do with inq_format, but let's check the base_pe
|
||||
* functions. */
|
||||
if (nc_set_base_pe(ncid, 0)) ERR;
|
||||
if (nc_inq_base_pe(ncid, NULL)) ERR;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("\n*** Testing netcdf format functions.\n");
|
||||
{
|
||||
int ncid;
|
||||
int f, d, a;
|
||||
int format[MAX_NUM_FORMATS];
|
||||
int num_formats;
|
||||
int ret;
|
||||
printf("\n*** Testing netcdf format functions.\n");
|
||||
{
|
||||
int ncid;
|
||||
int f, d, a;
|
||||
int format[MAX_NUM_FORMATS];
|
||||
int num_formats;
|
||||
int ret;
|
||||
|
||||
/* How many formats to be tested? */
|
||||
determine_test_formats(&num_formats, format);
|
||||
/* How many formats to be tested? */
|
||||
determine_test_formats(&num_formats, format);
|
||||
|
||||
for (f = 0; f < num_formats; f++)
|
||||
{
|
||||
printf("*** testing nc_inq_format() and nc_inq_format_extended() with format %d...", format[f]);
|
||||
{
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
int expected_mode;
|
||||
int expected_extended_format;
|
||||
|
||||
sprintf(file_name, "%s_%d.nc", FILE_NAME_BASE, format[f]);
|
||||
|
||||
/* Set up test. */
|
||||
switch (format[f]) {
|
||||
case NC_FORMAT_CLASSIC:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = 0;
|
||||
break;
|
||||
case NC_FORMAT_64BIT_OFFSET:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = NC_64BIT_OFFSET;
|
||||
break;
|
||||
case NC_FORMAT_CDF5:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = NC_CDF5;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4:
|
||||
expected_extended_format = NC_FORMATX_NC4;
|
||||
expected_mode = NC_NETCDF4;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4_CLASSIC:
|
||||
expected_extended_format = NC_FORMATX_NC4;
|
||||
expected_mode = NC_NETCDF4|NC_CLASSIC_MODEL;
|
||||
break;
|
||||
}
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
|
||||
/* Create a file. */
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Re-open the file and check it again. */
|
||||
if (nc_open(file_name, 0, &ncid)) ERR;
|
||||
/* Classic flag is not set on mode in nc_open(). Not sure if
|
||||
* this is a bug or not. */
|
||||
if (format[f] == NC_FORMAT_NETCDF4_CLASSIC)
|
||||
expected_mode = NC_NETCDF4;
|
||||
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
/* Test without and with actual data write. */
|
||||
for (d = 0; d < NUM_FILL_WRITE_TESTS; d++)
|
||||
{
|
||||
/* Test setting _FillValue directly or calling nc_def_var_fill(). */
|
||||
for (a = 0; a < NUM_FILL_WRITE_METHOD_TESTS; a++)
|
||||
for (f = 0; f < num_formats; f++)
|
||||
{
|
||||
printf("*** testing nc_inq_format() and nc_inq_format_extended() with format %d...", format[f]);
|
||||
{
|
||||
printf("*** testing late fill handling with format %d writing %d "
|
||||
"using def_var_fill %d...", format[f], d, a);
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
int dimid, varid;
|
||||
size_t index = {DIM_LEN - 1};
|
||||
int data = TEST_VAL_42;
|
||||
int data_in;
|
||||
int fill_value = TEST_VAL_42 * 2;
|
||||
int shuffle_in, deflate_in, deflate_level_in;
|
||||
int options_mask_in, pixels_per_block_in;
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
int expected_mode;
|
||||
int expected_extended_format;
|
||||
|
||||
/* Try to set fill mode after data have been written. */
|
||||
sprintf(file_name, "%s_%d_%d_%d_elatefill.nc", FILE_NAME_BASE, format[f], d, a);
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIM1, &dimid, &varid)) ERR;
|
||||
sprintf(file_name, "%s_%d.nc", FILE_NAME_BASE, format[f]);
|
||||
|
||||
/* There is no deflate on this var, and that is true in
|
||||
* all formats. */
|
||||
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in,
|
||||
&deflate_level_in)) ERR;
|
||||
if (shuffle_in || deflate_in || deflate_level_in) ERR;
|
||||
|
||||
/* There is no szip on this var, and that is true in
|
||||
* all formats. */
|
||||
if (nc_inq_var_szip(ncid, varid, &options_mask_in, &pixels_per_block_in)) ERR;
|
||||
if (options_mask_in || pixels_per_block_in) ERR;
|
||||
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
/* For netCDF-4, we don't actually have to write data to
|
||||
* prevent future setting of the fill value. Once the user
|
||||
* leaves calls enddef after defining a var, fill values
|
||||
* can no longer be set. */
|
||||
if (d)
|
||||
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (a)
|
||||
{
|
||||
ret = nc_def_var_fill(ncid, varid, NC_FILL, &fill_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = nc_put_att_int(ncid, varid, "_FillValue", NC_INT, 1,
|
||||
&fill_value);
|
||||
}
|
||||
/* Set up test. */
|
||||
switch (format[f]) {
|
||||
case NC_FORMAT_CLASSIC:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = 0;
|
||||
break;
|
||||
case NC_FORMAT_64BIT_OFFSET:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = NC_64BIT_OFFSET;
|
||||
break;
|
||||
case NC_FORMAT_CDF5:
|
||||
expected_extended_format = NC_FORMATX_NC3;
|
||||
expected_mode = NC_CDF5;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4:
|
||||
expected_extended_format = NC_FORMATX_NC4;
|
||||
expected_mode = NC_NETCDF4;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4_CLASSIC:
|
||||
expected_extended_format = NC_FORMATX_NC4;
|
||||
expected_mode = NC_NETCDF4|NC_CLASSIC_MODEL;
|
||||
break;
|
||||
}
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
|
||||
/* Setting the fill value after data are written is
|
||||
* allowed in classic formats, but not netcdf-4. */
|
||||
if (format[f] == NC_FORMAT_CLASSIC || format[f] == NC_FORMAT_64BIT_OFFSET ||
|
||||
format[f] == NC_FORMAT_CDF5)
|
||||
{
|
||||
if (ret) ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret != (a ? NC_ELATEDEF: NC_ELATEFILL)) ERR;
|
||||
}
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
/* Create a file. */
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* There is (still!) no deflate on this var, and that
|
||||
* is true in all formats. */
|
||||
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in,
|
||||
&deflate_level_in)) ERR;
|
||||
if (shuffle_in || deflate_in || deflate_level_in) ERR;
|
||||
|
||||
/* There is (still!) no szip on this var, and that is
|
||||
* true in all formats. */
|
||||
if (nc_inq_var_szip(ncid, varid, &options_mask_in, &pixels_per_block_in)) ERR;
|
||||
if (options_mask_in || pixels_per_block_in) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
/* Re-open the file and check it again. */
|
||||
if (nc_open(file_name, 0, &ncid)) ERR;
|
||||
/* Classic flag is not set on mode in nc_open(). Not sure if
|
||||
* this is a bug or not. */
|
||||
if (format[f] == NC_FORMAT_NETCDF4_CLASSIC)
|
||||
expected_mode = NC_NETCDF4;
|
||||
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
/* Test without and with actual data write. */
|
||||
for (d = 0; d < NUM_FILL_WRITE_TESTS; d++)
|
||||
{
|
||||
/* Test setting _FillValue directly or calling nc_def_var_fill(). */
|
||||
for (a = 0; a < NUM_FILL_WRITE_METHOD_TESTS; a++)
|
||||
{
|
||||
printf("*** testing late fill handling with format %d writing %d "
|
||||
"using def_var_fill %d...", format[f], d, a);
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
int dimid, varid;
|
||||
size_t index = {DIM_LEN - 1};
|
||||
int data = TEST_VAL_42;
|
||||
int data_in;
|
||||
int fill_value = TEST_VAL_42 * 2;
|
||||
int shuffle_in, deflate_in, deflate_level_in;
|
||||
int options_mask_in, pixels_per_block_in;
|
||||
int storage_in;
|
||||
unsigned int filterid;
|
||||
size_t nfilters;
|
||||
|
||||
/* Open the file and check data. */
|
||||
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_get_var1_int(ncid, varid, &index, &data_in)) ERR;
|
||||
if (data_in != (d ? data : NC_FILL_INT)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
SUMMARIZE_ERR;
|
||||
} /* next fill value method test */
|
||||
} /* next fill val write test */
|
||||
/* Try to set fill mode after data have been written. */
|
||||
sprintf(file_name, "%s_%d_%d_%d_elatefill.nc", FILE_NAME_BASE, format[f], d, a);
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIM1, &dimid, &varid)) ERR;
|
||||
|
||||
/* There is no deflate on this var, and that is true in
|
||||
* all formats. */
|
||||
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in,
|
||||
&deflate_level_in)) ERR;
|
||||
if (shuffle_in || deflate_in || deflate_level_in) ERR;
|
||||
|
||||
/* There is no szip on this var, and that is true in
|
||||
* all formats. */
|
||||
if (nc_inq_var_szip(ncid, varid, &options_mask_in, &pixels_per_block_in)) ERR;
|
||||
if (options_mask_in || pixels_per_block_in) ERR;
|
||||
|
||||
/* Since chunking is unset for netCDF-4 files, and
|
||||
* unavailable for classic formats, this will tell us
|
||||
* the var is contiguous. */
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, NULL)) ERR;
|
||||
if (storage_in != NC_CONTIGUOUS) ERR;
|
||||
|
||||
/* Since there are no filters defined, all of these
|
||||
should succeed or return NC_ENOFILTER */
|
||||
if (nc_inq_var_filter(ncid, varid, &filterid, NULL, NULL) != NC_ENOFILTER) ERR;
|
||||
filterid = H5Z_FILTER_DEFLATE;
|
||||
if (nc_inq_var_filter_info(ncid, varid, filterid, NULL, NULL) != NC_ENOFILTER) ERR;
|
||||
nfilters = 0;
|
||||
if (nc_inq_var_filterids(ncid, varid, &nfilters, NULL))
|
||||
ERR;
|
||||
if(nfilters != 0) ERR;
|
||||
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
/* For netCDF-4, we don't actually have to write data to
|
||||
* prevent future setting of the fill value. Once the user
|
||||
* leaves calls enddef after defining a var, fill values
|
||||
* can no longer be set. */
|
||||
if (d)
|
||||
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (a)
|
||||
{
|
||||
ret = nc_def_var_fill(ncid, varid, NC_FILL, &fill_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = nc_put_att_int(ncid, varid, "_FillValue", NC_INT, 1,
|
||||
&fill_value);
|
||||
}
|
||||
|
||||
/* Setting the fill value after data are written is
|
||||
* allowed in classic formats, but not netcdf-4. */
|
||||
if (format[f] == NC_FORMAT_CLASSIC || format[f] == NC_FORMAT_64BIT_OFFSET ||
|
||||
format[f] == NC_FORMAT_CDF5)
|
||||
{
|
||||
if (ret) ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret != (a ? NC_ELATEDEF: NC_ELATEFILL)) ERR;
|
||||
}
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
|
||||
/* There is (still!) no deflate on this var, and that
|
||||
* is true in all formats. */
|
||||
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in,
|
||||
&deflate_level_in)) ERR;
|
||||
if (shuffle_in || deflate_in || deflate_level_in) ERR;
|
||||
|
||||
/* There is (still!) no szip on this var, and that is
|
||||
* true in all formats. */
|
||||
if (nc_inq_var_szip(ncid, varid, &options_mask_in, &pixels_per_block_in)) ERR;
|
||||
if (options_mask_in || pixels_per_block_in) ERR;
|
||||
|
||||
/* Storage is (still) contiguous. */
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, NULL)) ERR;
|
||||
if (storage_in != NC_CONTIGUOUS) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check data. */
|
||||
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_get_var1_int(ncid, varid, &index, &data_in)) ERR;
|
||||
if (data_in != (d ? data : NC_FILL_INT)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
SUMMARIZE_ERR;
|
||||
} /* next fill value method test */
|
||||
} /* next fill val write test */
|
||||
|
||||
#define NDIM2 2
|
||||
#define DIM1_NAME "dim1"
|
||||
@ -251,84 +274,84 @@ main(int argc, char **argv)
|
||||
#define NTYPE 6
|
||||
#define DATA_LEN 4
|
||||
|
||||
printf("*** testing handling of null strides with format %d... ",
|
||||
format[f]);
|
||||
{
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
char var_name[NC_MAX_NAME + 1];
|
||||
int dimid[NDIM2];
|
||||
int xtype[NTYPE] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE};
|
||||
int type_size[NTYPE] = {1, 1, 2, 4, 4, 8};
|
||||
int varid[NTYPE];
|
||||
size_t start[NDIM2] = {0, 0};
|
||||
size_t count[NDIM2] = {2, 2};
|
||||
signed char data_byte[DATA_LEN] = {1, 2, 3, 4};
|
||||
unsigned char data_char[DATA_LEN] = {1, 2, 3, 4};
|
||||
short data_short[DATA_LEN] = {1, 2, 3, 4};
|
||||
int data_int[DATA_LEN] = {1, 2, 3, 4};
|
||||
float data_float[DATA_LEN] = {1, 2, 3, 4};
|
||||
double data_double[DATA_LEN] = {1, 2, 3, 4};
|
||||
void *data_ptr[NTYPE] = {data_byte, data_char, data_short, data_int, data_float, data_double};
|
||||
int t;
|
||||
|
||||
/* Create the test file. */
|
||||
sprintf(file_name, "%s_%d_null_strides.nc", FILE_NAME_BASE, format[f]);
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid[0])) ERR;
|
||||
if (nc_def_dim(ncid, DIM2_NAME, DIM_LEN, &dimid[1])) ERR;
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
printf("*** testing handling of null strides with format %d... ",
|
||||
format[f]);
|
||||
{
|
||||
sprintf(var_name, "var_%d", xtype[t]);
|
||||
if (nc_def_var(ncid, var_name, xtype[t], NDIM2, dimid, &varid[t])) ERR;
|
||||
}
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
char var_name[NC_MAX_NAME + 1];
|
||||
int dimid[NDIM2];
|
||||
int xtype[NTYPE] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE};
|
||||
int type_size[NTYPE] = {1, 1, 2, 4, 4, 8};
|
||||
int varid[NTYPE];
|
||||
size_t start[NDIM2] = {0, 0};
|
||||
size_t count[NDIM2] = {2, 2};
|
||||
signed char data_byte[DATA_LEN] = {1, 2, 3, 4};
|
||||
unsigned char data_char[DATA_LEN] = {1, 2, 3, 4};
|
||||
short data_short[DATA_LEN] = {1, 2, 3, 4};
|
||||
int data_int[DATA_LEN] = {1, 2, 3, 4};
|
||||
float data_float[DATA_LEN] = {1, 2, 3, 4};
|
||||
double data_double[DATA_LEN] = {1, 2, 3, 4};
|
||||
void *data_ptr[NTYPE] = {data_byte, data_char, data_short, data_int, data_float, data_double};
|
||||
int t;
|
||||
|
||||
/* Write some data. */
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
/* Create the test file. */
|
||||
sprintf(file_name, "%s_%d_null_strides.nc", FILE_NAME_BASE, format[f]);
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(file_name, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid[0])) ERR;
|
||||
if (nc_def_dim(ncid, DIM2_NAME, DIM_LEN, &dimid[1])) ERR;
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
{
|
||||
sprintf(var_name, "var_%d", xtype[t]);
|
||||
if (nc_def_var(ncid, var_name, xtype[t], NDIM2, dimid, &varid[t])) ERR;
|
||||
}
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
|
||||
/* Write some data. */
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
{
|
||||
if (nc_put_vars(ncid, varid[t], start, count, NULL, data_ptr[t])) ERR;
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check data. */
|
||||
{
|
||||
int ndims, nvars, ngatts, unlimdimid;
|
||||
|
||||
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
|
||||
if (ndims != 2 || nvars != NTYPE || ngatts != 0 || unlimdimid != -1) ERR;
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
{
|
||||
nc_type my_type;
|
||||
int var_ndims, natts;
|
||||
int var_dimid[NDIM2];
|
||||
void *data_in;
|
||||
|
||||
if (nc_inq_var(ncid, varid[t], NULL, &my_type, &var_ndims, var_dimid, &natts)) ERR;
|
||||
if (my_type != xtype[t] || var_ndims != 2 || var_dimid[0] != dimid[0] ||
|
||||
var_dimid[1] != dimid[1] || natts != 0) ERR;
|
||||
if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR;
|
||||
if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR;
|
||||
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR;
|
||||
free(data_in);
|
||||
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing bad name for nc_open/nc_create with format %d... ", format[f]);
|
||||
{
|
||||
if (nc_put_vars(ncid, varid[t], start, count, NULL, data_ptr[t])) ERR;
|
||||
int ncid;
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(NULL, 0, &ncid) != NC_EINVAL) ERR;
|
||||
if (nc_open(NULL, NC_NOWRITE, &ncid) != NC_EINVAL) ERR;
|
||||
if (nc_delete(NULL) != NC_EINVAL) ERR;
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check data. */
|
||||
{
|
||||
int ndims, nvars, ngatts, unlimdimid;
|
||||
|
||||
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
|
||||
if (ndims != 2 || nvars != NTYPE || ngatts != 0 || unlimdimid != -1) ERR;
|
||||
for (t = 0; t < NTYPE; t++)
|
||||
{
|
||||
nc_type my_type;
|
||||
int var_ndims, natts;
|
||||
int var_dimid[NDIM2];
|
||||
void *data_in;
|
||||
|
||||
if (nc_inq_var(ncid, varid[t], NULL, &my_type, &var_ndims, var_dimid, &natts)) ERR;
|
||||
if (my_type != xtype[t] || var_ndims != 2 || var_dimid[0] != dimid[0] ||
|
||||
var_dimid[1] != dimid[1] || natts != 0) ERR;
|
||||
if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR;
|
||||
if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR;
|
||||
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR;
|
||||
free(data_in);
|
||||
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing bad name for nc_open/nc_create with format %d... ", format[f]);
|
||||
{
|
||||
int ncid;
|
||||
if (nc_set_default_format(format[f], NULL)) ERR;
|
||||
if (nc_create(NULL, 0, &ncid) != NC_EINVAL) ERR;
|
||||
if (nc_open(NULL, NC_NOWRITE, &ncid) != NC_EINVAL) ERR;
|
||||
if (nc_delete(NULL) != NC_EINVAL) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
} /* next format */
|
||||
}
|
||||
FINAL_RESULTS;
|
||||
SUMMARIZE_ERR;
|
||||
} /* next format */
|
||||
}
|
||||
FINAL_RESULTS;
|
||||
}
|
||||
|
@ -150,7 +150,10 @@ static NC_Dispatch tst_dispatcher = {
|
||||
NC_NOTNC4_def_var_endian,
|
||||
NC_NOTNC4_def_var_filter,
|
||||
NC_NOTNC4_set_var_chunk_cache,
|
||||
NC_NOTNC4_get_var_chunk_cache
|
||||
NC_NOTNC4_get_var_chunk_cache,
|
||||
#if NC_DISPATCH_VERSION >= 2
|
||||
NC_NOOP_filter_actions
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This is the dispatch object that holds pointers to all the
|
||||
@ -242,7 +245,10 @@ static NC_Dispatch tst_dispatcher_bad_version = {
|
||||
NC_NOTNC4_def_var_endian,
|
||||
NC_NOTNC4_def_var_filter,
|
||||
NC_NOTNC4_set_var_chunk_cache,
|
||||
NC_NOTNC4_get_var_chunk_cache
|
||||
NC_NOTNC4_get_var_chunk_cache,
|
||||
#if NC_DISPATCH_VERSION >= 2
|
||||
NC_NOOP_filter_actions
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NUM_UDFS 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user