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