Skip to content
Open
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
15 changes: 8 additions & 7 deletions tests/run_gmerge_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
# Wesley Ebisuzaki 10/2025

set -e
set --

echo ""
echo "*** Running gmerge tests"

file=data/gdas.t12z.pgrb2.1p00.anl.75r.grib2

arg=''
i=0
while [ $i -lt 201 ]
do
arg="$arg $file"
i=`expr $i + 1`
set -- "$@" "$file"
i=$((i + 1))
done

../aux_progs/gmerge tmp.gmerge.grb $arg
../aux_progs/gmerge tmp.gmerge.grb "$@"

echo "*** running gmerge and ens_qc test "

../aux_progs/gmerge - $arg | ../src/wgrib2 - -ens_qc ens_qc.x ens_qc.y ens_qc.z 1 >/dev/null
../aux_progs/gmerge - "$@" | ../src/wgrib2 - -ens_qc ens_qc.x ens_qc.y ens_qc.z 1 >/dev/null

ck="1559805086 4891"
newck=`../src/wgrib2 ens_qc.x -match spread -stats | cksum`
newck=$(../src/wgrib2 ens_qc.x -match spread -stats | cksum)
echo "ck=$ck"
echo "newck=$newck"
if [ "$ck" != "$newck" ] ; then
Expand All @@ -43,7 +44,7 @@ if [ $? -ne 8 ]; then
fi

echo "Testing with bad argument."
../aux_progs/gmerge /bad_directory/tmp.gmerge.grb $arg && exit 1
../aux_progs/gmerge /bad_directory/tmp.gmerge.grb "$@" && exit 1
if [ $? -ne 8 ]; then
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions tests/run_ipolates_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ diff -w new_grid.txt data/ref_new_grid_gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt
echo "*** Testing new_grid on file in incorrect order. This will return an incomplete output file and error message."
../src/wgrib2 new_grid_test.grb -match ":UGRD:" -grib_out test_badorder.grb
../src/wgrib2 new_grid_test.grb -match ":VGRD:" -append -grib_out test_badorder.grb
{ out_err=$(../src/wgrib2 test_badorder.grb -new_grid_winds grid \
-new_grid latlon 0:360:1 00:91:1 junk_badorder.grb 2>&1 1>&$out); } {out}>&1
if [[ -z "$out_err" ]]; then
out_err=$(../src/wgrib2 test_badorder.grb -new_grid_winds grid \
-new_grid latlon 0:360:1 00:91:1 junk_badorder.grb 3>&1 1>&2 2>&3 3>&-)
if [ -z "$out_err" ]; then
exit 10
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/run_jpeg_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Alyson Stahl 7/26/2024

n=`../src/wgrib2 -config | grep -c "Supported encoding:.*jpeg2000"`
n=$(../src/wgrib2 -config | grep -c "Supported encoding:.*jpeg2000")
if [ "$n" -eq 0 ] ; then
echo "*** Not running jpeg tests"
exit 0
Expand Down
2 changes: 1 addition & 1 deletion tests/run_wgrib2_aec_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Alyson Stahl, 4/18/24

n=`../src/wgrib2 -config | grep -c "Supported encoding:.*CCSDS AEC"`
n=$(../src/wgrib2 -config | grep -c "Supported encoding:.*CCSDS AEC")
if [ "$n" -eq 0 ] ; then
echo "*** Not running aec tests"
exit 0
Expand Down
6 changes: 3 additions & 3 deletions tests/run_wgrib2_netcdf3_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ echo "*** Testing converting from grib to netcdf to grib"
# convert netcdf to grb
../src/wgrib2 junk_netcdf.template -import_netcdf junk_netcdf.nc TMP_500mb "0:1:0:181:0:360" -grib_out junk_netcdf.grb

n=`../src/wgrib2 data/ref_simple_packing.grib2 -var -lev -rpn "sto_1" -import_grib junk_netcdf.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l`
n=$(../src/wgrib2 data/ref_simple_packing.grib2 -var -lev -rpn "sto_1" -import_grib junk_netcdf.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l)

