eccodes/tests/grib_to_netcdf.sh

52 lines
1.5 KiB
Bash
Raw Normal View History

2013-03-25 12:04:10 +00:00
#!/bin/sh
2018-01-02 11:31:02 +00:00
# Copyright 2005-2018 ECMWF.
2013-03-25 12:04:10 +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.
. ./include.sh
#set -x
2018-05-22 16:51:28 +00:00
# Disable if autotools being used
src_config=${src_dir}/config.h
if [ -f ${src_config} ]; then
2013-03-25 12:04:10 +00:00
exit 0
fi
grib_files="\
2018-05-22 16:51:28 +00:00
regular_latlon_surface.grib2 \
regular_latlon_surface.grib1 \
regular_gaussian_model_level.grib1 \
regular_gaussian_pressure_level.grib2 \
regular_gaussian_surface.grib1 \
missing.grib2"
2013-03-25 12:04:10 +00:00
2013-08-20 16:19:49 +00:00
ncf_types="NC_SHORT NC_INT NC_FLOAT NC_DOUBLE"
2013-03-25 12:04:10 +00:00
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
2017-11-30 17:49:46 +00:00
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
2013-03-25 12:04:10 +00:00
done
done
# Try creating different kinds; netcdf3 classic and large
# TODO: enable tests for netcdf4 formats too
input=${data_dir}/regular_latlon_surface.grib2
2017-02-03 14:21:24 +00:00
${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
2017-11-30 17:49:46 +00:00
rm -f $tmp_netcdf