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