1 | |
---|
2 | # $Id$ |
---|
3 | # |
---|
4 | #!/bin/ksh |
---|
5 | #----------------------------------------------------------------- |
---|
6 | function LMDZ_sed |
---|
7 | { |
---|
8 | IGCM_debug_PushStack "LMDZ_sed" |
---|
9 | |
---|
10 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
11 | RET=$? |
---|
12 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
13 | \mv ${1}.tmp ${1} |
---|
14 | |
---|
15 | IGCM_debug_PopStack "LMDZ_sed" |
---|
16 | return $RET |
---|
17 | } |
---|
18 | |
---|
19 | function ATM_Initialize |
---|
20 | { |
---|
21 | IGCM_debug_PushStack "ATM_Initialize" |
---|
22 | |
---|
23 | RESOL_ATM=$( echo $RESOL | awk "-F-L" '{print $1}') |
---|
24 | |
---|
25 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
26 | |
---|
27 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' | awk "-F-" '{print $1}') |
---|
28 | |
---|
29 | ##-- Calendar type for LMDZ |
---|
30 | case ${config_UserChoices_CalendarType} in |
---|
31 | leap|gregorian) |
---|
32 | CalendarTypeForLmdz=earth_366d;; |
---|
33 | noleap) |
---|
34 | CalendarTypeForLmdz=earth_365d;; |
---|
35 | 360d) |
---|
36 | CalendarTypeForLmdz=earth_360d;; |
---|
37 | *) |
---|
38 | CalendarTypeForLmdz=earth_360d |
---|
39 | esac |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | ##- LMDZ physics version |
---|
44 | ## Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) |
---|
45 | if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then |
---|
46 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
47 | else |
---|
48 | LMDZ_Physics=AP |
---|
49 | fi |
---|
50 | echo LMDZ physics version : ${LMDZ_Physics} |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | ##- Create_etat0_limit version |
---|
55 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
56 | CREATE=${lmdz_UserChoices_CREATE} |
---|
57 | echo create_etat0_limit version : ${CREATE} |
---|
58 | |
---|
59 | ##- Default number of processor for lmdz |
---|
60 | NUM_PROC_ATM=4 |
---|
61 | if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then |
---|
62 | NUM_PROC_ATM=${BATCH_NUM_PROC_TOT} |
---|
63 | fi |
---|
64 | |
---|
65 | ##-- Output frequency purpose .... |
---|
66 | ##-- Initialisation .... |
---|
67 | ok_mensuel=n |
---|
68 | ok_journe=n |
---|
69 | ok_hf=n |
---|
70 | ok_hf3h=n |
---|
71 | ok_hf3hm=n |
---|
72 | ok_stn=n |
---|
73 | |
---|
74 | case ${config_UserChoices_PeriodLength} in |
---|
75 | 1Y|1y|1M|1m) ok_mensuel=y ;; |
---|
76 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
77 | esac |
---|
78 | |
---|
79 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
80 | case ${frequency} in |
---|
81 | 1M|1m) ok_mensuel=y ;; |
---|
82 | esac |
---|
83 | case ${frequency} in |
---|
84 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
85 | esac |
---|
86 | case ${frequency} in |
---|
87 | HF|hf) ok_hf=y ;; |
---|
88 | esac |
---|
89 | case ${frequency} in |
---|
90 | HF3h|hf3h) ok_hf3h=y ;; |
---|
91 | esac |
---|
92 | case ${frequency} in |
---|
93 | HF3hm|hf3hm) ok_hf3hm=y ;; |
---|
94 | esac |
---|
95 | case ${frequency} in |
---|
96 | STN|stn) ok_stn=y ;; |
---|
97 | esac |
---|
98 | done |
---|
99 | |
---|
100 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
101 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
102 | eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
103 | |
---|
104 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
105 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
106 | eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
107 | fi |
---|
108 | |
---|
109 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
110 | eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1 |
---|
111 | eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1 |
---|
112 | eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1 |
---|
113 | eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1 |
---|
114 | |
---|
115 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
116 | eval LMDZ_NMC_monthly=\${lmdz_UserChoices_LMDZ_NMC_monthly} > /dev/null 2>&1 |
---|
117 | eval LMDZ_NMC_daily=\${lmdz_UserChoices_LMDZ_NMC_daily} > /dev/null 2>&1 |
---|
118 | eval LMDZ_NMC_hf=\${lmdz_UserChoices_LMDZ_NMC_hf} > /dev/null 2>&1 |
---|
119 | |
---|
120 | IGCM_debug_PopStack "ATM_Initialize" |
---|
121 | } |
---|
122 | |
---|
123 | #----------------------------------------------------------------- |
---|
124 | function ATM_Update |
---|
125 | { |
---|
126 | IGCM_debug_PushStack "ATM_Update" |
---|
127 | |
---|
128 | case ${config_UserChoices_PeriodLength} in |
---|
129 | *Y|*y) |
---|
130 | LMDZ_ecrit_ISCCP=30. |
---|
131 | LMDZ_periodav=30. |
---|
132 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
133 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
134 | exit |
---|
135 | fi |
---|
136 | ;; |
---|
137 | *) |
---|
138 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
139 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
140 | ;; |
---|
141 | esac |
---|
142 | |
---|
143 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
144 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
145 | RAZ_DATE=1 |
---|
146 | else |
---|
147 | RAZ_DATE=0 |
---|
148 | fi |
---|
149 | |
---|
150 | |
---|
151 | ## algo : For CumulPeriod=1 ; |
---|
152 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
153 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
154 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
155 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
156 | |
---|
157 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
158 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
159 | if [ ! X${LMDZ_Bands_file_name} = X] ; then |
---|
160 | 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 |
---|
161 | 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 |
---|
162 | 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" |
---|
163 | fi |
---|
164 | fi |
---|
165 | fi |
---|
166 | |
---|
167 | LMDZ_adjust=n |
---|
168 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
169 | |
---|
170 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
171 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
172 | |
---|
173 | [ ${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 ) |
---|
174 | |
---|
175 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
176 | # columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : |
---|
177 | # histmth histday histhf histfh3h histhf3hm histstn |
---|
178 | LMDZ_sed physiq.def phys_out_filekeys "${ok_mensuel} ${ok_journe} ${ok_hf} ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" |
---|
179 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
180 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
181 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
182 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
183 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
184 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
185 | |
---|
186 | ##-- GHG forcing for the current year if forcing file is availible |
---|
187 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
188 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
189 | LMDZ_sed physiq.def solaire ${IPCC_SOLAR} |
---|
190 | fi |
---|
191 | if [ -f CO2.txt ] ; then |
---|
192 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
193 | LMDZ_sed physiq.def co2_ppm ${IPCC_CO2} |
---|
194 | fi |
---|
195 | if [ -f CH4.txt ] ; then |
---|
196 | IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
197 | LMDZ_sed physiq.def CH4_ppb ${IPCC_CH4} |
---|
198 | fi |
---|
199 | if [ -f N2O.txt ] ; then |
---|
200 | IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
201 | LMDZ_sed physiq.def N2O_ppb ${IPCC_N2O} |
---|
202 | fi |
---|
203 | if [ -f CFC11.txt ] ; then |
---|
204 | IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
205 | LMDZ_sed physiq.def CFC11_ppt ${IPCC_CFC11} |
---|
206 | fi |
---|
207 | if [ -f CFC12.txt ] ; then |
---|
208 | IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
209 | LMDZ_sed physiq.def CFC12_ppt ${IPCC_CFC12} |
---|
210 | fi |
---|
211 | |
---|
212 | ## Other specific parameters to this experience |
---|
213 | if [ ! X${lmdz_UserChoices_aer_type} = X ] ; then |
---|
214 | LMDZ_sed physiq.def aer_type ${lmdz_UserChoices_aer_type} |
---|
215 | fi |
---|
216 | if [ ! X${lmdz_UserChoices_pmagic} = X ] ; then |
---|
217 | LMDZ_sed physiq.def pmagic ${lmdz_UserChoices_pmagic} |
---|
218 | fi |
---|
219 | |
---|
220 | if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then |
---|
221 | LMDZ_sed guide.def ok_guide ${lmdz_UserChoices_ok_guide} |
---|
222 | fi |
---|
223 | |
---|
224 | ## gcm.def parameters : |
---|
225 | # Modification only for new physics |
---|
226 | if [ X${LMDZ_Physics} = X"NPv3.0" ] ; then |
---|
227 | LMDZ_sed gcm.def iphysiq 5 |
---|
228 | fi |
---|
229 | |
---|
230 | ## run.def parameters |
---|
231 | LMDZ_sed run.def dayref ${InitDay} |
---|
232 | LMDZ_sed run.def anneeref ${InitYear} |
---|
233 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
234 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
235 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
236 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
237 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
238 | |
---|
239 | # No filtre fft in case of zoom, 280x280x39-ZAf contains zoom |
---|
240 | if [ ${RESOL_ATM_3D} = "280x280x39-ZAf" ] || [ ${RESOL_ATM_3D} = "360x180x19-ZIn" ] ; then |
---|
241 | LMDZ_sed run.def use_filtre_fft n |
---|
242 | fi |
---|
243 | |
---|
244 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
245 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
246 | eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
247 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
248 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
249 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
250 | echo |
---|
251 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
252 | echo |
---|
253 | cat gcm.def |
---|
254 | ByPass_hgardfou_teta=n |
---|
255 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
256 | fi |
---|
257 | |
---|
258 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
259 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
260 | eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
261 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
262 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
263 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
264 | echo |
---|
265 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
266 | echo |
---|
267 | cat gcm.def |
---|
268 | ByPass_hgardfou_mats=n |
---|
269 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
270 | fi |
---|
271 | |
---|
272 | IGCM_debug_PopStack "ATM_Update" |
---|
273 | } |
---|
274 | |
---|
275 | #----------------------------------- |
---|
276 | function ATM_Finalize |
---|
277 | { |
---|
278 | IGCM_debug_PushStack "ATM_Finalize" |
---|
279 | |
---|
280 | [ ${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} |
---|
281 | |
---|
282 | echo FINALIZE ATM ! |
---|
283 | |
---|
284 | IGCM_debug_PopStack "ATM_Finalize" |
---|
285 | } |
---|