diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 4f56492f1d..422bad33da 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -12,7 +12,9 @@ include $(top_srcdir)/lib_flags.am # Un comment to use a more verbose test driver #SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose +#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose #LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose +#TESTS_ENVIRONMENT = export SETX=1; TEST_EXTENSIONS = .sh diff --git a/nc_test4/ref_bzip2.c b/nc_test4/ref_bzip2.c index e93f3cac29..ccf5515d60 100644 --- a/nc_test4/ref_bzip2.c +++ b/nc_test4/ref_bzip2.c @@ -48,8 +48,6 @@ main() {/* create bzip2.nc */ /* enter define mode */ stat = nc_create("bzip2.nc", NC_CLOBBER|NC_NETCDF4, &ncid); check_err(stat,__LINE__,__FILE__); - stat = nc_put_att_text(ncid, NC_GLOBAL, "_Format", 1, "netCDF-4"); - check_err(stat,__LINE__,__FILE__); bzip2_grp = ncid; /* define dimensions */ diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt index da43e1cdbf..0007888988 100644 --- a/ncdump/CMakeLists.txt +++ b/ncdump/CMakeLists.txt @@ -264,6 +264,9 @@ ENDIF(MSVC) ENDIF(USE_NETCDF4) add_sh_test(ncdump test_radix) + + add_sh_test(ncdump tst_ctests) + ENDIF() ENDIF() @@ -296,7 +299,7 @@ SET(MAN_FILES nccopy.1 ncdump.1) # Note, the L512.bin file is file containing exactly 512 bytes each of value 0. # It is used for creating hdf5 files with varying offsets for testing. -FILE(GLOB COPY_FILES ${CMAKE_BINARY_DIR}/ncgen/*.nc ${CMAKE_BINARY_DIR}/nc_test4/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.ncml ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.1 ${CMAKE_CURRENT_SOURCE_DIR}/L512.bin) +FILE(GLOB COPY_FILES ${CMAKE_BINARY_DIR}/ncgen/*.nc ${CMAKE_BINARY_DIR}/nc_test4/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.ncml ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.1 ${CMAKE_CURRENT_SOURCE_DIR}/L512.bin ${CMAKE_CURRENT_SOURCE_DIR}/ref_ctest*.c) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE) ADD_SUBDIRECTORY(cdl) diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am index 7381fe391f..764ae52748 100644 --- a/ncdump/Makefile.am +++ b/ncdump/Makefile.am @@ -107,6 +107,11 @@ if USE_HDF5 TESTS += tst_inmemory_nc4.sh tst_nccopy_w4.sh endif +if USE_HDF5 +# Re-activate the ncgen -lc tests +TESTS += tst_ctests.sh +endif + endif BUILD_TESTSETS # These files all have to be included with the distribution. @@ -150,6 +155,9 @@ ref_nccopy_w.cdl tst_nccopy_w3.sh tst_nccopy_w4.sh ref_no_ncproperty.nc # It is used for creating hdf5 files with varying offsets for testing. EXTRA_DIST += L512.bin +EXTRA_DIST += tst_ctests.sh ref_ctest_small_3.c ref_ctest_small_4.c \ + ref_ctest_special_atts_4.c + # CDL files and Expected results SUBDIRS = cdl expected @@ -175,4 +183,5 @@ tst_c0.cdl tst_c0_4.cdl tst_c0_4c.cdl tst_c0_64.cdl \ tst_compound_datasize_test.cdl tst_compound_datasize_test2.cdl \ tst_ncf199.cdl tst_tst_gattenum.cdl tst_tst_usuffix.cdl ctest.c \ ctest64.c nccopy3_subset_out.nc camrun.c tst_ncf213.cdl tst_ncf213.nc \ -tst_radix.nc tmp_radix.cdl +tst_radix.nc tmp_radix.cdl ctest_small_3.c ctest_small_4.c \ +ctest_special_atts_4.c diff --git a/ncdump/ctests.sh b/ncdump/ctests.sh deleted file mode 100755 index 3e00abeddc..0000000000 --- a/ncdump/ctests.sh +++ /dev/null @@ -1,235 +0,0 @@ -#!/bin/sh - -if test "x$srcdir" = x ; then srcdir=`pwd`; fi -. ../test_common.sh - -#set -e -echo "*** ctests.sh: testing ncgen4 -c" - -KFLAG=3 - -# get some config.h parameters -if test -f ${top_builddir}/config.h ; then - if fgrep -e '#define USE_NETCDF4 1' ${top_builddir}/config.h >/dev/null ; then - NETCDF4=1 - else - NETCDF4=0 - fi - if fgrep -e '#define ENABLE_DAP 1' ${top_builddir}/config.h >/dev/null ; then - DAP=1 - else - DAP=0 - fi - -else - echo "Cannot locate config.h" - exit 1 -fi - -# Locate the cdl and expected directories -cdl="${srcdir}/cdl4" -expected="${srcdir}/expected4" - -# Locate various libraries, programs, etc -# The hard part is locating the HDF5 and Z libraries - -NCGEN4=${NCGEN} -NCDUMP=${NCDUMP} - -HDFPATH="" -ZPATH="" -SZPATH="" -CURLPATH="" -CC=cc -if test -f ${builddir}/Makefile ; then - if test "x$NETCDF4" = "x1"; then - tmp=`sed -e '/^HDF5DIR/p' -e d <${builddir}/Makefile|tr -d " "` - HDFPATH=`echo $tmp |cut -d '=' -f2` - tmp=`sed -e '/^ZLIBDIR/p' -e d <${builddir}/Makefile|tr -d " "` - ZPATH=`echo $tmp |cut -d '=' -f2` - tmp=`sed -e '/^SZLIBDIR/p' -e d <${builddir}/Makefile|tr -d " "` - SZPATH=`echo $tmp |cut -d '=' -f2` - fi - if test "x$DAP" = "x1"; then - tmp=`sed -e '/^CURLDIR/p' -e d <${builddir}/Makefile|tr -d " "` - CURLPATH=`echo $tmp |cut -d '=' -f2` - fi - tmp=`sed -e "/^CC\ /p" -e d <${builddir}/Makefile|tr -d " "` - CC=`echo $tmp |cut -d '=' -f2` -else - echo "No Makefile => cannot locate HDF5 path" - exit 1 -fi - -if test "x$ZPATH" = "x" ; then - ZPATH="$SZPATH" -fi -if test "x$ZPATH" = "x" ; then - echo "NO libz or libsz specified" - exit 1 -fi - -INCL="" -LIBLOCS="" -RPATH="" - -if test "x$NETCDF4" = "x1"; then -NCLIBPATH="${builddir}/libsrc4/.libs" -NCINCLPATH="${srcdir}/libsrc4" -else -NCPATH="${builddir}/libsrc/.libs" -NCINCLPATH="${srcdir}/libsrc" -fi - -INCL="-I ${NCINCLPATH}" - -if test "x$NETCDF4" = "x1"; then -LIBLOCS="-L ${NCLIBPATH} -L ${HDFPATH}/lib -L ${ZPATH}/lib" -LIBS="${LIBLOCS} -lnetcdf -lhdf5_hl -lhdf5 -lz -lm" -#RPATH=-Wl,-rpath,${NCLIBPATH},-rpath,${HDFPATH}/lib,-rpath,${ZPATH}/lib -else -LIBLOCS="-L ${NCLIBPATH}" -LIBS="${LIBLOCS} -lnetcdf -lm" -#RPATH="-Wl,-rpath,${NCLIBPATH}" -fi - -if test "x$DAP" = "x1"; then -LIBS="${LIBS} -L ${CURLPATH}/lib -lcurl" -#RPATH="${RPATH},-rpath,${CURLPATH}/lib" -fi - -# Define the set of tests that can be -# processed with either the -k nc3 or -k nc4 flag - -TESTS3="\ -test0 \ -nc_enddef \ -ref_tst_unicode \ -ref_tst_utf8 \ -sfc_pres_temp \ -simple_xy \ -small \ -fills \ -c0 \ -example_good \ -nc_sync \ -pres_temp_4D \ -ref_tst_small \ -ref_nctst \ -ref_nctst_64bit_offset \ -small2 \ -tst_ncml \ -ref_ctest1_nc4 \ -ref_ctest1_nc4c \ -ref_nctst_netcdf4 \ -ref_nctst_netcdf4_classic" - -# Define the set of tests that must be -# processed with the -k nc4 flag - -TESTS4="\ -ref_dimscope \ -ref_typescope \ -ref_tst_string_data \ -ref_tst_comp \ -ref_tst_comp2 \ -ref_tst_group_data \ -ref_tst_opaque_data \ -ref_tst_solar_1 \ -ref_tst_solar_2 \ -ref_tst_enum_data \ -ref_tst_nans \ -ref_tst_special_atts \ -ref_const_test" - -if test "x$NOVLEN" = x ; then -TESTS4="$TESTS4 ref_tst_vlen_data" -fi - -SPECIALTESTS="ref_tst_special_atts" - -XFAILTESTS="ref_tst_special_atts" - -# Following are generally not run -# Because of the size of their output -BIGTESTS3="\ -bigf1 \ -bigf2 \ -bigf3 \ -bigr1 \ -bigr2" - -BIGTESTS4="ref_tst_solar_1" - -# This test is both big and slow -BIGBIG3="gfs1" - -if test "${KFLAG}" = 1 ; then -TESTSET="${TESTS3}" -elif test "${KFLAG}" = 3 ; then -TESTSET="${TESTS3} ${TESTS4}" -else -echo "Bad KFLAG=$KFLAG" -exit 1 -fi - -set -e - -rm -fr results_ctests -mkdir results_ctests - -failcount=0 -passcount=0 -xfailcount=0 - -for x in ${TESTSET} ; do - echo "Testing: ${x}" - specflag="" - isxfail=0 - for s in $SPECIALTESTS ; do - if test "$x" = "$s" ; then specflag="-s"; fi - done - for s in $XFAILTESTS ; do - if test "$x" = "$s" ; then isxfail=1; fi - done - ok=0; - cd results_ctests - if ${NCGEN4} -lc -k${KFLAG} ${cdl}/${x}.cdl >${x}.c - then ok=1; else ok=0; fi - if $CC ${INCL} -c ${x}.c - then ok=1; else ok=0; fi - if $CC -o ${x}.exe ${x}.o ${LIBS} ${RPATH} - then ok=1; else ok=0; fi - if ./${x}.exe - then ok=1; else ok=0; fi - if ${NCDUMP} ${specflag} ${x}.nc > ${x}.dmp - then ok=1; else ok=0; fi - cd .. -if test 1 = 1; then - # compare with expected - if diff -b -w ${expected}/${x}.dmp results_ctests/${x}.dmp - then ok=1; else ok=0; fi - if test "$ok" = "1" ; then - echo "*** PASS: ${x}" - passcount=`expr $passcount + 1` - elif test $isxfail = 1 ; then - echo "*** XFAIL : ${x}" - xfailcount=`expr $xfailcount + 1` - else - echo "*** FAIL: ${x}" - failcount=`expr $failcount + 1` - fi -fi -done - -totalcount=`expr $passcount + $failcount + $xfailcount` -okcount=`expr $passcount + $xfailcount` -rm -fr results_ctests - -echo "PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures" - -#if test $failcount -gt 0 ; then -# exit 1 -#else - exit 0 -#fi diff --git a/ncdump/ref_ctest_small_3.c b/ncdump/ref_ctest_small_3.c new file mode 100644 index 0000000000..ce6c9f914f --- /dev/null +++ b/ncdump/ref_ctest_small_3.c @@ -0,0 +1,81 @@ +#include +#include +#include + + +void +check_err(const int stat, const int line, const char *file) { + if (stat != NC_NOERR) { + (void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat)); + fflush(stderr); + exit(1); + } +} + +int +main() {/* create ref_tst_small.nc */ + + int stat; /* return status */ + int ncid; /* netCDF id */ + + /* dimension ids */ + int Time_dim; + int DateStrLen_dim; + + /* dimension lengths */ + size_t Time_len = NC_UNLIMITED; + size_t DateStrLen_len = 19; + + /* variable ids */ + int Times_id; + + /* rank (number of dimensions) for each variable */ +# define RANK_Times 2 + + /* variable shapes */ + int Times_dims[RANK_Times]; + + /* enter define mode */ + stat = nc_create("ref_tst_small.nc", NC_CLOBBER, &ncid); + check_err(stat,__LINE__,__FILE__); + + /* define dimensions */ + stat = nc_def_dim(ncid, "Time", Time_len, &Time_dim); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_dim(ncid, "DateStrLen", DateStrLen_len, &DateStrLen_dim); + check_err(stat,__LINE__,__FILE__); + + /* define variables */ + + Times_dims[0] = Time_dim; + Times_dims[1] = DateStrLen_dim; + stat = nc_def_var(ncid, "Times", NC_CHAR, RANK_Times, Times_dims, &Times_id); + check_err(stat,__LINE__,__FILE__); + + /* assign global attributes */ + + { + stat = nc_put_att_text(ncid, NC_GLOBAL, "TITLE", 31, " OUTPUT FROM WRF V2.0.3.1 MODEL"); + check_err(stat,__LINE__,__FILE__); + } + + + /* leave define mode */ + stat = nc_enddef (ncid); + check_err(stat,__LINE__,__FILE__); + + /* assign variable data */ + + { + char* Times_data = "2005-04-11_12:00:002005-04-11_13:00:00" ; + size_t Times_startset[2] = {0, 0} ; + size_t Times_countset[2] = {2, 19}; + stat = nc_put_vara(ncid, Times_id, Times_startset, Times_countset, Times_data); + check_err(stat,__LINE__,__FILE__); + } + + + stat = nc_close(ncid); + check_err(stat,__LINE__,__FILE__); + return 0; +} diff --git a/ncdump/ref_ctest_small_4.c b/ncdump/ref_ctest_small_4.c new file mode 100644 index 0000000000..722f2b2fe3 --- /dev/null +++ b/ncdump/ref_ctest_small_4.c @@ -0,0 +1,86 @@ +#include +#include +#include + + + +void +check_err(const int stat, const int line, const char *file) { + if (stat != NC_NOERR) { + (void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat)); + fflush(stderr); + exit(1); + } +} + +int +main() {/* create ref_tst_small.nc */ + + int stat; /* return status */ + int ncid; /* netCDF id */ + + /* group ids */ + int tst_small_grp; + + /* dimension ids */ + int Time_dim; + int DateStrLen_dim; + + /* dimension lengths */ + size_t Time_len = NC_UNLIMITED; + size_t DateStrLen_len = 19; + + /* variable ids */ + int Times_id; + + /* rank (number of dimensions) for each variable */ +# define RANK_Times 2 + + /* variable shapes */ + int Times_dims[RANK_Times]; + + /* enter define mode */ + stat = nc_create("ref_tst_small.nc", NC_CLOBBER|NC_NETCDF4, &ncid); + check_err(stat,__LINE__,__FILE__); + tst_small_grp = ncid; + + /* define dimensions */ + stat = nc_def_dim(tst_small_grp, "Time", Time_len, &Time_dim); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_dim(tst_small_grp, "DateStrLen", DateStrLen_len, &DateStrLen_dim); + check_err(stat,__LINE__,__FILE__); + + /* define variables */ + + Times_dims[0] = Time_dim; + Times_dims[1] = DateStrLen_dim; + stat = nc_def_var(tst_small_grp, "Times", NC_CHAR, RANK_Times, Times_dims, &Times_id); + check_err(stat,__LINE__,__FILE__); + + /* assign global attributes */ + + { + stat = nc_put_att_text(tst_small_grp, NC_GLOBAL, "TITLE", 31, " OUTPUT FROM WRF V2.0.3.1 MODEL"); + check_err(stat,__LINE__,__FILE__); + } + + + /* leave define mode */ + stat = nc_enddef (tst_small_grp); + check_err(stat,__LINE__,__FILE__); + + /* assign variable data */ + + { + char* Times_data = "2005-04-11_12:00:002005-04-11_13:00:00" ; + size_t Times_startset[2] = {0, 0} ; + size_t Times_countset[2] = {2, 19}; + stat = nc_put_vara(tst_small_grp, Times_id, Times_startset, Times_countset, Times_data); + check_err(stat,__LINE__,__FILE__); + } + + + stat = nc_close(tst_small_grp); + check_err(stat,__LINE__,__FILE__); + return 0; +} diff --git a/ncdump/ref_ctest_special_atts_4.c b/ncdump/ref_ctest_special_atts_4.c new file mode 100644 index 0000000000..dfea7761dd --- /dev/null +++ b/ncdump/ref_ctest_special_atts_4.c @@ -0,0 +1,170 @@ +#include +#include +#include + + +typedef struct obs_t { + signed char obs_t_PERIOD_day; + short obs_t_PERIOD_elev; + int obs_t_PERIOD_count; + float obs_t_PERIOD_relhum; + double obs_t_PERIOD_time; + unsigned char obs_t_PERIOD_category; + unsigned short obs_t_PERIOD_id; + unsigned int obs_t_PERIOD_particularity; + signed long long obs_t_PERIOD_attention_span; +} obs_t; + +static size_t var2_chunksizes[2] = {6, 7} ; +static size_t var3_chunksizes[3] = {6, 7, 8} ; +static size_t var4_chunksizes[3] = {6, 7, 8} ; +static size_t var5_chunksizes[1] = {6} ; + +void +check_err(const int stat, const int line, const char *file) { + if (stat != NC_NOERR) { + (void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat)); + fflush(stderr); + exit(1); + } +} + +int +main() {/* create ref_tst_special_atts.nc */ + + int stat; /* return status */ + int ncid; /* netCDF id */ + + /* group ids */ + int tst_special_atts_grp; + + /* type ids */ + int obs_t_typ; + + /* dimension ids */ + int dim1_dim; + int dim2_dim; + int dim3_dim; + + /* dimension lengths */ + size_t dim1_len = 10; + size_t dim2_len = 20; + size_t dim3_len = 30; + + /* variable ids */ + int var1_id; + int var2_id; + int var3_id; + int var4_id; + int var5_id; + + /* rank (number of dimensions) for each variable */ +# define RANK_var1 1 +# define RANK_var2 2 +# define RANK_var3 3 +# define RANK_var4 3 +# define RANK_var5 1 + + /* variable shapes */ + int var1_dims[RANK_var1]; + int var2_dims[RANK_var2]; + int var3_dims[RANK_var3]; + int var4_dims[RANK_var4]; + int var5_dims[RANK_var5]; + + /* enter define mode */ + stat = nc_create("ref_tst_special_atts.nc", NC_CLOBBER|NC_NETCDF4, &ncid); + check_err(stat,__LINE__,__FILE__); + tst_special_atts_grp = ncid; + + stat = nc_def_compound(tst_special_atts_grp, sizeof(obs_t), "obs_t", &obs_t_typ); check_err(stat,__LINE__,__FILE__); + { + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "day", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_day), NC_BYTE); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "elev", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_elev), NC_SHORT); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "count", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_count), NC_INT); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "relhum", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_relhum), NC_FLOAT); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "time", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_time), NC_DOUBLE); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "category", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_category), NC_UBYTE); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "id", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_id), NC_USHORT); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "particularity", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_particularity), NC_UINT); check_err(stat,__LINE__,__FILE__); + stat = nc_insert_compound(tst_special_atts_grp, obs_t_typ, "attention_span", NC_COMPOUND_OFFSET(obs_t,obs_t_PERIOD_attention_span), NC_INT64); check_err(stat,__LINE__,__FILE__); + } + + + /* define dimensions */ + stat = nc_def_dim(tst_special_atts_grp, "dim1", dim1_len, &dim1_dim); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_dim(tst_special_atts_grp, "dim2", dim2_len, &dim2_dim); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_dim(tst_special_atts_grp, "dim3", dim3_len, &dim3_dim); + check_err(stat,__LINE__,__FILE__); + + /* define variables */ + + var1_dims[0] = dim1_dim; + stat = nc_def_var(tst_special_atts_grp, "var1", NC_INT, RANK_var1, var1_dims, &var1_id); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_chunking(tst_special_atts_grp, var1_id, NC_CONTIGUOUS, NULL); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_endian(tst_special_atts_grp, var1_id, NC_ENDIAN_LITTLE); + check_err(stat,__LINE__,__FILE__); + + var2_dims[0] = dim1_dim; + var2_dims[1] = dim2_dim; + stat = nc_def_var(tst_special_atts_grp, "var2", NC_INT, RANK_var2, var2_dims, &var2_id); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_chunking(tst_special_atts_grp, var2_id, NC_CHUNKED, var2_chunksizes); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_fletcher32(tst_special_atts_grp, var2_id, 1); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_endian(tst_special_atts_grp, var2_id, NC_ENDIAN_BIG); + check_err(stat,__LINE__,__FILE__); + + var3_dims[0] = dim1_dim; + var3_dims[1] = dim2_dim; + var3_dims[2] = dim3_dim; + stat = nc_def_var(tst_special_atts_grp, "var3", NC_INT, RANK_var3, var3_dims, &var3_id); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_chunking(tst_special_atts_grp, var3_id, NC_CHUNKED, var3_chunksizes); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_deflate(tst_special_atts_grp, var3_id, NC_NOSHUFFLE, 1, 2); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_endian(tst_special_atts_grp, var3_id, NC_ENDIAN_LITTLE); + check_err(stat,__LINE__,__FILE__); + + var4_dims[0] = dim1_dim; + var4_dims[1] = dim2_dim; + var4_dims[2] = dim3_dim; + stat = nc_def_var(tst_special_atts_grp, "var4", NC_INT, RANK_var4, var4_dims, &var4_id); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_chunking(tst_special_atts_grp, var4_id, NC_CHUNKED, var4_chunksizes); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_deflate(tst_special_atts_grp, var4_id, NC_SHUFFLE, 1, 2); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_endian(tst_special_atts_grp, var4_id, NC_ENDIAN_LITTLE); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_fill(tst_special_atts_grp, var4_id, NC_NOFILL, NULL); + check_err(stat,__LINE__,__FILE__); + + var5_dims[0] = dim1_dim; + stat = nc_def_var(tst_special_atts_grp, "var5", obs_t_typ, RANK_var5, var5_dims, &var5_id); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_chunking(tst_special_atts_grp, var5_id, NC_CHUNKED, var5_chunksizes); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_fletcher32(tst_special_atts_grp, var5_id, 1); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_deflate(tst_special_atts_grp, var5_id, NC_SHUFFLE, 1, 2); + check_err(stat,__LINE__,__FILE__); + stat = nc_def_var_fill(tst_special_atts_grp, var5_id, NC_NOFILL, NULL); + check_err(stat,__LINE__,__FILE__); + + /* leave define mode */ + stat = nc_enddef (tst_special_atts_grp); + check_err(stat,__LINE__,__FILE__); + + /* assign variable data */ + + stat = nc_close(tst_special_atts_grp); + check_err(stat,__LINE__,__FILE__); + return 0; +} diff --git a/ncdump/tst_ctests.sh b/ncdump/tst_ctests.sh new file mode 100755 index 0000000000..91be836639 --- /dev/null +++ b/ncdump/tst_ctests.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +if test "x$srcdir" = x ; then srcdir=`pwd`; fi +. ../test_common.sh + +verbose=1 +set -e + +# Setup +PASS=1 + +# Do some limited testing of the ncgen -lc generated code + +NETCDF4=0 +if test -f ${top_builddir}/libnetcdf.settings ; then + if grep 'HDF5 Support:.*yes' ${top_builddir}/libnetcdf.settings >/dev/null ; then + NETCDF4=1 + fi +fi + +# Dump classic files two ways and compare +dotest() { +K=$1 +SF="_${K}" +for f in $2 ; do + echo "Testing ${f}" + F="${f}${SF}" + rm -f ./ctest_${F}.c + ${NCGEN} -$K -lc ${srcdir}/ref_tst_${f}.cdl > ./ctest_${F}.c + diff -w ./ctest_${F}.c ${srcdir}/ref_ctest_${F}.c +done +} + +#dotest 3 "small" +if test "x$NETCDF4" = x1 ; then +# dotest 4 "small special_atts" + dotest 4 "special_atts" +fi diff --git a/ncgen/genc.c b/ncgen/genc.c index 91293439a2..5afba81358 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -434,16 +434,10 @@ genc_netcdf(void) static void genc_defineglobalspecials(void) { - const char* format = NULL; if(usingclassic) return; if(!/*Main.*/format_attribute) return; - /* Watch out, this is a global Attribute */ - format = kind_string(globalspecials._Format); - bbprintf0(stmt,"%sstat = nc_put_att_text(ncid, NC_GLOBAL, \"_Format\", 1, \"%s\");\n", - indented(1), - format); - codedump(stmt); - codelined(1,"check_err(stat,__LINE__,__FILE__);"); + /* There are currently no global specials that + can be defined using nc_put_att.*/ } static void