1 | # $Id$ |
---|
2 | # |
---|
3 | #!/bin/ksh |
---|
4 | #----------------------------------------------------------------- |
---|
5 | function LMDZ_sed |
---|
6 | { |
---|
7 | IGCM_debug_PushStack "LMDZ_sed" |
---|
8 | |
---|
9 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
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 | |
---|
18 | function ATM_Initialize |
---|
19 | { |
---|
20 | IGCM_debug_PushStack "ATM_Initialize" |
---|
21 | |
---|
22 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
23 | |
---|
24 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x39 |
---|
25 | |
---|
26 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
27 | |
---|
28 | ##-- Calendar type for LMDZ |
---|
29 | case ${config_UserChoices_CalendarType} in |
---|
30 | leap|gregorian) |
---|
31 | CalendarTypeForLmdz=earth_366d;; |
---|
32 | noleap) |
---|
33 | CalendarTypeForLmdz=earth_365d;; |
---|
34 | 360d) |
---|
35 | CalendarTypeForLmdz=earth_360d;; |
---|
36 | *) |
---|
37 | CalendarTypeForLmdz=earth_360d |
---|
38 | esac |
---|
39 | |
---|
40 | ##- Create_etat0_limit version |
---|
41 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
42 | CREATE=${lmdz_UserChoices_CREATE} |
---|
43 | echo create_etat0_limit version : ${CREATE} |
---|
44 | |
---|
45 | ##- Default number of processor for lmdz |
---|
46 | NUM_PROC_ATM=4 |
---|
47 | if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then |
---|
48 | NUM_PROC_ATM=${BATCH_NUM_PROC_TOT} |
---|
49 | fi |
---|
50 | |
---|
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) |
---|
69 | ok_hf=y |
---|
70 | OK_instan=y |
---|
71 | ;; |
---|
72 | esac |
---|
73 | done |
---|
74 | |
---|
75 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
76 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
77 | eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
78 | |
---|
79 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
80 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
81 | eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
82 | fi |
---|
83 | |
---|
84 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
85 | eval LMDZ_Freq_aero=\${lmdz_UserChoices_LMDZ_Freq_aero} > /dev/null 2>&1 |
---|
86 | eval LMDZ_Length_aero=\${lmdz_UserChoices_LMDZ_Length_aero} > /dev/null 2>&1 |
---|
87 | |
---|
88 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
89 | eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1 |
---|
90 | eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1 |
---|
91 | eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1 |
---|
92 | eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1 |
---|
93 | |
---|
94 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
95 | eval LMDZ_NMC_monthly=\${lmdz_UserChoices_LMDZ_NMC_monthly} > /dev/null 2>&1 |
---|
96 | eval LMDZ_NMC_daily=\${lmdz_UserChoices_LMDZ_NMC_daily} > /dev/null 2>&1 |
---|
97 | eval LMDZ_NMC_hf=\${lmdz_UserChoices_LMDZ_NMC_hf} > /dev/null 2>&1 |
---|
98 | |
---|
99 | IGCM_debug_PopStack "ATM_Initialize" |
---|
100 | } |
---|
101 | |
---|
102 | #----------------------------------------------------------------- |
---|
103 | function ATM_Update |
---|
104 | { |
---|
105 | IGCM_debug_PushStack "ATM_Update" |
---|
106 | |
---|
107 | case ${config_UserChoices_PeriodLength} in |
---|
108 | *Y|*y) |
---|
109 | LMDZ_ecrit_mth=30. |
---|
110 | LMDZ_ecrit_ISCCP=30. |
---|
111 | LMDZ_periodav=30. |
---|
112 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
113 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
114 | exit |
---|
115 | fi |
---|
116 | ;; |
---|
117 | *) |
---|
118 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
119 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
120 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
121 | ;; |
---|
122 | esac |
---|
123 | |
---|
124 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
125 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
126 | RAZ_DATE=1 |
---|
127 | else |
---|
128 | RAZ_DATE=0 |
---|
129 | fi |
---|
130 | |
---|
131 | ## To have more variables in output files for aerosols. Parameters are set in lmdz.card |
---|
132 | #if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then |
---|
133 | # if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then |
---|
134 | # lev_histmth=4 |
---|
135 | # else |
---|
136 | # lev_histmth=2 |
---|
137 | # fi |
---|
138 | #else |
---|
139 | # lev_histmth=2 |
---|
140 | #fi |
---|
141 | |
---|
142 | ## algo : For CumulPeriod=1 ; |
---|
143 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
144 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
145 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
146 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
147 | |
---|
148 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
149 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
150 | 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 |
---|
151 | 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 |
---|
152 | 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" |
---|
153 | fi |
---|
154 | fi |
---|
155 | |
---|
156 | LMDZ_adjust=n |
---|
157 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
158 | |
---|
159 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
160 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
161 | |
---|
162 | [ ${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 ) |
---|
163 | |
---|
164 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
165 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
166 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
167 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
168 | #LMDZ_sed physiq.def lev_histmth ${lev_histmth} |
---|
169 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
170 | LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
171 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
172 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
173 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
174 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
175 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
176 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
177 | |
---|
178 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
179 | |
---|
180 | ## run.def parameters |
---|
181 | LMDZ_sed run.def dayref ${InitDay} |
---|
182 | LMDZ_sed run.def anneeref ${InitYear} |
---|
183 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
184 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
185 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
186 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
187 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
188 | |
---|
189 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
190 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
191 | eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
192 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
193 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
194 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
195 | echo |
---|
196 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
197 | echo |
---|
198 | cat gcm.def |
---|
199 | ByPass_hgardfou_teta=n |
---|
200 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
201 | fi |
---|
202 | |
---|
203 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
204 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
205 | eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
206 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
207 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
208 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
209 | echo |
---|
210 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
211 | echo |
---|
212 | cat gcm.def |
---|
213 | ByPass_hgardfou_mats=n |
---|
214 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
215 | fi |
---|
216 | |
---|
217 | IGCM_debug_PopStack "ATM_Update" |
---|
218 | } |
---|
219 | |
---|
220 | #----------------------------------- |
---|
221 | function ATM_Finalize |
---|
222 | { |
---|
223 | IGCM_debug_PushStack "ATM_Finalize" |
---|
224 | |
---|
225 | [ ${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} |
---|
226 | |
---|
227 | echo FINALIZE ATM ! |
---|
228 | |
---|
229 | IGCM_debug_PopStack "ATM_Finalize" |
---|
230 | } |
---|