1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Sonia Labetoulle, Nicolas Lebas, Sebastien Nguyen |
---|
5 | # Contact: Nicolas.Lebas__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 | # >>> Date ensemble <<< |
---|
13 | # Author: Nicolas Lebas (adapted from Sonia Labetoulle) |
---|
14 | # Contact: Nicolas.Lebas__at__locean-ipsl.upmc.fr |
---|
15 | # IPSL (2014) |
---|
16 | # |
---|
17 | # >>> Add 3D perturbation maps to oceanic restart <<< |
---|
18 | # Author: Sebastien Nguyen |
---|
19 | # Contact: Sebastien.Nguyen__at__locean-ipsl.upmc.fr |
---|
20 | # IPSL (2014) |
---|
21 | # |
---|
22 | #************************************************************** |
---|
23 | |
---|
24 | # Read which ensemble type are active |
---|
25 | function IGCM_ensemble_Init |
---|
26 | { |
---|
27 | IGCM_debug_PushStack "IGCM_ensemble_Init" |
---|
28 | |
---|
29 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB active |
---|
30 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active |
---|
31 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PARAMETRIC active |
---|
32 | |
---|
33 | IGCM_debug_Print 1 "Ens_PERTURB ACTIVE = ${ensemble_Ens_PERTURB_active}" |
---|
34 | IGCM_debug_Print 1 "Ens_DATE ACTIVE = ${ensemble_Ens_DATE_active}" |
---|
35 | IGCM_debug_Print 1 "Ens_PARAMETRIC ACTIVE = ${ensemble_Ens_PARAMETRIC_active}" |
---|
36 | echo "" |
---|
37 | |
---|
38 | #==================================================== |
---|
39 | # Define ARCHIVE : Dedicated to large files |
---|
40 | # Define STORAGE : Dedicated to small/medium files |
---|
41 | # Define R_OUT : Output tree located on ARCHIVE |
---|
42 | # Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
43 | # Define R_BUF : USELESS and DEPRECATED output tree. |
---|
44 | IGCM_sys_defineArchives |
---|
45 | |
---|
46 | IGCM_debug_PopStack "IGCM_ensemble_Init" |
---|
47 | } |
---|
48 | |
---|
49 | # Set Alphanumerical variables ajust to member nb |
---|
50 | function IGCM_ensemble_SetAlpha |
---|
51 | { |
---|
52 | IGCM_debug_PushStack "IGCM_ensemble_SetAlpha" |
---|
53 | |
---|
54 | 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 |
---|
55 | set -A AlphaMonth a b c d e f g h i j k l |
---|
56 | |
---|
57 | IGCM_debug_PopStack "IGCM_ensemble_SetAlpha" |
---|
58 | } |
---|
59 | |
---|
60 | ############### Perturb ENSEMBLE ################# |
---|
61 | function IGCM_ensemble_CastInit |
---|
62 | { |
---|
63 | IGCM_debug_PushStack "IGCM_ensemble_CastInit" |
---|
64 | |
---|
65 | IGCM_sys_Mkdir ${RUN_DIR} |
---|
66 | |
---|
67 | IGCM_sys_Cp ${SUBMIT_DIR}/config.card ${RUN_DIR} |
---|
68 | IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR} |
---|
69 | IGCM_sys_Cp ${SUBMIT_DIR}/Job_* ${RUN_DIR} |
---|
70 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR} |
---|
71 | if [ -f ${SUBMIT_DIR}/Qsub.* ]; then |
---|
72 | IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.* ${RUN_DIR} |
---|
73 | fi |
---|
74 | if [ -f ${SUBMIT_DIR}/Qclean.* ]; then |
---|
75 | IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.* ${RUN_DIR} |
---|
76 | fi |
---|
77 | |
---|
78 | ## Init some variables |
---|
79 | CastPeriodicStart=false |
---|
80 | CastNonPeriodicStart=false |
---|
81 | CastRestartNonPer=false |
---|
82 | CastLengthNonPer=false |
---|
83 | |
---|
84 | # Useful? |
---|
85 | #if [ -f ${SUBMIT_DIR}/CreatedDir.txt ] ; then |
---|
86 | # IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR} |
---|
87 | #fi |
---|
88 | # Useful? |
---|
89 | #if [ -f ${SUBMIT_DIR}/Qsub.sh ] ; then |
---|
90 | # IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.sh ${RUN_DIR} |
---|
91 | #fi |
---|
92 | echo ${PWD} |
---|
93 | |
---|
94 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB active |
---|
95 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB NAME |
---|
96 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB BEGIN_INIT |
---|
97 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB END_INIT |
---|
98 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB PERIODICITY |
---|
99 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB NONPERIODIC |
---|
100 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB RESTART_NONPERIODIC |
---|
101 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB LENGTH |
---|
102 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB LENGTH_NONPERIODIC |
---|
103 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER |
---|
104 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB PERTU_MAP_LIST |
---|
105 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER_NAMESLIST |
---|
106 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER_INITFROM |
---|
107 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER_INITPATH |
---|
108 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_PERTURB PERTURB_BIN |
---|
109 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB INITFROM |
---|
110 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB INITPATH |
---|
111 | IGCM_card_DefineVariableFromOption config.card UserChoices JobName |
---|
112 | IGCM_card_DefineVariableFromOption config.card UserChoices TagName |
---|
113 | IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType |
---|
114 | IGCM_card_DefineArrayFromSection config.card ListOfComponents |
---|
115 | |
---|
116 | echo |
---|
117 | IGCM_debug_Print 1 "[Ens_PERTURB]" |
---|
118 | IGCM_debug_Print 1 "ACTIVE = ${ensemble_Ens_PERTURB_active}" |
---|
119 | IGCM_debug_Print 1 "NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
120 | IGCM_debug_Print 1 "BEGIN_INIT = ${ensemble_Ens_PERTURB_BEGIN_INIT}" |
---|
121 | IGCM_debug_Print 1 "END_INIT = ${ensemble_Ens_PERTURB_END_INIT}" |
---|
122 | IGCM_debug_Print 1 "PERIODICITY = ${ensemble_Ens_PERTURB_PERIODICITY}" |
---|
123 | IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}" |
---|
124 | IGCM_debug_Print 1 "RESTART_NONPERIODIC=${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[*]}" |
---|
125 | IGCM_debug_Print 1 "LENGTH = ${ensemble_Ens_PERTURB_LENGTH}" |
---|
126 | IGCM_debug_Print 1 "LENGTH_NONPERIODIC= ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[*]}" |
---|
127 | IGCM_debug_Print 1 "MEMBER = ${ensemble_Ens_PERTURB_MEMBER}" |
---|
128 | IGCM_debug_Print 1 "PERTU_MAP_LIST = ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]}" |
---|
129 | IGCM_debug_Print 1 "MEMBER_NAMESLIST = ${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]}" |
---|
130 | IGCM_debug_Print 1 "MEMBER_INITFROM = ${ensemble_Ens_PERTURB_MEMBER_INITFROM}" |
---|
131 | IGCM_debug_Print 1 "MEMBER_INITPATH = ${ensemble_Ens_PERTURB_MEMBER_INITPATH}" |
---|
132 | IGCM_debug_Print 1 "PERTURB_BIN = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" |
---|
133 | IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITFROM}" |
---|
134 | IGCM_debug_Print 1 "INITPATH = ${ensemble_Ens_PERTURB_INITPATH}" |
---|
135 | IGCM_debug_Print 1 "JobName = ${config_UserChoices_JobName}" |
---|
136 | IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" |
---|
137 | IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" |
---|
138 | IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" |
---|
139 | |
---|
140 | ### Retro compatibility with former param name ### |
---|
141 | if [ X"${ensemble_Ens_PERTURB_MEMBER_LIST[0]}" != "XOption" ]; |
---|
142 | then |
---|
143 | if [ X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "XOption" ]; |
---|
144 | then |
---|
145 | ensemble_Ens_PERTURB_PERTU_MAP_LIST=${ensemble_Ens_PERTURB_MEMBER_LIST} |
---|
146 | IGCM_debug_Print 1 "WARNING: PERTU_MAP_LIST is deprecacated, please use PERTURB_PERTU_MAP_LIST instead." |
---|
147 | else |
---|
148 | IGCM_debug_Print 1 "WARNING: both PERTURB_PERTU_MAP_LIST and PERTU_MAP_LIST are specified!" |
---|
149 | IGCM_debug_Print 1 "Ignore PERTU_MAP_LIST which is deprecated." |
---|
150 | fi |
---|
151 | fi |
---|
152 | ####### End of retro compatibility code ####### |
---|
153 | |
---|
154 | ### Check unset variables and set them to empty |
---|
155 | # Following var are set because they could be unset in some |
---|
156 | # use case (ex: non periodic if periodic is active...) |
---|
157 | if [[ X"${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]}" = "X" ]]; |
---|
158 | then |
---|
159 | ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]=_0_ |
---|
160 | CastRestartNonPer=false |
---|
161 | else |
---|
162 | CastRestartNonPer=true |
---|
163 | fi |
---|
164 | if [[ X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "X" ]]; |
---|
165 | then |
---|
166 | ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]=_0_ |
---|
167 | fi |
---|
168 | if [[ X"${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]}" = "X" ]]; |
---|
169 | then |
---|
170 | CastLengthNonPer=false |
---|
171 | ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]=_0_ |
---|
172 | else |
---|
173 | CastLengthNonPer=true |
---|
174 | fi |
---|
175 | if [ X"${ensemble_Ens_PERTURB_NONPERIODIC[0]}" = "XOption" ]; |
---|
176 | then |
---|
177 | ensemble_Ens_PERTURB_NONPERIODIC[0]=_0_ |
---|
178 | fi |
---|
179 | if [[ "${ensemble_Ens_PERTURB_PERIODICITY}" = _0_ || "${ensemble_Ens_PERTURB_PERIODICITY}" = '' ]]; |
---|
180 | then |
---|
181 | ensemble_Ens_PERTURB_PERIODICITY=NONE |
---|
182 | fi |
---|
183 | if [[ "${ensemble_Ens_PERTURB_MEMBER}" = _0_ || "${ensemble_Ens_PERTURB_MEMBER}" = '' ]]; |
---|
184 | then |
---|
185 | ensemble_Ens_PERTURB_MEMBER=NONE |
---|
186 | fi |
---|
187 | if [[ "${ensemble_Ens_PERTURB_END_INIT}" = _0_ || "${ensemble_Ens_PERTURB_END_INIT}" = '' ]]; |
---|
188 | then |
---|
189 | ensemble_Ens_PERTURB_END_INIT=${ensemble_Ens_PERTURB_BEGIN_INIT} |
---|
190 | fi |
---|
191 | |
---|
192 | ### End check unset variables ### |
---|
193 | PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]} |
---|
194 | |
---|
195 | case ${PerturbExe} in |
---|
196 | AddNoise) |
---|
197 | PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} |
---|
198 | PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} |
---|
199 | PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} |
---|
200 | PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} |
---|
201 | |
---|
202 | IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" |
---|
203 | IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" |
---|
204 | IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" |
---|
205 | IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" |
---|
206 | IGCM_debug_Print 1 "PerturbAmp = ${PerturbAmp}" |
---|
207 | ;; |
---|
208 | AddPertu3DOCE) |
---|
209 | PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} |
---|
210 | PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} |
---|
211 | PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} |
---|
212 | PerturbMask=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} |
---|
213 | |
---|
214 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MASKPATH |
---|
215 | |
---|
216 | IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" |
---|
217 | IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" |
---|
218 | IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" |
---|
219 | IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" |
---|
220 | IGCM_debug_Print 1 "PerturbMask = ${PerturbMask}" |
---|
221 | IGCM_debug_Print 1 "MASK PATH = ${ensemble_Ens_PERTURB_MASKPATH}" |
---|
222 | ;; |
---|
223 | esac |
---|
224 | IGCM_ensemble_SetAlpha ${ensemble_Ens_PERTURB_MEMBER} |
---|
225 | |
---|
226 | # A few checks Period case: |
---|
227 | |
---|
228 | # ... Check PERIODICITY ... |
---|
229 | case ${ensemble_Ens_PERTURB_PERIODICITY} in |
---|
230 | NONE) |
---|
231 | IGCM_debug_Print 1 "periodic start not active" |
---|
232 | CastPeriodicStart=false |
---|
233 | ;; |
---|
234 | *[Yy]|*[Mm]) |
---|
235 | CastPeriodicStart=true |
---|
236 | IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITY}" ;; |
---|
237 | *) |
---|
238 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITY} : invalid PERIODICITY" |
---|
239 | IGCM_debug_Exit "Choose a value in *Y or *M" |
---|
240 | IGCM_debug_Verif_Exit ;; |
---|
241 | esac |
---|
242 | # ... Check LENGTH ... |
---|
243 | case ${ensemble_Ens_PERTURB_LENGTH} in |
---|
244 | *[Yy]|*[Mm]) |
---|
245 | IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_LENGTH}" ;; |
---|
246 | *) |
---|
247 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_LENGTH} invalid LENGTH" |
---|
248 | IGCM_debug_Exit "Choose a value in choose in *Y or *M" |
---|
249 | IGCM_debug_Verif_Exit ;; |
---|
250 | esac |
---|
251 | |
---|
252 | ################################ |
---|
253 | if [[ ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} != ${#ensemble_Ens_PERTURB_RESTART_NONPERIODIC[*]} && CastRestartNonPer = "true" ]] ; then |
---|
254 | IGCM_debug_Exit "IGCM_ensemble_CastInit: NONPERIODIC and RESTART_NONPERIODIC lists have different sizes" |
---|
255 | IGCM_debug_Verif_Exit |
---|
256 | fi |
---|
257 | if [[ ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_PERTURB_NONPERIODIC[0]} != _0_ ]]; then |
---|
258 | DateNonPeriodicStart=true |
---|
259 | |
---|
260 | # Use LENGTH if no NONPERIODIC_LENGTH given |
---|
261 | if [[ ${#ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[*]} < ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} || ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]} = _0_ ]] ; then |
---|
262 | IGCM_debug_Print 1 "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_PERTURB_LENGTH}' for all NONPERIODIC runs" |
---|
263 | echo "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_PERTURB_LENGTH}' for all NONPERIODIC runs" |
---|
264 | DateNum=0 |
---|
265 | while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
266 | ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_LENGTH} |
---|
267 | (( DateNum = DateNum + 1 )) |
---|
268 | done |
---|
269 | fi |
---|
270 | # Check lengths |
---|
271 | DateNum=0 |
---|
272 | while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
273 | # - Check LENGTH_NONPERIODIC |
---|
274 | case ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]} in |
---|
275 | _0_) |
---|
276 | IGCM_debug_Print 1 "non-periodic start not active" |
---|
277 | CastNonPeriodicStart=false |
---|
278 | break |
---|
279 | ;; |
---|
280 | *[Yy]|*[Mm]) |
---|
281 | IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]}" |
---|
282 | CastNonPeriodicStart=true |
---|
283 | ;; |
---|
284 | *) |
---|
285 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]} : invalid LENGTH" |
---|
286 | IGCM_debug_Exit "choose in *Y or *M" |
---|
287 | IGCM_debug_Verif_Exit ;; |
---|
288 | esac |
---|
289 | (( DateNum = DateNum + 1 )) |
---|
290 | |
---|
291 | # - Check RESTART_NONPERIODIC |
---|
292 | if [[ DateNonPeriodicStart ]]; then |
---|
293 | case ${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]} in |
---|
294 | _0_) |
---|
295 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]} : invalid NON PERIODIC RESTART" |
---|
296 | IGCM_debug_Verif_Exit ;; |
---|
297 | esac |
---|
298 | fi |
---|
299 | done |
---|
300 | |
---|
301 | # Use INITFROM if no INITFROM_NONPERIODIC given |
---|
302 | if [ ${#ensemble_Ens_PERTURB_INITFROM_NONPERIODIC[*]} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; then |
---|
303 | IGCM_debug_Print 1 "WARNING: INITFROM_NONPERIODIC is not fill (or not correctly). Use INITFROM value '${ensemble_Ens_PERTURB_INITFROM}' for all NONPERIODIC runs" |
---|
304 | DateNum=0 |
---|
305 | while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
306 | ensemble_Ens_PERTURB_INITFROM_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_INITFROM} |
---|
307 | (( DateNum = DateNum + 1 )) |
---|
308 | done |
---|
309 | fi |
---|
310 | |
---|
311 | # Use INITPATH if no INITPATH_NONPERIODIC given |
---|
312 | if [ ${#ensemble_Ens_PERTURB_INITPATH_NONPERIODIC[*]} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; then |
---|
313 | IGCM_debug_Print 1 "WARNING: INITPATH_NONPERIODIC is not fill (or not correctly). Use INITPATH value '${ensemble_Ens_PERTURB_INITPATH}' for all NONPERIODIC runs" |
---|
314 | DateNum=0 |
---|
315 | while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
316 | ensemble_Ens_PERTURB_INITPATH_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_INITPATH} |
---|
317 | (( DateNum = DateNum + 1 )) |
---|
318 | done |
---|
319 | fi |
---|
320 | else |
---|
321 | IGCM_debug_Print 1 "Non-Periodic start NOT ACTIVE" |
---|
322 | DateNonPeriodicStart=false |
---|
323 | fi |
---|
324 | ################################ |
---|
325 | |
---|
326 | # A few checks for the Non-Periodic case: |
---|
327 | |
---|
328 | # A few checks for the PERTU_MAP_LIST case: |
---|
329 | case ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]} in |
---|
330 | _0_) |
---|
331 | IGCM_debug_Print 1 "list of perturbation maps not active" |
---|
332 | CastMemberList=false |
---|
333 | ;; |
---|
334 | *) |
---|
335 | if [ ${CastPeriodicStart} = "true" ] ; then |
---|
336 | IGCM_debug_Exit "list of perturbation maps for periodic start not implemented, will stop execution" |
---|
337 | IGCM_debug_Verif_Exit |
---|
338 | elif [ ${CastNonPeriodicStart} = "true" ] ; then |
---|
339 | IGCM_debug_Exit "list of perturbation maps for non periodic start not implemented, will stop execution" |
---|
340 | IGCM_debug_Verif_Exit |
---|
341 | fi |
---|
342 | |
---|
343 | # test that MEMBER_NAMESLIST and PERTU_MAP_LIST have the same size |
---|
344 | |
---|
345 | if [ ${#ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]} -ne ${#ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]} ] ; then |
---|
346 | IGCM_debug_Exit "number of elements in PERTU_MAP_LIST and MEMBER_NAMESLIST differ" |
---|
347 | IGCM_debug_Verif_Exit |
---|
348 | fi |
---|
349 | |
---|
350 | IGCM_debug_Print 1 "list of perturbation maps : ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]}" |
---|
351 | IGCM_debug_Print 1 "list of members names : ${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]}" |
---|
352 | CastMemberList=true |
---|
353 | ;; |
---|
354 | esac |
---|
355 | |
---|
356 | # IGCM_debug_Exit "fin du test PERTU_MAP_LIST" |
---|
357 | # IGCM_debug_Verif_Exit |
---|
358 | |
---|
359 | # Need to know all the restart filename of the component we will apply the noise to |
---|
360 | IGCM_card_DefineArrayFromOption config.card ListOfComponents ${PerturbComp} |
---|
361 | eval compname=\${config_ListOfComponents_${PerturbComp}[0]} > /dev/null 2>&1 |
---|
362 | |
---|
363 | # Target the component's card we apply the noise to |
---|
364 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
365 | |
---|
366 | # Read the restart file list. To be used later |
---|
367 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
368 | ListFilesName=${compname}_RestartFiles_List |
---|
369 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
370 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
371 | |
---|
372 | # Check |
---|
373 | IGCM_debug_Print 1 "Nb Restart Files = ${NbFiles}" |
---|
374 | |
---|
375 | IGCM_debug_PopStack "IGCM_ensemble_CastInit" |
---|
376 | } |
---|
377 | |
---|
378 | function IGCM_ensemble_CastPeriodicStarts |
---|
379 | { |
---|
380 | IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" |
---|
381 | |
---|
382 | [ ${CastPeriodicStart} = false ] && return |
---|
383 | |
---|
384 | echo |
---|
385 | IGCM_debug_Print 1 "Manage periodic starts" |
---|
386 | |
---|
387 | #.. Manage periodic starts .. |
---|
388 | # ====================== |
---|
389 | |
---|
390 | # ... Loop over DateBegin ... |
---|
391 | eval DateBegin=\${ensemble_Ens_PERTURB_BEGIN_INIT} |
---|
392 | |
---|
393 | while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_END_INIT} ] ; do |
---|
394 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
395 | |
---|
396 | # - Determine number of day(s) in PERIODICITY |
---|
397 | PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITY} ) |
---|
398 | |
---|
399 | # - Determine number of day(s) in LENGTH |
---|
400 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 )) |
---|
401 | |
---|
402 | # - Determine DateEnd |
---|
403 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
404 | |
---|
405 | # - Build directory name |
---|
406 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITY} $year $month $StartDir |
---|
407 | |
---|
408 | # - Determine RestartDate |
---|
409 | (( Offset = -1 )) |
---|
410 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
411 | |
---|
412 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
413 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt |
---|
414 | |
---|
415 | # - Create directory for current DateBegin |
---|
416 | if [ ! -d ${StartDir} ] ; then |
---|
417 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
418 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
419 | ln -s ../../.resol . |
---|
420 | ln -s ../../.libmpi . |
---|
421 | IGCM_sys_Cd ${RUN_DIR} |
---|
422 | fi |
---|
423 | |
---|
424 | # - Create directory to store modified restart files |
---|
425 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
426 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
427 | |
---|
428 | # - Loop over members |
---|
429 | i=0 |
---|
430 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
431 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
432 | echo |
---|
433 | IGCM_debug_Print 3 "${MemberDir}" |
---|
434 | |
---|
435 | JobName="Job_${MemberDir}" |
---|
436 | |
---|
437 | # * Create directory if it doesn't exist and copy/link files |
---|
438 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
439 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
440 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
441 | ln -s ../../COMP |
---|
442 | ln -s ../../PARAM |
---|
443 | ln -s ../../POST |
---|
444 | ln -s ../../DRIVER |
---|
445 | IGCM_sys_Cd ${RUN_DIR} |
---|
446 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
447 | IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
448 | |
---|
449 | # Dump command to be lauched |
---|
450 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
451 | echo "${SUBMIT} ${JobName} ; cd -" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
452 | |
---|
453 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
454 | echo "${libIGCM}/clean_month.job ; cd -" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
455 | |
---|
456 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
457 | echo "${libIGCM}/clean_year.job ; cd -" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
458 | |
---|
459 | # * Update files : config.card, Job_, COMP/comp.card |
---|
460 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
461 | |
---|
462 | # * Apply noise on restart file |
---|
463 | IGCM_ensemble_CastPerturbFile |
---|
464 | fi |
---|
465 | |
---|
466 | (( i = i + 1 )) |
---|
467 | done |
---|
468 | |
---|
469 | # Done. Save ${StartDir} submission text file |
---|
470 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
471 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
472 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
473 | |
---|
474 | # - Next DateBegin |
---|
475 | echo "$DateBegin $PeriodLengthInDays" |
---|
476 | case ${ensemble_Ens_PERTURB_PERIODICITY} in |
---|
477 | *[Yy]|*[Mm]) |
---|
478 | (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) |
---|
479 | ;; |
---|
480 | esac |
---|
481 | echo "New DateBegin = $DateBegin" |
---|
482 | echo "========================================================================" |
---|
483 | done |
---|
484 | IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" |
---|
485 | } |
---|
486 | |
---|
487 | function IGCM_ensemble_CastNonPeriodicStarts |
---|
488 | { |
---|
489 | IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
490 | |
---|
491 | #.. Manage non periodic starts => Loop over DateBegin .. |
---|
492 | # ========================== |
---|
493 | |
---|
494 | [ ${CastNonPeriodicStart} = false ] && return |
---|
495 | |
---|
496 | echo |
---|
497 | IGCM_debug_Print 1 "Manage non periodic starts" |
---|
498 | |
---|
499 | DateNum=0 |
---|
500 | # ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ... |
---|
501 | echo ">${DateNum}<" |
---|
502 | echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<" |
---|
503 | while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
504 | DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[${DateNum}]} |
---|
505 | Duree=${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]} |
---|
506 | echo ">${DateBegin}<" |
---|
507 | echo ">${Duree}<" |
---|
508 | |
---|
509 | # - Determine number of day(s) in LENGTH_NONPERIODIC |
---|
510 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
511 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) |
---|
512 | |
---|
513 | # - Build directory name |
---|
514 | echo "========================================================================" |
---|
515 | echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
516 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir |
---|
517 | |
---|
518 | # - Determine DateEnd |
---|
519 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
520 | echo ">${DateEnd}<" |
---|
521 | echo "tout va bien 1" |
---|
522 | |
---|
523 | # - Determine RestartDate |
---|
524 | if [[ ${CastRestartNonPer} == "true" ]]; then |
---|
525 | RestartDate=${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]} |
---|
526 | else |
---|
527 | (( Offset = -1 )) |
---|
528 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
529 | fi |
---|
530 | |
---|
531 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
532 | |
---|
533 | # - Does $StartDir already exist ? |
---|
534 | #echo "tout va bien 2" ${StartDir} |
---|
535 | if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then |
---|
536 | echo "create dir" |
---|
537 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
538 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
539 | ln -s ../../.resol . |
---|
540 | ln -s ../../.libmpi . |
---|
541 | IGCM_sys_Cd ${RUN_DIR} |
---|
542 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt |
---|
543 | fi |
---|
544 | PeriodDateEnd=$( grep -m1 ${StartDir} ${RUN_DIR}/CreatedDir.txt | cut -f2 -d\ ) |
---|
545 | |
---|
546 | # - Create directory in which to store new restart files if it does'nt already exist |
---|
547 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
548 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
549 | |
---|
550 | # - Loop over members |
---|
551 | i=0 |
---|
552 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
553 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
554 | IGCM_debug_Print 3 "${MemberDir}" |
---|
555 | |
---|
556 | JobName="Job_${MemberDir}" |
---|
557 | |
---|
558 | # * Create directory if it doesn't exist and copy files |
---|
559 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
560 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
561 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
562 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
563 | ln -s ../../COMP |
---|
564 | ln -s ../../PARAM |
---|
565 | ln -s ../../POST |
---|
566 | ln -s ../../DRIVER |
---|
567 | IGCM_sys_Cd ${RUN_DIR} |
---|
568 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
569 | IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
570 | |
---|
571 | # Dump command to be lauched |
---|
572 | echo "cd ${StartDir}/${MemberDir}/ ;" >> Qsub.${StartDir}.sh |
---|
573 | echo "${SUBMIT} ${JobName} ; cd -" >> Qsub.${StartDir}.sh |
---|
574 | |
---|
575 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
576 | echo "${libIGCM}/clean_month.job ; cd -" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
577 | |
---|
578 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
579 | echo "${libIGCM}/clean_year.job ; cd -" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
580 | |
---|
581 | # * Update files : config.card, Job_, COMP/comp.card |
---|
582 | echo "${PeriodDateEnd} ? ${DateEnd}" |
---|
583 | if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then |
---|
584 | DateEnd=${PeriodDateEnd} |
---|
585 | fi |
---|
586 | |
---|
587 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
588 | |
---|
589 | # * Apply noise on restart file |
---|
590 | IGCM_ensemble_CastPerturbFile |
---|
591 | fi |
---|
592 | |
---|
593 | (( i = i + 1 )) |
---|
594 | done |
---|
595 | |
---|
596 | # Done. Save ${StartDir} submission text file |
---|
597 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
598 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
599 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
600 | |
---|
601 | (( DateNum = DateNum + 1 )) |
---|
602 | done |
---|
603 | IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
604 | } |
---|
605 | |
---|
606 | function IGCM_ensemble_CastMemberList |
---|
607 | { |
---|
608 | IGCM_debug_PushStack "IGCM_ensemble_CastMemberList" |
---|
609 | |
---|
610 | if [ ${CastMemberList} = false ] ; then |
---|
611 | IGCM_debug_PopStack "IGCM_ensemble_CastMemberList" |
---|
612 | return |
---|
613 | fi |
---|
614 | |
---|
615 | echo |
---|
616 | IGCM_debug_Print 1 "Manage members list" |
---|
617 | |
---|
618 | #.. Manage members list .. |
---|
619 | # ====================== |
---|
620 | |
---|
621 | # DateBegin |
---|
622 | eval DateBegin=\${ensemble_Ens_PERTURB_BEGIN_INIT} |
---|
623 | |
---|
624 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
625 | |
---|
626 | # - Determine number of day(s) in LENGTH |
---|
627 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 )) |
---|
628 | |
---|
629 | # - Determine DateEnd |
---|
630 | DateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) |
---|
631 | |
---|
632 | # bad hack enforce yearly for parent directory name |
---|
633 | # - Build directory name |
---|
634 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} 1Y $year $month $StartDir |
---|
635 | |
---|
636 | # - Determine RestartDate |
---|
637 | (( Offset = -1 )) |
---|
638 | RestartDate=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) |
---|
639 | |
---|
640 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
641 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt |
---|
642 | |
---|
643 | # - Create directory for current DateBegin |
---|
644 | if [ ! -d ${StartDir} ] ; then |
---|
645 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
646 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
647 | ln -s ../../.resol . |
---|
648 | ln -s ../../.libmpi . |
---|
649 | IGCM_sys_Cd ${RUN_DIR} |
---|
650 | fi |
---|
651 | |
---|
652 | # - Create directory to store modified restart files |
---|
653 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
654 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
655 | |
---|
656 | # - Loop over members |
---|
657 | i=0 |
---|
658 | nbmember=${#ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]} |
---|
659 | while [ $i -lt $nbmember ] ; do |
---|
660 | MemberDir=${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[${i}]} |
---|
661 | MemberVec=${ensemble_Ens_PERTURB_PERTU_MAP_LIST[${i}]} |
---|
662 | |
---|
663 | JobName="Job_${MemberDir}" |
---|
664 | echo |
---|
665 | IGCM_debug_Print 3 "${MemberDir}" |
---|
666 | |
---|
667 | # * Create directory if it doesn't exist and copy/link files |
---|
668 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
669 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
670 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
671 | ln -s ../../COMP |
---|
672 | ln -s ../../PARAM |
---|
673 | ln -s ../../POST |
---|
674 | ln -s ../../DRIVER |
---|
675 | IGCM_sys_Cd ${RUN_DIR} |
---|
676 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
677 | IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
678 | |
---|
679 | # Dump command to be lauched |
---|
680 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
681 | echo "${SUBMIT} ${JobName} ; cd -" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
682 | |
---|
683 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
684 | echo "${libIGCM}/clean_month.job ; cd -" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
685 | |
---|
686 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
687 | echo "${libIGCM}/clean_year.job ; cd -" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
688 | |
---|
689 | # * Update files : config.card, Job_, COMP/comp.card |
---|
690 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
691 | |
---|
692 | # * Apply noise on restart file |
---|
693 | IGCM_ensemble_CastPerturbFile |
---|
694 | fi |
---|
695 | |
---|
696 | (( i = i + 1 )) |
---|
697 | done |
---|
698 | |
---|
699 | # Done. Save ${StartDir} submission text file |
---|
700 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
701 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
702 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
703 | |
---|
704 | IGCM_debug_PopStack "IGCM_ensemble_CastMemberList" |
---|
705 | } |
---|
706 | |
---|
707 | function IGCM_ensemble_CastFilesUpdate |
---|
708 | { |
---|
709 | IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate" |
---|
710 | |
---|
711 | # Debug Print : |
---|
712 | echo |
---|
713 | IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :" |
---|
714 | |
---|
715 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
716 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
717 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
718 | # ==> config.card |
---|
719 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
720 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME} |
---|
721 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir} |
---|
722 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_PERTURB" |
---|
723 | |
---|
724 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
725 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
726 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
727 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n" |
---|
728 | |
---|
729 | for comp in ${config_ListOfComponents[*]} ; do |
---|
730 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "y" |
---|
731 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartDate ${HumanRestartDate} |
---|
732 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM} |
---|
733 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH} |
---|
734 | done |
---|
735 | |
---|
736 | # ==> Job |
---|
737 | sed -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \ |
---|
738 | -e "s/\(#.*\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir} \2/" \ |
---|
739 | -e "s/^PeriodNb=.*/PeriodNb=60/" \ |
---|
740 | ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
741 | IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
742 | |
---|
743 | IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate" |
---|
744 | } |
---|
745 | |
---|
746 | function IGCM_ensemble_CastDirectoryName |
---|
747 | { |
---|
748 | IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName" |
---|
749 | |
---|
750 | #.. Debug Print .. |
---|
751 | echo |
---|
752 | IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :" |
---|
753 | echo |
---|
754 | |
---|
755 | Name=$1 |
---|
756 | Duree=$2 |
---|
757 | year=$3 |
---|
758 | month=$4 |
---|
759 | |
---|
760 | # - Build directory name |
---|
761 | case ${Duree} in |
---|
762 | *Y|*y) |
---|
763 | siecle="$( echo $year | cut -c1-2 )" |
---|
764 | siecle=$( (( $siecle - 18 )) ) |
---|
765 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
766 | StartDir="${Name}${StartYear}" |
---|
767 | ;; |
---|
768 | *M|*m) |
---|
769 | echo $month |
---|
770 | siecle="$( echo $year | cut -c1-2 )" |
---|
771 | siecle=$( (( $siecle - 18 )) ) |
---|
772 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
773 | StartMonth="${AlphaMonth[ (( 10#${month} - 1 )) ]}" |
---|
774 | StartDir="${Name}${StartYear}${StartMonth}" |
---|
775 | ;; |
---|
776 | esac |
---|
777 | |
---|
778 | IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName" |
---|
779 | } |
---|
780 | |
---|
781 | function IGCM_ensemble_CastPerturbFile |
---|
782 | { |
---|
783 | IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile" |
---|
784 | |
---|
785 | typeset i i_ j |
---|
786 | typeset -Z4 j4 |
---|
787 | typeset file_out file_out_ |
---|
788 | |
---|
789 | #.. Debug Print .. |
---|
790 | echo |
---|
791 | IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :" |
---|
792 | |
---|
793 | #.. FileIn ? => RestartDate .. |
---|
794 | DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart" |
---|
795 | DirInTar="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART" |
---|
796 | FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}" |
---|
797 | DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart" |
---|
798 | |
---|
799 | # * Create member restart directory |
---|
800 | IGCM_sys_TestDirArchive ${DirOut} |
---|
801 | RET=$? |
---|
802 | if [ $RET -gt 0 ] ; then |
---|
803 | IGCM_sys_MkdirArchive ${DirOut} |
---|
804 | fi |
---|
805 | |
---|
806 | FileOut="${MemberDir}_${RestartDate}_${PerturbFile}" |
---|
807 | IGCM_debug_Print 1 "FileIn = ${DirIn}/${FileIn}" |
---|
808 | IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}.nc" |
---|
809 | |
---|
810 | IGCM_sys_TestFileArchive ${DirOut}/${FileOut}.nc |
---|
811 | RET=$? |
---|
812 | if [ $RET -gt 0 ] ; then |
---|
813 | |
---|
814 | # * Look for the restart file we apply the noise to |
---|
815 | |
---|
816 | # restart file list pertaining to the component we apply the noise to |
---|
817 | # but not being the precise restart file we will apply the noise to |
---|
818 | unset OtherFileInList |
---|
819 | # generic restart filename list (like flxat, sstoc, restart, ...) |
---|
820 | unset OtherGenericList |
---|
821 | |
---|
822 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
823 | (( i=0 )) |
---|
824 | until [ $i -ge ${NbFiles} ]; do |
---|
825 | |
---|
826 | (( i_ = i+1 )) |
---|
827 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
828 | eval file_out=${file_out_} |
---|
829 | |
---|
830 | generic_restart_file_name_out=$( basename ${file_out} .nc ) |
---|
831 | |
---|
832 | if [ ! ${generic_restart_file_name_out} = ${PerturbFile} ] ; then |
---|
833 | set +A OtherFileInList ${OtherFileInList[*]} ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic_restart_file_name_out}\*.nc |
---|
834 | set +A OtherGenericList ${OtherGenericList[*]} ${generic_restart_file_name_out} |
---|
835 | fi |
---|
836 | |
---|
837 | (( i=i+3 )) |
---|
838 | done |
---|
839 | fi |
---|
840 | # How many restart files other than the one we will apply the noise to |
---|
841 | NbOtherFiles=${#OtherGenericList[*]} |
---|
842 | |
---|
843 | ########################## |
---|
844 | # TO BE A FUNCTION BEGIN # |
---|
845 | ########################## |
---|
846 | |
---|
847 | if [ $( IGCM_sys_TestFileBuffer ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
848 | IGCM_debug_Print 3 "Buffered restart" |
---|
849 | Buffered=true |
---|
850 | Archived=false |
---|
851 | Tared=false |
---|
852 | nb_restart_file=$(IGCM_sys_CountFileBuffer ${DirIn}/${FileIn}_????.nc) |
---|
853 | elif [ $( IGCM_sys_TestFileArchive ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
854 | IGCM_debug_Print 3 "Archived restart" |
---|
855 | Buffered=false |
---|
856 | Archived=true |
---|
857 | Tared=false |
---|
858 | nb_restart_file=$(IGCM_sys_CountFileArchive ${DirIn}/${FileIn}_????.nc) |
---|
859 | else |
---|
860 | IGCM_debug_Print 3 "Tared restart" |
---|
861 | Buffered=false |
---|
862 | Archived=false |
---|
863 | Tared=true |
---|
864 | |
---|
865 | # Look for the tar file we want if we did not found it already |
---|
866 | for PotentialTarFile in $( find ${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART -name "${ensemble_Ens_PERTURB_INITFROM}_*restart*.tar" -print ) ; do |
---|
867 | IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:_restart::" | sed "s:^${ensemble_Ens_PERTURB_INITFROM}_::" | sed "s:\.tar$::" | gawk -F_ -v restartdate=${RestartDate} '{if (($1 <= restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' ) |
---|
868 | if [ ! X${IsMatching} = X ] ; then |
---|
869 | TarFileFound=${PotentialTarFile} |
---|
870 | break |
---|
871 | fi |
---|
872 | done |
---|
873 | |
---|
874 | # Extract relevant restart files |
---|
875 | IGCM_debug_Print 1 "tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]}" |
---|
876 | tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]} |
---|
877 | nb_restart_file=$( IGCM_sys_CountFileBuffer ${PerturbComp}_${FileIn}_????.nc ) |
---|
878 | fi |
---|
879 | |
---|
880 | # Move around and perturb restart files so as to be able to start hindcast/forecast simulation members |
---|
881 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
882 | j=0 |
---|
883 | until [ $j -ge ${nb_restart_file} ]; do |
---|
884 | j4=${j} |
---|
885 | if [ X${Buffered} = Xtrue ] ; then |
---|
886 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
887 | |
---|
888 | cd ${DirOut} |
---|
889 | for generic in ${OtherGenericList[*]} ; do |
---|
890 | ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc |
---|
891 | done |
---|
892 | cd - |
---|
893 | |
---|
894 | elif [ X${Archived} = Xtrue ] ; then |
---|
895 | IGCM_sys_Get ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
896 | |
---|
897 | for generic in ${OtherGenericList[*]} ; do |
---|
898 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc" |
---|
899 | done |
---|
900 | |
---|
901 | elif [ X${Tared} = Xtrue ] ; then |
---|
902 | IGCM_debug_Print 2 "IGCM_sys_Mv ${PerturbComp}_${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc" |
---|
903 | IGCM_sys_Mv ${PerturbComp}_${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
904 | |
---|
905 | for generic in ${OtherGenericList[*]} ; do |
---|
906 | IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}_${j4}.nc |
---|
907 | done |
---|
908 | |
---|
909 | fi |
---|
910 | (( j=j+1 )) |
---|
911 | done |
---|
912 | else |
---|
913 | if [ X${Buffered} = Xtrue ] ; then |
---|
914 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
915 | |
---|
916 | cd ${DirOut} |
---|
917 | for generic in ${OtherGenericList[*]} ; do |
---|
918 | ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc |
---|
919 | done |
---|
920 | cd - |
---|
921 | |
---|
922 | elif [ X${Archived} = Xtrue ] ; then |
---|
923 | IGCM_sys_Get ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
924 | |
---|
925 | for generic in ${OtherGenericList[*]} ; do |
---|
926 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc" |
---|
927 | done |
---|
928 | |
---|
929 | elif [ X${Tared} = Xtrue ] ; then |
---|
930 | IGCM_debug_Print 2 "IGCM_sys_Mv ${PerturbComp}_${FileIn}.nc ${RUN_DIR}/${FileOut}.nc" |
---|
931 | IGCM_sys_Mv ${PerturbComp}_${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
932 | |
---|
933 | for generic in ${OtherGenericList[*]} ; do |
---|
934 | IGCM_debug_Print 2 "IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}.nc" |
---|
935 | IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}.nc |
---|
936 | done |
---|
937 | |
---|
938 | fi |
---|
939 | fi |
---|
940 | |
---|
941 | ######################## |
---|
942 | # TO BE A FUNCTION END # |
---|
943 | ######################## |
---|
944 | |
---|
945 | # treat the perturbation on different components by looking at the executable name |
---|
946 | |
---|
947 | case ${PerturbExe} in |
---|
948 | (AddNoise) |
---|
949 | IGCM_sys_Chmod 644 ${RUN_DIR}/${FileOut}.nc |
---|
950 | |
---|
951 | IGCM_debug_Print 1 "${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp}" |
---|
952 | echo |
---|
953 | |
---|
954 | ${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp} > /dev/null 2>&1 |
---|
955 | if [ $? -ne 0 ] ; then |
---|
956 | IGCM_debug_Exit "Error with $( basename ${PerturbExe} )" |
---|
957 | IGCM_debug_Verif_Exit |
---|
958 | fi |
---|
959 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut}.nc ${DirOut}/ 644 |
---|
960 | ;; |
---|
961 | (AddPertu3DOCE) |
---|
962 | # where to find the pattern we apply to the restart |
---|
963 | PatternFile=${ensemble_Ens_PERTURB_MEMBER_INITPATH}/${ensemble_Ens_PERTURB_MEMBER_INITFROM}/${MemberVec}.nc |
---|
964 | |
---|
965 | # where to find the land mask for the grid |
---|
966 | MaskFile=${ensemble_Ens_PERTURB_MASKPATH}/${PerturbMask} |
---|
967 | |
---|
968 | # if there is multiple restart files rebuild restart file |
---|
969 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
970 | IGCM_debug_Print 1 "rebuild files ${FileOut}_????.nc" |
---|
971 | IGCM_sys_rebuild ${RUN_DIR}/${FileOut}.nc ${RUN_DIR}/${FileOut}_????.nc |
---|
972 | fi |
---|
973 | |
---|
974 | # there is now a single restart file |
---|
975 | IGCM_sys_Chmod 644 ${RUN_DIR}/${FileOut}.nc |
---|
976 | |
---|
977 | IGCM_debug_Print 1 "${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PatternFile} ${MaskFile}" |
---|
978 | echo |
---|
979 | |
---|
980 | # add pattern to restart file on variable PerturbVar |
---|
981 | ${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PatternFile} ${MaskFile} > /dev/null 2>&1 |
---|
982 | if [ $? -ne 0 ] ; then |
---|
983 | IGCM_debug_Exit "Error with $( basename ${PerturbExe} )" |
---|
984 | IGCM_debug_Verif_Exit |
---|
985 | fi |
---|
986 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut}.nc ${DirOut}/ 644 |
---|
987 | ;; |
---|
988 | esac |
---|
989 | |
---|
990 | fi |
---|
991 | |
---|
992 | #.. Update config.card.. |
---|
993 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y" |
---|
994 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate ${HumanRestartDate} |
---|
995 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir} |
---|
996 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ |
---|
997 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_PERTURB" |
---|
998 | |
---|
999 | IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile" |
---|
1000 | } |
---|
1001 | |
---|
1002 | ############### Date ENSEMBLE ################# |
---|
1003 | function IGCM_ensemble_DateInit |
---|
1004 | { |
---|
1005 | IGCM_debug_PushStack "IGCM_ensemble_DateInit" |
---|
1006 | |
---|
1007 | IGCM_sys_Mkdir ${RUN_DIR} |
---|
1008 | |
---|
1009 | IGCM_sys_Cp ${SUBMIT_DIR}/config.card ${RUN_DIR} |
---|
1010 | IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR} |
---|
1011 | IGCM_sys_Cp ${SUBMIT_DIR}/Job_* ${RUN_DIR} |
---|
1012 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR} |
---|
1013 | if [ -f ${SUBMIT_DIR}/Qsub.* ]; then |
---|
1014 | IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.* ${RUN_DIR} |
---|
1015 | fi |
---|
1016 | if [ -f ${SUBMIT_DIR}/Qclean.* ]; then |
---|
1017 | IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.* ${RUN_DIR} |
---|
1018 | fi |
---|
1019 | |
---|
1020 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active |
---|
1021 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE NAME |
---|
1022 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE BEGIN_INIT |
---|
1023 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE BEGIN_RESTART |
---|
1024 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE END_INIT |
---|
1025 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE PERIODICITY |
---|
1026 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_DATE NONPERIODIC |
---|
1027 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_DATE RESTART_NONPERIODIC |
---|
1028 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE LENGTH |
---|
1029 | IGCM_card_DefineArrayFromOption ${F_CFG_ENS} Ens_DATE LENGTH_NONPERIODIC |
---|
1030 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITFROM |
---|
1031 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITFROM_NONPERIODIC |
---|
1032 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITPATH |
---|
1033 | IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITPATH_NONPERIODIC |
---|
1034 | IGCM_card_DefineVariableFromOption config.card UserChoices JobName |
---|
1035 | IGCM_card_DefineVariableFromOption config.card UserChoices TagName |
---|
1036 | IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType |
---|
1037 | IGCM_card_DefineArrayFromSection config.card ListOfComponents |
---|
1038 | |
---|
1039 | echo |
---|
1040 | IGCM_debug_Print 1 "[Ens_DATE]" |
---|
1041 | IGCM_debug_Print 1 "ACTIVE = ${ensemble_Ens_DATE_active}" |
---|
1042 | IGCM_debug_Print 1 "NAME = ${ensemble_Ens_DATE_NAME}" |
---|
1043 | IGCM_debug_Print 1 "BEGIN_INIT = ${ensemble_Ens_DATE_BEGIN_INIT}" |
---|
1044 | IGCM_debug_Print 1 "END_INIT = ${ensemble_Ens_DATE_END_INIT}" |
---|
1045 | IGCM_debug_Print 1 "PERIODICITY = ${ensemble_Ens_DATE_PERIODICITY}" |
---|
1046 | IGCM_debug_Print 1 "BEGIN_RESTART = ${ensemble_Ens_DATE_BEGIN_RESTART}" |
---|
1047 | IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_DATE_NONPERIODIC[*]}" |
---|
1048 | IGCM_debug_Print 1 "RESTART_NONPERIODIC = ${ensemble_Ens_DATE_RESTART_NONPERIODIC[*]}" |
---|
1049 | IGCM_debug_Print 1 "LENGTH = ${ensemble_Ens_DATE_LENGTH}" |
---|
1050 | IGCM_debug_Print 1 "LENGTH_NONPERIODIC = ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]}" |
---|
1051 | IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_DATE_INITFROM}" |
---|
1052 | IGCM_debug_Print 1 "INITFROM_NONPERIODIC = ${ensemble_Ens_DATE_INITFROM_NONPERIODIC[*]}" |
---|
1053 | IGCM_debug_Print 1 "INITPATH = ${ensemble_Ens_DATE_INITPATH}" |
---|
1054 | IGCM_debug_Print 1 "INITPATH_NONPERIODIC = ${ensemble_Ens_DATE_INITPATH_NONPERIODIC[*]}" |
---|
1055 | IGCM_debug_Print 1 "JobName = ${config_UserChoices_JobName}" |
---|
1056 | IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" |
---|
1057 | IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" |
---|
1058 | IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" |
---|
1059 | echo "" |
---|
1060 | |
---|
1061 | ensemble_Ens_DATE_MEMBER=1 # actually use only 1 member |
---|
1062 | IGCM_ensemble_SetAlpha ${ensemble_Ens_DATE_MEMBER} |
---|
1063 | |
---|
1064 | IGCM_debug_Print 1 "Check args..." |
---|
1065 | DatePeriodicStart=false |
---|
1066 | DateNonPeriodicStart=false |
---|
1067 | |
---|
1068 | # ... Check LENGTH ... |
---|
1069 | case ${ensemble_Ens_DATE_LENGTH} in |
---|
1070 | *[Yy]|*[Mm]) |
---|
1071 | IGCM_debug_Print 1 "Default simulation duration : ${ensemble_Ens_DATE_LENGTH}" ;; |
---|
1072 | *) |
---|
1073 | IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_LENGTH} invalid LENGTH" |
---|
1074 | IGCM_debug_Exit "Choose a value in choose in *Y or *M" |
---|
1075 | IGCM_debug_Verif_Exit ;; |
---|
1076 | esac |
---|
1077 | |
---|
1078 | # *************************************** |
---|
1079 | # A few checks Period case: |
---|
1080 | # *************************************** |
---|
1081 | # if all Periodic params are not filled: desactivate Periodic mode |
---|
1082 | totalPeriodArgs=4 |
---|
1083 | periodFillArgs=0 |
---|
1084 | |
---|
1085 | if [[ X${ensemble_Ens_DATE_BEGIN_RESTART} != "X" ]]; then |
---|
1086 | (( periodFillArgs = periodFillArgs + 1 )) |
---|
1087 | fi |
---|
1088 | |
---|
1089 | if [[ X${ensemble_Ens_DATE_BEGIN_INIT} != "X" ]]; then |
---|
1090 | (( periodFillArgs = periodFillArgs + 1 )) |
---|
1091 | fi |
---|
1092 | |
---|
1093 | if [[ X${ensemble_Ens_DATE_END_INIT} != "X" ]]; then |
---|
1094 | (( periodFillArgs = periodFillArgs + 1 )) |
---|
1095 | fi |
---|
1096 | |
---|
1097 | if [[ X${ensemble_Ens_DATE_PERIODICITY} != "X" ]]; then |
---|
1098 | (( periodFillArgs = periodFillArgs + 1 )) |
---|
1099 | |
---|
1100 | # ... Check PERIODICITY ... |
---|
1101 | case ${ensemble_Ens_DATE_PERIODICITY} in |
---|
1102 | *[Yy]|*[Mm]) |
---|
1103 | IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_DATE_PERIODICITY}" ;; |
---|
1104 | *) |
---|
1105 | IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_PERIODICITY} : invalid PERIODICITY" |
---|
1106 | IGCM_debug_Exit "Choose a value in *Y or *M" |
---|
1107 | IGCM_debug_Verif_Exit ;; |
---|
1108 | esac |
---|
1109 | fi # if periodicity |
---|
1110 | |
---|
1111 | if [[ ${periodFillArgs} = ${totalPeriodArgs} ]]; then |
---|
1112 | DatePeriodicStart=true |
---|
1113 | else |
---|
1114 | if [[ ${periodFillArgs} = 0 ]]; then |
---|
1115 | IGCM_debug_Print 1 "Periodic start NOT ACTIVE" |
---|
1116 | DatePeriodicStart=false |
---|
1117 | else |
---|
1118 | IGCM_debug_Exit "IGCM_ensemble_DateInit missing arguments for Periodic mode!" |
---|
1119 | IGCM_debug_Exit "Get only ${periodFillArgs} on ${totalPeriodArgs} args. Check ${F_CFG_ENS} file." |
---|
1120 | IGCM_debug_Verif_Exit |
---|
1121 | fi |
---|
1122 | fi |
---|
1123 | |
---|
1124 | # *************************************** |
---|
1125 | # A few checks for the Non-Periodic case: |
---|
1126 | # *************************************** |
---|
1127 | if [[ ${#ensemble_Ens_DATE_NONPERIODIC[*]} != ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ]] ; then |
---|
1128 | IGCM_debug_Exit "IGCM_ensemble_DateInit: NONPERIODIC and RESTART_NONPERIODIC lists have different sizes" |
---|
1129 | IGCM_debug_Verif_Exit |
---|
1130 | fi |
---|
1131 | |
---|
1132 | if [[ ${#ensemble_Ens_DATE_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_DATE_NONPERIODIC[*]} != _0_ ]]; then |
---|
1133 | DateNonPeriodicStart=true |
---|
1134 | |
---|
1135 | # Use LENGTH if no NONPERIODIC_LENGTH given |
---|
1136 | if [[ ${#ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]} < ${#ensemble_Ens_DATE_NONPERIODIC[*]} ]] ; then |
---|
1137 | IGCM_debug_Print 1 "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_DATE_LENGTH}' for all NONPERIODIC runs" |
---|
1138 | DateNum=0 |
---|
1139 | while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do |
---|
1140 | ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_LENGTH} |
---|
1141 | (( DateNum = DateNum + 1 )) |
---|
1142 | done |
---|
1143 | fi |
---|
1144 | |
---|
1145 | # Use INITFROM if no INITFROM_NONPERIODIC given |
---|
1146 | if [ ${#ensemble_Ens_DATE_INITFROM_NONPERIODIC[*]} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; then |
---|
1147 | IGCM_debug_Print 1 "WARNING: INITFROM_NONPERIODIC is not fill (or not correctly). Use INITFROM value '${ensemble_Ens_DATE_INITFROM}' for all NONPERIODIC runs" |
---|
1148 | DateNum=0 |
---|
1149 | while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do |
---|
1150 | ensemble_Ens_DATE_INITFROM_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_INITFROM} |
---|
1151 | (( DateNum = DateNum + 1 )) |
---|
1152 | done |
---|
1153 | fi |
---|
1154 | |
---|
1155 | # Use INITPATH if no INITPATH_NONPERIODIC given |
---|
1156 | if [ ${#ensemble_Ens_DATE_INITPATH_NONPERIODIC[*]} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; then |
---|
1157 | IGCM_debug_Print 1 "WARNING: INITPATH_NONPERIODIC is not fill (or not correctly). Use INITPATH value '${ensemble_Ens_DATE_INITPATH}' for all NONPERIODIC runs" |
---|
1158 | DateNum=0 |
---|
1159 | while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do |
---|
1160 | ensemble_Ens_DATE_INITPATH_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_INITPATH} |
---|
1161 | (( DateNum = DateNum + 1 )) |
---|
1162 | done |
---|
1163 | fi |
---|
1164 | else |
---|
1165 | IGCM_debug_Print 1 "Non-Periodic start NOT ACTIVE" |
---|
1166 | DateNonPeriodicStart=false |
---|
1167 | fi |
---|
1168 | |
---|
1169 | if [[ ${DateNonPeriodicStart} = true ]]; then |
---|
1170 | DateNum=0 |
---|
1171 | while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do |
---|
1172 | # - Check LENGTH_NONPERIODIC |
---|
1173 | case ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]} in |
---|
1174 | *[Yy]|*[Mm]) |
---|
1175 | IGCM_debug_Print 1 "Non-periodic duration ${DateNum}: ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]}" |
---|
1176 | ;; |
---|
1177 | *) |
---|
1178 | IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]} : invalid NON PERIODIC LENGTH" |
---|
1179 | IGCM_debug_Exit "choose in *Y or *M" |
---|
1180 | IGCM_debug_Verif_Exit ;; |
---|
1181 | esac |
---|
1182 | |
---|
1183 | # - Check RESTART_NONPERIODIC |
---|
1184 | case ${ensemble_Ens_DATE_RESTART_NONPERIODIC[${DateNum}]} in |
---|
1185 | _0_) |
---|
1186 | IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_RESTART_NONPERIODIC[${DateNum}]} : invalid NON PERIODIC RESTART" |
---|
1187 | IGCM_debug_Verif_Exit ;; |
---|
1188 | esac |
---|
1189 | |
---|
1190 | (( DateNum = DateNum + 1 )) |
---|
1191 | done |
---|
1192 | fi # DateNonPeriodicStart = true |
---|
1193 | |
---|
1194 | IGCM_debug_PopStack "IGCM_ensemble_DateInit" |
---|
1195 | } |
---|
1196 | |
---|
1197 | function IGCM_ensemble_DatePeriodicStarts |
---|
1198 | { |
---|
1199 | IGCM_debug_PushStack "IGCM_ensemble_DatePeriodicStarts" |
---|
1200 | |
---|
1201 | [ ${DatePeriodicStart} = false ] && return |
---|
1202 | |
---|
1203 | echo |
---|
1204 | IGCM_debug_Print 1 ">>> MANAGE PERIODIC STARTS <<<" |
---|
1205 | |
---|
1206 | #.. Manage periodic starts .. |
---|
1207 | # ====================== |
---|
1208 | |
---|
1209 | # - Build directory name |
---|
1210 | StartDir="${ensemble_Ens_DATE_NAME}" |
---|
1211 | |
---|
1212 | # - Create directory for current DateBegin |
---|
1213 | if [ ! -d ${StartDir} ] ; then |
---|
1214 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
1215 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
1216 | ln -s ../../.resol . |
---|
1217 | ln -s ../../.libmpi . |
---|
1218 | IGCM_sys_Cd ${RUN_DIR} |
---|
1219 | fi |
---|
1220 | |
---|
1221 | # ... Loop over DateBegin ... |
---|
1222 | eval DateBegin=\${ensemble_Ens_DATE_BEGIN_INIT} |
---|
1223 | eval RestartDate=\${ensemble_Ens_DATE_BEGIN_RESTART} |
---|
1224 | |
---|
1225 | DateNum=0 |
---|
1226 | while [ ${DateBegin} -le ${ensemble_Ens_DATE_END_INIT} ] ; do |
---|
1227 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
1228 | |
---|
1229 | echo "========================================================================" |
---|
1230 | echo "New DateBegin = $DateBegin" |
---|
1231 | |
---|
1232 | # - Determine number of day(s) in PERIODICITY |
---|
1233 | PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_DATE_PERIODICITY} ) |
---|
1234 | |
---|
1235 | # - Determine number of day(s) in LENGTH |
---|
1236 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_DATE_LENGTH} ) - 1 )) |
---|
1237 | |
---|
1238 | # - Determine DateEnd |
---|
1239 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
1240 | |
---|
1241 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
1242 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt |
---|
1243 | |
---|
1244 | # - Loop over members (default =1 no member) |
---|
1245 | i=0 |
---|
1246 | while [ $i -lt ${ensemble_Ens_DATE_MEMBER} ] ; do |
---|
1247 | MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}_per" |
---|
1248 | echo |
---|
1249 | IGCM_debug_Print 3 "${MemberDir}" |
---|
1250 | |
---|
1251 | JobName="Job_${MemberDir}" |
---|
1252 | |
---|
1253 | # * Create directory if it doesn't exist and copy/link files |
---|
1254 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
1255 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1256 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1257 | ln -s ../../COMP |
---|
1258 | ln -s ../../PARAM |
---|
1259 | ln -s ../../POST |
---|
1260 | ln -s ../../DRIVER |
---|
1261 | IGCM_sys_Cd ${RUN_DIR} |
---|
1262 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1263 | IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
1264 | |
---|
1265 | # Dump command to be lauched |
---|
1266 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
1267 | echo "${SUBMIT} ${JobName} ; cd -" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
1268 | |
---|
1269 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
1270 | echo "${libIGCM}/clean_month.job ; cd -" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
1271 | |
---|
1272 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
1273 | echo "${libIGCM}/clean_year.job ; cd -" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
1274 | |
---|
1275 | # * Update files : config.card, Job_, COMP/comp.card |
---|
1276 | IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
1277 | fi |
---|
1278 | |
---|
1279 | (( i = i + 1 )) |
---|
1280 | done |
---|
1281 | |
---|
1282 | # - Next DateBegin & RestartDate |
---|
1283 | echo "$DateBegin $PeriodLengthInDays" |
---|
1284 | case ${ensemble_Ens_DATE_PERIODICITY} in |
---|
1285 | *[Yy]|*[Mm]) |
---|
1286 | (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) |
---|
1287 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${RestartDate} ${PeriodLengthInDays} ) )) |
---|
1288 | ;; |
---|
1289 | esac |
---|
1290 | |
---|
1291 | (( DateNum = DateNum + 1 )) # increment number of restart date |
---|
1292 | done |
---|
1293 | |
---|
1294 | # Done. Save ${StartDir} submission text file |
---|
1295 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
1296 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
1297 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
1298 | |
---|
1299 | IGCM_debug_PopStack "IGCM_ensemble_DatePeriodicStarts" |
---|
1300 | } |
---|
1301 | |
---|
1302 | function IGCM_ensemble_DateNonPeriodicStarts |
---|
1303 | { |
---|
1304 | IGCM_debug_PushStack "IGCM_ensemble_DateNonPeriodicStarts" |
---|
1305 | |
---|
1306 | #.. Manage non periodic starts => Loop over DateBegin .. |
---|
1307 | # ========================== |
---|
1308 | |
---|
1309 | [ ${DateNonPeriodicStart} = false ] && return |
---|
1310 | |
---|
1311 | echo |
---|
1312 | IGCM_debug_Print 1 ">>> MANAGE NON PERIODIC STARTS <<<" |
---|
1313 | |
---|
1314 | # - Build directory name |
---|
1315 | echo "" |
---|
1316 | echo "========================================================================" |
---|
1317 | echo "ensemble_Ens_DATE_NAME = ${ensemble_Ens_DATE_NAME}" |
---|
1318 | StartDir="${ensemble_Ens_DATE_NAME}" |
---|
1319 | |
---|
1320 | # - Does $StartDir already exist ? |
---|
1321 | if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then |
---|
1322 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
1323 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
1324 | ln -s ../../.resol . |
---|
1325 | ln -s ../../.libmpi . |
---|
1326 | IGCM_sys_Cd ${RUN_DIR} |
---|
1327 | fi |
---|
1328 | |
---|
1329 | DateNum=0 |
---|
1330 | # ... Loop over ensemble_Ens_DATE_NONPERIODIC ... |
---|
1331 | while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do |
---|
1332 | DateBegin=${ensemble_Ens_DATE_NONPERIODIC[${DateNum}]} |
---|
1333 | Duree=${ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]} |
---|
1334 | RestartDate=${ensemble_Ens_DATE_RESTART_NONPERIODIC[${DateNum}]} |
---|
1335 | InitFrom=${ensemble_Ens_DATE_INITFROM_NONPERIODIC[${DateNum}]} |
---|
1336 | InitPath=${ensemble_Ens_DATE_INITPATH_NONPERIODIC[${DateNum}]} |
---|
1337 | |
---|
1338 | # - Determine number of day(s) in LENGTH_NONPERIODIC |
---|
1339 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
1340 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) |
---|
1341 | |
---|
1342 | # - Determine DateEnd |
---|
1343 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
1344 | |
---|
1345 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
1346 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt |
---|
1347 | |
---|
1348 | PeriodDateEnd=$( grep -m1 ${StartDir} ${RUN_DIR}/CreatedDir.txt | cut -f2 -d\ ) |
---|
1349 | |
---|
1350 | # - Loop over members |
---|
1351 | i=0 |
---|
1352 | while [ $i -lt ${ensemble_Ens_DATE_MEMBER} ] ; do |
---|
1353 | MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}" |
---|
1354 | IGCM_debug_Print 3 "${MemberDir}" |
---|
1355 | |
---|
1356 | JobName="Job_${MemberDir}" |
---|
1357 | |
---|
1358 | # * Create directory if it doesn't exist and copy files |
---|
1359 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
1360 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1361 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1362 | ln -s ../../COMP |
---|
1363 | ln -s ../../PARAM |
---|
1364 | ln -s ../../POST |
---|
1365 | ln -s ../../DRIVER |
---|
1366 | IGCM_sys_Cd ${RUN_DIR} |
---|
1367 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
1368 | IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
1369 | |
---|
1370 | # Dump command to be lauched |
---|
1371 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
1372 | echo "${SUBMIT} ${JobName} ; cd -" >> ${RUN_DIR}/Qsub.${StartDir}.sh |
---|
1373 | |
---|
1374 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
1375 | echo "${libIGCM}/clean_month.job ; cd -" >> ${RUN_DIR}/Qclean.month.${StartDir}.sh |
---|
1376 | |
---|
1377 | echo "cd ${StartDir}/${MemberDir}/ ;" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
1378 | echo "${libIGCM}/clean_year.job ; cd -" >> ${RUN_DIR}/Qclean.year.${StartDir}.sh |
---|
1379 | |
---|
1380 | # * Update files : config.card, Job_, COMP/comp.card |
---|
1381 | IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} ${InitFrom} ${InitPath} |
---|
1382 | fi |
---|
1383 | |
---|
1384 | (( i = i + 1 )) |
---|
1385 | done |
---|
1386 | |
---|
1387 | # Done. Save ${StartDir} submission text file |
---|
1388 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
1389 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
1390 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
1391 | |
---|
1392 | (( DateNum = DateNum + 1 )) |
---|
1393 | done |
---|
1394 | |
---|
1395 | # Done. Save ${StartDir} submission text file |
---|
1396 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR} |
---|
1397 | IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR} |
---|
1398 | IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR} |
---|
1399 | |
---|
1400 | IGCM_debug_PopStack "IGCM_ensemble_DateNonPeriodicStarts" |
---|
1401 | } |
---|
1402 | |
---|
1403 | function IGCM_ensemble_DateFilesUpdate |
---|
1404 | { |
---|
1405 | IGCM_debug_PushStack "IGCM_ensemble_DateFilesUpdate" |
---|
1406 | |
---|
1407 | # Debug Print : |
---|
1408 | echo |
---|
1409 | IGCM_debug_Print 1 "IGCM_ensemble_DateFilesUpdate :" |
---|
1410 | |
---|
1411 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
1412 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
1413 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
1414 | if [[ X${4} != "X" ]]; then |
---|
1415 | initFrom=${4} # non periodic config (INITFROM could be different between members) |
---|
1416 | else |
---|
1417 | initFrom=${ensemble_Ens_DATE_INITFROM} # periodic (same INITFROM value) |
---|
1418 | fi |
---|
1419 | |
---|
1420 | if [[ X${5} != "X" ]]; then |
---|
1421 | initPath=${5} # non periodic config (INITPATH could be different between members) |
---|
1422 | else |
---|
1423 | initPath=${ensemble_Ens_DATE_INITPATH} # periodic (same INITPATH value) |
---|
1424 | fi |
---|
1425 | |
---|
1426 | # ==> config.card |
---|
1427 | # [ENSEMBLE] |
---|
1428 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
1429 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_DATE_NAME} |
---|
1430 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${HumanDateBegin} |
---|
1431 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_DATE" |
---|
1432 | |
---|
1433 | # [UserChoices] |
---|
1434 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
1435 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
1436 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
1437 | |
---|
1438 | # [Restarts] |
---|
1439 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "y" |
---|
1440 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartDate ${HumanRestartDate} |
---|
1441 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartJobName ${initFrom} |
---|
1442 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartPath ${initPath} |
---|
1443 | |
---|
1444 | # [ATM/OCE/...] |
---|
1445 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1446 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n" |
---|
1447 | done |
---|
1448 | unset initFrom |
---|
1449 | |
---|
1450 | # ==> Job |
---|
1451 | sed -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \ |
---|
1452 | -e "s/\(#.*\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir} \2/" \ |
---|
1453 | -e "s/^PeriodNb=.*/PeriodNb=60/" \ |
---|
1454 | ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
1455 | IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
1456 | |
---|
1457 | IGCM_debug_PopStack "IGCM_ensemble_DateFilesUpdate" |
---|
1458 | } |
---|
1459 | |
---|
1460 | ############### Parametric ENSEMBLE ################# |
---|