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