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