netcdf-c/nczarr_test/bm_utils.h

100 lines
2.4 KiB
C
Raw Normal View History

/*********************************************************************
* Copyright 2018, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#ifndef BM_UTILS_H
#define BM_UTILS_H
#include "config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "zincludes.h"
#undef DEBUG
/* Define the getopt tags */
#define OPT_UNKNOWN 0
#define OPT_TREEDEPTH 1
#define OPT_NGROUPS 2
#define OPT_NGROUPATTRS 3
#define OPT_NDIMS 4
#define OPT_NTYPES 5
#define OPT_NVARS 6
#define OPT_VARRANK 7
#define OPT_NVARATTRS 8
#define OPT_FORMAT 9
#define OPT_PATH 10
#define OPT_FILE 11
#define OPT_X 12
#define OPT_DEBUG 13
#define OPT_DIMS 14
#define OPT_CHUNKS 15
#define OPT_CACHEFACTOR 16
#define OPT_CACHESIZE 17
#define OPT_DEFLATELEVEL 18
#define OPT_WDEBUG 19
#define OPT_URL 20
#define OPT_READONLY 21
#define OPT_WRITEONLY 22
#define X_OPT_MATCH 1
extern struct BMOptions {
int format;
char* filename;
char* url;
char* path; /* as sent to e.g. nc_create() */
char* pathtemplate;
int xvalue;
NCZM_IMPL impl;
int debug;
int wdebug;
int readonly;
int writeonly;
struct BMMeta {
int treedepth;
int ngroups;
int ngroupattrs;
int ndims;
int ntypes;
int nvars;
int varrank;
int nvarattrs;
size_t cachefactor;
size_t cachesize;
struct IntList {
int count;
size_t* list;
} dims;
struct IntList chunks;
int deflatelevel;
} meta;
struct X {
int sync;
} x;
} bmoptions;
#define NCCHECK(expr) nccheck((expr),__LINE__)
EXTERNL int bm_buildpath(struct BMOptions*);
EXTERNL int bm_getoptions(int* argcp, char*** argvp, struct BMOptions*);
EXTERNL void bm_clearoptions(struct BMOptions*);
EXTERNL const char* formatname(const struct BMOptions*);
EXTERNL void bm_reportoptions(struct BMOptions* o);
EXTERNL void bm_reportmetaoptions(struct BMMeta* o);
EXTERNL const char* bm_printvector(int rank, const size_t* vec);
EXTERNL const char* bm_printvectorp(int rank, const ptrdiff_t* vec);
EXTERNL const char* bm_varasprint(int rank, const size_t* start, const size_t* edges, const ptrdiff_t* stride);
Add support for setting HDF5 alignment property when creating a file re: https://github.com/Unidata/netcdf-c/issues/2177 re: https://github.com/Unidata/netcdf-c/pull/2178 Provide get/set functions to store global data alignment information and apply it when a file is created. The api is as follows: ```` int nc_set_alignment(int threshold, int alignment); int nc_get_alignment(int* thresholdp, int* alignmentp); ```` If defined, then for every file created opened after the call to nc_set_alignment, for every new variable added to the file, the most recently set threshold and alignment values will be applied to that variable. The nc_get_alignment function return the last values set by nc_set_alignment. If nc_set_alignment has not been called, then it returns the value 0 for both threshold and alignment. The alignment parameters are stored in the NCglobalstate object (see below) for use as needed. Repeated calls to nc_set_alignment will overwrite any existing values in NCglobalstate. The alignment parameters are applied in libhdf5/hdf5create.c and libhdf5/hdf5open.c The set/get alignment functions are defined in libsrc4/nc4internal.c. A test program was added as nc_test4/tst_alignment.c. ## Misc. Changes Unrelated to Alignment * The NCRCglobalstate type was renamed to NCglobalstate to indicate that it represented more general global state than just .rc data. It was also moved to nc4internal.h. This led to a large number of small changes: mostly renaming. The global state management functions were moved to nc4internal.c. * The global chunk cache variables have been moved into NCglobalstate. As warranted, other global state will be moved as well. * Some misc. problems with the nczarr performance tests were corrected.
2022-01-30 06:27:52 +08:00
EXTERNL int nc4_buildpath(struct BMOptions* o, char** pathp);
EXTERNL void reportoptions(struct BMOptions* o);
EXTERNL void reportmetaoptions(struct BMMeta* o);
EXTERNL void clearoptions(struct BMOptions*);
#include "ut_test.h"
#endif /*BM_UTILS_H*/