[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 |
---|
| 61 | eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
[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 |
---|
| 65 | eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
[815] | 66 | fi |
---|
| 67 | |
---|
[912] | 68 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
| 69 | eval LMDZ_Freq_aero=\${lmdz_UserChoices_LMDZ_Freq_aero} > /dev/null 2>&1 |
---|
| 70 | eval LMDZ_Length_aero=\${lmdz_UserChoices_LMDZ_Length_aero} > /dev/null 2>&1 |
---|
| 71 | |
---|
[1000] | 72 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
| 73 | eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1 |
---|
| 74 | eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1 |
---|
| 75 | eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1 |
---|
| 76 | eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1 |
---|
| 77 | |
---|
[1003] | 78 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
| 79 | eval LMDZ_NMC_monthly=\${lmdz_UserChoices_LMDZ_NMC_monthly} > /dev/null 2>&1 |
---|
| 80 | eval LMDZ_NMC_daily=\${lmdz_UserChoices_LMDZ_NMC_daily} > /dev/null 2>&1 |
---|
| 81 | eval LMDZ_NMC_hf=\${lmdz_UserChoices_LMDZ_NMC_hf} > /dev/null 2>&1 |
---|
[1000] | 82 | |
---|
[1003] | 83 | |
---|
[396] | 84 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | #----------------------------------------------------------------- |
---|
| 88 | function ATM_Update |
---|
| 89 | { |
---|
| 90 | IGCM_debug_PushStack "ATM_Update" |
---|
| 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 | |
---|
[918] | 116 | ## To have more variables in output files for aerosols. Parameters are set in lmdz.card |
---|
| 117 | if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then |
---|
| 118 | if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then |
---|
| 119 | lev_histmth=4 |
---|
| 120 | else |
---|
| 121 | lev_histmth=2 |
---|
| 122 | fi |
---|
[912] | 123 | else |
---|
[918] | 124 | lev_histmth=2 |
---|
| 125 | fi |
---|
[912] | 126 | |
---|
[815] | 127 | ## algo : For CumulPeriod=1 ; |
---|
| 128 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 129 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 130 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 131 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 132 | |
---|
| 133 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 134 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 135 | 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] | 136 | 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 |
---|
| 137 | 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" |
---|
| 138 | fi |
---|
| 139 | fi |
---|
| 140 | |
---|
[743] | 141 | LMDZ_adjust=n |
---|
| 142 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 143 | |
---|
[815] | 144 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 145 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 146 | |
---|
[902] | 147 | [ ${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] | 148 | |
---|
[911] | 149 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
| 150 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
| 151 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
| 152 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
[912] | 153 | LMDZ_sed physiq.def lev_histmth ${lev_histmth} |
---|
[911] | 154 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
| 155 | LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
| 156 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
[1000] | 157 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 158 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 159 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 160 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
[1010] | 161 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
[396] | 162 | |
---|
[911] | 163 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
[396] | 164 | |
---|
[911] | 165 | ## run.def parameters |
---|
| 166 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 167 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 168 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 169 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 170 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 171 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 172 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 173 | |
---|
[902] | 174 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 175 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
| 176 | eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
[396] | 177 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 178 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 179 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 180 | echo |
---|
| 181 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 182 | echo |
---|
| 183 | cat gcm.def |
---|
| 184 | ByPass_hgardfou_teta=n |
---|
[902] | 185 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 186 | fi |
---|
| 187 | |
---|
[902] | 188 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 189 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
| 190 | eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
[396] | 191 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 192 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 193 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 194 | echo |
---|
| 195 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 196 | echo |
---|
| 197 | cat gcm.def |
---|
| 198 | ByPass_hgardfou_mats=n |
---|
[902] | 199 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 200 | fi |
---|
| 201 | |
---|
| 202 | if ( ${FirstInitialize} ) ; then |
---|
| 203 | |
---|
| 204 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
| 205 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[894] | 206 | ##-- suppression of ozone file construction -- |
---|
| 207 | cp physiq.def physiq.def.save |
---|
| 208 | LMDZ_sed physiq.def read_climoz 0 |
---|
[396] | 209 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 210 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[908] | 211 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
[894] | 212 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 213 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
[396] | 214 | fi |
---|
[894] | 215 | IGCM_sys_Mv physiq.def.save physiq.def |
---|
[396] | 216 | else |
---|
[908] | 217 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 218 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
[396] | 219 | fi |
---|
| 220 | fi |
---|
| 221 | |
---|
| 222 | fi |
---|
| 223 | |
---|
| 224 | IGCM_debug_PopStack "ATM_Update" |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | #----------------------------------- |
---|
| 228 | function ATM_Finalize |
---|
| 229 | { |
---|
| 230 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 231 | |
---|
[743] | 232 | [ ${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] | 233 | |
---|
| 234 | echo FINALIZE ATM ! |
---|
| 235 | |
---|
| 236 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 237 | } |
---|