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