close Jira NCF-154

This commit is contained in:
Dennis Heimbigner 2012-03-07 23:38:51 +00:00
parent 316d9a6327
commit 2349c62d18
18 changed files with 231 additions and 147 deletions

8
cf
View File

@ -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"

View File

@ -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

View File

@ -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.

View File

@ -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

57
ncdump/tst_iter.sh Executable file
View File

@ -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 <<EOF
netcdf tst_iter {
dimensions:
x = 5 ;
y = 256 ;
z = 256;
variables:
int var(x,y,z) ;
data:
var =
EOF
cat >./geniter.c <<EOF
#include <stdlib.h>
#include <stdio.h>
#define N (5*256*256)
int main() {
int i;
for(i=0;i<N-1;i++) {printf("%d,\n",i);}
printf("%d;\n}\n",N);
return 0;
}
EOF
$CC ./geniter.c
./a.out >>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' <tmp |tr '@' '\n' |sed -e '/^$/d' >./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

33
ncgen/Make0 Normal file
View File

@ -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

View File

@ -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

View File

@ -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)*/

View File

@ -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"

View File

@ -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;j<efield->typ.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);

View File

@ -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

View File

@ -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;i<nelems;i++) {
#ifdef ITERBUG
Constant* con = datalistith(vsym->data,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)

View File

@ -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<listlength(calllist);i++) {
char* callstmt = (char*)listget(calllist,i);
codeline(callstmt);
}
listclear(calllist);
}
}
/* Close the file */
codeline("stat = nf_close(ncid)");
codeline("call check_err(stat)");
codeline("end");
/* Invoke write procedures */
if(nvars > 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<listlength(calllist);i++) {
char* callstmt = (char*)listget(calllist,i);
codeline(callstmt);
}
listclear(calllist);
}
}
/* Close the file */
codeline("stat = nf_close(ncid)");
codeline("call check_err(stat)");
codeline("end");
/* Generate the write procedures */
if(listlength(f77procs) > 0) {
int i;
f77skip();
for(i=0;i<listlength(f77procs);i++) {
Bytebuffer* proctext = (Bytebuffer*)listget(f77procs,i);
codedump(proctext);
bbFree(proctext);
}
listfree(f77procs); f77procs = NULL;
f77skip();
f77skip();
for(i=0;i<listlength(f77procs);i++) {
Bytebuffer* proctext = (Bytebuffer*)listget(f77procs,i);
codedump(proctext);
bbFree(proctext);
}
listfree(f77procs); f77procs = NULL;
f77skip();
}
}
f77flush();

View File

@ -194,17 +194,19 @@ gen_ncjava(const char *filename)
codelined(1,"ncfile.create();"); /* equiv to nc_enddef */
/* 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);
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();
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);