123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #!/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=$(EBROOTGRIB_API)
- errmess="*ERROR*: Could not find the path to grib_info or codes_info
- commands. Please set GRIBAPI_BASE_DIR manually, or load the
- GRIB_API or ECCODES module if you rely on module to set your
- env, and run this script again."
- 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|eccodes]/definitions'
- echo from environment instead...
- echo Note that if both grib_info and codes_info are found in your path,
- echo GRIB_API takes precedence over ECCODES
- info=($(which grib_info codes_info 2>/dev/null || true))
- if [ -x "${info[0]}" ]
- then
- grib_def_dir=$(${info[0]} | sed -n "s|Default definition files path is used: ||p")
- else
- echo "$errmess"
- exit 1
- fi
- if [ -z "${grib_def_dir}" ]
- then
- echo "$errmess"
- exit 1
- else
- echo Found it.
- fi
- elif [ -e ${GRIBAPI_BASE_DIR}/share/grib_api/definitions ]
- then
- grib_def_dir=${GRIBAPI_BASE_DIR}/share/grib_api/definitions
- elif [ -e ${GRIBAPI_BASE_DIR}/share/eccodes/definitions ]
- then
- grib_def_dir=${GRIBAPI_BASE_DIR}/share/eccodes/definitions
- else
- echo "ERROR: Path ${GRIBAPI_BASE_DIR}/share/[grib_api|eccodes]/definitions does not exist"
- exit 1
- fi
- # --- Create target and populate
- target_dir=${HOME}/models/ecearth_3.3.3.2/sources/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
|