Skip to content

Commit

Permalink
Merge branch 'develop' into as_openjpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA authored Nov 8, 2024
2 parents 204974f + 9fa55bf commit 656906a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
22 changes: 22 additions & 0 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 8 additions & 9 deletions wgrib2/rdieee_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down

0 comments on commit 656906a

Please sign in to comment.