Skip to content

Commit

Permalink
ECC-1907: Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Aug 19, 2024
1 parent 2349dc3 commit cdb2e68
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ if( HAVE_BUILD_TOOLS )
grib_ecc-1467
grib_ecc-1764
grib_ecc-1792
grib_ecc-1907
grib_modelName
grib_sub_hourly
grib_set_bytes
Expand Down
60 changes: 60 additions & 0 deletions tests/grib_ecc-1907.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#

. ./include.ctest.sh

label="grib_ecc-1907_test"
tempGrib1=temp.$label.grib1
tempGrib2=temp.$label.grib2
tempFilt=temp.$label.filt
tempLog=temp.$label.log
tempOut=temp.$label.txt
tempRef=temp.$label.ref

sample_grib1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl

cat >$tempFilt<<EOF
set localDefinitionNumber = 13;
set marsStream = 'ewla';
set directionNumber = 1;
set frequencyNumber = 1;
set numberOfDirections = 36;
set numberOfFrequencies = 36;
set perturbationNumber = 44;
set scaledDirections={5000,15000,25000,35000,45000,55000,65000,75000,
85000,95000,105000,115000,125000,135000,145000,155000,
165000,175000,185000,195000,205000,215000,225000,235000,
245000,255000,265000,275000,285000,295000,305000,315000,
325000,335000,345000,355000};
set scaledFrequencies={34523,37975,41772,45950,50545,55599,61159,67275,
74002,81403,89543,98497,108347,119182,131100,144210,
158631,174494,191943,211138,232252,255477,281024,309127,
340039,374043,411448,452593,497852,547637,602401,662641,
728905,801795,881975,970172};
write;
EOF

${tools_dir}/grib_filter -o $tempGrib1 $tempFilt $sample_grib1
${tools_dir}/grib_set -s edition=2 $tempGrib1 $tempGrib2

echo 'print "[scaledDirections=]"; print; print "[scaledFrequencies=]";' | ${tools_dir}/grib_filter - $tempGrib2

${tools_dir}/grib_compare -c scaledDirections,scaledFrequencies $tempGrib1 $tempGrib2
${tools_dir}/grib_dump -O $tempGrib2

grib_check_key_equals $tempGrib2 productDefinitionTemplateNumber 100
grib_check_key_equals $tempGrib2 numberOfWaveDirections,numberOfWaveFrequencies '36 36'
grib_check_key_equals $tempGrib2 waveDirectionNumber,waveFrequencyNumber,perturbationNumber '1 1 44'

# Clean up
rm -f $tempGrib1 $tempGrib2 $tempFilt $tempLog $tempOut $tempRef

0 comments on commit cdb2e68

Please sign in to comment.