Tools: grib_to_netcdf test for GRIB_TO_NETCDF_CHECKVALIDTIME

This commit is contained in:
Shahram Najm 2023-07-27 13:15:48 +01:00
parent e524876975
commit 265b4fc49b
4 changed files with 24 additions and 3 deletions

View File

@ -1 +0,0 @@
ret,padding=0,level=500,grid=2/2,area=2/0/0/2,target=latlon.grib

View File

@ -1 +0,0 @@
ret,padding=0,level=500,resol=21,target=spectral.grib

View File

@ -135,5 +135,24 @@ ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempDir > $tempText
grep -q "Processing input file .*/subdir/regular_latlon_surface.grib2" $tempText grep -q "Processing input file .*/subdir/regular_latlon_surface.grib2" $tempText
rm -rf $tempDir rm -rf $tempDir
echo "Enable/Disable Checks ..."
# ---------------------------------
rm -f $tempNetcdf
input=${data_dir}/regular_latlon_surface.grib2
cat $input $input > $tempGrib
# By default checks are enabled. So this should fail
set +e
${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong number of fields" $tempText
export GRIB_TO_NETCDF_CHECKVALIDTIME=0
${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib
[ -f "$tempNetcdf" ]
unset GRIB_TO_NETCDF_CHECKVALIDTIME
# Clean up # Clean up
rm -f $tempNetcdf $tempGrib $tempText rm -f $tempNetcdf $tempGrib $tempText

View File

@ -2107,8 +2107,12 @@ static void get_nc_options(const request* user_r)
setup.history = history ? grib_context_strdup(ctx, (history)) : NULL; setup.history = history ? grib_context_strdup(ctx, (history)) : NULL;
setup.unlimited = unlimited ? grib_context_strdup(ctx, ((unlimited))) : NULL; setup.unlimited = unlimited ? grib_context_strdup(ctx, ((unlimited))) : NULL;
setup.checkvalidtime = true;
checkvalidtime_env = getenv("GRIB_TO_NETCDF_CHECKVALIDTIME"); checkvalidtime_env = getenv("GRIB_TO_NETCDF_CHECKVALIDTIME");
setup.checkvalidtime = checkvalidtime_env ? atol(checkvalidtime_env) : 1; if (checkvalidtime_env) {
const long v = atol(checkvalidtime_env);
if (v == 0) setup.checkvalidtime = false;
}
setup.mars_description = empty_request("MARS"); setup.mars_description = empty_request("MARS");
} }