mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Fix nc-config.in so --all option works with or without nf-config installed. Add -r and -w options to nccopy for diskless speedups.
This commit is contained in:
parent
353b7ebf53
commit
df361a2891
17
nc-config.in
17
nc-config.in
@ -21,15 +21,14 @@ has_hdf5="@HAS_HDF5@"
|
||||
has_szlib="@HAS_SZLIB@"
|
||||
version="@PACKAGE_NAME@ @PACKAGE_VERSION@"
|
||||
|
||||
if type -p nf-config; then
|
||||
if type -p nf-config > /dev/null 2>&1; then
|
||||
fc=`nf-config --fc`
|
||||
fflags=`nf-config --fflags`
|
||||
flibs=`nf-config --flibs`
|
||||
has_f77=`nf-config --has_f77`
|
||||
has_f90=`nf-config --has_f90`
|
||||
has_f90=`nf-config --has-f90`
|
||||
fi
|
||||
|
||||
if type -p ncxx-config; then
|
||||
if type -p ncxx-config > /dev/null 2>&1; then
|
||||
cxx=`ncxx-config --cxx`
|
||||
has_cxx=`ncxx-config --has_cxx`
|
||||
fi
|
||||
@ -59,19 +58,18 @@ Available values for OPTION include:
|
||||
--version Library version
|
||||
|
||||
EOF
|
||||
if type -p ncxx-config; then
|
||||
if type -p ncxx-config > /dev/null 2>&1; then
|
||||
cat <<EOF
|
||||
--cxx C++ compiler
|
||||
--has-c++ whether C++ API is enabled in this build
|
||||
|
||||
EOF
|
||||
fi
|
||||
if type -p nf-config; then
|
||||
if type -p nf-config > /dev/null 2>&1; then
|
||||
cat <<EOF
|
||||
--fc Fortran compiler
|
||||
--fflags flags needed to compile a Fortran program
|
||||
--flibs libraries needed to link a Fortran program
|
||||
--has-f77 whether Fortran 77 API is enabled in this build
|
||||
--has-f90 whether Fortran 90 API is enabled in this build
|
||||
|
||||
EOF
|
||||
@ -94,7 +92,6 @@ all()
|
||||
echo " --fc -> $fc"
|
||||
echo " --fflags -> $fflags"
|
||||
echo " --flibs -> $flibs"
|
||||
echo " --has-f77 -> $has_f77"
|
||||
echo " --has-f90 -> $has_f90"
|
||||
echo
|
||||
echo " --has-dap -> $has_dap"
|
||||
@ -206,10 +203,6 @@ while test $# -gt 0; do
|
||||
echo $flibs
|
||||
;;
|
||||
|
||||
--has-f77)
|
||||
echo $has_f77
|
||||
;;
|
||||
|
||||
--has-f90)
|
||||
echo $has_f90
|
||||
;;
|
||||
|
@ -44,6 +44,8 @@ static size_t option_chunk_cache_size = CHUNK_CACHE_SIZE; /* default from config
|
||||
static size_t option_chunk_cache_nelems = CHUNK_CACHE_NELEMS; /* default from config.h */
|
||||
static int option_compute_chunkcaches = 0; /* default, don't try still flaky estimate of
|
||||
* chunk cache for each variable */
|
||||
static int option_read_diskless = 0; /* default, don't read input into memory on open */
|
||||
static int option_write_diskless = 0; /* default, don't write output to diskless file */
|
||||
|
||||
/* get group id in output corresponding to group igrp in input,
|
||||
* given parent group id (or root group id) parid in output. */
|
||||
@ -1058,38 +1060,31 @@ count_dims(ncid) {
|
||||
* to copy data a record at a time. */
|
||||
static int
|
||||
nc3_special_case(int ncid, int kind) {
|
||||
int ret = 0;
|
||||
if (kind == NC_FORMAT_CLASSIC || kind == NC_FORMAT_64BIT) {
|
||||
int recdimid = 0;
|
||||
NC_CHECK(nc_inq_unlimdim(ncid, &recdimid));
|
||||
if (recdimid != -1) { /* we have a record dimension */
|
||||
int nrecvars = 0; /* number of record variables */
|
||||
int nvars;
|
||||
int varid;
|
||||
NC_CHECK(nc_inq_nvars(ncid, &nvars));
|
||||
if (nvars > 1) {
|
||||
int varid;
|
||||
for (varid = 0; varid < nvars; varid++) {
|
||||
int *dimids = 0;
|
||||
int ndims;
|
||||
NC_CHECK( nc_inq_varndims(ncid, varid, &ndims) );
|
||||
if (ndims > 0) {
|
||||
dimids = (int *) emalloc((ndims + 1) * sizeof(int));
|
||||
NC_CHECK( nc_inq_vardimid(ncid, varid, dimids) );
|
||||
if(dimids[0] == recdimid) { /* this is a record variable */
|
||||
nrecvars++;
|
||||
if (nrecvars > 1) {
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
free(dimids);
|
||||
if(ret)
|
||||
break;
|
||||
for (varid = 0; varid < nvars; varid++) {
|
||||
int *dimids = 0;
|
||||
int ndims;
|
||||
NC_CHECK( nc_inq_varndims(ncid, varid, &ndims) );
|
||||
if (ndims > 0) {
|
||||
int dimids0;
|
||||
dimids = (int *) emalloc((ndims + 1) * sizeof(int));
|
||||
NC_CHECK( nc_inq_vardimid(ncid, varid, dimids) );
|
||||
dimids0 = dimids[0];
|
||||
free(dimids);
|
||||
if(dimids0 == recdimid) {
|
||||
return 1; /* found a record variable */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Classify variables in ncid as either fixed-size variables (with no
|
||||
@ -1250,12 +1245,18 @@ copy(char* infile, char* outfile)
|
||||
int stat = NC_NOERR;
|
||||
int igrp, ogrp;
|
||||
int inkind, outkind;
|
||||
int open_mode = NC_NOWRITE;
|
||||
int create_mode = NC_CLOBBER;
|
||||
size_t ndims;
|
||||
|
||||
NC_CHECK(nc_open(infile,NC_NOWRITE,&igrp));
|
||||
NC_CHECK(nc_open(infile, open_mode, &igrp));
|
||||
|
||||
NC_CHECK(nc_inq_format(igrp, &inkind));
|
||||
|
||||
if(option_read_diskless) {
|
||||
open_mode |= NC_DISKLESS;
|
||||
}
|
||||
|
||||
/* option_kind specifies which netCDF format for output:
|
||||
* -1 -> same as input,
|
||||
* 1 -> classic
|
||||
@ -1289,19 +1290,21 @@ copy(char* infile, char* outfile)
|
||||
}
|
||||
#endif /* USE_NETCDF4 */
|
||||
|
||||
if(option_write_diskless)
|
||||
create_mode |= NC_WRITE | NC_DISKLESS; /* NC_WRITE persists diskless file on close */
|
||||
switch(outkind) {
|
||||
case NC_FORMAT_CLASSIC:
|
||||
NC_CHECK(nc_create(outfile,NC_CLOBBER,&ogrp));
|
||||
/* nothing to do */
|
||||
break;
|
||||
case NC_FORMAT_64BIT:
|
||||
NC_CHECK(nc_create(outfile,NC_CLOBBER|NC_64BIT_OFFSET,&ogrp));
|
||||
create_mode |= NC_64BIT_OFFSET;
|
||||
break;
|
||||
#ifdef USE_NETCDF4
|
||||
case NC_FORMAT_NETCDF4:
|
||||
NC_CHECK(nc_create(outfile,NC_CLOBBER|NC_NETCDF4,&ogrp));
|
||||
create_mode |= NC_NETCDF4;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4_CLASSIC:
|
||||
NC_CHECK(nc_create(outfile,NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL,&ogrp));
|
||||
create_mode |= NC_NETCDF4 | NC_CLASSIC_MODEL;
|
||||
break;
|
||||
#else
|
||||
case NC_FORMAT_NETCDF4:
|
||||
@ -1313,6 +1316,7 @@ copy(char* infile, char* outfile)
|
||||
error("bad value (%d) for -k option\n", option_kind);
|
||||
break;
|
||||
}
|
||||
NC_CHECK(nc_create(outfile, create_mode, &ogrp));
|
||||
NC_CHECK(nc_set_fill(ogrp, NC_NOFILL, NULL));
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
@ -1369,13 +1373,15 @@ usage(void)
|
||||
[-m n] set size in bytes of copy buffer, default is 5000000 bytes\n\
|
||||
[-h n] set size in bytes of chunk_cache for chunked variables\n\
|
||||
[-e n] set number of elements that chunk_cache can hold\n\
|
||||
[-r] read whole input file into diskless file on open (classic or 64-bit offset format only)\n\
|
||||
[-w] write whole output file from diskless netCDF on close\n\
|
||||
infile name of netCDF input file\n\
|
||||
outfile name for netCDF output file\n"
|
||||
|
||||
/* Don't document this flaky option until it works better */
|
||||
/* [-x] use experimental computed estimates for variable-specific chunk caches\n\ */
|
||||
|
||||
error("%s [-k n] [-d n] [-s] [-c chunkspec] [-u] [-m n] [-h n] [-e n] infile outfile\n%s",
|
||||
error("%s [-k n] [-d n] [-s] [-c chunkspec] [-u] [-m n] [-h n] [-e n] [-r] [-w] infile outfile\n%s",
|
||||
progname, USAGE);
|
||||
}
|
||||
|
||||
@ -1425,7 +1431,7 @@ main(int argc, char**argv)
|
||||
usage();
|
||||
}
|
||||
|
||||
while ((c = getopt(argc, argv, "k:d:sum:c:h:e:x")) != -1) {
|
||||
while ((c = getopt(argc, argv, "k:d:sum:c:h:e:rwx")) != -1) {
|
||||
switch(c) {
|
||||
case 'k': /* for specifying variant of netCDF format to be generated
|
||||
Possible values are:
|
||||
@ -1527,6 +1533,12 @@ main(int argc, char**argv)
|
||||
error("invalid value for number of chunk cache elements: %d", option_chunk_cache_nelems);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
option_read_diskless = 1; /* read into memory on open */
|
||||
break;
|
||||
case 'w':
|
||||
option_write_diskless = 1; /* write to memory, persist on close */
|
||||
break;
|
||||
case 'x': /* use experimental variable-specific chunk caches */
|
||||
option_compute_chunkcaches = 1;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user