diff --git a/tests/run_wgrib2_tests.sh b/tests/run_wgrib2_tests.sh index 7dde2e9..e125228 100755 --- a/tests/run_wgrib2_tests.sh +++ b/tests/run_wgrib2_tests.sh @@ -125,5 +125,27 @@ if [ "$n" -ne 1 ] ; then exit 1 fi +echo "*** test import_ieee big-endian ***" + +../wgrib2/wgrib2 data/ref_simple_packing.grib2 -ieee ieee.bin -inv ieee.inv -d 1 +../wgrib2/wgrib2 data/ref_simple_packing.grib2 -d 1 -rpn 0 -import_ieee ieee.bin -grib_out ieee.grb +line=`../wgrib2/wgrib2 -d 1 data/ref_simple_packing.grib2 -rpn sto_1 -import_ieee ieee.bin -rpn "rcl_1:print_rms"` + +if [ `echo "$line" | grep -c ":rpn_rms=0:"` -ne 1 ] ; then + exit 1 +fi + +echo "*** test import_ieee little-endian ***" + +../wgrib2/wgrib2 data/ref_simple_packing.grib2 -little_endian -ieee ieee.bin.le -inv ieee.inv.le -d 1 +../wgrib2/wgrib2 data/ref_simple_packing.grib2 -little_endian -d 1 -rpn 0 -import_ieee ieee.bin.le -grib_out ieee.grb.le +line=`../wgrib2/wgrib2 -little_endian -d 1 data/ref_simple_packing.grib2 -rpn sto_1 -import_ieee ieee.bin.le -rpn "rcl_1:print_rms"` + +if [ `echo "$line" | grep -c ":rpn_rms=0:"` -ne 1 ] ; then + exit 1 +fi + + + echo "*** SUCCESS!" exit 0 diff --git a/wgrib2/rdieee_file.c b/wgrib2/rdieee_file.c index dee5f54..39fdc54 100644 --- a/wgrib2/rdieee_file.c +++ b/wgrib2/rdieee_file.c @@ -3,13 +3,13 @@ #include "wgrib2.h" /* - * rdieee_file: reads a big/little endian file with optional header + * rdieee_file: reads a big/little endian ieee file with optional header * * 10/2008 Public domain Wesley Ebisuzaki */ /* BSIZ number of floats to process at one time */ -#define BSIZ 4096 +#define BSIZ 8*4096 extern int ieee_little_endian; @@ -33,15 +33,14 @@ int rdieee_file(float *array, unsigned int n, int header, struct seq_file *input if (l != nbytes) fatal_error("rdieee: bad header",""); } - while (n > 0) { - j = n < BSIZ ? n : BSIZ; + for (i = 0; i < n; i += BSIZ) { + j = n-i > BSIZ ? BSIZ : n-i; if (fread_file(buff,1,4*j,input) != 4*j) fatal_error("rdieee: data read",""); if (ieee_little_endian) swap_buffer(buff, 4*j); -#pragma omp parallel for private(i) schedule(static) - for (i = 0; i < j; i++) { - array[i] = ieee2flt(buff + 4*i); - } - n = n - j; +#pragma omp parallel for private(l) schedule(static) + for (l = 0; l < j; l++) { + array[i+l] = ieee2flt(buff + 4*l); + } } if (header) {