define_table_126.sh.tmpl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # This script defines grib table 126 for EC-Earth usage.
  3. # The new grib definitions are put in the source dir of EC-Earth 3.
  4. set -e
  5. # --- Path to "grib_api/definitions"
  6. GRIBAPI_BASE_DIR=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]
  7. if [ -z "${GRIBAPI_BASE_DIR}" ]
  8. then
  9. echo Your GRIBAPI_BASE_DIR is empty
  10. echo Trying to retrieve '<your-grib_api-root-dir>/share/grib_api/definitions' instead
  11. echo You probably rely on module to set your env. Be sure that the grib_api is loaded.
  12. grib_def_dir=$(grib_info | sed -n "s|Default definition files path is used: ||p")
  13. if [ -z "${grib_def_dir}" ]
  14. then
  15. echo "Could not find the path to grib_api/definitions"
  16. echo "Please set GRIBAPI_BASE_DIR manually, or load the grib_api module and run again this script."
  17. exit 1
  18. fi
  19. else
  20. grib_def_dir=${GRIBAPI_BASE_DIR}/share/grib_api/definitions
  21. fi
  22. # --- Create target and populate
  23. target_dir=[[[PLT:ACTIVE:ECEARTH_SRC_DIR]]]/util/grib_table_126/grib1/localConcepts/ecmf
  24. mkdir -p ${target_dir}
  25. cp ${grib_def_dir}/grib1/localConcepts/ecmf/* ${target_dir}
  26. # --- additions to grib definitions for EC-Earth table 126
  27. cd $target_dir
  28. for ((i=1;i<=255;i++))
  29. do
  30. #cfVarname
  31. cat >> cfVarName.def <<EOF
  32. # EC-Earth product $i
  33. 'ece${i}.126' = {
  34. table2Version = 126 ;
  35. indicatorOfParameter = $i ;
  36. }
  37. EOF
  38. # paramId
  39. str=126${i}
  40. lim=100
  41. if [ $i -lt $lim ]; then
  42. str=1260${i}
  43. fi
  44. lim=10
  45. if [ $i -lt $lim ]; then
  46. str=12600${i}
  47. fi
  48. cat >> paramId.def <<EOF
  49. # EC-Earth product $i
  50. '${str}' = {
  51. table2Version = 126 ;
  52. indicatorOfParameter = $i ;
  53. }
  54. EOF
  55. #name
  56. cat >> name.def <<EOF
  57. # EC-Earth product $i
  58. 'EC-Earth product $i' = {
  59. table2Version = 126 ;
  60. indicatorOfParameter = $i ;
  61. }
  62. EOF
  63. #shortName
  64. cat >> shortName.def <<EOF
  65. # EC-Earth product $i
  66. '~' = {
  67. table2Version = 126 ;
  68. indicatorOfParameter = $i ;
  69. }
  70. EOF
  71. #units
  72. cat >> units.def <<EOF
  73. # EC-Earth product $i
  74. '~' = {
  75. table2Version = 126 ;
  76. indicatorOfParameter = $i ;
  77. }
  78. EOF
  79. done