[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
[894] | 3 | function LMDZ_sed |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "LMDZ_sed" |
---|
| 6 | |
---|
[911] | 7 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
[894] | 8 | RET=$? |
---|
| 9 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 10 | \mv ${1}.tmp ${1} |
---|
| 11 | |
---|
| 12 | IGCM_debug_PopStack "LMDZ_sed" |
---|
| 13 | return $RET |
---|
| 14 | } |
---|
| 15 | |
---|
[396] | 16 | function ATM_Initialize |
---|
| 17 | { |
---|
| 18 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 19 | |
---|
[671] | 20 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
[396] | 21 | |
---|
[659] | 22 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
[396] | 23 | |
---|
[659] | 24 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
[649] | 25 | |
---|
[697] | 26 | ##-- Calendar type for LMDZ |
---|
| 27 | case ${config_UserChoices_CalendarType} in |
---|
| 28 | leap|gregorian) |
---|
| 29 | CalendarTypeForLmdz=earth_366d;; |
---|
| 30 | noleap) |
---|
| 31 | CalendarTypeForLmdz=earth_365d;; |
---|
| 32 | 360d) |
---|
| 33 | CalendarTypeForLmdz=earth_360d;; |
---|
| 34 | *) |
---|
| 35 | CalendarTypeForLmdz=earth_360d |
---|
| 36 | esac |
---|
| 37 | |
---|
[396] | 38 | ##--Frequency purpose .... |
---|
| 39 | ##-- Initialisation .... |
---|
| 40 | OK_instan=n |
---|
| 41 | OK_journe=n |
---|
| 42 | OK_mensuel=n |
---|
| 43 | ok_hf=n |
---|
| 44 | |
---|
| 45 | case ${config_UserChoices_PeriodLength} in |
---|
| 46 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
| 47 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 48 | esac |
---|
| 49 | |
---|
| 50 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 51 | case ${frequency} in |
---|
| 52 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 53 | esac |
---|
| 54 | case ${frequency} in |
---|
| 55 | HF|hf) ok_hf=y ;; |
---|
| 56 | esac |
---|
| 57 | done |
---|
| 58 | |
---|
[902] | 59 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
| 60 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
[1172] | 61 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
[396] | 62 | |
---|
[815] | 63 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 64 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
[1172] | 65 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
[815] | 66 | fi |
---|
| 67 | |
---|
[912] | 68 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
[1172] | 69 | LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero} |
---|
| 70 | LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero} |
---|
[912] | 71 | |
---|
[1001] | 72 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
[1172] | 73 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 74 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 75 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 76 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
[1001] | 77 | |
---|
[1003] | 78 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
[1172] | 79 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 80 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 81 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
[1003] | 82 | |
---|
[396] | 83 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | #----------------------------------------------------------------- |
---|
| 87 | function ATM_Update |
---|
| 88 | { |
---|
| 89 | IGCM_debug_PushStack "ATM_Update" |
---|
| 90 | |
---|
[1537] | 91 | |
---|
[749] | 92 | case ${config_UserChoices_PeriodLength} in |
---|
| 93 | *Y|*y) |
---|
| 94 | LMDZ_ecrit_mth=30. |
---|
| 95 | LMDZ_ecrit_ISCCP=30. |
---|
| 96 | LMDZ_periodav=30. |
---|
[755] | 97 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[749] | 98 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 99 | exit |
---|
| 100 | fi |
---|
| 101 | ;; |
---|
| 102 | *) |
---|
| 103 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
| 104 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 105 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 106 | ;; |
---|
| 107 | esac |
---|
[396] | 108 | |
---|
| 109 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 110 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 111 | RAZ_DATE=1 |
---|
| 112 | else |
---|
| 113 | RAZ_DATE=0 |
---|
| 114 | fi |
---|
| 115 | |
---|
[815] | 116 | ## algo : For CumulPeriod=1 ; |
---|
| 117 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 118 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 119 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 120 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 121 | |
---|
| 122 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 123 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 124 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
[815] | 125 | 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 |
---|
| 126 | 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" |
---|
| 127 | fi |
---|
| 128 | fi |
---|
| 129 | |
---|
[743] | 130 | LMDZ_adjust=n |
---|
| 131 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 132 | |
---|
[815] | 133 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 134 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 135 | |
---|
[902] | 136 | [ ${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] | 137 | |
---|
[1537] | 138 | |
---|
[1535] | 139 | ##-- GHG forcing : |
---|
| 140 | ## If forcing file exist in run directory, read values for the current year and modify physiq.def |
---|
| 141 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
| 142 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
| 143 | LMDZ_sed physiq.def solaire ${IPCC_SOLAR} |
---|
| 144 | fi |
---|
| 145 | if [ -f CO2.txt ] ; then |
---|
| 146 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
| 147 | LMDZ_sed physiq.def co2_ppm ${IPCC_CO2} |
---|
| 148 | fi |
---|
| 149 | if [ -f CH4.txt ] ; then |
---|
| 150 | IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
| 151 | LMDZ_sed physiq.def CH4_ppb ${IPCC_CH4} |
---|
| 152 | fi |
---|
| 153 | if [ -f N2O.txt ] ; then |
---|
| 154 | IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
| 155 | LMDZ_sed physiq.def N2O_ppb ${IPCC_N2O} |
---|
| 156 | fi |
---|
| 157 | if [ -f CFC11.txt ] ; then |
---|
| 158 | IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
| 159 | LMDZ_sed physiq.def CFC11_ppt ${IPCC_CFC11} |
---|
| 160 | fi |
---|
| 161 | if [ -f CFC12.txt ] ; then |
---|
| 162 | IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
| 163 | LMDZ_sed physiq.def CFC12_ppt ${IPCC_CFC12} |
---|
| 164 | fi |
---|
| 165 | |
---|
[1537] | 166 | |
---|
| 167 | # Add special treatement for CARBON CYCLE |
---|
| 168 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 169 | |
---|
| 170 | typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 |
---|
| 171 | typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 172 | typeset PathCO2log |
---|
| 173 | typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX |
---|
| 174 | |
---|
| 175 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then |
---|
| 176 | ##--Initialization of fluxes to an undefined value at the first run |
---|
| 177 | UndefinedValueCo2=-9999 |
---|
| 178 | InitPeriodCo2=0 |
---|
| 179 | InitDateBeginCo2=${UndefinedValueCo2} |
---|
| 180 | InitYearCo2=$(( ${year} - 1 )) |
---|
| 181 | InitDateEndCo2=${InitYearCo2}1231 |
---|
| 182 | fCO2_ff=${UndefinedValueCo2} |
---|
| 183 | CO2SBG=${UndefinedValueCo2} |
---|
| 184 | CO2LU=${UndefinedValueCo2} |
---|
| 185 | CO2MBG=${UndefinedValueCo2} |
---|
| 186 | CO2_ppm_prec=${UndefinedValueCo2} |
---|
| 187 | # Get the initial value of atmosp. pco2 |
---|
| 188 | CO2_ppm=${lmdz_UserChoices_co2_init} |
---|
| 189 | |
---|
| 190 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 191 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 192 | |
---|
| 193 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 194 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 195 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 196 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 197 | |
---|
| 198 | # Get the path where the log file co2.log is |
---|
| 199 | PathCO2log=${SUBMIT_DIR} |
---|
| 200 | # Get Previous line in co2.log |
---|
| 201 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 202 | |
---|
| 203 | else |
---|
| 204 | |
---|
| 205 | # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): |
---|
| 206 | # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. |
---|
| 207 | #SubmitRestartPath= |
---|
| 208 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then |
---|
| 209 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath |
---|
| 210 | PathCO2log=${config_ATM_SubmitRestartPath} |
---|
| 211 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) |
---|
| 212 | PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) |
---|
| 213 | |
---|
| 214 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 215 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 216 | |
---|
| 217 | # Save Last Line of control in new co2.log file |
---|
| 218 | InitPeriodCo2=0 |
---|
| 219 | InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) |
---|
| 220 | InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) |
---|
| 221 | fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) |
---|
| 222 | CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) |
---|
| 223 | CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) |
---|
| 224 | CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) |
---|
| 225 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) |
---|
| 226 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 227 | |
---|
| 228 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 229 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 230 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 231 | else |
---|
| 232 | # Get restart line in co2.log |
---|
| 233 | PathCO2log=${SUBMIT_DIR} |
---|
| 234 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 235 | # Get the value of atmosp. pco2 in co2.log |
---|
| 236 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 237 | fi |
---|
| 238 | |
---|
| 239 | fi |
---|
| 240 | |
---|
| 241 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 242 | # Modify co2_ppm in physiq.def only for historical run |
---|
| 243 | LMDZ_sed physiq.def co2_ppm ${CO2_ppm} |
---|
| 244 | fi |
---|
| 245 | fi |
---|
| 246 | # end CARBON_CYCLE |
---|
| 247 | |
---|
| 248 | |
---|
[911] | 249 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
| 250 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
| 251 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
| 252 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
| 253 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
| 254 | LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
| 255 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
[1001] | 256 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 257 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 258 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 259 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
[1012] | 260 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
[396] | 261 | |
---|
[911] | 262 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
[396] | 263 | |
---|
[911] | 264 | ## run.def parameters |
---|
| 265 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 266 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 267 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 268 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 269 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 270 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 271 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 272 | |
---|
[902] | 273 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 274 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
[1172] | 275 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
[396] | 276 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 277 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 278 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 279 | echo |
---|
| 280 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 281 | echo |
---|
| 282 | cat gcm.def |
---|
| 283 | ByPass_hgardfou_teta=n |
---|
[902] | 284 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 285 | fi |
---|
| 286 | |
---|
[902] | 287 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 288 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
[1172] | 289 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
[396] | 290 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 291 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 292 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 293 | echo |
---|
| 294 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 295 | echo |
---|
| 296 | cat gcm.def |
---|
| 297 | ByPass_hgardfou_mats=n |
---|
[902] | 298 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 299 | fi |
---|
| 300 | |
---|
| 301 | if ( ${FirstInitialize} ) ; then |
---|
| 302 | |
---|
| 303 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
| 304 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[894] | 305 | ##-- suppression of ozone file construction -- |
---|
| 306 | cp physiq.def physiq.def.save |
---|
| 307 | LMDZ_sed physiq.def read_climoz 0 |
---|
[396] | 308 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 309 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[908] | 310 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
[894] | 311 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 312 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
[396] | 313 | fi |
---|
[894] | 314 | IGCM_sys_Mv physiq.def.save physiq.def |
---|
[396] | 315 | else |
---|
[908] | 316 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 317 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
[396] | 318 | fi |
---|
| 319 | fi |
---|
| 320 | |
---|
| 321 | fi |
---|
| 322 | |
---|
| 323 | IGCM_debug_PopStack "ATM_Update" |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | #----------------------------------- |
---|
| 327 | function ATM_Finalize |
---|
| 328 | { |
---|
| 329 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 330 | |
---|
[743] | 331 | [ ${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] | 332 | |
---|
[1537] | 333 | |
---|
| 334 | # Add special treatement for CARBON CYCLE |
---|
| 335 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 336 | typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 337 | |
---|
| 338 | # Fossil fuel emission |
---|
| 339 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then |
---|
| 340 | # For Control, no fossil fuel emission : |
---|
| 341 | fCO2_ff=0 |
---|
| 342 | echo "Fossil Fuel for control run :" ${fCO2_ff} |
---|
| 343 | else |
---|
| 344 | # For historical, get the fossile fuel file : |
---|
| 345 | 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 ) |
---|
| 346 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
---|
| 347 | fi |
---|
| 348 | |
---|
| 349 | # Get the value of ocean carbon flux |
---|
| 350 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
---|
| 351 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
---|
| 352 | echo "Ocean carbon flux :" ${CO2MBG} |
---|
| 353 | |
---|
| 354 | # Get the value of land fluxes |
---|
| 355 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
---|
| 356 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
---|
| 357 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
---|
| 358 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
---|
| 359 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
---|
| 360 | echo "LU flux (FLUC) :" ${CO2LU} |
---|
| 361 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
---|
| 362 | |
---|
| 363 | # Previous CO2 |
---|
| 364 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 365 | echo "Previous CO2 :" ${CO2_ppm_prec} |
---|
| 366 | |
---|
| 367 | # Formula |
---|
| 368 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
---|
| 369 | echo "New CO2 :" ${CO2_ppm} |
---|
| 370 | |
---|
| 371 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 372 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 373 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 374 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 375 | |
---|
| 376 | fi |
---|
| 377 | |
---|
[396] | 378 | echo FINALIZE ATM ! |
---|
| 379 | |
---|
| 380 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 381 | } |
---|