[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function ATM_Initialize |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 6 | |
---|
| 7 | |
---|
[4281] | 8 | # Define the resolution only if the composant ICO for DYNAMICO is not set in config.card |
---|
| 9 | if [ X${config_ListOfComponents_ICO} = X ] ; then |
---|
[396] | 10 | |
---|
[4281] | 11 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x39 |
---|
[649] | 12 | |
---|
[4281] | 13 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
| 14 | RESOL_ATM_X=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $1}' ) |
---|
| 15 | RESOL_ATM_Y=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $2}' ) |
---|
| 16 | RESOL_ATM_XY="${RESOL_ATM_X}x${RESOL_ATM_Y}" |
---|
| 17 | |
---|
| 18 | else |
---|
| 19 | RESOL_ATM_Z=${dynamico_UserChoices_RESOL_ATM_Z} |
---|
| 20 | fi |
---|
| 21 | |
---|
[1541] | 22 | ##- LMDZ physics version |
---|
| 23 | ## Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) |
---|
| 24 | if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then |
---|
| 25 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
| 26 | else |
---|
| 27 | LMDZ_Physics=AP |
---|
| 28 | fi |
---|
| 29 | echo LMDZ physics version : ${LMDZ_Physics} |
---|
| 30 | |
---|
[1643] | 31 | ##- Create_etat0_limit version |
---|
[1782] | 32 | ## Define variable CREATE only if it is set in lmdz.card section UserChoices. |
---|
| 33 | ## This variable is only used in lmdz.card to choose input files. |
---|
| 34 | if [ ! X${lmdz_UserChoices_CREATE} = X ] ; then |
---|
| 35 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
| 36 | CREATE=${lmdz_UserChoices_CREATE} |
---|
| 37 | echo create_etat0_limit version : ${CREATE} |
---|
| 38 | fi |
---|
[1643] | 39 | |
---|
[1782] | 40 | |
---|
[1550] | 41 | ## - LMDZ choice of config.def file |
---|
| 42 | ## ConfType must be set in lmdz.card |
---|
| 43 | ConfType=${lmdz_UserChoices_ConfType} |
---|
[1541] | 44 | |
---|
[1550] | 45 | ##- LMDZ output level, to be set in lmdz.card |
---|
| 46 | if [ X${lmdz_UserChoices_OutLevel} = X ] ; then |
---|
| 47 | # OutLevel is not set. Take default value low. |
---|
| 48 | OutLevel=low |
---|
| 49 | else |
---|
| 50 | OutLevel=${lmdz_UserChoices_OutLevel} |
---|
| 51 | fi |
---|
| 52 | |
---|
[1539] | 53 | ##-- Output frequency purpose .... |
---|
[396] | 54 | ##-- Initialisation .... |
---|
[2605] | 55 | ok_mensuel=.FALSE. |
---|
| 56 | ok_journe=.FALSE. |
---|
| 57 | ok_hf=.FALSE. |
---|
| 58 | ok_hf3h=.FALSE. |
---|
| 59 | ok_hf3hm=.FALSE. |
---|
| 60 | ok_stn=.FALSE. |
---|
[396] | 61 | |
---|
[3505] | 62 | |
---|
[396] | 63 | case ${config_UserChoices_PeriodLength} in |
---|
[2605] | 64 | 1Y|1y|1M|1m) ok_mensuel=.TRUE. ;; |
---|
| 65 | 5D|5d|1D|1d) ok_journe=.TRUE. ;; |
---|
[396] | 66 | esac |
---|
| 67 | |
---|
| 68 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 69 | case ${frequency} in |
---|
[2605] | 70 | 1M|1m) ok_mensuel=.TRUE. ;; |
---|
[396] | 71 | esac |
---|
| 72 | case ${frequency} in |
---|
[2605] | 73 | 5D|5d|1D|1d) ok_journe=.TRUE. ;; |
---|
[1539] | 74 | esac |
---|
| 75 | case ${frequency} in |
---|
[2605] | 76 | HF|hf) ok_hf=.TRUE. ;; |
---|
[396] | 77 | esac |
---|
[1539] | 78 | case ${frequency} in |
---|
[2605] | 79 | HF3h|hf3h) ok_hf3h=.TRUE. ;; |
---|
[1539] | 80 | esac |
---|
| 81 | case ${frequency} in |
---|
[2605] | 82 | HF3hm|hf3hm) ok_hf3hm=.TRUE. ;; |
---|
[1539] | 83 | esac |
---|
| 84 | case ${frequency} in |
---|
[2605] | 85 | STN|stn) ok_stn=.TRUE. ;; |
---|
[1539] | 86 | esac |
---|
[396] | 87 | done |
---|
| 88 | |
---|
[3505] | 89 | |
---|
| 90 | ## Read LMDZ_COSP_OK in lmdz.card |
---|
[2600] | 91 | if [ X${lmdz_UserChoices_LMDZ_COSP_OK} = Xy ] ; then |
---|
| 92 | ## LMDZ_COSP_OK=y, now read all other COSP variables |
---|
| 93 | ## Read LMDZ_COSP_monthly in lmdz.card |
---|
| 94 | if [ X${lmdz_UserChoices_LMDZ_COSP_monthly} = Xy ] ; then |
---|
[2605] | 95 | LMDZ_COSP_monthly=.TRUE. |
---|
[2600] | 96 | else |
---|
[2605] | 97 | LMDZ_COSP_monthly=.FALSE. |
---|
[2600] | 98 | fi |
---|
| 99 | ## Read LMDZ_COSP_daily in lmdz.card |
---|
| 100 | if [ X${lmdz_UserChoices_LMDZ_COSP_daily} = Xy ] ; then |
---|
[2605] | 101 | LMDZ_COSP_daily=.TRUE. |
---|
[2600] | 102 | else |
---|
[2605] | 103 | LMDZ_COSP_daily=.FALSE. |
---|
[2600] | 104 | fi |
---|
| 105 | ## Read LMDZ_COSP_hf in lmdz.card |
---|
| 106 | if [ X${lmdz_UserChoices_LMDZ_COSP_hf} = Xy ] ; then |
---|
[2605] | 107 | LMDZ_COSP_hf=.TRUE. |
---|
[2600] | 108 | else |
---|
[2605] | 109 | LMDZ_COSP_hf=.FALSE. |
---|
[2600] | 110 | fi |
---|
[1783] | 111 | else |
---|
[2600] | 112 | # LMDZ_COSP_OK=n : All cosp output are deactivated |
---|
[2605] | 113 | LMDZ_COSP_monthly=.FALSE. |
---|
| 114 | LMDZ_COSP_daily=.FALSE. |
---|
| 115 | LMDZ_COSP_hf=.FALSE. |
---|
[2600] | 116 | fi |
---|
[1000] | 117 | |
---|
[1783] | 118 | ## Read LMDZ_NMC_monthly in lmdz.card |
---|
[2600] | 119 | if [ X${lmdz_UserChoices_LMDZ_NMC_monthly} = Xy ] ; then |
---|
[2605] | 120 | LMDZ_NMC_monthly=.TRUE. |
---|
[1783] | 121 | else |
---|
[2605] | 122 | LMDZ_NMC_monthly=.FALSE. |
---|
[1783] | 123 | fi |
---|
[2600] | 124 | |
---|
[1783] | 125 | ## Read LMDZ_NMC_daily in lmdz.card |
---|
[2600] | 126 | if [ X${lmdz_UserChoices_LMDZ_NMC_daily} = Xy ] ; then |
---|
[2605] | 127 | LMDZ_NMC_daily=.TRUE. |
---|
[1783] | 128 | else |
---|
[2605] | 129 | LMDZ_NMC_daily=.FALSE. |
---|
[1783] | 130 | fi |
---|
| 131 | |
---|
| 132 | ## Read LMDZ_NMC_hf in lmdz.card |
---|
[2600] | 133 | if [ X${lmdz_UserChoices_LMDZ_NMC_hf} = Xy ] ; then |
---|
[2605] | 134 | LMDZ_NMC_hf=.TRUE. |
---|
[1783] | 135 | else |
---|
[2605] | 136 | LMDZ_NMC_hf=.FALSE. |
---|
[1783] | 137 | fi |
---|
[2600] | 138 | |
---|
[1783] | 139 | |
---|
[396] | 140 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | #----------------------------------------------------------------- |
---|
| 144 | function ATM_Update |
---|
| 145 | { |
---|
| 146 | IGCM_debug_PushStack "ATM_Update" |
---|
| 147 | |
---|
[1535] | 148 | ##-- GHG forcing : |
---|
[2321] | 149 | ## If forcing file exist in run directory, read values for the current year |
---|
| 150 | ## and set in config.def. If not use the default value set in config.def |
---|
[2333] | 151 | |
---|
| 152 | # Read value for solaire from file SOLARANDVOLCANOES.txt. If file not existing, take DEFAULT value from file. |
---|
[3127] | 153 | IGCM_debug_Print 1 "Note that the solaire parameter is here below changed but it is only used by LMDZ for old physics(AP and NPv3.2)" |
---|
| 154 | IGCM_debug_Print 1 "For newer physics with iflag_rrtm=1 and ok_suntime_rrtm=y, the solar constant is instead taken from solarforcing.nc file" |
---|
[1535] | 155 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
[2333] | 156 | value=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
| 157 | if [ X"${value}" = X ] ; then |
---|
[2321] | 158 | # The grep returned empty variable, stop execution |
---|
| 159 | IGCM_debug_Exit "The file SOLARANDVOLCANOES.txt do not contain the current year." |
---|
| 160 | IGCM_debug_Verif_Exit |
---|
| 161 | fi |
---|
[1690] | 162 | else |
---|
[2333] | 163 | value=DEFAULT |
---|
[1535] | 164 | fi |
---|
[2333] | 165 | IGCM_comp_modifyDefFile nonblocker config.def solaire $value |
---|
[2321] | 166 | |
---|
[3771] | 167 | # Read value for eccentricity from file Eccentricity.txt. If file not existing, take DEFAULT value from file. |
---|
| 168 | if [ -f Eccentricity.txt ] ; then |
---|
| 169 | value=`grep Annee_${year} Eccentricity.txt | awk -F= '{print $2}'` |
---|
| 170 | if [ X"${value}" = X ] ; then |
---|
| 171 | # The grep returned empty variable, stop execution |
---|
| 172 | IGCM_debug_Exit "The file Eccentricity.txt do not contain the current year." |
---|
| 173 | IGCM_debug_Verif_Exit |
---|
| 174 | fi |
---|
| 175 | else |
---|
| 176 | value=DEFAULT |
---|
| 177 | fi |
---|
| 178 | IGCM_comp_modifyDefFile nonblocker config.def R_ecc $value |
---|
[2333] | 179 | |
---|
[3771] | 180 | # Read value for obliquity from file Obliquity.txt. If file not existing, take DEFAULT value from file. |
---|
| 181 | if [ -f Obliquity.txt ] ; then |
---|
| 182 | value=`grep Annee_${year} Obliquity.txt | awk -F= '{print $2}'` |
---|
| 183 | if [ X"${value}" = X ] ; then |
---|
| 184 | # The grep returned empty variable, stop execution |
---|
| 185 | IGCM_debug_Exit "The file Obliquity.txt do not contain the current year." |
---|
| 186 | IGCM_debug_Verif_Exit |
---|
| 187 | fi |
---|
| 188 | else |
---|
| 189 | value=DEFAULT |
---|
| 190 | fi |
---|
| 191 | IGCM_comp_modifyDefFile nonblocker config.def R_incl $value |
---|
| 192 | |
---|
| 193 | # Read value for perihelie from file Perihelie.txt. If file not existing, take DEFAULT value from file. |
---|
| 194 | if [ -f Perihelie.txt ] ; then |
---|
| 195 | value=`grep Annee_${year} Perihelie.txt | awk -F= '{print $2}'` |
---|
| 196 | if [ X"${value}" = X ] ; then |
---|
| 197 | # The grep returned empty variable, stop execution |
---|
| 198 | IGCM_debug_Exit "The file Perihelie.txt do not contain the current year." |
---|
| 199 | IGCM_debug_Verif_Exit |
---|
| 200 | fi |
---|
| 201 | else |
---|
| 202 | value=DEFAULT |
---|
| 203 | fi |
---|
| 204 | IGCM_comp_modifyDefFile nonblocker config.def R_peri $value |
---|
| 205 | |
---|
[2333] | 206 | # Read value for co2_ppm from file CO2.txt. If file not existing, take DEFAULT value from file. |
---|
[3568] | 207 | # Calculate co2_ppm_per as co2_ppm*4. |
---|
[1535] | 208 | if [ -f CO2.txt ] ; then |
---|
[2333] | 209 | value=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
| 210 | if [ X"${value}" = X ] ; then |
---|
[2321] | 211 | # The grep returned empty variable, stop execution |
---|
| 212 | IGCM_debug_Exit "The file CO2.txt do not contain the current year." |
---|
| 213 | IGCM_debug_Verif_Exit |
---|
| 214 | fi |
---|
[3568] | 215 | value4=`grep Annee_${year} CO2.txt | awk -F= '{print $2 * 4}'` |
---|
[1690] | 216 | else |
---|
[2333] | 217 | value=DEFAULT |
---|
[3568] | 218 | value4=DEFAULT |
---|
[1535] | 219 | fi |
---|
[2333] | 220 | IGCM_comp_modifyDefFile nonblocker config.def co2_ppm $value |
---|
[3568] | 221 | IGCM_comp_modifyDefFile nonblocker config.def co2_ppm_per $value4 |
---|
[1690] | 222 | |
---|
[2333] | 223 | |
---|
| 224 | # Read value for CH4_ppb from file CH4.txt. If file not existing, take DEFAULT value from file. |
---|
[1535] | 225 | if [ -f CH4.txt ] ; then |
---|
[2333] | 226 | value=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
| 227 | if [ X"${value}" = X ] ; then |
---|
[2321] | 228 | # The grep returned empty variable, stop execution |
---|
| 229 | IGCM_debug_Exit "The file CH4.txt do not contain the current year." |
---|
| 230 | IGCM_debug_Verif_Exit |
---|
| 231 | fi |
---|
[2333] | 232 | else |
---|
| 233 | value=DEFAULT |
---|
[1535] | 234 | fi |
---|
[2333] | 235 | IGCM_comp_modifyDefFile nonblocker config.def CH4_ppb $value |
---|
[2321] | 236 | |
---|
[2333] | 237 | |
---|
| 238 | # Read value for N2O_ppb from file N2O.txt. If file not existing, take DEFAULT value from file. |
---|
[1535] | 239 | if [ -f N2O.txt ] ; then |
---|
[2333] | 240 | value=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
| 241 | if [ X"${value}" = X ] ; then |
---|
[2321] | 242 | # The grep returned empty variable, stop execution |
---|
| 243 | IGCM_debug_Exit "The file N2O.txt do not contain the current year." |
---|
| 244 | IGCM_debug_Verif_Exit |
---|
| 245 | fi |
---|
[1690] | 246 | else |
---|
[2333] | 247 | value=DEFAULT |
---|
[1535] | 248 | fi |
---|
[2333] | 249 | IGCM_comp_modifyDefFile nonblocker config.def N2O_ppb $value |
---|
[2321] | 250 | |
---|
[2333] | 251 | # Read value for CFC11_ppt from file CFC11.txt. If file not existing, take DEFAULT value from file. |
---|
[1535] | 252 | if [ -f CFC11.txt ] ; then |
---|
[2333] | 253 | value=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
| 254 | if [ X"${value}" = X ] ; then |
---|
[2321] | 255 | # The grep returned empty variable, stop execution |
---|
| 256 | IGCM_debug_Exit "The file CFC11.txt do not contain the current year." |
---|
| 257 | IGCM_debug_Verif_Exit |
---|
| 258 | fi |
---|
[1690] | 259 | else |
---|
[2333] | 260 | value=DEFAULT |
---|
[1535] | 261 | fi |
---|
[2333] | 262 | IGCM_comp_modifyDefFile nonblocker config.def CFC11_ppt $value |
---|
[2321] | 263 | |
---|
[2333] | 264 | |
---|
| 265 | # Read value for CFC12_ppt from file CFC12.txt. If file not existing, take DEFAULT value from file. |
---|
[1535] | 266 | if [ -f CFC12.txt ] ; then |
---|
[2333] | 267 | value=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
| 268 | if [ X"${value}" = X ] ; then |
---|
[2321] | 269 | # The grep returned empty variable, stop execution |
---|
| 270 | IGCM_debug_Exit "The file CFC12.txt do not contain the current year." |
---|
| 271 | IGCM_debug_Verif_Exit |
---|
| 272 | fi |
---|
[1690] | 273 | else |
---|
[2333] | 274 | value=DEFAULT |
---|
[1535] | 275 | fi |
---|
[2333] | 276 | IGCM_comp_modifyDefFile nonblocker config.def CFC12_ppt $value |
---|
[1535] | 277 | |
---|
[1780] | 278 | |
---|
[2336] | 279 | ## Coupling Time Step : Take value of FreqCoupling set in oasis.card or if it is not set, take default value 86400 |
---|
| 280 | LMDZ_t_coupl=${oasis_UserChoices_FreqCoupling:-86400} |
---|
[2332] | 281 | IGCM_debug_Print 3 "LMDZ_t_coupl " ${LMDZ_t_coupl} |
---|
[2333] | 282 | IGCM_comp_modifyDefFile nonblocker config.def t_coupl ${LMDZ_t_coupl} |
---|
[2332] | 283 | |
---|
[1780] | 284 | ##-- Add special treatement for CARBON CYCLE |
---|
[1546] | 285 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 286 | ATM_Carbon_Update |
---|
| 287 | fi |
---|
[1537] | 288 | |
---|
| 289 | |
---|
[1538] | 290 | ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate |
---|
| 291 | ## COSP daily output for years 1979 and later (mandatory for historical CMIP5 run). |
---|
| 292 | if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] && [ ${year} -ge 1979 ]) ; then |
---|
[2605] | 293 | LMDZ_COSP_daily=.TRUE. |
---|
[1538] | 294 | fi |
---|
[1537] | 295 | |
---|
[2600] | 296 | ## Modifiy |
---|
[2605] | 297 | IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled ${ok_mensuel} |
---|
| 298 | |
---|
| 299 | IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled ${ok_journe} |
---|
| 300 | |
---|
[2600] | 301 | if [ X${OutLevel} = Xlow ] || [ X${OutLevel} = Xmedium ] ; then |
---|
| 302 | IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level 2 |
---|
| 303 | else |
---|
| 304 | IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level 5 |
---|
| 305 | fi |
---|
| 306 | |
---|
[2605] | 307 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled ${ok_hf} |
---|
| 308 | |
---|
[2600] | 309 | if [ X${OutLevel} = Xlow ] ; then |
---|
| 310 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 5 |
---|
| 311 | elif [ X${OutLevel} = Xmedium ] ; then |
---|
| 312 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 6 |
---|
| 313 | elif [ X${OutLevel} = Xhigh ] ; then |
---|
| 314 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 7 |
---|
[2582] | 315 | fi |
---|
[2600] | 316 | |
---|
[2755] | 317 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf3h_lmdz.xml histhf3h enabled ${ok_hf3h} |
---|
| 318 | IGCM_comp_modifyXmlFile nonblocker file_def_histhf3hm_lmdz.xml histhf3hm enabled ${ok_hf3hm} |
---|
[2605] | 319 | |
---|
| 320 | IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled ${ok_stn} |
---|
[2600] | 321 | |
---|
[2605] | 322 | IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled ${LMDZ_NMC_monthly} |
---|
| 323 | IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled ${LMDZ_NMC_daily} |
---|
| 324 | IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled ${LMDZ_NMC_hf} |
---|
[2600] | 325 | |
---|
[2605] | 326 | IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP enabled ${LMDZ_COSP_monthly} |
---|
| 327 | IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP enabled ${LMDZ_COSP_daily} |
---|
| 328 | IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP enabled ${LMDZ_COSP_hf} |
---|
[2332] | 329 | |
---|
[3104] | 330 | # Activate the histstrataer output file only for configuration with interactive stratospheric aersols |
---|
| 331 | # done by setting the key word LMDZ_strataero=y in lmdz.card |
---|
| 332 | if [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then |
---|
| 333 | IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled .TRUE. |
---|
| 334 | else |
---|
| 335 | IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled .FALSE. |
---|
| 336 | fi |
---|
[396] | 337 | |
---|
[3104] | 338 | |
---|
[911] | 339 | ## run.def parameters |
---|
[2598] | 340 | |
---|
| 341 | |
---|
| 342 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
[4281] | 343 | |
---|
[2598] | 344 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 345 | IGCM_comp_modifyDefFile blocker run.def raz_date 1 |
---|
| 346 | else |
---|
| 347 | IGCM_comp_modifyDefFile blocker run.def raz_date 0 |
---|
| 348 | fi |
---|
| 349 | |
---|
| 350 | ##-- Calendar type for LMDZ and create_etat0_limit |
---|
[4281] | 351 | # calend is read from both LMDZ dynamics and physics parts of the model |
---|
[2598] | 352 | case ${config_UserChoices_CalendarType} in |
---|
| 353 | leap|gregorian) |
---|
| 354 | IGCM_comp_modifyDefFile blocker run.def calend gregorian ;; |
---|
| 355 | noleap) |
---|
| 356 | IGCM_comp_modifyDefFile blocker run.def calend earth_365d ;; |
---|
| 357 | 360d) |
---|
| 358 | IGCM_comp_modifyDefFile blocker run.def calend earth_360d ;; |
---|
| 359 | *) |
---|
| 360 | IGCM_comp_modifyDefFile blocker run.def calend earth_360d ;; |
---|
| 361 | esac |
---|
| 362 | |
---|
[396] | 363 | |
---|
[4281] | 364 | ## -- Modify more calendar related variables. These variables are only read by LMDZ dynamics part. |
---|
| 365 | # Set them to dummy if component ICO (DYNAMICO) is set in config.card. |
---|
| 366 | if [ X${config_ListOfComponents_ICO} = X ] ; then |
---|
| 367 | # Following variables are read by LMDZ dynamics |
---|
| 368 | IGCM_comp_modifyDefFile blocker run.def dayref ${InitDay} |
---|
| 369 | IGCM_comp_modifyDefFile blocker run.def nday ${PeriodLengthInDays} |
---|
[2480] | 370 | |
---|
[4281] | 371 | # Set anneeref different for gcm and ce0l |
---|
| 372 | # Test if executable create_etat0_limit is present and lmdz.x is not present |
---|
| 373 | if [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
| 374 | # for case ce0l : always take current year |
---|
| 375 | IGCM_comp_modifyDefFile blocker run.def anneeref ${year} |
---|
| 376 | |
---|
| 377 | # Temporary, set use_filtre_fft=n because we now use dyn3d for ce0l version where fft is not implemented. |
---|
| 378 | # In more recent versions of LMDZ, this will not be needed. |
---|
| 379 | IGCM_comp_modifyDefFile force run.def use_filtre_fft n |
---|
| 380 | else |
---|
| 381 | # for case gcm : take first year of simulation |
---|
| 382 | IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear} |
---|
| 383 | fi |
---|
| 384 | |
---|
[1804] | 385 | else |
---|
[4281] | 386 | # ICO is found in config.card which means that DYNMAICO is activated. |
---|
| 387 | # Set these variables to DUMMY. They will not be read. |
---|
| 388 | IGCM_comp_modifyDefFile blocker run.def dayref DUMMY |
---|
| 389 | IGCM_comp_modifyDefFile blocker run.def nday DUMMY |
---|
| 390 | IGCM_comp_modifyDefFile blocker run.def anneeref DUMMY |
---|
| 391 | IGCM_comp_modifyDefFile force run.def use_filtre_fft DUMMY |
---|
[1804] | 392 | fi |
---|
[1643] | 393 | |
---|
[1650] | 394 | ## Determine from the variable ListOfComponents in config.card coupling to external models |
---|
| 395 | ## and set corresponding parameters in run.def |
---|
| 396 | echo ListOfComponents now running : ${config_ListOfComponents[*]} |
---|
| 397 | |
---|
| 398 | if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then |
---|
| 399 | echo "Activate ORCHIDEE, set VEGET=y in run.def" |
---|
[2333] | 400 | IGCM_comp_modifyDefFile blocker run.def VEGET y |
---|
[1650] | 401 | else |
---|
| 402 | echo "No ORCHIDEE, set VEGET=n in run.def" |
---|
[2333] | 403 | IGCM_comp_modifyDefFile blocker run.def VEGET n |
---|
[1650] | 404 | fi |
---|
| 405 | |
---|
| 406 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
| 407 | echo "Activate coupling to ocean, set type_ocean=couple in run.def" |
---|
[2333] | 408 | IGCM_comp_modifyDefFile blocker run.def type_ocean couple |
---|
[1650] | 409 | else |
---|
| 410 | echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def" |
---|
[3935] | 411 | IGCM_comp_modifyDefFile nonblocker run.def type_ocean force |
---|
[1650] | 412 | fi |
---|
| 413 | |
---|
| 414 | if [ X${config_ListOfComponents_CHM} = Xinca ] ; then |
---|
| 415 | echo "Activate coupling to INCA, set type_trac=inca in run.def" |
---|
[2333] | 416 | IGCM_comp_modifyDefFile blocker run.def type_trac inca |
---|
[1650] | 417 | elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then |
---|
| 418 | echo "Activate coupling to REPROBUS, set type_trac=repr in run.def" |
---|
[2333] | 419 | IGCM_comp_modifyDefFile blocker run.def type_trac repr |
---|
| 420 | IGCM_comp_modifyDefFile blocker run.def config_inca none |
---|
[1650] | 421 | else |
---|
| 422 | echo "No coupling to chemistry model, set type_trac=lmdz in run.def" |
---|
[2333] | 423 | IGCM_comp_modifyDefFile blocker run.def type_trac lmdz |
---|
| 424 | IGCM_comp_modifyDefFile blocker run.def config_inca none |
---|
[1650] | 425 | fi |
---|
| 426 | |
---|
| 427 | |
---|
[4020] | 428 | # run.def : Activate the call to phytrac |
---|
| 429 | if [ ! X${lmdz_UserChoices_iflag_phytrac} = X ]; then |
---|
| 430 | IGCM_comp_modifyDefFile nonblocker run.def iflag_phytrac ${lmdz_UserChoices_iflag_phytrac} |
---|
| 431 | else |
---|
| 432 | IGCM_comp_modifyDefFile nonblocker run.def iflag_phytrac 0 |
---|
| 433 | fi |
---|
| 434 | |
---|
| 435 | # physiq.def : Activate the call to phytrac |
---|
| 436 | if [ ! X${lmdz_UserChoices_ok_bug_cv_trac} = X ]; then |
---|
| 437 | IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac ${lmdz_UserChoices_ok_bug_cv_trac} |
---|
| 438 | else |
---|
| 439 | IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac n |
---|
| 440 | fi |
---|
| 441 | |
---|
[2015] | 442 | # config.def : Activate direct radiative effect if ok_ade=y |
---|
| 443 | if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then |
---|
[2333] | 444 | IGCM_comp_modifyDefFile nonblocker config.def ok_ade ${lmdz_UserChoices_ok_ade} |
---|
[2015] | 445 | else |
---|
[2333] | 446 | IGCM_comp_modifyDefFile nonblocker config.def ok_ade n |
---|
[2015] | 447 | fi |
---|
| 448 | |
---|
| 449 | # config.def : Activate indirect radiative effect if ok_aie=y |
---|
| 450 | if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then |
---|
[2333] | 451 | IGCM_comp_modifyDefFile nonblocker config.def ok_aie ${lmdz_UserChoices_ok_aie} |
---|
[2015] | 452 | else |
---|
[2333] | 453 | IGCM_comp_modifyDefFile nonblocker config.def ok_aie n |
---|
[2015] | 454 | fi |
---|
[1816] | 455 | |
---|
[2015] | 456 | # config.def : Activate online aerosol coupled model if aerosol_couple=y |
---|
| 457 | if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then |
---|
[2333] | 458 | IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple} |
---|
[1686] | 459 | else |
---|
[2333] | 460 | IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple n |
---|
[2015] | 461 | fi |
---|
[1686] | 462 | |
---|
[4020] | 463 | # config.def : Activate online Ozone chemistry coupled model if chemistry_couple=y |
---|
| 464 | if [ ! X${lmdz_UserChoices_chemistry_couple} = X ]; then |
---|
| 465 | IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple ${lmdz_UserChoices_chemistry_couple} |
---|
| 466 | else |
---|
| 467 | IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple n |
---|
| 468 | fi |
---|
| 469 | |
---|
[2015] | 470 | # config.def : Activate reading of ozone in climatology if read_climoz=2 |
---|
| 471 | if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then |
---|
[2333] | 472 | IGCM_comp_modifyDefFile nonblocker config.def read_climoz ${lmdz_UserChoices_read_climoz} |
---|
[2015] | 473 | else |
---|
[2333] | 474 | IGCM_comp_modifyDefFile nonblocker config.def read_climoz 0 |
---|
[2015] | 475 | fi |
---|
| 476 | |
---|
| 477 | # config.def : Choose aerosol use in radiative effect |
---|
| 478 | # type of coupled aerosol =1 (default) =2 => bc only =3 => pom only =4 => seasalt only |
---|
| 479 | # =5 => dust only =6 => all aerosol |
---|
| 480 | if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then |
---|
[2333] | 481 | IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol} |
---|
[2015] | 482 | else |
---|
[2333] | 483 | IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol 0 |
---|
[2015] | 484 | fi |
---|
| 485 | |
---|
| 486 | # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y |
---|
| 487 | if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then |
---|
[2333] | 488 | IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc} |
---|
[2015] | 489 | else |
---|
[2333] | 490 | IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n |
---|
[2015] | 491 | fi |
---|
| 492 | |
---|
[2893] | 493 | # config.def : Activate COSP |
---|
| 494 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ]; then |
---|
| 495 | IGCM_comp_modifyDefFile nonblocker config.def ok_cosp ${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 496 | else |
---|
| 497 | IGCM_comp_modifyDefFile nonblocker config.def ok_cosp n |
---|
| 498 | fi |
---|
| 499 | |
---|
[2911] | 500 | # config.def : Modify parameter pmagic if it is set in lmdz.card |
---|
| 501 | if [ ! X${lmdz_UserChoices_pmagic} = X ]; then |
---|
| 502 | IGCM_comp_modifyDefFile nonblocker config.def pmagic ${lmdz_UserChoices_pmagic} |
---|
| 503 | else |
---|
| 504 | # Take default value set in config.def |
---|
| 505 | IGCM_comp_modifyDefFile nonblocker config.def pmagic DEFAULT |
---|
| 506 | fi |
---|
[2893] | 507 | |
---|
[3868] | 508 | # physiq.def : Modify parameter tau_gl if it is set in lmdz.card |
---|
| 509 | if [ ! X${lmdz_UserChoices_tau_gl} = X ]; then |
---|
| 510 | IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl ${lmdz_UserChoices_tau_gl} |
---|
| 511 | else |
---|
| 512 | # Take default value set in physiq.def |
---|
[4038] | 513 | IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl DEFAULT |
---|
[3868] | 514 | fi |
---|
| 515 | |
---|
| 516 | |
---|
[1690] | 517 | # guide.def : Activate nudging if ok_guide=y set in lmdz.card |
---|
[1643] | 518 | if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then |
---|
[2333] | 519 | IGCM_comp_modifyDefFile nonblocker guide.def ok_guide ${lmdz_UserChoices_ok_guide} |
---|
[1690] | 520 | else |
---|
[2333] | 521 | IGCM_comp_modifyDefFile nonblocker guide.def ok_guide n |
---|
[1643] | 522 | fi |
---|
| 523 | |
---|
[3868] | 524 | |
---|
[4281] | 525 | # Specific ByPass option only used with LMDZ dynamcis (without DYNMAICO) |
---|
| 526 | if [ X${config_ListOfComponents_ICO} = X ] ; then |
---|
[396] | 527 | |
---|
[4281] | 528 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 529 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
| 530 | if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then |
---|
| 531 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 532 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 533 | echo |
---|
| 534 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 535 | echo |
---|
| 536 | cat gcm.def |
---|
| 537 | ByPass_hgardfou_teta=n |
---|
| 538 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
| 539 | fi |
---|
| 540 | |
---|
| 541 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 542 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
| 543 | if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then |
---|
| 544 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 545 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 546 | echo |
---|
| 547 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 548 | echo |
---|
| 549 | cat gcm.def |
---|
| 550 | ByPass_hgardfou_mats=n |
---|
| 551 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
| 552 | fi |
---|
[396] | 553 | fi |
---|
| 554 | |
---|
[4281] | 555 | |
---|
[2904] | 556 | # Add include of LMDZ context in iodef.xml |
---|
[4108] | 557 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
[2904] | 558 | echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp |
---|
[4108] | 559 | # Add inclusion of file context_input_lmdz.xml if this file exists |
---|
| 560 | if [ -f context_input_lmdz.xml ] ; then |
---|
| 561 | echo '<context id="LMDZ" src="./context_input_lmdz.xml"/>' >> add.tmp |
---|
| 562 | fi |
---|
| 563 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
[3505] | 564 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
| 565 | echo '<context id="LMDZ" src="./ping_lmdz.xml"/>' >> add.tmp |
---|
| 566 | echo '<context id="LMDZ" src="./dr2xml_lmdz.xml"/>' >> add.tmp |
---|
| 567 | fi |
---|
[2904] | 568 | cp iodef.xml iodef.xml.tmp |
---|
| 569 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
| 570 | rm iodef.xml.tmp add.tmp |
---|
[2476] | 571 | |
---|
[2904] | 572 | #Long Name as global attribute (if LongName is not empty) |
---|
| 573 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
| 574 | listfile=$(ls file_def*lmdz.xml) |
---|
| 575 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
| 576 | for file in ${listfile} |
---|
| 577 | do |
---|
| 578 | cp ${file} ${file}.tmp |
---|
| 579 | sed -e "/<file id/r add.tmp" \ |
---|
| 580 | ${file}.tmp > ${file} |
---|
| 581 | rm ${file}.tmp |
---|
| 582 | done |
---|
| 583 | rm add.tmp |
---|
[2332] | 584 | fi |
---|
[2904] | 585 | |
---|
[396] | 586 | IGCM_debug_PopStack "ATM_Update" |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | #----------------------------------- |
---|
| 590 | function ATM_Finalize |
---|
| 591 | { |
---|
| 592 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 593 | |
---|
[1537] | 594 | # Add special treatement for CARBON CYCLE |
---|
[1546] | 595 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 596 | ATM_Carbon_Finalize |
---|
| 597 | fi |
---|
[1537] | 598 | |
---|
[1780] | 599 | echo FINALIZE ATM ! |
---|
[1537] | 600 | |
---|
[1780] | 601 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 602 | } |
---|
[1537] | 603 | |
---|
| 604 | |
---|
| 605 | |
---|
[1780] | 606 | function ATM_Carbon_Update |
---|
| 607 | { |
---|
| 608 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
[1537] | 609 | |
---|
[1780] | 610 | IGCM_debug_PushStack "ATM_Carbon_Update" |
---|
| 611 | |
---|
| 612 | typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 |
---|
| 613 | typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 614 | typeset PathCO2log |
---|
| 615 | typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX |
---|
| 616 | |
---|
| 617 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then |
---|
| 618 | ##--Initialization of fluxes to an undefined value at the first run |
---|
| 619 | UndefinedValueCo2=-9999 |
---|
| 620 | InitPeriodCo2=0 |
---|
| 621 | InitDateBeginCo2=${UndefinedValueCo2} |
---|
| 622 | InitYearCo2=$(( ${year} - 1 )) |
---|
| 623 | InitDateEndCo2=${InitYearCo2}1231 |
---|
| 624 | fCO2_ff=${UndefinedValueCo2} |
---|
| 625 | CO2SBG=${UndefinedValueCo2} |
---|
| 626 | CO2LU=${UndefinedValueCo2} |
---|
| 627 | CO2MBG=${UndefinedValueCo2} |
---|
| 628 | CO2_ppm_prec=${UndefinedValueCo2} |
---|
| 629 | # Get the initial value of atmosp. pco2 |
---|
| 630 | CO2_ppm=${lmdz_UserChoices_co2_init} |
---|
| 631 | |
---|
| 632 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 633 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 634 | |
---|
[1537] | 635 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
[1780] | 636 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
[1537] | 637 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
[1780] | 638 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 639 | |
---|
| 640 | # Get the path where the log file co2.log is |
---|
| 641 | PathCO2log=${SUBMIT_DIR} |
---|
| 642 | # Get Previous line in co2.log |
---|
| 643 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 644 | |
---|
| 645 | else |
---|
| 646 | |
---|
| 647 | # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): |
---|
| 648 | # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. |
---|
| 649 | #SubmitRestartPath= |
---|
| 650 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then |
---|
| 651 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath |
---|
| 652 | PathCO2log=${config_ATM_SubmitRestartPath} |
---|
| 653 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) |
---|
| 654 | PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) |
---|
| 655 | |
---|
| 656 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 657 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 658 | |
---|
| 659 | # Save Last Line of control in new co2.log file |
---|
| 660 | InitPeriodCo2=0 |
---|
| 661 | InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) |
---|
| 662 | InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) |
---|
| 663 | fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) |
---|
| 664 | CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) |
---|
| 665 | CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) |
---|
| 666 | CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) |
---|
| 667 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) |
---|
| 668 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 669 | |
---|
| 670 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 671 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 672 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 673 | else |
---|
| 674 | # Get restart line in co2.log |
---|
| 675 | PathCO2log=${SUBMIT_DIR} |
---|
| 676 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 677 | # Get the value of atmosp. pco2 in co2.log |
---|
| 678 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 679 | fi |
---|
| 680 | |
---|
[1537] | 681 | fi |
---|
[1780] | 682 | |
---|
| 683 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
[2841] | 684 | # Modify co2_ppm in config.def only for historical run |
---|
| 685 | # If not historical run, keep co2_ppm value set earlier by IGCM_comp_modifyDefFile |
---|
| 686 | IGCM_comp_modifyDefFile force config.def co2_ppm ${CO2_ppm} |
---|
[1780] | 687 | fi |
---|
| 688 | IGCM_debug_PopStack "ATM_Carbon_Update" |
---|
| 689 | } |
---|
[1537] | 690 | |
---|
[396] | 691 | |
---|
[1780] | 692 | function ATM_Carbon_Finalize |
---|
| 693 | { |
---|
| 694 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
| 695 | |
---|
| 696 | IGCM_debug_PushStack "ATM_Carbon_Finalize" |
---|
| 697 | |
---|
| 698 | typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 699 | |
---|
| 700 | # Fossil fuel emission |
---|
| 701 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then |
---|
| 702 | # For Control, no fossil fuel emission : |
---|
| 703 | fCO2_ff=0 |
---|
| 704 | echo "Fossil Fuel for control run :" ${fCO2_ff} |
---|
| 705 | else |
---|
| 706 | # For historical, get the fossile fuel file : |
---|
| 707 | fCO2_ff=$( gawk "{if (match(\$0,\"${year}\ *${month}\")) {print \$3}}" ${SUBMIT_DIR}/PARAM/CMIP5_gridcar_CO2_emissions_fossil_fuel_Andres_1751-2007_monthly_SC.txt ) |
---|
| 708 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
---|
| 709 | fi |
---|
| 710 | |
---|
| 711 | # Get the value of ocean carbon flux |
---|
| 712 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
---|
| 713 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
---|
| 714 | echo "Ocean carbon flux :" ${CO2MBG} |
---|
| 715 | |
---|
| 716 | # Get the value of land fluxes |
---|
| 717 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
---|
| 718 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
---|
| 719 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
---|
| 720 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
---|
| 721 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
---|
| 722 | echo "LU flux (FLUC) :" ${CO2LU} |
---|
| 723 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
---|
| 724 | |
---|
| 725 | # Previous CO2 |
---|
| 726 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 727 | echo "Previous CO2 :" ${CO2_ppm_prec} |
---|
| 728 | |
---|
| 729 | # Formula |
---|
| 730 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
---|
| 731 | echo "New CO2 :" ${CO2_ppm} |
---|
| 732 | |
---|
| 733 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 734 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 735 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 736 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 737 | |
---|
| 738 | IGCM_debug_PopStack "ATM_Carbon_Finalize" |
---|
[396] | 739 | } |
---|