[925] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #----------------------------------- |
---|
| 4 | function MBG_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "MBG_Initialize" |
---|
| 7 | |
---|
| 8 | # Local function to find namelists parameters |
---|
| 9 | supergrep () { |
---|
| 10 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
| 11 | } |
---|
| 12 | |
---|
[1785] | 13 | # Local function to find parameters in LMDZ .def files |
---|
| 14 | |
---|
| 15 | lmdzgrep () { |
---|
| 16 | grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}' |
---|
| 17 | } |
---|
| 18 | |
---|
[925] | 19 | ##--Variables used by MBG -- |
---|
| 20 | |
---|
[972] | 21 | # ln_rsttr boolean term for tracer model restart (true or false) |
---|
[925] | 22 | # nrsttr control of the time step (0, 1 or 2) |
---|
| 23 | |
---|
| 24 | ##--Variables used by PISCES -- |
---|
| 25 | |
---|
[2198] | 26 | NAMELIST_TOP_CFG=${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE}_cfg |
---|
| 27 | NAMELIST_PISCES_CFG=${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE}_cfg |
---|
[925] | 28 | |
---|
[2198] | 29 | PAT_TOP_LRSTTR=$( supergrep ln_rsttr ${NAMELIST_TOP_CFG} ) |
---|
[2221] | 30 | PAT_TOP_NRSTTR=$( supergrep nn_rsttr ${NAMELIST_TOP_CFG} ) |
---|
[2198] | 31 | PAT_PIS_ATCCO2=$( supergrep atcco2 ${NAMELIST_PISCES_CFG} ) |
---|
| 32 | PAT_PIS_LRIVER=$( supergrep ln_river ${NAMELIST_PISCES_CFG} ) |
---|
| 33 | |
---|
[925] | 34 | IGCM_debug_PopStack "MBG_Initialize" |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | #----------------------------------- |
---|
| 38 | function MBG_Update |
---|
| 39 | { |
---|
| 40 | IGCM_debug_PushStack "MBG_Update" |
---|
| 41 | |
---|
| 42 | ##-- Restart configuration |
---|
| 43 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
| 44 | |
---|
| 45 | #echo "NO RESTART FOR TOP" |
---|
| 46 | TOP_LRSTTR=.FALSE. |
---|
| 47 | TOP_NRSTTR=0 |
---|
| 48 | |
---|
| 49 | PISCES_LRIVER=.FALSE. |
---|
| 50 | |
---|
| 51 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
| 52 | |
---|
| 53 | #echo "RESTART TOP" |
---|
| 54 | TOP_LRSTTR=.TRUE. |
---|
| 55 | TOP_NRSTTR=0 |
---|
| 56 | |
---|
[2277] | 57 | PISCES_LRIVER=.FALSE. |
---|
[925] | 58 | |
---|
[2206] | 59 | # If we start from IPSLCM5* restart files. |
---|
| 60 | for file in restart_trc*.nc ; do |
---|
| 61 | ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1 |
---|
| 62 | done |
---|
| 63 | |
---|
[925] | 64 | else |
---|
| 65 | |
---|
| 66 | #echo "RESTART TOP" |
---|
| 67 | TOP_LRSTTR=.TRUE. |
---|
| 68 | TOP_NRSTTR=2 |
---|
| 69 | |
---|
[2277] | 70 | PISCES_LRIVER=.FALSE. |
---|
[925] | 71 | |
---|
| 72 | fi |
---|
| 73 | |
---|
[1437] | 74 | ##-- Enable dbio output file |
---|
| 75 | DBIO_ENABLE=".FALSE." |
---|
| 76 | eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1 |
---|
| 77 | if [ "${pisces_DBIO_ENABLE}" = "y" ]; then |
---|
| 78 | DBIO_ENABLE=".TRUE." |
---|
| 79 | fi |
---|
| 80 | |
---|
| 81 | # update iodef.xml |
---|
| 82 | |
---|
| 83 | echo 'Informations into iodef.xml : DBIO_ENABLE' |
---|
| 84 | echo ${DBIO_ENABLE} |
---|
| 85 | |
---|
| 86 | sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \ |
---|
| 87 | iodef.xml > iodef.xml.tmp |
---|
| 88 | |
---|
| 89 | IGCM_sys_Mv iodef.xml.tmp iodef.xml |
---|
| 90 | |
---|
[2198] | 91 | ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg |
---|
[1775] | 92 | if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then |
---|
[1535] | 93 | # Special case for carbon cycle |
---|
| 94 | # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices |
---|
[2198] | 95 | echo 'Update atcco2 in namelist_pisces_cfg with value from file co2.log' |
---|
[1535] | 96 | PathCO2log=${SUBMIT_DIR} |
---|
| 97 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 98 | IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 99 | sed -e "s%${PAT_PIS_ATCCO2}% atcco2=${IPCC_PIS_CO2}%" \ |
---|
[2198] | 100 | namelist_pisces_cfg > namelist_pisces_cfg.tmp |
---|
| 101 | IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg |
---|
[1550] | 102 | else |
---|
| 103 | # Take same CO2 as for LMDZ, in parameter file config.def. |
---|
| 104 | # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2. |
---|
[2198] | 105 | echo 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ' |
---|
[1550] | 106 | LMDZ_CO2=$( lmdzgrep co2_ppm config.def ) |
---|
| 107 | sed -e "s%${PAT_PIS_ATCCO2}% atcco2=${LMDZ_CO2}%" \ |
---|
[2198] | 108 | namelist_pisces_cfg > namelist_pisces_cfg.tmp |
---|
| 109 | IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg |
---|
[1535] | 110 | fi |
---|
| 111 | |
---|
[2198] | 112 | ##-- Update namelist_top_cfg and namelist_pisces_cfg |
---|
[925] | 113 | |
---|
| 114 | sed -e "s%${PAT_TOP_LRSTTR}% ln_rsttr=${TOP_LRSTTR}%" \ |
---|
[2221] | 115 | -e "s%${PAT_TOP_NRSTTR}% nn_rsttr=${TOP_NRSTTR}%" \ |
---|
[2198] | 116 | namelist_top_cfg > namelist_top_cfg.tmp |
---|
[925] | 117 | |
---|
[2198] | 118 | IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg |
---|
[925] | 119 | |
---|
| 120 | sed -e "s%${PAT_PIS_LRIVER}% ln_river=${PISCES_LRIVER}%" \ |
---|
[2198] | 121 | namelist_pisces_cfg > namelist_pisces_cfg.tmp |
---|
[925] | 122 | |
---|
[2198] | 123 | IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg |
---|
[925] | 124 | |
---|
| 125 | |
---|
| 126 | IGCM_debug_PopStack "MBG_Update" |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | #----------------------------------- |
---|
| 130 | function MBG_Finalize |
---|
| 131 | { |
---|
| 132 | IGCM_debug_PushStack "MBG_Finalize" |
---|
| 133 | |
---|
| 134 | echo FINALIZE MBG !!! |
---|
| 135 | |
---|
| 136 | IGCM_debug_PopStack "MBG_Finalize" |
---|
| 137 | } |
---|
| 138 | |
---|