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