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