#!/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 '/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 <> paramId.def <> name.def <> shortName.def <> units.def <