mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-06 15:34:44 +08:00
f3e711e2b8
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.
46 lines
854 B
C
46 lines
854 B
C
/*
|
|
* Copyright 2018, University Corporation for Atmospheric Research
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include "stdlib.h"
|
|
#include "stdio.h"
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#undef DEBUG
|
|
|
|
static char hex[16] = "0123456789abcdef";
|
|
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
unsigned char c;
|
|
unsigned int c0,c1;
|
|
FILE* f = NULL;
|
|
|
|
if(argc > 1) {
|
|
/* use argv[1] as input */
|
|
f = fopen(argv[1],"r");
|
|
if(f == NULL) {fprintf(stderr,"No such file: %s\n",argv[1]); exit(1);}
|
|
} else
|
|
f = stdin;
|
|
|
|
for(;;) {
|
|
int ret = fread(&c, 1, 1, f);
|
|
if(ret != 1) break;
|
|
c1 = c;
|
|
c0 = c1 & 0xf;
|
|
c1 = (c1 >> 4);
|
|
c0 = hex[c0];
|
|
c1 = hex[c1];
|
|
printf("%c%c",(char)c1,(char)c0);
|
|
}
|
|
if(f != stdin) fclose(f);
|
|
return 0;
|
|
}
|