[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 | |
---|
[1221] | 16 | function LMDZ_string_sed |
---|
| 17 | { |
---|
| 18 | IGCM_debug_PushStack "LMDZ_string_sed" |
---|
| 19 | |
---|
| 20 | sed -e "s/${2}/${3}/" ${1} > ${1}.tmp |
---|
| 21 | RET=$? |
---|
| 22 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 23 | \mv ${1}.tmp ${1} |
---|
| 24 | |
---|
| 25 | IGCM_debug_PopStack "LMDZ_string_sed" |
---|
| 26 | return $RET |
---|
| 27 | } |
---|
| 28 | |
---|
[396] | 29 | function ATM_Initialize |
---|
| 30 | { |
---|
| 31 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 32 | |
---|
[671] | 33 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
[396] | 34 | |
---|
[659] | 35 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
[396] | 36 | |
---|
[659] | 37 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
[649] | 38 | |
---|
[697] | 39 | ##-- Calendar type for LMDZ |
---|
| 40 | case ${config_UserChoices_CalendarType} in |
---|
| 41 | leap|gregorian) |
---|
| 42 | CalendarTypeForLmdz=earth_366d;; |
---|
| 43 | noleap) |
---|
| 44 | CalendarTypeForLmdz=earth_365d;; |
---|
| 45 | 360d) |
---|
| 46 | CalendarTypeForLmdz=earth_360d;; |
---|
| 47 | *) |
---|
| 48 | CalendarTypeForLmdz=earth_360d |
---|
| 49 | esac |
---|
| 50 | |
---|
[396] | 51 | ##--Frequency purpose .... |
---|
| 52 | ##-- Initialisation .... |
---|
| 53 | OK_instan=n |
---|
| 54 | OK_journe=n |
---|
| 55 | OK_mensuel=n |
---|
| 56 | ok_hf=n |
---|
| 57 | |
---|
| 58 | case ${config_UserChoices_PeriodLength} in |
---|
| 59 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
| 60 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 61 | esac |
---|
| 62 | |
---|
| 63 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 64 | case ${frequency} in |
---|
| 65 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 66 | esac |
---|
| 67 | case ${frequency} in |
---|
| 68 | HF|hf) ok_hf=y ;; |
---|
| 69 | esac |
---|
| 70 | done |
---|
| 71 | |
---|
[1220] | 72 | ## Read LMDZPhysics option in lmdz.card |
---|
| 73 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Physics |
---|
| 74 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
| 75 | |
---|
[902] | 76 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
| 77 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
[1172] | 78 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
[396] | 79 | |
---|
[815] | 80 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 81 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
[1172] | 82 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
[815] | 83 | fi |
---|
| 84 | |
---|
[912] | 85 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
[1172] | 86 | LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero} |
---|
| 87 | LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero} |
---|
[912] | 88 | |
---|
[1001] | 89 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
[1172] | 90 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 91 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 92 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 93 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
[1001] | 94 | |
---|
[1003] | 95 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
[1172] | 96 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 97 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 98 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
[1003] | 99 | |
---|
[396] | 100 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | #----------------------------------------------------------------- |
---|
| 104 | function ATM_Update |
---|
| 105 | { |
---|
| 106 | IGCM_debug_PushStack "ATM_Update" |
---|
| 107 | |
---|
[749] | 108 | case ${config_UserChoices_PeriodLength} in |
---|
| 109 | *Y|*y) |
---|
[1221] | 110 | # LMDZ_ecrit_mth=30. |
---|
| 111 | LMDZ_ecrit_mth=1mth |
---|
[749] | 112 | LMDZ_ecrit_ISCCP=30. |
---|
| 113 | LMDZ_periodav=30. |
---|
[755] | 114 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[749] | 115 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 116 | exit |
---|
| 117 | fi |
---|
| 118 | ;; |
---|
| 119 | *) |
---|
[1221] | 120 | LMDZ_ecrit_mth="${PeriodLengthInDays}""day" |
---|
[749] | 121 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 122 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 123 | ;; |
---|
| 124 | esac |
---|
[396] | 125 | |
---|
| 126 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 127 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 128 | RAZ_DATE=1 |
---|
| 129 | else |
---|
| 130 | RAZ_DATE=0 |
---|
| 131 | fi |
---|
| 132 | |
---|
[815] | 133 | ## algo : For CumulPeriod=1 ; |
---|
| 134 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 135 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 136 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 137 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 138 | |
---|
| 139 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 140 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
[902] | 141 | 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] | 142 | 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 |
---|
| 143 | 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" |
---|
| 144 | fi |
---|
| 145 | fi |
---|
| 146 | |
---|
[743] | 147 | LMDZ_adjust=n |
---|
| 148 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 149 | |
---|
[815] | 150 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 151 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
[743] | 152 | |
---|
[902] | 153 | [ ${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] | 154 | |
---|
[911] | 155 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
| 156 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
| 157 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
| 158 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
| 159 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
[1221] | 160 | # LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
| 161 | LMDZ_string_sed config.def _ecrit-mth_ ${LMDZ_ecrit_mth} |
---|
[911] | 162 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
[1001] | 163 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 164 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 165 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 166 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
[1012] | 167 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
[396] | 168 | |
---|
[911] | 169 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
[396] | 170 | |
---|
[911] | 171 | ## run.def parameters |
---|
| 172 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 173 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 174 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 175 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 176 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 177 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 178 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
[396] | 179 | |
---|
[902] | 180 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 181 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
[1172] | 182 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
[396] | 183 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 184 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 185 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 186 | echo |
---|
| 187 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 188 | echo |
---|
| 189 | cat gcm.def |
---|
| 190 | ByPass_hgardfou_teta=n |
---|
[902] | 191 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
[396] | 192 | fi |
---|
| 193 | |
---|
[902] | 194 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 195 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
[1172] | 196 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
[396] | 197 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 198 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 199 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 200 | echo |
---|
| 201 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 202 | echo |
---|
| 203 | cat gcm.def |
---|
| 204 | ByPass_hgardfou_mats=n |
---|
[902] | 205 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
[396] | 206 | fi |
---|
| 207 | |
---|
| 208 | if ( ${FirstInitialize} ) ; then |
---|
| 209 | |
---|
| 210 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
| 211 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[894] | 212 | ##-- suppression of ozone file construction -- |
---|
| 213 | cp physiq.def physiq.def.save |
---|
| 214 | LMDZ_sed physiq.def read_climoz 0 |
---|
[396] | 215 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 216 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[908] | 217 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
[894] | 218 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 219 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
[396] | 220 | fi |
---|
[894] | 221 | IGCM_sys_Mv physiq.def.save physiq.def |
---|
[396] | 222 | else |
---|
[908] | 223 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 224 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
[396] | 225 | fi |
---|
| 226 | fi |
---|
| 227 | |
---|
| 228 | fi |
---|
| 229 | |
---|
| 230 | IGCM_debug_PopStack "ATM_Update" |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | #----------------------------------- |
---|
| 234 | function ATM_Finalize |
---|
| 235 | { |
---|
| 236 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 237 | |
---|
[743] | 238 | [ ${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] | 239 | |
---|
| 240 | echo FINALIZE ATM ! |
---|
| 241 | |
---|
| 242 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 243 | } |
---|