Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #288 fix -import_ieee WNE #290

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading