Skip to content

Commit

Permalink
Added tests for netcdf
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Apr 22, 2024
1 parent 196cf89 commit 57a93a8
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ endfunction()
copy_test_data(gdaswave.t00z.wcoast.0p16.f000.grib2)
copy_test_data(ref_gdaswave.t00z.wcoast.0p16.f000.grib2.inv)
copy_test_data(ref_npts_gdaswave.t00z.wcoast.0p16.f000.grib2.txt)
copy_test_data(tmp_int.grb)

# Run these shell tests.
shell_test(run_wgrib2_tests)

if (USE_NETCDF4)
shell_test(run_wgrib2_netcdf4_tests)
endif()
if (USE_NETCDF3)
shell_test(run_wgrib2_netcdf3_tests)
endif()
Binary file added tests/data/tmp_int.grb
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/run_wgrib2_netcdf3_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
# This checks the use of AEC compression, only available if USE_NETCDF4 is turned on in CMake.
#
# Alyson Stahl, 4/22/24

set -e
set -x

# make template
../wgrib2/wgrib2 data/tmp_int.grb -rpn 0 -grib_out junk.template

# make netcdf file
../wgrib2/wgrib2 data/tmp_int.grb -nc3 -netcdf junk.nc

# convert netcdf to grb
../wgrib2/wgrib2 junk.template -import_netcdf junk.nc TMP_500mb "0:1:0:181:0:360" -grib_out junk.grb

n=`../wgrib2/wgrib2 data/tmp_int.grb -var -lev -rpn "sto_1" -import_grib junk.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l`

rm junk.grb junk.nc junk.template
if [ "$n" -eq 1 ] ; then
echo "success"
exit 0
else
exit 1
fi

28 changes: 28 additions & 0 deletions tests/run_wgrib2_netcdf4_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
# This checks the use of AEC compression, only available if USE_NETCDF4 is turned on in CMake.
#
# Alyson Stahl, 4/22/24

set -e
set -x

# make template
../wgrib2/wgrib2 data/tmp_int.grb -rpn 0 -grib_out junk.template

# make netcdf file
../wgrib2/wgrib2 data/tmp_int.grb -nc4 -netcdf junk.nc

# convert netcdf to grb
../wgrib2/wgrib2 junk.template -import_netcdf junk.nc TMP_500mb "0:1:0:181:0:360" -grib_out junk.grb

n=`../wgrib2/wgrib2 data/tmp_int.grb -var -lev -rpn "sto_1" -import_grib junk.grb -rpn "rcl_1:print_rms" | \
grep -v ":rpn=0:" | wc -l`

rm junk.grb junk.nc junk.template
if [ "$n" -eq 1 ] ; then
echo "success"
exit 0
else
exit 1
fi

0 comments on commit 57a93a8

Please sign in to comment.