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