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