diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index 5e1aaf015..d19c4995d 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -104,8 +104,23 @@ echo "Test shuffle and deflate ..." if [ $have_netcdf4 -eq 1 ]; then input=${data_dir}/sst_globus0083.grib ${tools_dir}/grib_to_netcdf -s -d9 -k4 -o $tempNetcdf $input + + set +e + ${tools_dir}/grib_to_netcdf -s -o $tempNetcdf $input > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Invalid shuffle option. Deflate option needed" $tempText + + set +e + ${tools_dir}/grib_to_netcdf -s -dy -o $tempNetcdf $input > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Invalid number" $tempText fi + echo "Test ECC-1060 ..." # ---------------------- sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -172,6 +187,16 @@ set -e grep -q "not on a regular lat/lon grid or on a regular Gaussian grid" $tempText +echo "No output ..." +# -------------------------- +set +e +${tools_dir}/grib_to_netcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "No output file" $tempText + + # ECC-1783: No error message when input file has invalid fields input=$data_dir/bad.grib set +e diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index 0dad044ab..713ffcfaf 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -4294,6 +4294,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) int creation_mode = NC_CLOBBER; if (options->outfile == NULL || options->outfile->name == NULL) { + grib_context_log(ctx, GRIB_LOG_ERROR, "No output file. Exiting!"); usage(); exit(1); }