diff --git a/tests/bitmap.sh b/tests/bitmap.sh index 570d55fbe..64c13d91f 100755 --- a/tests/bitmap.sh +++ b/tests/bitmap.sh @@ -19,6 +19,9 @@ infile=${data_dir}/reduced_gaussian_model_level.grib1 outfile=${data_dir}/with_bitmap.grib1 outfile1=${data_dir}/without_bitmap.grib1 +# Create the grib2 file from grib1 +${tools_dir}grib_set -s editionNumber=2 $grib1 $grib2 2> $REDIRECT > $REDIRECT + rm -f $outfile || true ${tools_dir}grib_set -s bitmapPresent=1 $infile $outfile >$REDIRECT @@ -59,5 +62,5 @@ ${tools_dir}grib_get_data -m missing out.grib2 > out.grib2.data diff out.grib1.data out.grib2.data rm -f out.grib1.data out.grib2.data out.grib1 out.grib2 bitmap.rules - +rm -f $grib2 diff --git a/tests/bitsPerValue.sh b/tests/bitsPerValue.sh index 1db2c80cb..8c864feac 100755 --- a/tests/bitsPerValue.sh +++ b/tests/bitsPerValue.sh @@ -14,6 +14,10 @@ files="regular_latlon_surface.grib2 \ regular_latlon_surface.grib1" +# Create the grib2 file from grib1 +${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2 + + for file in `echo $files`; do infile=${data_dir}/$file @@ -33,3 +37,4 @@ done # Extra test for grid_complex_spatial_differencing ${tools_dir}grib_get -p decimalScaleFactor,bitsPerValue ${data_dir}/gfs.c255.grib2 > /dev/null +rm -f ${data_dir}/regular_latlon_surface.grib2 diff --git a/tests/change_scanning.sh b/tests/change_scanning.sh index c3624da74..2901832fb 100755 --- a/tests/change_scanning.sh +++ b/tests/change_scanning.sh @@ -68,6 +68,7 @@ EOF ${tools_dir}grib_get_data -F "%g" ${data_dir}/scan.grib > ${data_dir}/scan_y_${gridType}_${Ni}_${Nj}.dump diff ${data_dir}/scan_y_${gridType}_${Ni}_${Nj}.dump ${data_dir}/scan_y_${gridType}_${Ni}_${Nj}_good.dump rm -f ${data_dir}/scan_y_${gridType}_${Ni}_${Nj}.dump + rm -f ${data_dir}/change_scanning_${gridType}.filter done done diff --git a/tests/compare.sh b/tests/compare.sh index 86bef74e3..de6076053 100755 --- a/tests/compare.sh +++ b/tests/compare.sh @@ -22,3 +22,4 @@ ${tools_dir}grib_set -s shortName=2d $infile $outfile ${tools_dir}grib_compare -b indicatorOfParameter,paramId,shortName $infile $outfile > $REDIRECT +rm -f $outfile || true diff --git a/tests/decimalPrecision.sh b/tests/decimalPrecision.sh index 2ed0f0fcb..c52b2c66a 100755 --- a/tests/decimalPrecision.sh +++ b/tests/decimalPrecision.sh @@ -8,8 +8,6 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - - . ./include.sh REDIRECT=/dev/null @@ -17,24 +15,20 @@ REDIRECT=/dev/null files="regular_latlon_surface.grib2 \ regular_latlon_surface.grib1" +# First create the necessary grib2 files +${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2 + for file in `echo $files` do - -infile=${data_dir}/$file -outfile1=${infile}_decimalPrecision_1 -outfile2=${infile}_decimalPrecision_2 - -${tools_dir}grib_set -r -s decimalScaleFactor=1,bitsPerValue=0 $infile $outfile1 - -${tools_dir}grib_compare -b totalLength,section4Length,section7Length,dataLength,decimalScaleFactor,binaryScaleFactor,referenceValue,bitsPerValue $infile $outfile1 > $REDIRECT - -${tools_dir}grib_set -s changeDecimalPrecision=1 $infile $outfile2 - -${tools_dir}grib_compare -b totalLength,section4Length,section7Length,dataLength,decimalScaleFactor,binaryScaleFactor,referenceValue,bitsPerValue $infile $outfile2 > $REDIRECT - -${tools_dir}grib_compare $outfile1 $outfile2 - -rm -f $outfile1 $outfile2 || true - + infile=${data_dir}/$file + outfile1=${infile}_decimalPrecision_1 + outfile2=${infile}_decimalPrecision_2 + ${tools_dir}grib_set -r -s decimalScaleFactor=1,bitsPerValue=0 $infile $outfile1 + ${tools_dir}grib_compare -b totalLength,section4Length,section7Length,dataLength,decimalScaleFactor,binaryScaleFactor,referenceValue,bitsPerValue $infile $outfile1 > $REDIRECT + ${tools_dir}grib_set -s changeDecimalPrecision=1 $infile $outfile2 + ${tools_dir}grib_compare -b totalLength,section4Length,section7Length,dataLength,decimalScaleFactor,binaryScaleFactor,referenceValue,bitsPerValue $infile $outfile2 > $REDIRECT + ${tools_dir}grib_compare $outfile1 $outfile2 + rm -f $outfile1 $outfile2 || true done +rm -f ${data_dir}/regular_latlon_surface.grib2 diff --git a/tests/filter.sh b/tests/filter.sh index 642499bf6..25dc62cc4 100755 --- a/tests/filter.sh +++ b/tests/filter.sh @@ -29,6 +29,7 @@ EOF ${tools_dir}grib_filter ${data_dir}/f.rules ${data_dir}/tigge_pf_ecmwf.grib2 2> $REDIRECT > $REDIRECT rm -f ${data_dir}/split/* +rm -f ${data_dir}/f.rules # Test with nonexistent keys. Note spelling of centre! ####################################################### diff --git a/tests/grib1to2.sh b/tests/grib1to2.sh index fbd2658f3..850fd1e15 100755 --- a/tests/grib1to2.sh +++ b/tests/grib1to2.sh @@ -8,7 +8,6 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - . ./include.sh REDIRECT=/dev/null @@ -32,25 +31,22 @@ files="constant_field\ for f in `echo $files` do + file=${data_dir}/$f + g2file=${file}.grib2_ + rm -f $g2file || true + ${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT -file=${data_dir}/$f + grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1` + grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${g2file}` -rm -f ${file}.grib2 || true - -${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT - - -grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1` -grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib2` - -if [ "$grib1Statistics" != "$grib2Statistics" ] -then - exit 1 -fi - -#${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${file}.grib2 2> /dev/null > /dev/null -${tools_dir}grib_compare -P -c values ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT + if [ "$grib1Statistics" != "$grib2Statistics" ] + then + exit 1 + fi + #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${g2file} 2> /dev/null > /dev/null + ${tools_dir}grib_compare -P -c values ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT + rm -f ${g2file} || true done #sed "s:toolsdir:${tools_dir}:" ${tools_dir}grib1to2.txt > ${tools_dir}grib1to2.test diff --git a/tests/grib2to1.sh b/tests/grib2to1.sh index 669010438..148ade26c 100755 --- a/tests/grib2to1.sh +++ b/tests/grib2to1.sh @@ -31,21 +31,26 @@ files="constant_field\ for f in `echo $files` do - file=${data_dir}/$f - rm -f ${file}.grib1_ || true + file=${data_dir}/$f + + # First create the grib2 file + rm -f ${file}.grib2 || true + ${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT + + rm -f ${file}.grib1_ || true + ${tools_dir}grib_set -s editionNumber=1 ${file}.grib2 ${file}.grib1_ 2> $REDIRECT > $REDIRECT - ${tools_dir}grib_set -s editionNumber=1 ${file}.grib2 ${file}.grib1_ 2> $REDIRECT > $REDIRECT + grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1_` + grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib2` - grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1_` - grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib2` + if [ "$grib1Statistics" != "$grib2Statistics" ] + then + exit 1 + fi - if [ "$grib1Statistics" != "$grib2Statistics" ] - then - exit 1 - fi - - #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1_ ${file}.grib2 2> /dev/null > /dev/null - rm -f ${file}.grib1_ || true + #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1_ ${file}.grib2 2> /dev/null > /dev/null + rm -f ${file}.grib1_ || true + rm -f ${file}.grib2 || true done # GRIB-262 Conversion works without error for L137 data diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index 82f86bc2d..6e1b1e428 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -35,7 +35,6 @@ fi echo "NetCDF was enabled." grib_files="\ -set.grib2 set.grib1 \ regular_latlon_surface.grib2 \ regular_latlon_surface.grib1 \ regular_gaussian_model_level.grib1 \ diff --git a/tests/ieee.sh b/tests/ieee.sh index c801d61c2..b25f5acd9 100755 --- a/tests/ieee.sh +++ b/tests/ieee.sh @@ -71,5 +71,5 @@ export GRIB_IEEE_PACKING #${tools_dir}grib_filter r.filter ${shdata}_64 > ${shdata}_64.txt #diff ${shdata}_64.txt ${shdata}.good -rm -f r.filter ${shdata}_64.txt ${shdata}_32.txt +rm -f r.filter ${shdata}_64.txt ${shdata}_32.txt $shdata.txt diff --git a/tests/iterator.sh b/tests/iterator.sh index 99e711c65..97c09ae88 100755 --- a/tests/iterator.sh +++ b/tests/iterator.sh @@ -8,7 +8,6 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - . ./include.sh files="reduced_latlon_surface.grib1 \ @@ -22,15 +21,33 @@ files="reduced_latlon_surface.grib1 \ reduced_gaussian_sub_area.grib2 \ regular_latlon_surface.grib2" -for f in `echo $files` -do - -file=${data_dir}/$f - -iterator_count=`${tools_dir}grib_get_data -m 9999:missing -f -p centre -F "%g" -w count=1 $file | grep -v Lat |wc -l ` -numberOfPoints=`${tools_dir}grib_get -w count=1 -p numberOfPoints $file` - -[ $numberOfPoints = ${iterator_count} ] - +# First create the necessary grib2 files from grib1 +files2conv="\ + reduced_latlon_surface\ + reduced_gaussian_pressure_level\ + regular_gaussian_pressure_level\ + reduced_gaussian_sub_area\ + regular_latlon_surface\ +" +for f in $files2conv; do + ${tools_dir}grib_set -s editionNumber=2 ${data_dir}/$f.grib1 ${data_dir}/$f.grib2 done +# First create the necessary grib2 files +#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2 +#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_pressure_level.grib1 ${data_dir}/reduced_gaussian_pressure_level.grib2 +#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_gaussian_pressure_level.grib1 ${data_dir}/regular_gaussian_pressure_level.grib2 +#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_sub_area.grib1 ${data_dir}/reduced_gaussian_sub_area.grib2 + +for f in `echo $files` +do + file=${data_dir}/$f + iterator_count=`${tools_dir}grib_get_data -m 9999:missing -f -p centre -F "%g" -w count=1 $file | grep -v Lat |wc -l ` + numberOfPoints=`${tools_dir}grib_get -w count=1 -p numberOfPoints $file` + [ $numberOfPoints = ${iterator_count} ] +done + +# Clean up +for f in $files2conv; do + rm -f ${data_dir}/$f.grib2 +done diff --git a/tests/jpeg.sh b/tests/jpeg.sh index 50c806989..d7dcd8b44 100755 --- a/tests/jpeg.sh +++ b/tests/jpeg.sh @@ -8,7 +8,6 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - . ./include.sh REDIRECT=/dev/null @@ -34,6 +33,8 @@ fi rm -f $infile.1 $infile.2 || true infile=${data_dir}/reduced_latlon_surface.grib2 +# Create the grib2 file from grib1 +${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2 ${tools_dir}grib_set -s packingType=grid_jpeg $infile $infile.1 ${tools_dir}grib_compare -P -b $BLACKLIST $infile $infile.1 > $REDIRECT @@ -47,3 +48,4 @@ res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.2` [ "$res1" = "$res3" ] rm -f $infile.1 $infile.2 || true +rm -f ${data_dir}/reduced_latlon_surface.grib2 diff --git a/tests/lamb_az_eq_area.sh b/tests/lamb_az_eq_area.sh index 10a083d0d..b364c4ffb 100755 --- a/tests/lamb_az_eq_area.sh +++ b/tests/lamb_az_eq_area.sh @@ -10,9 +10,13 @@ . ./include.sh #set -x -GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 +GRIB1_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib1 +GRIB2_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 REF_FILE=lamb_az_eq_area.ref +# First create the grib2 file from grib1 +${tools_dir}grib_set -s editionNumber=2 $GRIB1_INFILE $GRIB2_INFILE + # Temporary files created for this test FILTER_FILE=lamb_az_eq_area.filter GRIB_OUTFILE=lamb_az_eq_area.grib2 @@ -41,7 +45,7 @@ write "lamb_az_eq_area.grib2"; EOF # Use this filter and the input GRIB to create a new GRIB -${tools_dir}grib_filter $FILTER_FILE $GRIB_INFILE +${tools_dir}grib_filter $FILTER_FILE $GRIB2_INFILE if [ ! -f "$GRIB_OUTFILE" ]; then echo Failed to create output GRIB from filter >&2 exit 1 @@ -53,5 +57,5 @@ ${tools_dir}grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE diff $DATA_OUTFILE $REF_FILE # Clean up -rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE +rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE $GRIB2_INFILE diff --git a/tests/list.sh b/tests/list.sh index 7a307d118..37aba1cdd 100755 --- a/tests/list.sh +++ b/tests/list.sh @@ -21,8 +21,13 @@ set scaledValueOfCentralWaveNumber={26870,9272,8377,22334}; write "test.grib"; EOF -file="${data_dir}/reduced_gaussian_model_level.grib2" +# First create the grib2 file from grib1 +gname=reduced_gaussian_model_level +grib1File=${data_dir}/${gname}.grib1 +grib2File=${data_dir}/${gname}.grib2 +${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File +file="$grib2File" ${tools_dir}grib_filter list.filter $file cat >list.filter<> log - ${tools_dir}grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> log +do + [ -f "$file" ] + echo $file >> log + ${tools_dir}grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> log done diff log ls.log @@ -70,11 +90,16 @@ rm -f tmp_rlls.grib1 | true # GRIB-305. GRIB edition 1 file with one large message if [ -f "sst_globus0083.grib" ]; then - ${tools_dir}grib_ls sst_globus0083.grib > /dev/null + ${tools_dir}grib_ls sst_globus0083.grib > /dev/null fi # GRIB-387 printing key of type byte ${tools_dir}grib_ls -p uuidOfVGrid test_uuid.grib2 > /dev/null +# Clean up +for f in $files2conv; do + rm -f $f.grib2 +done + cd $workdir diff --git a/tests/second_order.sh b/tests/second_order.sh index 4840c378a..ef9fffd49 100755 --- a/tests/second_order.sh +++ b/tests/second_order.sh @@ -82,3 +82,4 @@ test_data ${tools_dir}grib_dump second_ord_rbr.grib1 > $REDIRECT +rm -f test.filter diff --git a/tests/set.sh b/tests/set.sh index 9fac387d6..de7be8046 100755 --- a/tests/set.sh +++ b/tests/set.sh @@ -8,7 +8,6 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - . ./include.sh REDIRECT=/dev/null @@ -32,7 +31,14 @@ levtype=`${tools_dir}grib_get -p levtype:l $outfile` centre=`${tools_dir}grib_get -p centre:l $outfile` [ $centre -eq 80 ] -infile=${data_dir}/regular_gaussian_surface.grib2 +rm -f $outfile || true + +# Create the grib2 file from grib1 +grib1File=${data_dir}/regular_gaussian_surface.grib1 +grib2File=${data_dir}/regular_gaussian_surface.grib2 +${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File + +infile=$grib2File outfile=${data_dir}/set.grib2 rm -f $outfile || true @@ -57,4 +63,4 @@ ${tools_dir}grib_set -p levtype $infile $outfile 2> $REDIRECT > $REDIRECT [ $? -ne 0 ] - +rm -f $outfile $grib2File || true diff --git a/tests/step.sh b/tests/step.sh index bcce45d5b..3f049ef25 100755 --- a/tests/step.sh +++ b/tests/step.sh @@ -56,7 +56,13 @@ rm -f ${data_dir}/log | true # GRIB-180 # Set PDT 4.8 where you can find the EndOfOverallTimeInterval keys -grib2File=${data_dir}/reduced_latlon_surface_constant.grib2 +# First create the necessary grib2 file +gname=reduced_latlon_surface_constant +grib1File=${data_dir}/${gname}.grib1 +grib2File=${data_dir}/${gname}.grib2 +rm -f $grib2File || true +${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File + ${tools_dir}grib_set -sproductDefinitionTemplateNumber=8 $grib2File ${grib2File}.p8tmp # 78 hours is 3 days and 6 hours @@ -73,4 +79,4 @@ hourEnd=$1; dayEnd=$2 [ "$dayEnd" = "6" ] rm -f $grib2File.p8tmp ${grib2File}.tmp | true - +rm -f $grib2File