123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #!/bin/bash
- # This script defines grib table 126 for EC-Earth usage.
- # The new grib definitions are put in the source dir of EC-Earth 3.
- set -e
- # --- Path to "grib_api/definitions"
- GRIBAPI_BASE_DIR=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]
- if [ -z "${GRIBAPI_BASE_DIR}" ]
- then
- echo Your GRIBAPI_BASE_DIR is empty
- echo Trying to retrieve '<your-grib_api-root-dir>/share/grib_api/definitions' instead
- echo You probably rely on module to set your env. Be sure that the grib_api is loaded.
- grib_def_dir=$(grib_info | sed -n "s|Default definition files path is used: ||p")
- if [ -z "${grib_def_dir}" ]
- then
- echo "Could not find the path to grib_api/definitions"
- echo "Please set GRIBAPI_BASE_DIR manually, or load the grib_api module and run again this script."
- exit 1
- fi
- else
- grib_def_dir=${GRIBAPI_BASE_DIR}/share/grib_api/definitions
- fi
- # --- Create target and populate
- target_dir=[[[PLT:ACTIVE:ECEARTH_SRC_DIR]]]/util/grib_table_126/grib1/localConcepts/ecmf
- mkdir -p ${target_dir}
- cp ${grib_def_dir}/grib1/localConcepts/ecmf/* ${target_dir}
- # --- additions to grib definitions for EC-Earth table 126
- cd $target_dir
- for ((i=1;i<=255;i++))
- do
- #cfVarname
- cat >> cfVarName.def <<EOF
- # EC-Earth product $i
- 'ece${i}.126' = {
- table2Version = 126 ;
- indicatorOfParameter = $i ;
- }
- EOF
- # paramId
- str=126${i}
- lim=100
- if [ $i -lt $lim ]; then
- str=1260${i}
- fi
- lim=10
- if [ $i -lt $lim ]; then
- str=12600${i}
- fi
- cat >> paramId.def <<EOF
- # EC-Earth product $i
- '${str}' = {
- table2Version = 126 ;
- indicatorOfParameter = $i ;
- }
- EOF
- #name
- cat >> name.def <<EOF
- # EC-Earth product $i
- 'EC-Earth product $i' = {
- table2Version = 126 ;
- indicatorOfParameter = $i ;
- }
- EOF
- #shortName
- cat >> shortName.def <<EOF
- # EC-Earth product $i
- '~' = {
- table2Version = 126 ;
- indicatorOfParameter = $i ;
- }
- EOF
- #units
- cat >> units.def <<EOF
- # EC-Earth product $i
- '~' = {
- table2Version = 126 ;
- indicatorOfParameter = $i ;
- }
- EOF
- done
|