diff --git a/cf b/cf index 8a6ff3441..4670cb58b 100644 --- a/cf +++ b/cf @@ -5,7 +5,7 @@ HDF5=1 DAP=1 #CDMR=1 #RPC=1 -PGI=1 +#PGI=1 #M32=1 #M64=1 @@ -14,10 +14,10 @@ PGI=1 cmds="" #cmds="all" -cmds="all check" +#cmds="all check" #cmds="all dist" #cmds="all distcheck" -cmds="$cmds install" +#cmds="$cmds install" # Test pgi compiler if test "x$PGI" = x1 ; then @@ -124,7 +124,7 @@ FLAGS="$FLAGS --disable-pnetcdf" #FLAGS="$FLAGS --with-libcf" #FLAGS="$FLAGS --enable-benchmarks" FLAGS="$FLAGS --enable-extra-tests" -#FLAGS="$FLAGS --enable-logging" +FLAGS="$FLAGS --enable-logging" FLAGS="$FLAGS --disable-shared" #FLAGS="$FLAGS --enable-shared" diff --git a/h5_test/Makefile.am b/h5_test/Makefile.am index b61e7bdcb..7f9f9dea9 100644 --- a/h5_test/Makefile.am +++ b/h5_test/Makefile.am @@ -18,7 +18,7 @@ tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps \ tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl \ tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints \ tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 \ -tst_h_enums tst_h_dimscales4 #tst_h_filters +tst_h_enums tst_h_dimscales4 #tst_h_filters # If benchmarks were turned on, build and run a bunch more tests. if BUILD_BENCHMARKS diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am index 88ba2300a..ad6dbe121 100644 --- a/ncdump/Makefile.am +++ b/ncdump/Makefile.am @@ -8,6 +8,8 @@ include $(top_srcdir)/lib_flags.am LDADD = ${top_builddir}/liblib/libnetcdf.la +TESTS_ENVIRONMENT=CC=${CC} + # This is the program we're building, and it's sources. bin_PROGRAMS = ncdump ncdump_SOURCES = ncdump.c vardata.c dumplib.c indent.c nctime0.c \ @@ -28,7 +30,7 @@ if !BUILD_DLL check_PROGRAMS = rewrite-scalar ctest ctest64 ncdump tst_utf8 TESTS = run_tests.sh tst_64bit.sh ctest ctest64 tst_output.sh \ tst_lengths.sh tst_calendars.sh tst_utf8 run_utf8_tests.sh \ -tst_nccopy3.sh tst_charfill.sh +tst_nccopy3.sh tst_charfill.sh tst_iter.sh if USE_NETCDF4 # NetCDF-4 has some extra tests. @@ -67,7 +69,9 @@ tst_compounds4.cdl tst_utf8.cdl tst_compounds3.cdl \ tst_special_atts.cdl tst_nans.cdl tst_format_att_64.cdl \ tst_vlen_data.cdl tst_solar_1.cdl tst_format_att.cdl tst_inflated.nc \ tmp_subset.cdl tst_inflated4.nc tst_deflated.nc tst_chunking.nc tmp*.nc \ -tst_charfill.nc tmp_tst_charfill.cdl +tst_charfill.nc tmp_tst_charfill.cdl \ +tst_iter.nc ref_tst_iter.cdl tst_iter.cdl \ +tst_nc_test_netcdf4_4_0.cdl # These files all have to be included with the distribution. EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \ @@ -86,7 +90,8 @@ ref_tst_format_att.cdl ref_tst_format_att_64.cdl tst_nccopy3.sh \ tst_nccopy4.sh ref_nc_test_netcdf4_4_0.nc run_back_comp_tests.sh \ ref_nc_test_netcdf4.cdl ref_tst_special_atts3.cdl tst_brecs.cdl \ ref_tst_grp_spec0.cdl ref_tst_grp_spec.cdl tst_grp_spec.sh \ -ref_tst_charfill.cdl tst_charfill.cdl tst_charfill.sh +ref_tst_charfill.cdl tst_charfill.cdl tst_charfill.sh \ +tst_iter.sh # Can't run ncgen to generate ctest.c and ctest64.c on cross-compiles. diff --git a/ncdump/run_back_comp_tests.sh b/ncdump/run_back_comp_tests.sh index d3ce58af6..edda22f46 100755 --- a/ncdump/run_back_comp_tests.sh +++ b/ncdump/run_back_comp_tests.sh @@ -12,7 +12,6 @@ echo "*** checking ref_nc_test_netcdf4_4_0.nc..." #diff -w tmp.cdl tmp_4_0.cdl diff -w $srcdir/ref_nc_test_netcdf4.cdl tst_nc_test_netcdf4_4_0.cdl - # echo "*** Testing that old versions can read data produced by this version of netCDF." # echo "*** checking version 4.0..." # ../ncgen/ncgen -b -o tst_nc_test_netcdf4 -k 4 $srcdir/ref_nc_test_netcdf4.cdl diff --git a/ncdump/tst_iter.sh b/ncdump/tst_iter.sh new file mode 100755 index 000000000..b966809b0 --- /dev/null +++ b/ncdump/tst_iter.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# This shell script runs an ncdump bug test for netcdf +# Test if the nciter code is working. + +set -e + +echo "*** Running ncdump nc_iter test." + +if test "x$CC" = "x" ; then CC="gcc"; fi + +CLEANUP="geniter.c ref_tst_iter.cdl a.out tst_iter.nc tst_iter.cdl tmp" + +rm -f $CLEANUP + +echo "create ref_tst_iter.cdl" +cat > ref_tst_iter.cdl <./geniter.c < +#include +#define N (5*256*256) +int main() { + int i; + for(i=0;i>ref_tst_iter.cdl + +echo "*** create tst_iter.nc " +../ncgen/ncgen -k1 -o tst_iter.nc ./ref_tst_iter.cdl +echo "*** dumping tst_iter.nc to tst_iter.cdl..." +./ncdump tst_iter.nc > tst_iter.cdl +echo "*** reformat tst_iter.cdl" +mv tst_iter.cdl tmp +sed -e 's/\([0-9][,]\) /\1@/g' ./tst_iter.cdl + +echo "*** comparing tst_iter.cdl with ref_tst_iter.cdl..." +diff -w tst_iter.cdl ./ref_tst_iter.cdl + +# cleanup +rm -f $CLEANUP + +echo "*** PASS: ncdump iter tests" +exit 0 diff --git a/ncgen/Make0 b/ncgen/Make0 new file mode 100644 index 000000000..a3aef68de --- /dev/null +++ b/ncgen/Make0 @@ -0,0 +1,33 @@ +# Test c output +T=t +#VG=valgrind --leak-check=full + +CFLAGS=-I../include -I/share/ed/local/spock/include +LDFLAGS=../liblib/.libs/libnetcdf.a -L/share/ed/local/spock/lib -lhdf5_hl -lhdf5 -lz -lcurl -lm -llber -lldap -lrt -lssl -lcrypto -ldl + +CLASSPATH=".:ncCore-4.2.jar" + +btest:: + ./ncgen -k3 -lb ${T}.cdl -o ${T}.nc + ../ncdump/ncdump ./${T}.nc >${T}.dmp + diff -wBb ${T}.cdl ${T}.dmp + +ctest:: + ./ncgen -k3 -lc ${T}.cdl >${T}.c + gcc -o ${T} ${CFLAGS} ${T}.c ${LDFLAGS} + ./${T} + ../ncdump/ncdump ./${T}.nc >${T}.dmp + diff -wBb ${T}.cdl ${T}.dmp + +ct:: + gcc -o t ${CFLAGS} t.c ${LDFLAGS} -lm + ${VG} ./t + ../ncdump/ncdump ./t.nc |tee t.dmp + +jtest:: + ./ncgen -lj ${T}.cdl >Main.java + javac -d . -classpath "${CLASSPATH}" Main.java + +# java -cp ${CPATH} ./${T} +# ../ncdump/ncdump ./${T}.nc >${T}.dmp +# diff -wBb ${T}.cdl ${T}.dmp diff --git a/ncgen/Makefile.am b/ncgen/Makefile.am index 56612e412..319da4b29 100644 --- a/ncgen/Makefile.am +++ b/ncgen/Makefile.am @@ -46,37 +46,3 @@ makeparser:: bison -pncg -t ncgen.y rm -f ncgentab.c mv ncgen.tab.c ncgentab.c - -# Test c output -CTEST=test - -btest:: - ./ncgen -k3 -lb ${CTEST}.cdl -o ${CTEST}.nc - ../ncdump/ncdump ./${CTEST}.nc >${CTEST}.dmp - diff -wBb ${CTEST}.cdl ${CTEST}.dmp - - -ctest:: - ./ncgen -k3 -lc ${CTEST}.cdl >${CTEST}.c - CFLAGS=`../nc-config --cflags` \ - LDFLAGS=`../nc-config --libs` \ - gcc -o ${CTEST} -I../include ${CFLAGS} ${CTEST}.c ../liblib/.libs/libnetcdf.a ${LDFLAGS} -lm - ./${CTEST} - ../ncdump/ncdump ./${CTEST}.nc >${CTEST}.dmp - diff -wBb ${CTEST}.cdl ${CTEST}.dmp - -ct:: - CFLAGS=`../nc-config --cflags` \ - LDFLAGS=`../nc-config --libs` \ - gcc -o t -I../include ${CFLAGS} t.c ../liblib/.libs/libnetcdf.a ${LDFLAGS} -lm - ./t - - -CLASSPATH=".:ncCore-4.2.jar" -jtest:: - ./ncgen -lj ${CTEST}.cdl >Main.java - javac -d . -classpath "${CLASSPATH}" Main.java - -# java -cp ${CPATH} ./${CTEST} -# ../ncdump/ncdump ./${CTEST}.nc >${CTEST}.dmp -# diff -wBb ${CTEST}.cdl ${CTEST}.dmp diff --git a/ncgen/data.h b/ncgen/data.h index 9c255c587..9b458958e 100644 --- a/ncgen/data.h +++ b/ncgen/data.h @@ -37,8 +37,7 @@ typedef union Constvalue { double doublev; /* NC_DOUBLE*/ struct Stringv { /* NC_STRING*/ int len; - char* stringv; - /*struct Datalist* charlist;*/ + char* stringv; } stringv; struct Opaquev { /* NC_OPAQUE*/ int len; /* length as originally written (rounded to even number)*/ diff --git a/ncgen/env b/ncgen/env index 40f83cc79..85b960d8b 100644 --- a/ncgen/env +++ b/ncgen/env @@ -1,10 +1,14 @@ -L="-lc" -K="-k1" -F="test" -NCGEN="./.libs/ncgen" -alias q0="$NCGEN -d $K $L $F.cdl" -alias qq="gdb --args $NCGEN -d $K $L $F.cdl" -alias qv="valgrind --leak-check=full $NCGEN -d $K $L $F.cdl" +K="-k3" +F="t" +#B="-B12" +#NCGEN="./.libs/ncgen" +NCGEN="./ncgen" +alias q0="$NCGEN -d $K -lb $B $F.cdl" +alias qh="$NCGEN -d $K -lb $B -h $F.cdl" +alias qc="$NCGEN -d $K -lc $B $F.cdl" +alias qq="gdb --args $NCGEN -d $K -lb $B $F.cdl" +alias qqc="gdb --args $NCGEN -d $K -lc $B $F.cdl" +alias qv="valgrind --leak-check=full $NCGEN -d $K -lb $B $F.cdl" diff --git a/ncgen/genbin.c b/ncgen/genbin.c index 952cb3ac8..325d969bc 100644 --- a/ncgen/genbin.c +++ b/ncgen/genbin.c @@ -166,15 +166,17 @@ gen_netcdf(const char *filename) stat = nc_enddef(rootgroup->ncid); check_err(stat,__LINE__,__FILE__); - /* Load values into those variables with defined data */ - if(nvars > 0) { - for(ivar = 0; ivar < nvars; ivar++) { - Symbol* vsym = (Symbol*)listget(vardefs,ivar); - if(vsym->data != NULL) { - bbClear(databuf); - genbin_definevardata(vsym); - } - } + if(!header_only) { + /* Load values into those variables with defined data */ + if(nvars > 0) { + for(ivar = 0; ivar < nvars; ivar++) { + Symbol* vsym = (Symbol*)listget(vardefs,ivar); + if(vsym->data != NULL) { + bbClear(databuf); + genbin_definevardata(vsym); + } + } + } } bbFree(databuf); } @@ -308,11 +310,11 @@ genbin_deftype(Symbol* tsym) efield->typ.basetype->ncid); } else { int j; - Bytebuffer* dimbuf = bbNew(); + int dimsizes[NC_MAX_VAR_DIMS]; /* Generate the field dimension constants*/ for(j=0;jtyp.dimset.ndims;j++) { unsigned int size = efield->typ.dimset.dimsyms[j]->dim.declsize; - bbAppendn(dimbuf,(char*)&size,sizeof(size)); + dimsizes[j] = size; } stat = nc_insert_array_compound( tsym->container->ncid, @@ -321,8 +323,7 @@ genbin_deftype(Symbol* tsym) efield->typ.offset, efield->typ.basetype->ncid, efield->typ.dimset.ndims, - (int*)bbContents(dimbuf)); - bbFree(dimbuf); + dimsizes); } check_err(stat,__LINE__,__FILE__); } @@ -398,7 +399,7 @@ genbin_writevar(Generator* generator, Symbol* vsym, Bytebuffer* memory, #endif if(rank == 0) { - size_t count[1] = {1}; + size_t count[1] = {0}; stat = nc_put_var1(vsym->container->ncid, vsym->ncid, count, data); } else { stat = nc_put_vara(vsym->container->ncid, vsym->ncid, start, count, data); diff --git a/ncgen/genc.c b/ncgen/genc.c index 17b68e727..c463200b6 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -394,18 +394,19 @@ gen_ncc(const char *filename) codelined(1,"check_err(stat,__LINE__,__FILE__);"); codeflush(); - /* Load values into those variables with defined data */ - - if(nvars > 0) { - codeline(""); - codelined(1,"/* assign variable data */"); - for(ivar = 0; ivar < nvars; ivar++) { - Symbol* vsym = (Symbol*)listget(vardefs,ivar); - if(vsym->data != NULL) genc_definevardata(vsym); - } - codeline(""); + if(!header_only) { + /* Load values into those variables with defined data */ + if(nvars > 0) { + codeline(""); + codelined(1,"/* assign variable data */"); + for(ivar = 0; ivar < nvars; ivar++) { + Symbol* vsym = (Symbol*)listget(vardefs,ivar); + if(vsym->data != NULL) genc_definevardata(vsym); + } + codeline(""); + } + codeflush(); } - codeflush(); } #ifdef USE_NETCDF4 diff --git a/ncgen/generate.c b/ncgen/generate.c index e99217945..1372e9243 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -8,6 +8,8 @@ #include "odom.h" #include "offsets.h" +#undef ITERBUG + /**************************************************/ /* Code for generating data lists*/ /**************************************************/ @@ -124,18 +126,25 @@ generate_array(Symbol* vsym, writer(generator,vsym,code,odom->rank,odom->start,odom->count); } else - /* Case 2: the only unlimited is dimension 0 */ + /* Case 2: dim 1..n are not unlimited */ if(findunlimited(dimset,1) == rank) { + size_t offset = 0; /* where are we in the data list */ + size_t nelems = 0; /* # of data list items to read */ /* Create an iterator and odometer and just walk the datalist */ nc_get_iter(vsym,nciterbuffersize,&iter); odom = newodometer(dimset,NULL,NULL); - for(;;) { + for(;;offset+=nelems) { int i,uid; - size_t nelems=nc_next_iter(&iter,odom->start,odom->count); + nelems=nc_next_iter(&iter,odom->start,odom->count); if(nelems == 0) break; + bbClear(code); generator->listbegin(generator,LISTDATA,vsym->data->length,code,&uid); for(i=0;idata,i); +#else + Constant* con = datalistith(vsym->data,i+offset); +#endif generator->list(generator,LISTDATA,uid,i,code); #ifdef USE_NOFILL if(nofill_flag && con == NULL) diff --git a/ncgen/genf77.c b/ncgen/genf77.c index 6bb7b98a0..3eb34c6b6 100644 --- a/ncgen/genf77.c +++ b/ncgen/genf77.c @@ -318,61 +318,63 @@ gen_ncf77(const char *filename) f77skip(); f77flush(); - /* Assign scalar variable data and non-unlimited arrays in-line */ - if(nvars > 0) { - f77skip(); - f77skip(); - f77comment("assign scalar and fixed dimension variable data"); - for(ivar = 0; ivar < nvars; ivar++) { - Symbol* vsym = (Symbol*)listget(vardefs,ivar); - if(vsym->data == NULL) continue; - if(vsym->typ.dimset.ndims == 0) - genf77_definevardata(vsym); - } - f77skip(); - } + if(!header_only) { + /* Assign scalar variable data and non-unlimited arrays in-line */ + if(nvars > 0) { + f77skip(); + f77skip(); + f77comment("assign scalar and fixed dimension variable data"); + for(ivar = 0; ivar < nvars; ivar++) { + Symbol* vsym = (Symbol*)listget(vardefs,ivar); + if(vsym->data == NULL) continue; + if(vsym->typ.dimset.ndims == 0) + genf77_definevardata(vsym); + } + f77skip(); + } + + /* Invoke write procedures */ + if(nvars > 0) { + List* calllist; + f77skip(); + f77skip(); + f77comment("perform variable data writes"); + for(ivar = 0; ivar < nvars; ivar++) { + int i; + Symbol* vsym = (Symbol*)listget(vardefs,ivar); + /* Call the procedures for writing unlimited variables */ + if(vsym->data != NULL + && vsym->typ.dimset.ndims > 0) { + genf77_definevardata(vsym); + } + /* dump any calls */ + generator_getstate(f77_generator,(void*)&calllist); + ASSERT(calllist != NULL); + for(i=0;i 0) { - List* calllist; - f77skip(); - f77skip(); - f77comment("perform variable data writes"); - for(ivar = 0; ivar < nvars; ivar++) { + /* Generate the write procedures */ + if(listlength(f77procs) > 0) { int i; - Symbol* vsym = (Symbol*)listget(vardefs,ivar); - /* Call the procedures for writing unlimited variables */ - if(vsym->data != NULL - && vsym->typ.dimset.ndims > 0) { - genf77_definevardata(vsym); - } - /* dump any calls */ - generator_getstate(f77_generator,(void*)&calllist); - ASSERT(calllist != NULL); - for(i=0;i 0) { - int i; - f77skip(); - for(i=0;i 0) { - codeline(""); - codelined(1,"/* assign variable data */"); - for(ivar = 0; ivar < nvars; ivar++) { - Symbol* vsym = (Symbol*)listget(vardefs,ivar); - if(vsym->data != NULL) genj_definevardata(vsym); + if(!header_only) { + /* Load values into those variables with defined data */ + if(nvars > 0) { + codeline(""); + codelined(1,"/* assign variable data */"); + for(ivar = 0; ivar < nvars; ivar++) { + Symbol* vsym = (Symbol*)listget(vardefs,ivar); + if(vsym->data != NULL) genj_definevardata(vsym); + } + codeline(""); } - codeline(""); } + codeflush(); } diff --git a/ncgen/genlib.h b/ncgen/genlib.h index 958e09ea3..ba32bbf5b 100644 --- a/ncgen/genlib.h +++ b/ncgen/genlib.h @@ -184,6 +184,7 @@ extern int cml_flag; extern int java_flag; extern int java_jni_flag; extern int nofill_flag; +extern int header_only; extern char* mainname; extern size_t nciterbuffersize; diff --git a/ncgen/main.c b/ncgen/main.c index 6d9c55097..066199291 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -31,6 +31,7 @@ int f77_flag; int cml_flag; int java_flag; /* 1=> use netcdf java interface */ int syntax_only; +int header_only; /* flags for tracking what output format to use */ int k_flag; /* > 0 => -k was specified on command line*/ @@ -156,6 +157,7 @@ main( binary_flag = 0; nofill_flag = 0; syntax_only = 0; + header_only = 0; mainname = "main"; nciterbuffersize = 0; @@ -169,7 +171,7 @@ main( (void) par_io_init(32, 32); #endif - while ((c = getopt(argc, argv, "bcfk:l:no:v:xdM:D:B:")) != EOF) + while ((c = getopt(argc, argv, "hbcfk:l:no:v:xdM:D:B:")) != EOF) switch(c) { case 'd': debug = 1; @@ -188,6 +190,9 @@ main( case 'b': /* for binary netcdf output, ".nc" extension */ binary_flag = 1; break; + case 'h': + header_only = 1; + break; case 'l': /* specify language, instead of using -c or -f or -b */ { struct Languages* langs; diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index 9b025c16b..002a9d7d3 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -787,7 +787,7 @@ datalist: ; datalist0: - /*empty*/ {$$ = NULL;} + /*empty*/ {$$ = builddatalist(0);} ; datalist1: /* Must have at least 1 element */ @@ -1015,7 +1015,7 @@ makeconstdata(nc_type nctype) con.value.doublev = double_val; break; case NC_STRING: { /* convert to a set of chars*/ - int len; + size_t len; len = bbLength(lextext); con.value.stringv.len = len; con.value.stringv.stringv = bbDup(lextext); diff --git a/ncgen/ncgentab.c b/ncgen/ncgentab.c index 441d8bbed..817f2480d 100644 --- a/ncgen/ncgentab.c +++ b/ncgen/ncgentab.c @@ -2705,7 +2705,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); /* Line 1806 of yacc.c */ #line 790 "ncgen.y" - {(yyval.datalist) = NULL;} + {(yyval.datalist) = builddatalist(0);} break; case 114: @@ -3323,7 +3323,7 @@ makeconstdata(nc_type nctype) con.value.doublev = double_val; break; case NC_STRING: { /* convert to a set of chars*/ - int len; + size_t len; len = bbLength(lextext); con.value.stringv.len = len; con.value.stringv.stringv = bbDup(lextext);