[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
[894] | 3 | function LMDZ_sed |
---|
| 4 | { |
---|
[1690] | 5 | # Usage : LMDZ_sed filedef var_name myvalue |
---|
| 6 | # In file filedef modify the line containing var_name=xxx into var_name=myvalue |
---|
[894] | 7 | IGCM_debug_PushStack "LMDZ_sed" |
---|
[1783] | 8 | |
---|
| 9 | # Test if the fichier exist |
---|
| 10 | if [ ! -f ${1} ] ; then |
---|
| 11 | echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed : ${1} ${2} ${3}" |
---|
[2208] | 12 | IGCM_debug_PopStack "LMDZ_sed" |
---|
[1783] | 13 | return |
---|
| 14 | fi |
---|
[894] | 15 | |
---|
[911] | 16 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
[894] | 17 | RET=$? |
---|
| 18 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 19 | \mv ${1}.tmp ${1} |
---|
| 20 | |
---|
| 21 | IGCM_debug_PopStack "LMDZ_sed" |
---|
| 22 | return $RET |
---|
| 23 | } |
---|
[1690] | 24 | function LMDZ_sed_default |
---|
| 25 | { |
---|
| 26 | # Usage : LMDZ_sed_default filedef var_name |
---|
| 27 | # In file filedef modify the line "var_name=xxx DEFAULT= myvalue" |
---|
| 28 | # into "var_name=myvalue" |
---|
| 29 | IGCM_debug_PushStack "LMDZ_sed_default" |
---|
[894] | 30 | |
---|
[1690] | 31 | DefValue=$( grep ${2} ${1} | awk -F"DEFAULT.=*" '{print $2}') |
---|
| 32 | |
---|
| 33 | LMDZ_sed ${1} ${2} $DefValue |
---|
| 34 | IGCM_debug_PopStack "LMDZ_sed_default" |
---|
| 35 | return $RET |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | |
---|
[396] | 39 | function ATM_Initialize |
---|
| 40 | { |
---|
| 41 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 42 | |
---|
[671] | 43 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
[396] | 44 | |
---|
[659] | 45 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
[396] | 46 | |
---|
[659] | 47 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
[1802] | 48 | RESOL_ATM_X=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $1}' ) |
---|
| 49 | RESOL_ATM_Y=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $2}' ) |
---|
| 50 | RESOL_ATM_XY="${RESOL_ATM_X}x${RESOL_ATM_Y}" |
---|
[649] | 51 | |
---|
[1923] | 52 | ##-- Calendar type for LMDZ and create_etat0_limit |
---|
[697] | 53 | case ${config_UserChoices_CalendarType} in |
---|
| 54 | leap|gregorian) |
---|
[1923] | 55 | CalendarTypeForLmdz=earth_366d |
---|
| 56 | CalendarTypeForCreate=gregorian;; |
---|
[697] | 57 | noleap) |
---|
[1923] | 58 | CalendarTypeForLmdz=earth_365d |
---|
| 59 | CalendarTypeForCreate=${CalendarTypeForLmdz};; |
---|
[697] | 60 | 360d) |
---|
[1923] | 61 | CalendarTypeForLmdz=earth_360d |
---|
| 62 | CalendarTypeForCreate=${CalendarTypeForLmdz};; |
---|
[697] | 63 | *) |
---|
| 64 | CalendarTypeForLmdz=earth_360d |
---|
[1923] | 65 | CalendarTypeForCreate=${CalendarTypeForLmdz} |
---|
[697] | 66 | esac |
---|
| 67 | |
---|
[1541] | 68 | ##- LMDZ physics version |
---|
| 69 | ## Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) |
---|
| 70 | if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then |
---|
| 71 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
| 72 | else |
---|
| 73 | LMDZ_Physics=AP |
---|
| 74 | fi |
---|
| 75 | echo LMDZ physics version : ${LMDZ_Physics} |
---|
| 76 | |
---|
[1643] | 77 | ##- Create_etat0_limit version |
---|
[1782] | 78 | ## Define variable CREATE only if it is set in lmdz.card section UserChoices. |
---|
| 79 | ## This variable is only used in lmdz.card to choose input files. |
---|
| 80 | if [ ! X${lmdz_UserChoices_CREATE} = X ] ; then |
---|
| 81 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
| 82 | CREATE=${lmdz_UserChoices_CREATE} |
---|
| 83 | echo create_etat0_limit version : ${CREATE} |
---|
| 84 | fi |
---|
[1643] | 85 | |
---|
[1782] | 86 | |
---|
[1550] | 87 | ## - LMDZ choice of config.def file |
---|
| 88 | ## ConfType must be set in lmdz.card |
---|
| 89 | ConfType=${lmdz_UserChoices_ConfType} |
---|
[1541] | 90 | |
---|
[1550] | 91 | ##- LMDZ output level, to be set in lmdz.card |
---|
| 92 | if [ X${lmdz_UserChoices_OutLevel} = X ] ; then |
---|
| 93 | # OutLevel is not set. Take default value low. |
---|
| 94 | OutLevel=low |
---|
| 95 | else |
---|
| 96 | OutLevel=${lmdz_UserChoices_OutLevel} |
---|
| 97 | fi |
---|
| 98 | |
---|
[1539] | 99 | ##-- Output frequency purpose .... |
---|
[396] | 100 | ##-- Initialisation .... |
---|
[1539] | 101 | ok_mensuel=n |
---|
| 102 | ok_journe=n |
---|
[396] | 103 | ok_hf=n |
---|
[1539] | 104 | ok_hf3h=n |
---|
| 105 | ok_hf3hm=n |
---|
| 106 | ok_stn=n |
---|
[396] | 107 | |
---|
| 108 | case ${config_UserChoices_PeriodLength} in |
---|
[1539] | 109 | 1Y|1y|1M|1m) ok_mensuel=y ;; |
---|
| 110 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
[396] | 111 | esac |
---|
| 112 | |
---|
| 113 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 114 | case ${frequency} in |
---|
[1539] | 115 | 1M|1m) ok_mensuel=y ;; |
---|
[396] | 116 | esac |
---|
| 117 | case ${frequency} in |
---|
[1539] | 118 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
| 119 | esac |
---|
| 120 | case ${frequency} in |
---|
[396] | 121 | HF|hf) ok_hf=y ;; |
---|
| 122 | esac |
---|
[1539] | 123 | case ${frequency} in |
---|
| 124 | HF3h|hf3h) ok_hf3h=y ;; |
---|
| 125 | esac |
---|
| 126 | case ${frequency} in |
---|
| 127 | HF3hm|hf3hm) ok_hf3hm=y ;; |
---|
| 128 | esac |
---|
| 129 | case ${frequency} in |
---|
| 130 | STN|stn) ok_stn=y ;; |
---|
| 131 | esac |
---|
[396] | 132 | done |
---|
| 133 | |
---|
[902] | 134 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
[1688] | 135 | if [ X"${lmdz_UserChoices_LMDZ_NbPeriod_adjust}" = X"" ] ; then |
---|
| 136 | # The variable is not in lmdz.card, set default value |
---|
| 137 | LMDZ_NbPeriod_adjust=0 |
---|
| 138 | else |
---|
| 139 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
| 140 | fi |
---|
[396] | 141 | |
---|
[815] | 142 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[1688] | 143 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
[815] | 144 | fi |
---|
| 145 | |
---|
[912] | 146 | |
---|
[1783] | 147 | ## Read LMDZ_COSP_OK in lmdz.card |
---|
| 148 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ] ; then |
---|
| 149 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 150 | else |
---|
| 151 | LMDZ_COSP_OK=n |
---|
| 152 | fi |
---|
| 153 | ## Read LMDZ_COSP_monthly in lmdz.card |
---|
| 154 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_monthly} = X ] ; then |
---|
| 155 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 156 | else |
---|
| 157 | LMDZ_COSP_monthly=n |
---|
| 158 | fi |
---|
| 159 | ## Read LMDZ_COSP_daily in lmdz.card |
---|
| 160 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_daily} = X ] ; then |
---|
| 161 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 162 | else |
---|
| 163 | LMDZ_COSP_daily=n |
---|
| 164 | fi |
---|
| 165 | ## Read LMDZ_COSP_hf in lmdz.card |
---|
| 166 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_hf} = X ] ; then |
---|
| 167 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
| 168 | else |
---|
| 169 | LMDZ_COSP_hf=n |
---|
| 170 | fi |
---|
[1000] | 171 | |
---|
[1783] | 172 | ## Read LMDZ_NMC_monthly in lmdz.card |
---|
| 173 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_monthly} = X ] ; then |
---|
| 174 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 175 | else |
---|
| 176 | LMDZ_NMC_monthly=n |
---|
| 177 | fi |
---|
[1000] | 178 | |
---|
[1783] | 179 | ## Read LMDZ_NMC_daily in lmdz.card |
---|
| 180 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_daily} = X ] ; then |
---|
| 181 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 182 | else |
---|
| 183 | LMDZ_NMC_daily=n |
---|
| 184 | fi |
---|
| 185 | |
---|
| 186 | ## Read LMDZ_NMC_hf in lmdz.card |
---|
| 187 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_hf} = X ] ; then |
---|
| 188 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
| 189 | else |
---|
| 190 | LMDZ_NMC_hf=n |
---|
| 191 | fi |
---|
| 192 | |
---|
| 193 | |
---|
[396] | 194 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | #----------------------------------------------------------------- |
---|
| 198 | function ATM_Update |
---|
| 199 | { |
---|
| 200 | IGCM_debug_PushStack "ATM_Update" |
---|
| 201 | |
---|
[1537] | 202 | |
---|
[749] | 203 | case ${config_UserChoices_PeriodLength} in |
---|
| 204 | *Y|*y) |
---|
| 205 | LMDZ_ecrit_ISCCP=30. |
---|
| 206 | LMDZ_periodav=30. |
---|
[755] | 207 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[1649] | 208 | echo Do not consider following warning if your running create_etat0_limit : |
---|
[1650] | 209 | echo WARNING !!! For lmdz : calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
[1649] | 210 | fi |
---|
[749] | 211 | ;; |
---|
| 212 | *) |
---|
| 213 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 214 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 215 | ;; |
---|
| 216 | esac |
---|
[1546] | 217 | |
---|
[396] | 218 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 219 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 220 | RAZ_DATE=1 |
---|
| 221 | else |
---|
| 222 | RAZ_DATE=0 |
---|
| 223 | fi |
---|
| 224 | |
---|
[1892] | 225 | ## Algorithme for special treatment for Bands_xxx file |
---|
| 226 | ## For CumulPeriod=1 ; |
---|
| 227 | ## IF NbPeriod_Adjust = 0 ; set LMDZ_adjust=n |
---|
| 228 | ## IF LMDZ_Bands_file_name was given in lmdz.card THEN Get Bands file directly from server. Store it later with _0 suffix. |
---|
| 229 | ## IF no LMDZ_Bands_file_name was given, start without Bands file. Store it later with _0 suffix. |
---|
| 230 | ## ELSE set LMDZ_adjust=y ; start without Bands file ; Store it later in PARAM/ directory in submit directory with suffix _1 ; |
---|
| 231 | ## |
---|
| 232 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; |
---|
| 233 | ## Get Bands file from PARAM/ in submit directory (CumulPeriod-1) ; set LMDZ_adjust=y ; Store Bands file in PARAM/ ; |
---|
| 234 | ## |
---|
| 235 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from PARAM/ ; Do not store ; |
---|
[815] | 236 | |
---|
| 237 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 238 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[1778] | 239 | if [ ! X${LMDZ_Bands_file_name} = X ] ; then |
---|
[1688] | 240 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 241 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 242 | IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0" |
---|
| 243 | fi |
---|
[815] | 244 | fi |
---|
| 245 | fi |
---|
| 246 | |
---|
[743] | 247 | LMDZ_adjust=n |
---|
| 248 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 249 | |
---|
[815] | 250 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 251 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 252 | |
---|
[1897] | 253 | # Get Bands file from PARAM directory if file exist |
---|
[1998] | 254 | if ( [ ${CumulPeriod} -gt 1 ] && [ -f ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} ] ) ; then |
---|
[1894] | 255 | IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
[1892] | 256 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 257 | fi |
---|
[743] | 258 | |
---|
[1535] | 259 | ##-- GHG forcing : |
---|
[2322] | 260 | ## If forcing file exist in run directory, read values for the current year |
---|
| 261 | ## and set in config.def. If not use the default value set in config.def |
---|
[1535] | 262 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
| 263 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
[2322] | 264 | if [ X"${IPCC_SOLAR}" = X ] ; then |
---|
| 265 | # The grep returned empty variable, stop execution |
---|
| 266 | IGCM_debug_Exit "The file SOLARANDVOLCANOES.txt do not contain the current year." |
---|
| 267 | IGCM_debug_Verif_Exit |
---|
| 268 | else |
---|
| 269 | # Set new variable in config.def file |
---|
| 270 | LMDZ_sed config.def solaire ${IPCC_SOLAR} |
---|
| 271 | fi |
---|
[1690] | 272 | else |
---|
| 273 | LMDZ_sed_default config.def solaire |
---|
[1535] | 274 | fi |
---|
[2322] | 275 | |
---|
[1535] | 276 | if [ -f CO2.txt ] ; then |
---|
| 277 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
[2322] | 278 | if [ X"${IPCC_CO2}" = X ] ; then |
---|
| 279 | # The grep returned empty variable, stop execution |
---|
| 280 | IGCM_debug_Exit "The file CO2.txt do not contain the current year." |
---|
| 281 | IGCM_debug_Verif_Exit |
---|
| 282 | else |
---|
| 283 | # Set new variable in config.def file |
---|
| 284 | LMDZ_sed config.def co2_ppm ${IPCC_CO2} |
---|
| 285 | fi |
---|
[1690] | 286 | else |
---|
| 287 | LMDZ_sed_default config.def co2_ppm |
---|
[1535] | 288 | fi |
---|
[1690] | 289 | |
---|
[1535] | 290 | if [ -f CH4.txt ] ; then |
---|
| 291 | IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
[2322] | 292 | if [ X"${IPCC_CH4}" = X ] ; then |
---|
| 293 | # The grep returned empty variable, stop execution |
---|
| 294 | IGCM_debug_Exit "The file CH4.txt do not contain the current year." |
---|
| 295 | IGCM_debug_Verif_Exit |
---|
| 296 | else |
---|
| 297 | # Set new variable in config.def file |
---|
| 298 | LMDZ_sed config.def CH4_ppb ${IPCC_CH4} |
---|
| 299 | fi |
---|
| 300 | else |
---|
[1690] | 301 | LMDZ_sed_default config.def CH4_ppb |
---|
[1535] | 302 | fi |
---|
[2322] | 303 | |
---|
[1535] | 304 | if [ -f N2O.txt ] ; then |
---|
| 305 | IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
[2322] | 306 | if [ X"${IPCC_N2O}" = X ] ; then |
---|
| 307 | # The grep returned empty variable, stop execution |
---|
| 308 | IGCM_debug_Exit "The file N2O.txt do not contain the current year." |
---|
| 309 | IGCM_debug_Verif_Exit |
---|
| 310 | else |
---|
| 311 | # Set new variable in config.def file |
---|
| 312 | LMDZ_sed config.def N2O_ppb ${IPCC_N2O} |
---|
| 313 | fi |
---|
[1690] | 314 | else |
---|
| 315 | LMDZ_sed_default config.def N2O_ppb |
---|
[1535] | 316 | fi |
---|
[2322] | 317 | |
---|
[1535] | 318 | if [ -f CFC11.txt ] ; then |
---|
| 319 | IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
[2322] | 320 | if [ X"${IPCC_CFC11}" = X ] ; then |
---|
| 321 | # The grep returned empty variable, stop execution |
---|
| 322 | IGCM_debug_Exit "The file CFC11.txt do not contain the current year." |
---|
| 323 | IGCM_debug_Verif_Exit |
---|
| 324 | else |
---|
| 325 | # Set new variable in config.def file |
---|
| 326 | LMDZ_sed config.def CFC11_ppt ${IPCC_CFC11} |
---|
| 327 | fi |
---|
[1690] | 328 | else |
---|
| 329 | LMDZ_sed_default config.def CFC11_ppt |
---|
[1535] | 330 | fi |
---|
[2322] | 331 | |
---|
[1535] | 332 | if [ -f CFC12.txt ] ; then |
---|
| 333 | IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
[2322] | 334 | if [ X"${IPCC_CFC12}" = X ] ; then |
---|
| 335 | # The grep returned empty variable, stop execution |
---|
| 336 | IGCM_debug_Exit "The file CFC12.txt do not contain the current year." |
---|
| 337 | IGCM_debug_Verif_Exit |
---|
| 338 | else |
---|
| 339 | # Set new variable in config.def file |
---|
| 340 | LMDZ_sed config.def CFC12_ppt ${IPCC_CFC12} |
---|
| 341 | fi |
---|
[1690] | 342 | else |
---|
| 343 | LMDZ_sed_default config.def CFC12_ppt |
---|
[1535] | 344 | fi |
---|
| 345 | |
---|
[1780] | 346 | |
---|
| 347 | ##-- Add special treatement for CARBON CYCLE |
---|
[1546] | 348 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 349 | ATM_Carbon_Update |
---|
| 350 | fi |
---|
[1537] | 351 | |
---|
| 352 | |
---|
[1538] | 353 | ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate |
---|
| 354 | ## COSP daily output for years 1979 and later (mandatory for historical CMIP5 run). |
---|
| 355 | if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] && [ ${year} -ge 1979 ]) ; then |
---|
| 356 | LMDZ_COSP_daily=y |
---|
| 357 | fi |
---|
[1537] | 358 | |
---|
[1538] | 359 | |
---|
[1540] | 360 | ## output.def parameters |
---|
[1546] | 361 | # columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : |
---|
[1539] | 362 | # histmth histday histhf histfh3h histhf3hm histstn |
---|
[1546] | 363 | LMDZ_sed output.def phys_out_filekeys "${ok_mensuel} ${ok_journe} ${ok_hf} ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" |
---|
[1540] | 364 | LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
| 365 | LMDZ_sed output.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 366 | LMDZ_sed output.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 367 | LMDZ_sed output.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 368 | LMDZ_sed output.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
[1783] | 369 | LMDZ_sed output.def ok_histNMC "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily} ${LMDZ_NMC_hf}" |
---|
[396] | 370 | |
---|
[1544] | 371 | ## gcm.def parameters : |
---|
[2288] | 372 | # Modification for timestep in physics due to differnt type of physics |
---|
| 373 | # To know the time step in minutes the physics part of LMDZ use: 1440/day_step*ipysiq/nsplit_phys |
---|
| 374 | if [ X${LMDZ_Physics} = X"NPv3.1" ] && [ ${RESOL_ATM_3D} = 96x95x39 ] ; then |
---|
| 375 | # Time step in physics: 7.5min |
---|
[1544] | 376 | LMDZ_sed gcm.def iphysiq 5 |
---|
[2288] | 377 | elif [ X${LMDZ_Physics} = X"NPv3.1" ] && [ ${RESOL_ATM_3D} = 144x142x39 ] ; then |
---|
[2294] | 378 | # Time step in physics: 10min |
---|
| 379 | LMDZ_sed gcm.def iphysiq 5 |
---|
[2288] | 380 | elif [ X${LMDZ_Physics} = X"NPv3.2" ] && [ ${RESOL_ATM_3D} = 96x95x39 ] ; then |
---|
[2294] | 381 | # Time step in physics: 15min |
---|
| 382 | LMDZ_sed gcm.def iphysiq 5 |
---|
[2288] | 383 | elif [ X${LMDZ_Physics} = X"NPv3.2" ] && [ ${RESOL_ATM_3D} = 144x142x39 ] ; then |
---|
[2294] | 384 | # Time step in physics: 10min |
---|
| 385 | LMDZ_sed gcm.def iphysiq 5 |
---|
| 386 | elif [ X${LMDZ_Physics} = X"NPv3.2" ] && [ ${RESOL_ATM_3D} = 128x118x39 ] ; then |
---|
| 387 | # Time step in physics: 7.5min |
---|
| 388 | LMDZ_sed gcm.def iphysiq 15 |
---|
[2288] | 389 | elif [ X${LMDZ_Physics} = X"AP" ] ; then |
---|
| 390 | # Time step in physics: 30min |
---|
| 391 | # Use default value for old physics |
---|
| 392 | LMDZ_sed_default gcm.def iphysiq |
---|
[1690] | 393 | else |
---|
[2288] | 394 | # Warning this combination has not been prepared |
---|
| 395 | echo "" |
---|
| 396 | echo "WARNING!! LMDZ_Physics=${LMDZ_Physics} has not been tested with resolution ${RESOL_ATM_3D}." |
---|
| 397 | echo " => The default timestep for iphysiq will be used. " |
---|
| 398 | echo " => You can change the default time step in gcm.def_${RESOL_ATM_3D} but be carefull to keep the syntax: iphysiq=_AUTO_ : DEFAULT = new_value" |
---|
| 399 | echo " => Calculate new time step in minutes in the physics of LMDZ as : 1440/day_step*ipysiq/nsplit_phys" |
---|
[1690] | 400 | LMDZ_sed_default gcm.def iphysiq |
---|
[2288] | 401 | echo "" |
---|
[1544] | 402 | fi |
---|
[2288] | 403 | |
---|
[396] | 404 | |
---|
[1544] | 405 | |
---|
[911] | 406 | ## run.def parameters |
---|
| 407 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 408 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 409 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 410 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 411 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 412 | |
---|
[1804] | 413 | # Set anneeref different for gcm and ce0l |
---|
[1923] | 414 | # Variable calend is different for a run with create_etat0_limit and the gcm |
---|
[1804] | 415 | # Test if executable create_etat0_limit is present and lmdz.x is not present |
---|
| 416 | if [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
| 417 | # for case ce0l : always take current year |
---|
| 418 | LMDZ_sed run.def anneeref ${year} |
---|
[1923] | 419 | LMDZ_sed run.def calend ${CalendarTypeForCreate} |
---|
[1804] | 420 | else |
---|
| 421 | # for case gcm : take first year of simulation |
---|
| 422 | LMDZ_sed run.def anneeref ${InitYear} |
---|
[1923] | 423 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
[1804] | 424 | fi |
---|
[1643] | 425 | |
---|
[1804] | 426 | # Activate creation of file grilles_gcm.nc only at first period |
---|
| 427 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 428 | LMDZ_sed run.def grilles_gcm_netcdf y |
---|
| 429 | else |
---|
| 430 | LMDZ_sed run.def grilles_gcm_netcdf n |
---|
| 431 | fi |
---|
| 432 | |
---|
[1650] | 433 | ## Determine from the variable ListOfComponents in config.card coupling to external models |
---|
| 434 | ## and set corresponding parameters in run.def |
---|
| 435 | echo ListOfComponents now running : ${config_ListOfComponents[*]} |
---|
| 436 | |
---|
| 437 | if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then |
---|
[2101] | 438 | echo "Activate ORCHIDEE: set VEGET=y and add INCLUDEDEF=orchidee.def in run.def" |
---|
[1650] | 439 | LMDZ_sed run.def VEGET y |
---|
[2101] | 440 | # Add "INCLUDEDEF=orchidee.def" before the 5th line in run.def |
---|
| 441 | sed -i '5iINCLUDEDEF=orchidee.def' run.def |
---|
[1650] | 442 | else |
---|
| 443 | echo "No ORCHIDEE, set VEGET=n in run.def" |
---|
| 444 | LMDZ_sed run.def VEGET n |
---|
| 445 | fi |
---|
| 446 | |
---|
| 447 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
| 448 | echo "Activate coupling to ocean, set type_ocean=couple in run.def" |
---|
| 449 | LMDZ_sed run.def type_ocean couple |
---|
| 450 | else |
---|
| 451 | echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def" |
---|
| 452 | LMDZ_sed run.def type_ocean force |
---|
| 453 | fi |
---|
| 454 | |
---|
| 455 | if [ X${config_ListOfComponents_CHM} = Xinca ] ; then |
---|
[2101] | 456 | echo "Activate coupling to INCA: set type_trac=inca and add INCLUDEDEF=inca.def in run.def" |
---|
[1666] | 457 | LMDZ_sed run.def type_trac inca |
---|
[2101] | 458 | # Add "INCLUDEDEF=inca.def" before the 5th line in run.def |
---|
| 459 | sed -i '5iINCLUDEDEF=inca.def' run.def |
---|
[1650] | 460 | elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then |
---|
[2101] | 461 | echo "Activate coupling to REPROBUS: set type_trac=repr and add INCLUDEDEF=reprobus.def in run.def" |
---|
[1666] | 462 | LMDZ_sed run.def type_trac repr |
---|
[1779] | 463 | LMDZ_sed run.def config_inca none |
---|
[2101] | 464 | # Add "INCLUDEDEF=reprobus.def" before the 5th line in run.def |
---|
| 465 | sed -i '5iINCLUDEDEF=reprobus.def' run.def |
---|
[1650] | 466 | else |
---|
| 467 | echo "No coupling to chemistry model, set type_trac=lmdz in run.def" |
---|
[1666] | 468 | LMDZ_sed run.def type_trac lmdz |
---|
[1779] | 469 | LMDZ_sed run.def config_inca none |
---|
[1650] | 470 | fi |
---|
| 471 | |
---|
| 472 | |
---|
[2015] | 473 | # config.def : Activate direct radiative effect if ok_ade=y |
---|
| 474 | if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then |
---|
| 475 | LMDZ_sed config.def ok_ade ${lmdz_UserChoices_ok_ade} |
---|
| 476 | else |
---|
[1686] | 477 | LMDZ_sed config.def ok_ade n |
---|
[2015] | 478 | fi |
---|
| 479 | |
---|
| 480 | # config.def : Activate indirect radiative effect if ok_aie=y |
---|
| 481 | if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then |
---|
| 482 | LMDZ_sed config.def ok_aie ${lmdz_UserChoices_ok_aie} |
---|
| 483 | else |
---|
[1686] | 484 | LMDZ_sed config.def ok_aie n |
---|
[2015] | 485 | fi |
---|
[1816] | 486 | |
---|
[2015] | 487 | # config.def : Activate online aerosol coupled model if aerosol_couple=y |
---|
| 488 | if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then |
---|
| 489 | LMDZ_sed config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple} |
---|
[1686] | 490 | else |
---|
[1816] | 491 | LMDZ_sed config.def aerosol_couple n |
---|
[2015] | 492 | fi |
---|
[1686] | 493 | |
---|
[2015] | 494 | # config.def : Activate reading of ozone in climatology if read_climoz=2 |
---|
| 495 | if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then |
---|
| 496 | LMDZ_sed config.def read_climoz ${lmdz_UserChoices_read_climoz} |
---|
| 497 | else |
---|
| 498 | LMDZ_sed config.def read_climoz 0 |
---|
| 499 | fi |
---|
| 500 | |
---|
| 501 | # config.def : Choose aerosol use in radiative effect |
---|
| 502 | # type of coupled aerosol =1 (default) =2 => bc only =3 => pom only =4 => seasalt only |
---|
| 503 | # =5 => dust only =6 => all aerosol |
---|
| 504 | if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then |
---|
| 505 | LMDZ_sed config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol} |
---|
| 506 | else |
---|
| 507 | LMDZ_sed config.def flag_aerosol 0 |
---|
| 508 | fi |
---|
| 509 | |
---|
| 510 | # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y |
---|
| 511 | if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then |
---|
| 512 | LMDZ_sed config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc} |
---|
| 513 | else |
---|
| 514 | LMDZ_sed config.def ok_cdnc n |
---|
| 515 | fi |
---|
| 516 | |
---|
[1690] | 517 | # guide.def : Activate nudging if ok_guide=y set in lmdz.card |
---|
[2101] | 518 | if [ X${lmdz_UserChoices_ok_guide} = Xy ] ; then |
---|
| 519 | # Set ok_guide=y in guide.def |
---|
[1643] | 520 | LMDZ_sed guide.def ok_guide ${lmdz_UserChoices_ok_guide} |
---|
[2101] | 521 | # Add "INCLUDEDEF=guide.def" before the 5th line in run.def |
---|
| 522 | sed -i '5iINCLUDEDEF=guide.def' run.def |
---|
[1690] | 523 | else |
---|
| 524 | LMDZ_sed guide.def ok_guide n |
---|
[1643] | 525 | fi |
---|
| 526 | |
---|
[902] | 527 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
[1172] | 528 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
[1688] | 529 | if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then |
---|
[396] | 530 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 531 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 532 | echo |
---|
| 533 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 534 | echo |
---|
| 535 | cat gcm.def |
---|
| 536 | ByPass_hgardfou_teta=n |
---|
[902] | 537 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 538 | fi |
---|
| 539 | |
---|
[902] | 540 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
[1172] | 541 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
[1688] | 542 | if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then |
---|
[396] | 543 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 544 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 545 | echo |
---|
| 546 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 547 | echo |
---|
| 548 | cat gcm.def |
---|
| 549 | ByPass_hgardfou_mats=n |
---|
[902] | 550 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 551 | fi |
---|
| 552 | |
---|
| 553 | if ( ${FirstInitialize} ) ; then |
---|
[1643] | 554 | if [ -f start.nc ] && [ -f startphy.nc ] ; then |
---|
| 555 | # The restart files already exist. They have been copied from a previous run or from a CREATE job |
---|
| 556 | echo "Restart files for LMDZ have been copied from a previous run" |
---|
[1778] | 557 | elif [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
[1649] | 558 | # Do nothing because it is the program for creating restart files that is running and not LMDZ |
---|
| 559 | echo "create_etat0_limit.e will create initial start files" |
---|
[1643] | 560 | else |
---|
| 561 | # Restart files have to be created |
---|
[2319] | 562 | # Old option. Now removed. |
---|
| 563 | echo "REMOVED OPTION: Run create_etat0_limit.e to create restart files start.nc and startphy.nc for LMDZ" |
---|
| 564 | echo "You must now create start.nc and startphy.nc before launching the model or use restart files" |
---|
| 565 | IGCM_debug_Exit "ATM_Update: start.nc and startphy.nc files are missing!" |
---|
| 566 | IGCM_debug_Verif_Exit |
---|
| 567 | fi |
---|
[396] | 568 | fi |
---|
| 569 | |
---|
| 570 | IGCM_debug_PopStack "ATM_Update" |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | #----------------------------------- |
---|
| 574 | function ATM_Finalize |
---|
| 575 | { |
---|
| 576 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 577 | |
---|
[1897] | 578 | # If the file exist, copy Bands_ file to PARAM/ in submit directory. This file will be used for the simulation. |
---|
[1892] | 579 | # Copy also the same file into ATM/Restart at ARCHIVE directory for backup. |
---|
[1897] | 580 | if [ -f Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ] ; then |
---|
| 581 | if [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] ; then |
---|
| 582 | IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
| 583 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
| 584 | elif [ ${CumulPeriod} -eq 1 ] && [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 585 | # Special case : first period and no adjust => Save bands file with suffix _0 |
---|
| 586 | IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 587 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 588 | fi |
---|
[1892] | 589 | fi |
---|
[396] | 590 | |
---|
[1537] | 591 | # Add special treatement for CARBON CYCLE |
---|
[1546] | 592 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 593 | ATM_Carbon_Finalize |
---|
| 594 | fi |
---|
[1537] | 595 | |
---|
[1780] | 596 | echo FINALIZE ATM ! |
---|
[1537] | 597 | |
---|
[1780] | 598 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 599 | } |
---|
[1537] | 600 | |
---|
| 601 | |
---|
| 602 | |
---|
[1780] | 603 | function ATM_Carbon_Update |
---|
| 604 | { |
---|
| 605 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
[1537] | 606 | |
---|
[1780] | 607 | IGCM_debug_PushStack "ATM_Carbon_Update" |
---|
| 608 | |
---|
| 609 | typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 |
---|
| 610 | typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 611 | typeset PathCO2log |
---|
| 612 | typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX |
---|
| 613 | |
---|
| 614 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then |
---|
| 615 | ##--Initialization of fluxes to an undefined value at the first run |
---|
| 616 | UndefinedValueCo2=-9999 |
---|
| 617 | InitPeriodCo2=0 |
---|
| 618 | InitDateBeginCo2=${UndefinedValueCo2} |
---|
| 619 | InitYearCo2=$(( ${year} - 1 )) |
---|
| 620 | InitDateEndCo2=${InitYearCo2}1231 |
---|
| 621 | fCO2_ff=${UndefinedValueCo2} |
---|
| 622 | CO2SBG=${UndefinedValueCo2} |
---|
| 623 | CO2LU=${UndefinedValueCo2} |
---|
| 624 | CO2MBG=${UndefinedValueCo2} |
---|
| 625 | CO2_ppm_prec=${UndefinedValueCo2} |
---|
| 626 | # Get the initial value of atmosp. pco2 |
---|
| 627 | CO2_ppm=${lmdz_UserChoices_co2_init} |
---|
| 628 | |
---|
| 629 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 630 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 631 | |
---|
[1537] | 632 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
[1780] | 633 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
[1537] | 634 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
[1780] | 635 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 636 | |
---|
| 637 | # Get the path where the log file co2.log is |
---|
| 638 | PathCO2log=${SUBMIT_DIR} |
---|
| 639 | # Get Previous line in co2.log |
---|
| 640 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 641 | |
---|
| 642 | else |
---|
| 643 | |
---|
| 644 | # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): |
---|
| 645 | # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. |
---|
| 646 | #SubmitRestartPath= |
---|
| 647 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then |
---|
| 648 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath |
---|
| 649 | PathCO2log=${config_ATM_SubmitRestartPath} |
---|
| 650 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) |
---|
| 651 | PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) |
---|
| 652 | |
---|
| 653 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 654 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 655 | |
---|
| 656 | # Save Last Line of control in new co2.log file |
---|
| 657 | InitPeriodCo2=0 |
---|
| 658 | InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) |
---|
| 659 | InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) |
---|
| 660 | fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) |
---|
| 661 | CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) |
---|
| 662 | CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) |
---|
| 663 | CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) |
---|
| 664 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) |
---|
| 665 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 666 | |
---|
| 667 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 668 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 669 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 670 | else |
---|
| 671 | # Get restart line in co2.log |
---|
| 672 | PathCO2log=${SUBMIT_DIR} |
---|
| 673 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 674 | # Get the value of atmosp. pco2 in co2.log |
---|
| 675 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 676 | fi |
---|
| 677 | |
---|
[1537] | 678 | fi |
---|
[1780] | 679 | |
---|
| 680 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 681 | # Modify co2_ppm in config.def only for historical run |
---|
| 682 | # If not historical run, keep co2_ppm value set earlier by LMDZ_sed |
---|
| 683 | LMDZ_sed config.def co2_ppm ${CO2_ppm} |
---|
| 684 | fi |
---|
| 685 | IGCM_debug_PopStack "ATM_Carbon_Update" |
---|
| 686 | } |
---|
[1537] | 687 | |
---|
[396] | 688 | |
---|
[1780] | 689 | function ATM_Carbon_Finalize |
---|
| 690 | { |
---|
| 691 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
| 692 | |
---|
| 693 | IGCM_debug_PushStack "ATM_Carbon_Finalize" |
---|
| 694 | |
---|
| 695 | typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 696 | |
---|
| 697 | # Fossil fuel emission |
---|
| 698 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then |
---|
| 699 | # For Control, no fossil fuel emission : |
---|
| 700 | fCO2_ff=0 |
---|
| 701 | echo "Fossil Fuel for control run :" ${fCO2_ff} |
---|
| 702 | else |
---|
| 703 | # For historical, get the fossile fuel file : |
---|
| 704 | 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 ) |
---|
| 705 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
---|
| 706 | fi |
---|
| 707 | |
---|
| 708 | # Get the value of ocean carbon flux |
---|
| 709 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
---|
| 710 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
---|
| 711 | echo "Ocean carbon flux :" ${CO2MBG} |
---|
| 712 | |
---|
| 713 | # Get the value of land fluxes |
---|
| 714 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
---|
| 715 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
---|
| 716 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
---|
| 717 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
---|
| 718 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
---|
| 719 | echo "LU flux (FLUC) :" ${CO2LU} |
---|
| 720 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
---|
| 721 | |
---|
| 722 | # Previous CO2 |
---|
| 723 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 724 | echo "Previous CO2 :" ${CO2_ppm_prec} |
---|
| 725 | |
---|
| 726 | # Formula |
---|
| 727 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
---|
| 728 | echo "New CO2 :" ${CO2_ppm} |
---|
| 729 | |
---|
| 730 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 731 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 732 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 733 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 734 | |
---|
| 735 | IGCM_debug_PopStack "ATM_Carbon_Finalize" |
---|
[396] | 736 | } |
---|