2017-10-27 13:31:33 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2017-10-27 13:31:33 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2022-04-03 22:02:48 +00:00
|
|
|
. ./include.ctest.sh
|
2018-03-13 18:19:20 +00:00
|
|
|
pwd
|
2020-07-04 14:30:10 +00:00
|
|
|
# Define a common label for all the tmp files
|
2017-10-27 13:31:33 +00:00
|
|
|
label="codes_split_file"
|
2018-03-13 18:19:20 +00:00
|
|
|
temp=$label.temp.grib
|
2017-10-27 13:31:33 +00:00
|
|
|
|
|
|
|
# Do all the work in a temporary directory
|
|
|
|
temp_dir=tempdir.${label}
|
|
|
|
mkdir -p $temp_dir
|
2018-03-13 18:19:20 +00:00
|
|
|
cd $temp_dir
|
2017-10-27 13:31:33 +00:00
|
|
|
|
|
|
|
# Test 1: File with 3 messages
|
|
|
|
# -----------------------------
|
2018-03-13 18:19:20 +00:00
|
|
|
cp ${data_dir}/mixed.grib ./
|
|
|
|
input=mixed.grib
|
2017-10-27 13:31:33 +00:00
|
|
|
${tools_dir}/codes_split_file 3 $input
|
|
|
|
# There should now be 3 new files. Make sure they are valid
|
2019-08-09 01:48:16 +00:00
|
|
|
${tools_dir}/grib_ls mixed.grib_001
|
|
|
|
${tools_dir}/grib_ls mixed.grib_002
|
|
|
|
${tools_dir}/grib_ls mixed.grib_003
|
2017-10-27 13:31:33 +00:00
|
|
|
|
2018-03-13 18:19:20 +00:00
|
|
|
total=`${tools_dir}/codes_count mixed.grib_*`
|
2017-10-27 13:31:33 +00:00
|
|
|
[ $total -eq 14 ]
|
|
|
|
|
2018-03-13 18:19:20 +00:00
|
|
|
cat mixed.grib_* > $temp
|
|
|
|
${tools_dir}/grib_compare $input $temp
|
2017-10-27 15:28:59 +00:00
|
|
|
|
|
|
|
|
2017-10-27 13:31:33 +00:00
|
|
|
# Test 2: File with 248 messages
|
|
|
|
# -----------------------------
|
2018-03-13 18:19:20 +00:00
|
|
|
cp ${data_dir}/tigge_ecmwf.grib2 ./
|
|
|
|
input=tigge_ecmwf.grib2
|
2017-10-27 13:31:33 +00:00
|
|
|
${tools_dir}/codes_split_file 10 $input
|
2018-03-13 18:19:20 +00:00
|
|
|
total=`${tools_dir}/codes_count tigge_ecmwf.grib2_[0-9]*`
|
2017-10-27 13:31:33 +00:00
|
|
|
[ $total -eq 248 ]
|
|
|
|
|
2019-08-09 01:48:16 +00:00
|
|
|
cat tigge_ecmwf.grib2_[0-9][0-9][0-9] > $temp
|
|
|
|
${tools_dir}/grib_compare $input $temp
|
|
|
|
|
|
|
|
|
|
|
|
# Test 3: nchunk=-1 File with 248 messages
|
|
|
|
# -----------------------------
|
|
|
|
cp ${data_dir}/tigge_ecmwf.grib2 ./
|
|
|
|
input=tigge_ecmwf.grib2
|
|
|
|
${tools_dir}/codes_split_file -1 $input
|
|
|
|
total=`${tools_dir}/codes_count tigge_ecmwf.grib2_[0-9]*`
|
|
|
|
[ $total -eq 248 ]
|
|
|
|
|
|
|
|
cat tigge_ecmwf.grib2_[0-9][0-9][0-9] > $temp
|
2018-03-13 18:19:20 +00:00
|
|
|
${tools_dir}/grib_compare $input $temp
|
2017-10-27 15:28:59 +00:00
|
|
|
|
2017-10-27 13:31:33 +00:00
|
|
|
|
|
|
|
# Clean up
|
2018-03-13 18:19:20 +00:00
|
|
|
cd $test_dir
|
2017-10-27 13:31:33 +00:00
|
|
|
rm -fr $temp_dir
|