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