[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" |
---|
| 8 | |
---|
[911] | 9 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
[894] | 10 | RET=$? |
---|
| 11 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 12 | \mv ${1}.tmp ${1} |
---|
| 13 | |
---|
| 14 | IGCM_debug_PopStack "LMDZ_sed" |
---|
| 15 | return $RET |
---|
| 16 | } |
---|
[1690] | 17 | function LMDZ_sed_default |
---|
| 18 | { |
---|
| 19 | # Usage : LMDZ_sed_default filedef var_name |
---|
| 20 | # In file filedef modify the line "var_name=xxx DEFAULT= myvalue" |
---|
| 21 | # into "var_name=myvalue" |
---|
| 22 | IGCM_debug_PushStack "LMDZ_sed_default" |
---|
[894] | 23 | |
---|
[1690] | 24 | DefValue=$( grep ${2} ${1} | awk -F"DEFAULT.=*" '{print $2}') |
---|
| 25 | |
---|
| 26 | LMDZ_sed ${1} ${2} $DefValue |
---|
| 27 | IGCM_debug_PopStack "LMDZ_sed_default" |
---|
| 28 | return $RET |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | |
---|
[396] | 32 | function ATM_Initialize |
---|
| 33 | { |
---|
| 34 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 35 | |
---|
[671] | 36 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
[396] | 37 | |
---|
[659] | 38 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
[396] | 39 | |
---|
[659] | 40 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
[649] | 41 | |
---|
[697] | 42 | ##-- Calendar type for LMDZ |
---|
| 43 | case ${config_UserChoices_CalendarType} in |
---|
| 44 | leap|gregorian) |
---|
| 45 | CalendarTypeForLmdz=earth_366d;; |
---|
| 46 | noleap) |
---|
| 47 | CalendarTypeForLmdz=earth_365d;; |
---|
| 48 | 360d) |
---|
| 49 | CalendarTypeForLmdz=earth_360d;; |
---|
| 50 | *) |
---|
| 51 | CalendarTypeForLmdz=earth_360d |
---|
| 52 | esac |
---|
| 53 | |
---|
[1541] | 54 | ##- LMDZ physics version |
---|
| 55 | ## Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) |
---|
| 56 | if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then |
---|
| 57 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
| 58 | else |
---|
| 59 | LMDZ_Physics=AP |
---|
| 60 | fi |
---|
| 61 | echo LMDZ physics version : ${LMDZ_Physics} |
---|
| 62 | |
---|
[1643] | 63 | ##- Create_etat0_limit version |
---|
[1782] | 64 | ## Define variable CREATE only if it is set in lmdz.card section UserChoices. |
---|
| 65 | ## This variable is only used in lmdz.card to choose input files. |
---|
| 66 | if [ ! X${lmdz_UserChoices_CREATE} = X ] ; then |
---|
| 67 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
| 68 | CREATE=${lmdz_UserChoices_CREATE} |
---|
| 69 | echo create_etat0_limit version : ${CREATE} |
---|
| 70 | fi |
---|
[1643] | 71 | |
---|
[1782] | 72 | |
---|
[1550] | 73 | ## - LMDZ choice of config.def file |
---|
| 74 | ## ConfType must be set in lmdz.card |
---|
| 75 | ConfType=${lmdz_UserChoices_ConfType} |
---|
[1541] | 76 | |
---|
[1550] | 77 | ##- LMDZ output level, to be set in lmdz.card |
---|
| 78 | if [ X${lmdz_UserChoices_OutLevel} = X ] ; then |
---|
| 79 | # OutLevel is not set. Take default value low. |
---|
| 80 | OutLevel=low |
---|
| 81 | else |
---|
| 82 | OutLevel=${lmdz_UserChoices_OutLevel} |
---|
| 83 | fi |
---|
| 84 | |
---|
[1539] | 85 | ##-- Output frequency purpose .... |
---|
[396] | 86 | ##-- Initialisation .... |
---|
[1539] | 87 | ok_mensuel=n |
---|
| 88 | ok_journe=n |
---|
[396] | 89 | ok_hf=n |
---|
[1539] | 90 | ok_hf3h=n |
---|
| 91 | ok_hf3hm=n |
---|
| 92 | ok_stn=n |
---|
[396] | 93 | |
---|
| 94 | case ${config_UserChoices_PeriodLength} in |
---|
[1539] | 95 | 1Y|1y|1M|1m) ok_mensuel=y ;; |
---|
| 96 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
[396] | 97 | esac |
---|
| 98 | |
---|
| 99 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 100 | case ${frequency} in |
---|
[1539] | 101 | 1M|1m) ok_mensuel=y ;; |
---|
[396] | 102 | esac |
---|
| 103 | case ${frequency} in |
---|
[1539] | 104 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
| 105 | esac |
---|
| 106 | case ${frequency} in |
---|
[396] | 107 | HF|hf) ok_hf=y ;; |
---|
| 108 | esac |
---|
[1539] | 109 | case ${frequency} in |
---|
| 110 | HF3h|hf3h) ok_hf3h=y ;; |
---|
| 111 | esac |
---|
| 112 | case ${frequency} in |
---|
| 113 | HF3hm|hf3hm) ok_hf3hm=y ;; |
---|
| 114 | esac |
---|
| 115 | case ${frequency} in |
---|
| 116 | STN|stn) ok_stn=y ;; |
---|
| 117 | esac |
---|
[396] | 118 | done |
---|
| 119 | |
---|
[902] | 120 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
[1688] | 121 | if [ X"${lmdz_UserChoices_LMDZ_NbPeriod_adjust}" = X"" ] ; then |
---|
| 122 | # The variable is not in lmdz.card, set default value |
---|
| 123 | LMDZ_NbPeriod_adjust=0 |
---|
| 124 | else |
---|
| 125 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
| 126 | fi |
---|
[396] | 127 | |
---|
[815] | 128 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[1688] | 129 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
[815] | 130 | fi |
---|
| 131 | |
---|
[912] | 132 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
[1172] | 133 | LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero} |
---|
| 134 | LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero} |
---|
[912] | 135 | |
---|
[1000] | 136 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
[1172] | 137 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 138 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 139 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 140 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
[1000] | 141 | |
---|
[1003] | 142 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
[1172] | 143 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 144 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 145 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
[1000] | 146 | |
---|
[396] | 147 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | #----------------------------------------------------------------- |
---|
| 151 | function ATM_Update |
---|
| 152 | { |
---|
| 153 | IGCM_debug_PushStack "ATM_Update" |
---|
| 154 | |
---|
[1537] | 155 | |
---|
[749] | 156 | case ${config_UserChoices_PeriodLength} in |
---|
| 157 | *Y|*y) |
---|
| 158 | LMDZ_ecrit_ISCCP=30. |
---|
| 159 | LMDZ_periodav=30. |
---|
[755] | 160 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[1649] | 161 | echo Do not consider following warning if your running create_etat0_limit : |
---|
[1650] | 162 | echo WARNING !!! For lmdz : calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
[1649] | 163 | fi |
---|
[749] | 164 | ;; |
---|
| 165 | *) |
---|
| 166 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 167 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 168 | ;; |
---|
| 169 | esac |
---|
[1546] | 170 | |
---|
[396] | 171 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 172 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 173 | RAZ_DATE=1 |
---|
| 174 | else |
---|
| 175 | RAZ_DATE=0 |
---|
| 176 | fi |
---|
| 177 | |
---|
[815] | 178 | ## algo : For CumulPeriod=1 ; |
---|
| 179 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 180 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 181 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 182 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 183 | |
---|
| 184 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 185 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[1778] | 186 | if [ ! X${LMDZ_Bands_file_name} = X ] ; then |
---|
[1688] | 187 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 188 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 189 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 190 | 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" |
---|
| 191 | fi |
---|
[815] | 192 | fi |
---|
| 193 | fi |
---|
| 194 | |
---|
[743] | 195 | LMDZ_adjust=n |
---|
| 196 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 197 | |
---|
[815] | 198 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 199 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 200 | |
---|
[902] | 201 | [ ${CumulPeriod} -gt 1 ] && ( IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ) |
---|
[743] | 202 | |
---|
[1535] | 203 | ##-- GHG forcing : |
---|
[1546] | 204 | ## If forcing file exist in run directory, read values for the current year and modify config.def |
---|
[1535] | 205 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
| 206 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
[1546] | 207 | LMDZ_sed config.def solaire ${IPCC_SOLAR} |
---|
[1690] | 208 | else |
---|
| 209 | LMDZ_sed_default config.def solaire |
---|
[1535] | 210 | fi |
---|
| 211 | if [ -f CO2.txt ] ; then |
---|
| 212 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
[1546] | 213 | LMDZ_sed config.def co2_ppm ${IPCC_CO2} |
---|
[1690] | 214 | else |
---|
| 215 | LMDZ_sed_default config.def co2_ppm |
---|
[1535] | 216 | fi |
---|
[1690] | 217 | |
---|
| 218 | |
---|
[1535] | 219 | if [ -f CH4.txt ] ; then |
---|
| 220 | IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
[1546] | 221 | LMDZ_sed config.def CH4_ppb ${IPCC_CH4} |
---|
[1690] | 222 | else |
---|
| 223 | LMDZ_sed_default config.def CH4_ppb |
---|
[1535] | 224 | fi |
---|
| 225 | if [ -f N2O.txt ] ; then |
---|
| 226 | IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
[1546] | 227 | LMDZ_sed config.def N2O_ppb ${IPCC_N2O} |
---|
[1690] | 228 | else |
---|
| 229 | LMDZ_sed_default config.def N2O_ppb |
---|
[1535] | 230 | fi |
---|
| 231 | if [ -f CFC11.txt ] ; then |
---|
| 232 | IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
[1546] | 233 | LMDZ_sed config.def CFC11_ppt ${IPCC_CFC11} |
---|
[1690] | 234 | else |
---|
| 235 | LMDZ_sed_default config.def CFC11_ppt |
---|
[1535] | 236 | fi |
---|
| 237 | if [ -f CFC12.txt ] ; then |
---|
| 238 | IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
[1546] | 239 | LMDZ_sed config.def CFC12_ppt ${IPCC_CFC12} |
---|
[1690] | 240 | else |
---|
| 241 | LMDZ_sed_default config.def CFC12_ppt |
---|
[1535] | 242 | fi |
---|
| 243 | |
---|
[1780] | 244 | |
---|
| 245 | ##-- Add special treatement for CARBON CYCLE |
---|
[1546] | 246 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 247 | ATM_Carbon_Update |
---|
| 248 | fi |
---|
[1537] | 249 | |
---|
| 250 | |
---|
[1538] | 251 | ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate |
---|
| 252 | ## COSP daily output for years 1979 and later (mandatory for historical CMIP5 run). |
---|
| 253 | if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] && [ ${year} -ge 1979 ]) ; then |
---|
| 254 | LMDZ_COSP_daily=y |
---|
| 255 | fi |
---|
[1537] | 256 | |
---|
[1538] | 257 | |
---|
[1540] | 258 | ## output.def parameters |
---|
[1546] | 259 | # columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : |
---|
[1539] | 260 | # histmth histday histhf histfh3h histhf3hm histstn |
---|
[1546] | 261 | LMDZ_sed output.def phys_out_filekeys "${ok_mensuel} ${ok_journe} ${ok_hf} ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" |
---|
[1540] | 262 | LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
| 263 | LMDZ_sed output.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 264 | LMDZ_sed output.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 265 | LMDZ_sed output.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 266 | LMDZ_sed output.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
| 267 | LMDZ_sed output.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
[396] | 268 | |
---|
[1544] | 269 | ## gcm.def parameters : |
---|
| 270 | # Modification only for new physics |
---|
[1750] | 271 | if [ X${LMDZ_Physics} = X"NPv3.1" ] ; then |
---|
[1544] | 272 | LMDZ_sed gcm.def iphysiq 5 |
---|
[1690] | 273 | else |
---|
| 274 | LMDZ_sed_default gcm.def iphysiq |
---|
[1544] | 275 | fi |
---|
[396] | 276 | |
---|
[1544] | 277 | |
---|
[911] | 278 | ## run.def parameters |
---|
| 279 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 280 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 281 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 282 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 283 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 284 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 285 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 286 | |
---|
[1643] | 287 | |
---|
[1650] | 288 | ## Determine from the variable ListOfComponents in config.card coupling to external models |
---|
| 289 | ## and set corresponding parameters in run.def |
---|
| 290 | echo ListOfComponents now running : ${config_ListOfComponents[*]} |
---|
| 291 | |
---|
| 292 | if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then |
---|
| 293 | echo "Activate ORCHIDEE, set VEGET=y in run.def" |
---|
| 294 | LMDZ_sed run.def VEGET y |
---|
| 295 | else |
---|
| 296 | echo "No ORCHIDEE, set VEGET=n in run.def" |
---|
| 297 | LMDZ_sed run.def VEGET n |
---|
| 298 | fi |
---|
| 299 | |
---|
| 300 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
| 301 | echo "Activate coupling to ocean, set type_ocean=couple in run.def" |
---|
| 302 | LMDZ_sed run.def type_ocean couple |
---|
| 303 | else |
---|
| 304 | echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def" |
---|
| 305 | LMDZ_sed run.def type_ocean force |
---|
| 306 | fi |
---|
| 307 | |
---|
| 308 | if [ X${config_ListOfComponents_CHM} = Xinca ] ; then |
---|
| 309 | echo "Activate coupling to INCA, set type_trac=inca in run.def" |
---|
[1665] | 310 | LMDZ_sed run.def type_trac inca |
---|
[1650] | 311 | elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then |
---|
| 312 | echo "Activate coupling to REPROBUS, set type_trac=repr in run.def" |
---|
[1665] | 313 | LMDZ_sed run.def type_trac repr |
---|
[1779] | 314 | LMDZ_sed run.def config_inca none |
---|
[1650] | 315 | else |
---|
| 316 | echo "No coupling to chemistry model, set type_trac=lmdz in run.def" |
---|
[1665] | 317 | LMDZ_sed run.def type_trac lmdz |
---|
[1779] | 318 | LMDZ_sed run.def config_inca none |
---|
[1650] | 319 | fi |
---|
| 320 | |
---|
| 321 | |
---|
[1686] | 322 | # config.def : If running with Reprobus, desactivate ok_ade, ok_aie and read_climoz |
---|
[1698] | 323 | if [ X${config_ListOfComponents_CHM} = Xreprobus ] || [ X${config_ListOfComponents_CHM} = Xinca ] ; then |
---|
[1686] | 324 | LMDZ_sed config.def ok_ade n |
---|
| 325 | LMDZ_sed config.def ok_aie n |
---|
| 326 | LMDZ_sed config.def read_climoz 0 |
---|
| 327 | else |
---|
| 328 | LMDZ_sed config.def ok_ade y |
---|
| 329 | LMDZ_sed config.def ok_aie y |
---|
| 330 | LMDZ_sed config.def read_climoz 2 |
---|
| 331 | fi |
---|
| 332 | |
---|
[1690] | 333 | # guide.def : Activate nudging if ok_guide=y set in lmdz.card |
---|
[1643] | 334 | if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then |
---|
| 335 | LMDZ_sed guide.def ok_guide ${lmdz_UserChoices_ok_guide} |
---|
[1690] | 336 | else |
---|
| 337 | LMDZ_sed guide.def ok_guide n |
---|
[1643] | 338 | fi |
---|
| 339 | |
---|
[902] | 340 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
[1172] | 341 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
[1688] | 342 | if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then |
---|
[396] | 343 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 344 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 345 | echo |
---|
| 346 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 347 | echo |
---|
| 348 | cat gcm.def |
---|
| 349 | ByPass_hgardfou_teta=n |
---|
[902] | 350 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 351 | fi |
---|
| 352 | |
---|
[902] | 353 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
[1172] | 354 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
[1688] | 355 | if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then |
---|
[396] | 356 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 357 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 358 | echo |
---|
| 359 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 360 | echo |
---|
| 361 | cat gcm.def |
---|
| 362 | ByPass_hgardfou_mats=n |
---|
[902] | 363 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 364 | fi |
---|
| 365 | |
---|
| 366 | if ( ${FirstInitialize} ) ; then |
---|
[1643] | 367 | if [ -f start.nc ] && [ -f startphy.nc ] ; then |
---|
| 368 | # The restart files already exist. They have been copied from a previous run or from a CREATE job |
---|
| 369 | echo "Restart files for LMDZ have been copied from a previous run" |
---|
[1778] | 370 | elif [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
[1649] | 371 | # Do nothing because it is the program for creating restart files that is running and not LMDZ |
---|
| 372 | echo "create_etat0_limit.e will create initial start files" |
---|
[1643] | 373 | else |
---|
| 374 | # Restart files have to be created |
---|
| 375 | echo "Run create_etat0_limit.e to create restart files start.nc and startphy.nc for LMDZ" |
---|
[396] | 376 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[894] | 377 | ##-- suppression of ozone file construction -- |
---|
[1643] | 378 | cp config.def config.def.save |
---|
| 379 | LMDZ_sed config.def read_climoz 0 |
---|
[396] | 380 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 381 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[908] | 382 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
[1643] | 383 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 384 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
[396] | 385 | fi |
---|
[1643] | 386 | IGCM_sys_Mv config.def.save config.def |
---|
[396] | 387 | else |
---|
[908] | 388 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 389 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
[396] | 390 | fi |
---|
| 391 | fi |
---|
| 392 | fi |
---|
| 393 | |
---|
| 394 | IGCM_debug_PopStack "ATM_Update" |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | #----------------------------------- |
---|
| 398 | function ATM_Finalize |
---|
| 399 | { |
---|
| 400 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 401 | |
---|
[743] | 402 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
[396] | 403 | |
---|
[1537] | 404 | |
---|
| 405 | # Add special treatement for CARBON CYCLE |
---|
[1546] | 406 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
[1780] | 407 | ATM_Carbon_Finalize |
---|
| 408 | fi |
---|
[1537] | 409 | |
---|
[1780] | 410 | echo FINALIZE ATM ! |
---|
[1537] | 411 | |
---|
[1780] | 412 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 413 | } |
---|
[1537] | 414 | |
---|
| 415 | |
---|
| 416 | |
---|
[1780] | 417 | function ATM_Carbon_Update |
---|
| 418 | { |
---|
| 419 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
[1537] | 420 | |
---|
[1780] | 421 | IGCM_debug_PushStack "ATM_Carbon_Update" |
---|
| 422 | |
---|
| 423 | typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 |
---|
| 424 | typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 425 | typeset PathCO2log |
---|
| 426 | typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX |
---|
| 427 | |
---|
| 428 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then |
---|
| 429 | ##--Initialization of fluxes to an undefined value at the first run |
---|
| 430 | UndefinedValueCo2=-9999 |
---|
| 431 | InitPeriodCo2=0 |
---|
| 432 | InitDateBeginCo2=${UndefinedValueCo2} |
---|
| 433 | InitYearCo2=$(( ${year} - 1 )) |
---|
| 434 | InitDateEndCo2=${InitYearCo2}1231 |
---|
| 435 | fCO2_ff=${UndefinedValueCo2} |
---|
| 436 | CO2SBG=${UndefinedValueCo2} |
---|
| 437 | CO2LU=${UndefinedValueCo2} |
---|
| 438 | CO2MBG=${UndefinedValueCo2} |
---|
| 439 | CO2_ppm_prec=${UndefinedValueCo2} |
---|
| 440 | # Get the initial value of atmosp. pco2 |
---|
| 441 | CO2_ppm=${lmdz_UserChoices_co2_init} |
---|
| 442 | |
---|
| 443 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 444 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 445 | |
---|
[1537] | 446 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
[1780] | 447 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
[1537] | 448 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
[1780] | 449 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 450 | |
---|
| 451 | # Get the path where the log file co2.log is |
---|
| 452 | PathCO2log=${SUBMIT_DIR} |
---|
| 453 | # Get Previous line in co2.log |
---|
| 454 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 455 | |
---|
| 456 | else |
---|
| 457 | |
---|
| 458 | # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): |
---|
| 459 | # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. |
---|
| 460 | #SubmitRestartPath= |
---|
| 461 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then |
---|
| 462 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath |
---|
| 463 | PathCO2log=${config_ATM_SubmitRestartPath} |
---|
| 464 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) |
---|
| 465 | PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) |
---|
| 466 | |
---|
| 467 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 468 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 469 | |
---|
| 470 | # Save Last Line of control in new co2.log file |
---|
| 471 | InitPeriodCo2=0 |
---|
| 472 | InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) |
---|
| 473 | InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) |
---|
| 474 | fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) |
---|
| 475 | CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) |
---|
| 476 | CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) |
---|
| 477 | CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) |
---|
| 478 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) |
---|
| 479 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 480 | |
---|
| 481 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 482 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 483 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 484 | else |
---|
| 485 | # Get restart line in co2.log |
---|
| 486 | PathCO2log=${SUBMIT_DIR} |
---|
| 487 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 488 | # Get the value of atmosp. pco2 in co2.log |
---|
| 489 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 490 | fi |
---|
| 491 | |
---|
[1537] | 492 | fi |
---|
[1780] | 493 | |
---|
| 494 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 495 | # Modify co2_ppm in config.def only for historical run |
---|
| 496 | # If not historical run, keep co2_ppm value set earlier by LMDZ_sed |
---|
| 497 | LMDZ_sed config.def co2_ppm ${CO2_ppm} |
---|
| 498 | fi |
---|
| 499 | IGCM_debug_PopStack "ATM_Carbon_Update" |
---|
| 500 | } |
---|
[1537] | 501 | |
---|
[396] | 502 | |
---|
[1780] | 503 | function ATM_Carbon_Finalize |
---|
| 504 | { |
---|
| 505 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
| 506 | |
---|
| 507 | IGCM_debug_PushStack "ATM_Carbon_Finalize" |
---|
| 508 | |
---|
| 509 | typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 510 | |
---|
| 511 | # Fossil fuel emission |
---|
| 512 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then |
---|
| 513 | # For Control, no fossil fuel emission : |
---|
| 514 | fCO2_ff=0 |
---|
| 515 | echo "Fossil Fuel for control run :" ${fCO2_ff} |
---|
| 516 | else |
---|
| 517 | # For historical, get the fossile fuel file : |
---|
| 518 | 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 ) |
---|
| 519 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
---|
| 520 | fi |
---|
| 521 | |
---|
| 522 | # Get the value of ocean carbon flux |
---|
| 523 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
---|
| 524 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
---|
| 525 | echo "Ocean carbon flux :" ${CO2MBG} |
---|
| 526 | |
---|
| 527 | # Get the value of land fluxes |
---|
| 528 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
---|
| 529 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
---|
| 530 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
---|
| 531 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
---|
| 532 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
---|
| 533 | echo "LU flux (FLUC) :" ${CO2LU} |
---|
| 534 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
---|
| 535 | |
---|
| 536 | # Previous CO2 |
---|
| 537 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 538 | echo "Previous CO2 :" ${CO2_ppm_prec} |
---|
| 539 | |
---|
| 540 | # Formula |
---|
| 541 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
---|
| 542 | echo "New CO2 :" ${CO2_ppm} |
---|
| 543 | |
---|
| 544 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 545 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 546 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 547 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 548 | |
---|
| 549 | IGCM_debug_PopStack "ATM_Carbon_Finalize" |
---|
[396] | 550 | } |
---|