1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sonia Labetoulle |
---|
5 | # Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2012) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | |
---|
14 | function IGCM_ensemble_CastInit |
---|
15 | { |
---|
16 | IGCM_debug_PushStack "IGCM_ensemble_CastInit" |
---|
17 | |
---|
18 | set -A Alpha A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
---|
19 | set -A AlphaMonth a b c d e f g h i j k l |
---|
20 | |
---|
21 | IGCM_sys_Mkdir ${RUN_DIR} |
---|
22 | |
---|
23 | IGCM_sys_Cp ${SUBMIT_DIR}/config.card ${RUN_DIR} |
---|
24 | IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR} |
---|
25 | IGCM_sys_Cp ${SUBMIT_DIR}/Job_* ${RUN_DIR} |
---|
26 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR} |
---|
27 | |
---|
28 | if [ -f ${SUBMIT_DIR}/CreatedDir.txt ] ; then |
---|
29 | IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR} |
---|
30 | fi |
---|
31 | if [ -f ${SUBMIT_DIR}/Qsub.txt ] ; then |
---|
32 | IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR} |
---|
33 | fi |
---|
34 | |
---|
35 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB actif |
---|
36 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME |
---|
37 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT |
---|
38 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT |
---|
39 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE |
---|
40 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB NONPERIODIC |
---|
41 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE |
---|
42 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB DUREE_NONPERIODIC |
---|
43 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER |
---|
44 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB PERTURB_BIN |
---|
45 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM |
---|
46 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH |
---|
47 | IGCM_card_DefineVariableFromOption config.card UserChoices TagName |
---|
48 | IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType |
---|
49 | IGCM_card_DefineArrayFromSection config.card ListOfComponents |
---|
50 | |
---|
51 | echo |
---|
52 | IGCM_debug_Print 1 "ACTIVE = ${ensemble_Ens_PERTURB_actif}" |
---|
53 | IGCM_debug_Print 1 "NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
54 | IGCM_debug_Print 1 "DEBUT_INIT = ${ensemble_Ens_PERTURB_DEBUT_INIT}" |
---|
55 | IGCM_debug_Print 1 "FIN_INIT = ${ensemble_Ens_PERTURB_FIN_INIT}" |
---|
56 | IGCM_debug_Print 1 "PERIODICITE = ${ensemble_Ens_PERTURB_PERIODICITE}" |
---|
57 | IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}" |
---|
58 | IGCM_debug_Print 1 "DUREE = ${ensemble_Ens_PERTURB_DUREE}" |
---|
59 | IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[*]}" |
---|
60 | IGCM_debug_Print 1 "MEMBER = ${ensemble_Ens_PERTURB_MEMBER}" |
---|
61 | IGCM_debug_Print 1 "PERTURB_BIN = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" |
---|
62 | IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITFROM}" |
---|
63 | IGCM_debug_Print 1 "INITPATH = ${ensemble_Ens_PERTURB_INITPATH}" |
---|
64 | IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" |
---|
65 | IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" |
---|
66 | IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" |
---|
67 | |
---|
68 | PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]} |
---|
69 | PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} |
---|
70 | PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} |
---|
71 | PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} |
---|
72 | PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} |
---|
73 | |
---|
74 | IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" |
---|
75 | IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" |
---|
76 | IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" |
---|
77 | IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" |
---|
78 | IGCM_debug_Print 1 "PerturbAmp = ${PerturbAmp}" |
---|
79 | |
---|
80 | # A few checks Period case: |
---|
81 | |
---|
82 | # ... Check PERIODICITE ... |
---|
83 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
84 | _0_) |
---|
85 | IGCM_debug_Print 1 "periodic start not active" |
---|
86 | CastPeriodicStart=false |
---|
87 | return |
---|
88 | ;; |
---|
89 | *[Yy]|*[Mm]) |
---|
90 | CastPeriodicStart=true |
---|
91 | IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;; |
---|
92 | *) |
---|
93 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE" |
---|
94 | IGCM_debug_Exit "Choose a value in *Y or *M" |
---|
95 | IGCM_debug_Verif_Exit ;; |
---|
96 | esac |
---|
97 | # ... Check DUREE ... |
---|
98 | case ${ensemble_Ens_PERTURB_DUREE} in |
---|
99 | *[Yy]|*[Mm]) |
---|
100 | IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;; |
---|
101 | *) |
---|
102 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE} invalid DUREE" |
---|
103 | IGCM_debug_Exit "Choose a value in choose in *Y or *M" |
---|
104 | IGCM_debug_Verif_Exit ;; |
---|
105 | esac |
---|
106 | |
---|
107 | # A few checks for the Non-Periodic case: |
---|
108 | DateNum=0 |
---|
109 | while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
110 | |
---|
111 | # - Check DUREE_NONPERIODIC |
---|
112 | case ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} in |
---|
113 | _0_) |
---|
114 | IGCM_debug_Print 1 "non-periodic start not active" |
---|
115 | CastNonPeriodicStart=false |
---|
116 | return |
---|
117 | ;; |
---|
118 | *[Yy]|*[Mm]) |
---|
119 | IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}" |
---|
120 | CastNonPeriodicStart=true |
---|
121 | ;; |
---|
122 | *) |
---|
123 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} : invalid DUREE" |
---|
124 | IGCM_debug_Exit "choose in *Y or *M" |
---|
125 | IGCM_debug_Verif_Exit ;; |
---|
126 | esac |
---|
127 | (( DateNum = DateNum + 1 )) |
---|
128 | done |
---|
129 | |
---|
130 | IGCM_debug_PopStack "IGCM_ensemble_CastInit" |
---|
131 | } |
---|
132 | |
---|
133 | function IGCM_ensemble_CastPeriodicStarts |
---|
134 | { |
---|
135 | IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" |
---|
136 | |
---|
137 | [ ${CastPeriodicStart} = false ] && return |
---|
138 | |
---|
139 | echo |
---|
140 | IGCM_debug_Print 1 "Manage periodic starts" |
---|
141 | |
---|
142 | #.. Manage periodic starts .. |
---|
143 | # ====================== |
---|
144 | |
---|
145 | # ... Loop over DateBegin ... |
---|
146 | eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT} |
---|
147 | |
---|
148 | while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do |
---|
149 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
150 | |
---|
151 | # - Determine number of day(s) in PERIODICITE |
---|
152 | PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} ) |
---|
153 | |
---|
154 | # - Determine number of day(s) in DUREE |
---|
155 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 )) |
---|
156 | |
---|
157 | # - Determine DateEnd |
---|
158 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
159 | |
---|
160 | # - Build directory name |
---|
161 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir |
---|
162 | |
---|
163 | # - Determine RestartDate |
---|
164 | (( Offset = -1 )) |
---|
165 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
166 | |
---|
167 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
168 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
169 | |
---|
170 | # - Create directory for current DateBegin |
---|
171 | if [ ! -d ${StartDir} ] ; then |
---|
172 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
173 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
174 | ln -s ../../.resol . |
---|
175 | ln -s ../../.libmpi . |
---|
176 | IGCM_sys_Cd ${RUN_DIR} |
---|
177 | fi |
---|
178 | |
---|
179 | # - Create directory in which to store new restart files |
---|
180 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
181 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
182 | |
---|
183 | # - Loop over members |
---|
184 | i=0 |
---|
185 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
186 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
187 | echo |
---|
188 | IGCM_debug_Print 3 "${MemberDir}" |
---|
189 | |
---|
190 | JobName="Job_${MemberDir}" |
---|
191 | |
---|
192 | # * Create directory if it doesn't exist and copy/link files |
---|
193 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
194 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
195 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
196 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
197 | ln -s ../../COMP |
---|
198 | ln -s ../../PARAM |
---|
199 | ln -s ../../POST |
---|
200 | IGCM_sys_Cd ${RUN_DIR} |
---|
201 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
202 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
203 | |
---|
204 | ############################## |
---|
205 | # TO BE A SYS FUNCTION BEGIN # |
---|
206 | ############################## |
---|
207 | |
---|
208 | # Dump command to be lauched in Qsub.txt |
---|
209 | echo "cd ${StartDir}/${MemberDir}/ ;" >> Qsub.txt |
---|
210 | echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt |
---|
211 | echo "mv ${JobName}.tmp ${JobName} ; " >> Qsub.txt |
---|
212 | echo "ccc_msub ${JobName} ; cd -" >> Qsub.txt |
---|
213 | |
---|
214 | ############################ |
---|
215 | # TO BE A SYS FUNCTION END # |
---|
216 | ############################ |
---|
217 | |
---|
218 | fi |
---|
219 | |
---|
220 | # * Update files : config.card, Job_, COMP/comp.card |
---|
221 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
222 | |
---|
223 | # * Apply noise on restart file |
---|
224 | IGCM_ensemble_CastPerturbFile |
---|
225 | |
---|
226 | (( i = i + 1 )) |
---|
227 | done |
---|
228 | |
---|
229 | # - Next DateBegin |
---|
230 | echo "$DateBegin $PeriodLengthInDays" |
---|
231 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
232 | *[Yy]|*[Mm]) |
---|
233 | (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) |
---|
234 | ;; |
---|
235 | esac |
---|
236 | echo "New DateBegin = $DateBegin" |
---|
237 | echo "========================================================================" |
---|
238 | done |
---|
239 | IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" |
---|
240 | } |
---|
241 | |
---|
242 | function IGCM_ensemble_CastNonPeriodicStarts |
---|
243 | { |
---|
244 | IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
245 | |
---|
246 | #.. Manage non periodic starts => Loop over DateBegin .. |
---|
247 | # ========================== |
---|
248 | |
---|
249 | [ ${CastNonPeriodicStart} = false ] && return |
---|
250 | |
---|
251 | echo |
---|
252 | IGCM_debug_Print 1 "Manage non periodic starts" |
---|
253 | |
---|
254 | DateNum=0 |
---|
255 | # ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ... |
---|
256 | echo ">${DateNum}<" |
---|
257 | echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<" |
---|
258 | while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
259 | DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]} |
---|
260 | Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} |
---|
261 | echo ">${DateBegin}<" |
---|
262 | echo ">${Duree}<" |
---|
263 | |
---|
264 | # - Determine number of day(s) in DUREE_NONPERIODIC |
---|
265 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
266 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) |
---|
267 | |
---|
268 | # - Build directory name |
---|
269 | echo "========================================================================" |
---|
270 | echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
271 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir |
---|
272 | |
---|
273 | # - Determine DateEnd |
---|
274 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
275 | echo ">${DateEnd}<" |
---|
276 | echo "tout va bien 1" |
---|
277 | |
---|
278 | # - Determine RestartDate |
---|
279 | (( Offset = -1 )) |
---|
280 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
281 | |
---|
282 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
283 | |
---|
284 | # - Does $StartDir already exist ? |
---|
285 | #echo "tout va bien 2" ${StartDir} |
---|
286 | if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then |
---|
287 | echo "create dir" |
---|
288 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
289 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
290 | ln -s ../../.resol . |
---|
291 | ln -s ../../.libmpi . |
---|
292 | IGCM_sys_Cd ${RUN_DIR} |
---|
293 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
294 | fi |
---|
295 | PeriodDateEnd=$( grep -m1 ${StartDir} CreatedDir.txt | cut -f2 -d\ ) |
---|
296 | |
---|
297 | # - Create directory in which to store new restart files if it does'nt already exist |
---|
298 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
299 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
300 | |
---|
301 | # - Loop over members |
---|
302 | i=0 |
---|
303 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
304 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
305 | IGCM_debug_Print 3 "${MemberDir}" |
---|
306 | |
---|
307 | JobName="Job_${MemberDir}" |
---|
308 | |
---|
309 | # * Create directory if it doesn't exist and copy files |
---|
310 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
311 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
312 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
313 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
314 | ln -s ../../COMP |
---|
315 | ln -s ../../PARAM |
---|
316 | ln -s ../../POST |
---|
317 | IGCM_sys_Cd ${RUN_DIR} |
---|
318 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
319 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
320 | |
---|
321 | ############################## |
---|
322 | # TO BE A SYS FUNCTION BEGIN # |
---|
323 | ############################## |
---|
324 | |
---|
325 | # Dump command to be lauched in Qsub.txt |
---|
326 | echo "cd ${StartDir}/${MemberDir}/ ;" >> Qsub.txt |
---|
327 | echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt |
---|
328 | echo "mv ${JobName}.tmp ${JobName} ; " >> Qsub.txt |
---|
329 | echo "ccc_msub ${JobName} ; cd -" >> Qsub.txt |
---|
330 | |
---|
331 | ############################ |
---|
332 | # TO BE A SYS FUNCTION END # |
---|
333 | ############################ |
---|
334 | |
---|
335 | fi |
---|
336 | |
---|
337 | # * Update files : config.card, Job_, COMP/comp.card |
---|
338 | echo "${PeriodDateEnd} ? ${DateEnd}" |
---|
339 | if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then |
---|
340 | DateEnd=${PeriodDateEnd} |
---|
341 | fi |
---|
342 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
343 | |
---|
344 | # * Apply noise on restart file |
---|
345 | IGCM_ensemble_CastPerturbFile |
---|
346 | (( i = i + 1 )) |
---|
347 | done |
---|
348 | |
---|
349 | (( DateNum = DateNum + 1 )) |
---|
350 | done |
---|
351 | IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
352 | } |
---|
353 | |
---|
354 | function IGCM_ensemble_CastFilesUpdate |
---|
355 | { |
---|
356 | IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate" |
---|
357 | |
---|
358 | # Debug Print : |
---|
359 | echo |
---|
360 | IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :" |
---|
361 | |
---|
362 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
363 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
364 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
365 | # ==> config.card |
---|
366 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
367 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME} |
---|
368 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir} |
---|
369 | |
---|
370 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
371 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
372 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
373 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n" |
---|
374 | |
---|
375 | for Comp in ${config_ListOfComponents[*]} ; do |
---|
376 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} Restart "y" |
---|
377 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartDate ${HumanRestartDate} |
---|
378 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM} |
---|
379 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH} |
---|
380 | done |
---|
381 | # ==> Job |
---|
382 | ############################## |
---|
383 | # TO BE A SYS FUNCTION BEGIN # |
---|
384 | ############################## |
---|
385 | |
---|
386 | #sed -e "s/\(#MSUB -r \)[A-Za-z0-9]*\( *#.*\)/\1 ${MemberDir} \2/" \ |
---|
387 | # -e "s/\(#MSUB -o Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
388 | # -e "s/\(#MSUB -e Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
389 | # ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
390 | #IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
391 | |
---|
392 | ############################ |
---|
393 | # TO BE A SYS FUNCTION END # |
---|
394 | ############################ |
---|
395 | |
---|
396 | IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate" |
---|
397 | } |
---|
398 | |
---|
399 | function IGCM_ensemble_CastDirectoryName |
---|
400 | { |
---|
401 | IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName" |
---|
402 | |
---|
403 | #.. Debug Print .. |
---|
404 | echo |
---|
405 | IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :" |
---|
406 | echo |
---|
407 | |
---|
408 | Name=$1 |
---|
409 | Duree=$2 |
---|
410 | year=$3 |
---|
411 | month=$4 |
---|
412 | |
---|
413 | # - Build directory name |
---|
414 | case ${Duree} in |
---|
415 | *Y|*y) |
---|
416 | siecle="$( echo $year | cut -c1-2 )" |
---|
417 | siecle=$( (( $siecle - 18 )) ) |
---|
418 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
419 | StartDir="${Name}${StartYear}" |
---|
420 | ;; |
---|
421 | *M|*m) |
---|
422 | echo $month |
---|
423 | siecle="$( echo $year | cut -c1-2 )" |
---|
424 | siecle=$( (( $siecle - 18 )) ) |
---|
425 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
426 | StartMonth="${AlphaMonth[ (( $month - 1 )) ]}" |
---|
427 | StartDir="${Name}${StartYear}${StartMonth}" |
---|
428 | ;; |
---|
429 | esac |
---|
430 | |
---|
431 | IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName" |
---|
432 | } |
---|
433 | |
---|
434 | function IGCM_ensemble_CastPerturbFile |
---|
435 | { |
---|
436 | IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile" |
---|
437 | |
---|
438 | #.. Debug Print .. |
---|
439 | echo |
---|
440 | IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :" |
---|
441 | |
---|
442 | #.. FileIn ? => RestartDate .. |
---|
443 | DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart" |
---|
444 | DirInTar="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART" |
---|
445 | FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}" |
---|
446 | DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart" |
---|
447 | |
---|
448 | # * Create member restart directory |
---|
449 | IGCM_sys_TestDirArchive ${DirOut} |
---|
450 | RET=$? |
---|
451 | if [ $RET -gt 0 ] ; then |
---|
452 | IGCM_sys_MkdirArchive ${DirOut} |
---|
453 | fi |
---|
454 | |
---|
455 | FileOut="${MemberDir}_${RestartDate}_${PerturbFile}" |
---|
456 | IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}.nc" |
---|
457 | |
---|
458 | #IGCM_debug_Print 1 "FileIn = ${DirIn}/${FileIn}" |
---|
459 | |
---|
460 | IGCM_sys_TestFileArchive ${DirOut}/${FileOut}.nc |
---|
461 | RET=$? |
---|
462 | if [ $RET -gt 0 ] ; then |
---|
463 | |
---|
464 | # * Look for the restart file we apply the noise to |
---|
465 | |
---|
466 | ########################## |
---|
467 | # TO BE A FUNCTION BEGIN # |
---|
468 | ########################## |
---|
469 | |
---|
470 | if [ $( IGCM_sys_TestFileBuffer ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
471 | IGCM_debug_Print 3 "Buffered restart" |
---|
472 | Buffered=true |
---|
473 | Archived=false |
---|
474 | Tared=false |
---|
475 | nb_restart_file=$(IGCM_sys_CountFileBuffer ${DirIn}/${FileIn}_????.nc) |
---|
476 | elif [ $( IGCM_sys_TestFileArchive ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
477 | IGCM_debug_Print 3 "Archived restart" |
---|
478 | Buffered=false |
---|
479 | Archived=true |
---|
480 | Tared=false |
---|
481 | nb_restart_file=$(IGCM_sys_CountFileArchive ${DirIn}/${FileIn}_????.nc) |
---|
482 | else |
---|
483 | IGCM_debug_Print 3 "Tared restart" |
---|
484 | Buffered=false |
---|
485 | Archived=false |
---|
486 | Tared=true |
---|
487 | # Look for the tar file we want if we did not found it already |
---|
488 | #if [ X${IsMatching} = X ] ; then |
---|
489 | for PotentialTarFile in $( find ${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART -name "${ensemble_Ens_PERTURB_INITFROM}_*_restart.tar" -print ) ; do |
---|
490 | IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:^${ensemble_Ens_PERTURB_INITFROM}_::" | sed "s:\.restart\.tar$::" | gawk -F_ -v restartdate=${RestartDate} '{if (($1 < restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' ) |
---|
491 | if [ ! X${IsMatching} = X ] ; then |
---|
492 | TarFileFound=${PotentialTarFile} |
---|
493 | break |
---|
494 | fi |
---|
495 | done |
---|
496 | #fi |
---|
497 | # already specialized for CPL sstoc and flxat! |
---|
498 | IGCM_debug_Print 1 "tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc" |
---|
499 | tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc |
---|
500 | nb_restart_file=$( IGCM_sys_CountFileBuffer ${PerturbComp}_${FileIn}_????.nc ) |
---|
501 | fi |
---|
502 | |
---|
503 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
504 | j=0 |
---|
505 | until [ $j -ge $nb_restart_file ]; do |
---|
506 | j4=${j} |
---|
507 | if [ X${Buffered} = Xtrue ] ; then |
---|
508 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
509 | elif [ X${Archived} = Xtrue ] ; then |
---|
510 | IGCM_sys_Get ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
511 | elif [ X${Tared} = Xtrue ] ; then |
---|
512 | IGCM_sys_Mv ${PerturbComp}_${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
513 | fi |
---|
514 | (( j=j+1 )) |
---|
515 | done |
---|
516 | else |
---|
517 | if [ X${Buffered} = Xtrue ] ; then |
---|
518 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
519 | # already specialized for CPL sstoc and flxat! |
---|
520 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc" |
---|
521 | elif [ X${Archived} = Xtrue ] ; then |
---|
522 | IGCM_sys_Get ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
523 | # already specialized for CPL sstoc and flxat! |
---|
524 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc" |
---|
525 | elif [ X${Tared} = Xtrue ] ; then |
---|
526 | IGCM_sys_Mv ${PerturbComp}_${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
527 | # already specialized for CPL sstoc and flxat! |
---|
528 | IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${DirOut}/${MemberDir}_${RestartDate}_flxat.nc |
---|
529 | fi |
---|
530 | fi |
---|
531 | |
---|
532 | ######################## |
---|
533 | # TO BE A FUNCTION END # |
---|
534 | ######################## |
---|
535 | |
---|
536 | IGCM_sys_Chmod 644 ${RUN_DIR}/${FileOut}.nc |
---|
537 | IGCM_debug_Print 1 "${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp}" |
---|
538 | echo |
---|
539 | ${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp} > /dev/null 2>&1 |
---|
540 | |
---|
541 | if [ $? -ne 0 ] ; then |
---|
542 | echo "Abend $( basename ${PerturbExe} )" |
---|
543 | return |
---|
544 | fi |
---|
545 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut}.nc ${DirOut}/ 644 |
---|
546 | fi |
---|
547 | |
---|
548 | #.. Update config.card.. |
---|
549 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y" |
---|
550 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate ${HumanRestartDate} |
---|
551 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir} |
---|
552 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ |
---|
553 | |
---|
554 | IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile" |
---|
555 | } |
---|