rm junk_netcdf.grb junk_netcdf.nc junk_netcdf.template
if [ "$n" -ne 1 ] ; then
exit 1
fi

echo "*** SUCCESS!"
exit 0
exit 0
6 changes: 3 additions & 3 deletions tests/run_wgrib2_netcdf4_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ echo "*** Testing converting from grib to netcdf to grib"
# convert netcdf to grb
../src/wgrib2 junk_netcdf.template -import_netcdf junk_netcdf.nc TMP_500mb "0:1:0:181:0:360" -grib_out junk_netcdf.grb

n=`../src/wgrib2 data/ref_simple_packing.grib2 -var -lev -rpn "sto_1" -import_grib junk_netcdf.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l`
n=$(../src/wgrib2 data/ref_simple_packing.grib2 -var -lev -rpn "sto_1" -import_grib junk_netcdf.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l)

rm junk_netcdf.grb junk_netcdf.nc junk_netcdf.template
if [ "$n" -ne 1 ] ; then
Expand All @@ -38,7 +38,7 @@ diff -w tablenc.txt data/ref_tablenc.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt

echo "*** Testing nc_time"
../src/wgrib2 data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -match ":UGRD:" -nc_time 20200101000000 -netcdf test_time.nc
if [ `ncdump test_time.nc | grep -c "time = 1577836800,"` -ne 1 ] ; then
if [ "$(ncdump test_time.nc | grep -c "time = 1577836800,")" -ne 1 ] ; then
exit 1
fi

Expand Down
6 changes: 3 additions & 3 deletions tests/run_wgrib2_png_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Alyson Stahl 5/7/2024

n=`../src/wgrib2 -config | grep -c "Supported decoding:.*png"`
n=$(../src/wgrib2 -config | grep -c "Supported decoding:.*png")
if [ "$n" -eq 0 ] ; then
echo "*** Not running png tests"
exit 0
Expand All @@ -16,15 +16,15 @@ echo "*** Running wgrib2 png tests"


r1="1:0:(2000,1000),lon=304.937500,lat=-27.584172,val=1"
r2=`../src/wgrib2 data/png_4bits.png -ijlat 2000 1000`
r2=$(../src/wgrib2 data/png_4bits.png -ijlat 2000 1000)
if [ "$r1" != "$r2" ] ; then
echo "failed png test1 $r2"
echo "expected $r1"
exit 1
fi

r1="1:0:(2000,2000),lon=249.995002,lat=39.995000,val=0"
r2=`../src/wgrib2 data/large_png.grb2 -ijlat 2000 2000`
r2=$(../src/wgrib2 data/large_png.grb2 -ijlat 2000 2000)
if [ "$r1" != "$r2" ] ; then
echo "failed png test2 $r2"
echo "expected $r1"
Expand Down
24 changes: 12 additions & 12 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ diff -w secs.txt simple.txt


echo "*** test pdt 48 ***"
n=`../src/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +48 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
n=$(../src/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +48 -set_byte 4 12 00:12:0 | grep -c "aerosol_size")
if [ "$n" -ne 1 ] ; then
exit 1
fi
set -x
echo "*** test pdt 49 ***"
n=`../src/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +49 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
n=$(../src/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +49 -set_byte 4 12 00:12:0 | grep -c "aerosol_size")
if [ "$n" -ne 1 ] ; then
exit 1
fi
Expand All @@ -129,19 +129,19 @@ echo "*** test import_ieee big-endian ***"

