ECC-1041: grib_to_netcdf gives unexpected parameter names

This commit is contained in:
Shahram Najm 2019-12-18 17:16:33 +00:00
parent 2fd17d0773
commit 9363da6570
2 changed files with 39 additions and 19 deletions

View File

@ -8,14 +8,36 @@
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
. ./include.sh
#set -x
# Disable if autotools being used
src_config=${src_dir}/config.h
if [ -f ${src_config} ]; then
exit 0
exit 0
fi
label="grib_to_netcdf_test"
tempGrib=temp.${label}.grib
tempNetcdf=temp.${label}.nc
tempText=temp.${label}.txt
# Do we have ncdump?
NC_DUMPER=""
if command -v "ncdump" >/dev/null 2>&1; then
NC_DUMPER="ncdump"
fi
# ECC-1041: One parameter with different expvers
# This has 5 messages, all 'tp'. Change the first message to have a different expver
input=${data_dir}/tp_ecmwf.grib
${tools_dir}/grib_set -w stepRange=12 -s experimentVersionNumber=0005 $input $tempGrib
${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib
if test "x$NC_DUMPER" != "x"; then
$NC_DUMPER -h $tempNetcdf > $tempText
grep -q "short tp_0005" $tempText
grep -q "short tp_0001" $tempText
fi
grib_files="\
regular_latlon_surface.grib2 \
regular_latlon_surface.grib1 \
@ -26,26 +48,23 @@ grib_files="\
ncf_types="NC_SHORT NC_INT NC_FLOAT NC_DOUBLE"
tmp_netcdf=tmp.ncf
# Go thru all the specified GRIB files and convert them to NetCDF
for dt in $ncf_types
do
for f in $grib_files
do
rm -f $tmp_netcdf
[ -f ${data_dir}/$f ]
${tools_dir}/grib_to_netcdf -D $dt -o $tmp_netcdf ${data_dir}/$f >/dev/null
${tools_dir}/grib_to_netcdf -T -o $tmp_netcdf ${data_dir}/$f >/dev/null
done
for dt in $ncf_types; do
for f in $grib_files; do
rm -f $tempNetcdf
[ -f ${data_dir}/$f ]
${tools_dir}/grib_to_netcdf -D $dt -o $tempNetcdf ${data_dir}/$f >/dev/null
${tools_dir}/grib_to_netcdf -T -o $tempNetcdf ${data_dir}/$f >/dev/null
done
done
# Try creating different kinds; netcdf3 classic and large
# TODO: enable tests for netcdf4 formats too
input=${data_dir}/regular_latlon_surface.grib2
${tools_dir}/grib_to_netcdf -k 1 -o $tmp_netcdf $input >/dev/null
${tools_dir}/grib_to_netcdf -k 2 -o $tmp_netcdf $input >/dev/null
#${tools_dir}/grib_to_netcdf -k 3 -o $tmp_netcdf $input >/dev/null
#${tools_dir}/grib_to_netcdf -k 4 -o $tmp_netcdf $input >/dev/null
${tools_dir}/grib_to_netcdf -k 1 -o $tempNetcdf $input >/dev/null
${tools_dir}/grib_to_netcdf -k 2 -o $tempNetcdf $input >/dev/null
#${tools_dir}/grib_to_netcdf -k 3 -o $tempNetcdf $input >/dev/null
#${tools_dir}/grib_to_netcdf -k 4 -o $tempNetcdf $input >/dev/null
rm -f $tmp_netcdf
rm -f $tempNetcdf $tempGrib $tempText

View File

@ -3573,7 +3573,8 @@ static void find_nc_attributes(const request *subset_r, const request *user_r, n
if(!isalpha(att->name[0]))
{
char buf[1048];
sprintf(buf,"p%s",att->name);
const char *val = get_value(subset_r, "param", 0);
sprintf(buf,"%s_%s", (val ? val : "p"), att->name);
strcpy(att->name,buf);
}
}