[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 |
---|
[988] | 55 | HF|hf) |
---|
| 56 | ok_hf=y |
---|
| 57 | OK_instan=y |
---|
| 58 | ;; |
---|
[396] | 59 | esac |
---|
| 60 | done |
---|
| 61 | |
---|
[902] | 62 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
| 63 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
[1172] | 64 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
[396] | 65 | |
---|
[815] | 66 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 67 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
[1172] | 68 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
[815] | 69 | fi |
---|
| 70 | |
---|
[912] | 71 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
[1172] | 72 | LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero} |
---|
| 73 | LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero} |
---|
[912] | 74 | |
---|
[1001] | 75 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
[1172] | 76 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 77 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 78 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 79 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
[1001] | 80 | |
---|
[1003] | 81 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
[1172] | 82 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 83 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 84 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
[1003] | 85 | |
---|
[396] | 86 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | #----------------------------------------------------------------- |
---|
| 90 | function ATM_Update |
---|
| 91 | { |
---|
| 92 | IGCM_debug_PushStack "ATM_Update" |
---|
| 93 | |
---|
[749] | 94 | case ${config_UserChoices_PeriodLength} in |
---|
| 95 | *Y|*y) |
---|
| 96 | LMDZ_ecrit_mth=30. |
---|
| 97 | LMDZ_ecrit_ISCCP=30. |
---|
| 98 | LMDZ_periodav=30. |
---|
[755] | 99 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[749] | 100 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 101 | exit |
---|
| 102 | fi |
---|
| 103 | ;; |
---|
| 104 | *) |
---|
| 105 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
| 106 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 107 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 108 | ;; |
---|
| 109 | esac |
---|
[396] | 110 | |
---|
| 111 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 112 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 113 | RAZ_DATE=1 |
---|
| 114 | else |
---|
| 115 | RAZ_DATE=0 |
---|
| 116 | fi |
---|
| 117 | |
---|
[918] | 118 | ## To have more variables in output files for aerosols. Parameters are set in lmdz.card |
---|
[988] | 119 | #if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then |
---|
| 120 | # if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then |
---|
| 121 | # lev_histmth=4 |
---|
| 122 | # else |
---|
| 123 | # lev_histmth=2 |
---|
| 124 | # fi |
---|
| 125 | #else |
---|
| 126 | # lev_histmth=2 |
---|
| 127 | #fi |
---|
[912] | 128 | |
---|
[815] | 129 | ## algo : For CumulPeriod=1 ; |
---|
| 130 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 131 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 132 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 133 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 134 | |
---|
| 135 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 136 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[1961] | 137 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
[815] | 138 | 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 |
---|
[1961] | 139 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
[815] | 140 | 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" |
---|
| 141 | fi |
---|
| 142 | fi |
---|
| 143 | |
---|
[743] | 144 | LMDZ_adjust=n |
---|
| 145 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 146 | |
---|
[815] | 147 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 148 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 149 | |
---|
[902] | 150 | [ ${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] | 151 | |
---|
[988] | 152 | ##-- GHG forcing for the current year |
---|
[1083] | 153 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES_1610_2008.txt | awk -F= '{print $2}'` |
---|
[988] | 154 | IPCC_CO2=`grep Annee_${year} CO2_1765_2005.txt | awk -F= '{print $2}'` |
---|
| 155 | IPCC_CH4=`grep Annee_${year} CH4_1765_2005.txt | awk -F= '{print $2}'` |
---|
| 156 | IPCC_N2O=`grep Annee_${year} N2O_1765_2005.txt | awk -F= '{print $2}'` |
---|
| 157 | IPCC_CFC11=`grep Annee_${year} CFC11_1765_2005.txt | awk -F= '{print $2}'` |
---|
| 158 | IPCC_CFC12=`grep Annee_${year} CFC12_1765_2005.txt | awk -F= '{print $2}'` |
---|
| 159 | |
---|
[1172] | 160 | ##-- For historical daily cosp must be output during 1979-2005 period |
---|
| 161 | [ ${year} -ge 1979 ] && LMDZ_COSP_daily=y |
---|
| 162 | |
---|
[911] | 163 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
| 164 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
| 165 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
| 166 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
[988] | 167 | #LMDZ_sed physiq.def lev_histmth ${lev_histmth} |
---|
[911] | 168 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
| 169 | LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
| 170 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
[1001] | 171 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 172 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 173 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 174 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
[1012] | 175 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
[1026] | 176 | LMDZ_sed physiq.def solaire ${IPCC_SOLAR} |
---|
[988] | 177 | LMDZ_sed physiq.def co2_ppm ${IPCC_CO2} |
---|
| 178 | LMDZ_sed physiq.def CH4_ppb ${IPCC_CH4} |
---|
| 179 | LMDZ_sed physiq.def N2O_ppb ${IPCC_N2O} |
---|
| 180 | LMDZ_sed physiq.def CFC11_ppt ${IPCC_CFC11} |
---|
| 181 | LMDZ_sed physiq.def CFC12_ppt ${IPCC_CFC12} |
---|
[396] | 182 | |
---|
[911] | 183 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
[396] | 184 | |
---|
[911] | 185 | ## run.def parameters |
---|
| 186 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 187 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 188 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 189 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 190 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 191 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 192 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 193 | |
---|
[902] | 194 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 195 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
[1172] | 196 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
[396] | 197 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 198 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 199 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 200 | echo |
---|
| 201 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 202 | echo |
---|
| 203 | cat gcm.def |
---|
| 204 | ByPass_hgardfou_teta=n |
---|
[902] | 205 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 206 | fi |
---|
| 207 | |
---|
[902] | 208 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 209 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
[1172] | 210 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
[396] | 211 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 212 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 213 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 214 | echo |
---|
| 215 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 216 | echo |
---|
| 217 | cat gcm.def |
---|
| 218 | ByPass_hgardfou_mats=n |
---|
[902] | 219 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 220 | fi |
---|
| 221 | |
---|
| 222 | if ( ${FirstInitialize} ) ; then |
---|
| 223 | |
---|
| 224 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
| 225 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[894] | 226 | ##-- suppression of ozone file construction -- |
---|
| 227 | cp physiq.def physiq.def.save |
---|
| 228 | LMDZ_sed physiq.def read_climoz 0 |
---|
[396] | 229 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 230 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[908] | 231 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
[894] | 232 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 233 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
[396] | 234 | fi |
---|
[894] | 235 | IGCM_sys_Mv physiq.def.save physiq.def |
---|
[396] | 236 | else |
---|
[908] | 237 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 238 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
[396] | 239 | fi |
---|
| 240 | fi |
---|
| 241 | |
---|
| 242 | fi |
---|
| 243 | |
---|
| 244 | IGCM_debug_PopStack "ATM_Update" |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | #----------------------------------- |
---|
| 248 | function ATM_Finalize |
---|
| 249 | { |
---|
| 250 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 251 | |
---|
[743] | 252 | [ ${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] | 253 | |
---|
| 254 | echo FINALIZE ATM ! |
---|
| 255 | |
---|
| 256 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 257 | } |
---|