../src/wgrib2 data/ref_simple_packing.grib2 -ieee ieee.bin -inv ieee.inv -d 1
../src/wgrib2 data/ref_simple_packing.grib2 -d 1 -rpn 0 -import_ieee ieee.bin -grib_out ieee.grb
line=`../src/wgrib2 -d 1 data/ref_simple_packing.grib2 -rpn sto_1 -import_ieee ieee.bin -rpn "rcl_1:print_rms"`
line=$(../src/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
if [ "$(echo "$line" | grep -c ":rpn_rms=0:")" -ne 1 ] ; then
exit 1
fi

echo "*** test import_ieee little-endian ***"

../src/wgrib2 data/ref_simple_packing.grib2 -little_endian -ieee ieee.bin.le -inv ieee.inv.le -d 1
../src/wgrib2 data/ref_simple_packing.grib2 -little_endian -d 1 -rpn 0 -import_ieee ieee.bin.le -grib_out ieee.grb.le
line=`../src/wgrib2 -little_endian -d 1 data/ref_simple_packing.grib2 -rpn sto_1 -import_ieee ieee.bin.le -rpn "rcl_1:print_rms"`
line=$(../src/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
if [ "$(echo "$line" | grep -c ":rpn_rms=0:")" -ne 1 ] ; then
exit 1
fi

Expand All @@ -150,26 +150,26 @@ fi
echo "*** test import_ieee little-endian ***"

echo "*** test set_prob ***"
line=`../src/wgrib2 data/ref_simple_packing.grib2 -d 1 -set_prob 1 2 3 222.2 0`
line=$(../src/wgrib2 data/ref_simple_packing.grib2 -d 1 -set_prob 1 2 3 222.2 0)
echo "$line"
if [ "$line" != '1:0:d=2009060500:TMP:500 mb:180 hour fcst:prob >222.2:prob fcst 1/2' ] ; then
exit 1
fi


echo '*** test new code table 4.6 entries ***'
line=`../src/wgrib2 data/ref_simple_packing.grib2 -set table_4.6 6`
if [ "`echo $line`" -ne "1:0:d=2009060500:TMP:500 mb:180 hour fcst:P-ENS=19" ] ; then
line=$(../src/wgrib2 data/ref_simple_packing.grib2 -set table_4.6 6)
if [ "$line" != "1:0:d=2009060500:TMP:500 mb:180 hour fcst:P-ENS=19" ] ; then
exit 1
fi

echo "*** test set_ts_dates ***"
dates=`../src/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_ts_dates 200001 1dy 1 | cut -f3 -d:`
dates=$(../src/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_ts_dates 200001 1dy 1 | cut -f3 -d:)

if [ "`echo "$dates" | head -n 1`" != "d=2000010100" ] ; then
if [ "$(echo "$dates" | head -n 1)" != "d=2000010100" ] ; then
exit 1
fi
if [ "`echo "$dates" | tail -n 1`" != "d=2000011900" ] ; then
if [ "$(echo "$dates" | tail -n 1)" != "d=2000011900" ] ; then
exit 1
fi

Expand Down
4 changes: 2 additions & 2 deletions tests/run_wgrib2_update_table_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ echo "*** testing MRMS update 3/2025"
file=data/ref_simple_packing.grib2
# wgrib2=wgrib2
wgrib2=../src/wgrib2
inv=`$wgrib2 $file -set_var var209_255_1_161_3_57 | cut -f4 -d:`
inv=$($wgrib2 $file -set_var var209_255_1_161_3_57 | cut -f4 -d:)
if [ "$inv" != "ReflectivityAtLowestAltitude" ] ; then
echo "failed: making ReflectivityAtLowestAltitude"
exit 1
fi
inv=`$wgrib2 $file -set_var var209_255_1_161_3_40 | cut -f4 -d:`
inv=$($wgrib2 $file -set_var var209_255_1_161_3_40 | cut -f4 -d:)
if [ "$inv" != "VILMax1440min" ] ; then
echo "failed: making VILMax1440min"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
echo "see if shared library made"
set -xe

if [[ ! -f ../src/libwgrib2.so && ! -f ../src/libwgrib2.a && ! -f ../src/libwgrib2.dylib ]]; then
if [ ! -f ../src/libwgrib2.so ] && [ ! -f ../src/libwgrib2.a ] && [ ! -f ../src/libwgrib2.dylib ]; then
echo "failed: did not find libwgrib2"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/test_shared_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
echo "see if shared library made"
set -xe

if [[ ! -f ../src/libwgrib2.so && ! -f ../src/libwgrib2.dylib ]]; then
if [ ! -f ../src/libwgrib2.so ] && [ ! -f ../src/libwgrib2.dylib ]; then
echo "failed: did not find shared library"
exit 1
fi
Expand Down