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