1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Jacques Belier |
---|
5 | # Contact: |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | #--------------------------------------------------------------------- |
---|
14 | #- Installation of jobs according to environment |
---|
15 | #--------------------------------------------------------------------- |
---|
16 | function ins_job_Usage |
---|
17 | { |
---|
18 | print - " |
---|
19 | ins_job installs the jobs in the directories |
---|
20 | which contain a file config.card |
---|
21 | |
---|
22 | ins_job must be launched on the host |
---|
23 | on which the job will be submitted |
---|
24 | |
---|
25 | Usage : |
---|
26 | ${b_n} [-h] [-v] [-e] |
---|
27 | or on irene/TGCC : |
---|
28 | ${b_n} [-h] [-v] [-e] [-p project] [-q type_of_node] [-c number of cores] |
---|
29 | or on ada /IDRIS |
---|
30 | ${b_n} [-h] [-v] [-e] [-m MPI environment] |
---|
31 | Options : |
---|
32 | -h : help |
---|
33 | -v : verbose mode |
---|
34 | -e : turn on ensemble mode (hindcast/forecast or date restart) |
---|
35 | -f : ins_job is force to create jobs even if they already exist |
---|
36 | on irene only : |
---|
37 | -p project : add default project on irene |
---|
38 | -q type_of_node : add default type of nodes for postprocessing on irene skylake/xlarge |
---|
39 | -c number of cores : add default number of cores for postprocessing on irene 1-112 |
---|
40 | on ada only : |
---|
41 | - m MPI environment : add default MPI environment (Intel MPI or IBM MPI) |
---|
42 | -t wall time : change default wall time |
---|
43 | " |
---|
44 | } |
---|
45 | function ins_job_Warning |
---|
46 | { |
---|
47 | [[ ${x_v} = 'verbose' ]] && print - "\n############### WARNING ###############"; |
---|
48 | [[ ${x_v} = 'verbose' ]] && print - "File ${n_f} already exists\nin directory ${j}"; |
---|
49 | [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !"; |
---|
50 | } |
---|
51 | |
---|
52 | function ins_job_Check_JobName |
---|
53 | { |
---|
54 | verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])} |
---|
55 | |
---|
56 | if [ ${#verif} -ne 0 ] ; then |
---|
57 | echo "################ ERROR ################" |
---|
58 | echo "${JobName} is invalid." |
---|
59 | echo "- JobName can only contain alphanumeric characters, \".\" and \"-\"" |
---|
60 | echo "- JobName must start with a letter" |
---|
61 | |
---|
62 | ((NbErr=NbErr+1)) |
---|
63 | |
---|
64 | Status=1 |
---|
65 | else |
---|
66 | Status=0 |
---|
67 | fi |
---|
68 | |
---|
69 | return ${Status} |
---|
70 | } |
---|
71 | |
---|
72 | #- |
---|
73 | # dirname and basename |
---|
74 | #- |
---|
75 | d_n=$(dirname ${0}); b_n=$(basename ${0}); |
---|
76 | #- |
---|
77 | # Retrieving and validation of the options |
---|
78 | #- |
---|
79 | x_v='silencious'; |
---|
80 | x_e=false; |
---|
81 | x_f=false; |
---|
82 | x_p=false; |
---|
83 | x_q=false; |
---|
84 | x_c=false; |
---|
85 | x_m=false; |
---|
86 | x_t=false; |
---|
87 | while getopts :hvefc:p:m:q:s:t: V ; do |
---|
88 | case $V in |
---|
89 | (h) ins_job_Usage; exit 0;; |
---|
90 | (v) x_v='verbose';; |
---|
91 | (e) x_e=true;; |
---|
92 | (f) x_f=true;; |
---|
93 | (p) x_p=true |
---|
94 | ProjectID=${OPTARG} ;; |
---|
95 | (q) x_q=true |
---|
96 | ProjectNode=${OPTARG} ;; |
---|
97 | (c) x_c=true |
---|
98 | ProjectCore=${OPTARG} ;; |
---|
99 | (m) x_m=true |
---|
100 | MPIEnvironment=${OPTARG} ;; |
---|
101 | (t) x_t=true |
---|
102 | WallTime=${OPTARG} ;; |
---|
103 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
104 | exit 2;; |
---|
105 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
106 | exit 2;; |
---|
107 | esac |
---|
108 | done |
---|
109 | [ ${x_v} = 'silencious' ] && export DEBUG_sys=false |
---|
110 | shift $(($OPTIND-1)); |
---|
111 | #- |
---|
112 | # Define working files |
---|
113 | #- |
---|
114 | F_MOD=$(cd ${d_n}'/..';/bin/pwd;) |
---|
115 | # [[ ${F_MOD##*/} != 'modipsl' ]] && \ |
---|
116 | # { print - "directory 'modipsl' unreachable"; exit 3; } |
---|
117 | W_W=${d_n}'/../libIGCM' |
---|
118 | [[ ! -d ${W_W} ]] && { print - "${W_W} unreachable"; exit 3; } |
---|
119 | libIGCM=$(cd ${W_W};/bin/pwd;) |
---|
120 | F_JOB=${libIGCM}'/AA_job'; |
---|
121 | [[ ! -f ${F_JOB} ]] && { print - "${F_JOB} unreachable"; exit 3; } |
---|
122 | F_JOB_DEBUG=${libIGCM}'/AA_job_debug'; |
---|
123 | [[ ! -f ${F_JOB_DEBUG} ]] && { print - "${F_JOB_DEBUG} unreachable"; exit 3; } |
---|
124 | F_RCI=${libIGCM}'/run.card.init'; |
---|
125 | [[ ! -f ${F_RCI} ]] && { print - "${F_RCI} unreachable"; exit 3; } |
---|
126 | #- |
---|
127 | # Accessing to functions (without stack) |
---|
128 | #- |
---|
129 | # No verbosity (0, 1, 2, 3) |
---|
130 | Verbosity=0 |
---|
131 | # No de debug |
---|
132 | DEBUG_debug=false |
---|
133 | # Dont move libIGCM |
---|
134 | MirrorlibIGCM=false |
---|
135 | # Behave like computing job |
---|
136 | TaskType=computing |
---|
137 | # Source libIGCM |
---|
138 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
139 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
140 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
141 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
142 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
143 | if [ $x_e = 'true' ] ; then |
---|
144 | . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh |
---|
145 | fi |
---|
146 | |
---|
147 | #- |
---|
148 | [[ ${x_v} = 'verbose' ]] && \ |
---|
149 | { |
---|
150 | print - ""; |
---|
151 | print - '--- Host : '${SYSTEM}; |
---|
152 | print - '--- modipsl : '${F_MOD}; |
---|
153 | print - '--- libIGCM : '${libIGCM}; |
---|
154 | print - '--- basic job : '${F_JOB}; |
---|
155 | print - '--- basic card : '${F_RCI}; |
---|
156 | } |
---|
157 | #- |
---|
158 | [[ ${x_v} = 'verbose' ]] && print - "\nInstallation of jobs for '${SYSTEM}'"; |
---|
159 | #- |
---|
160 | |
---|
161 | NbErr=0 |
---|
162 | |
---|
163 | #- |
---|
164 | # Define Project parameters to set up jobs header for Irene (TGCC) |
---|
165 | # on Irene define ProjectID and ProjectCore : option or answer |
---|
166 | # on Irene ProjectNode default projectnode set to xlarge since 17/10/2018 |
---|
167 | #- |
---|
168 | |
---|
169 | |
---|
170 | if [ X"${SYSTEM}" == "Xirene" ] ; then |
---|
171 | |
---|
172 | #- set ProjectID if required |
---|
173 | if ( ! ${x_p} ) ; then |
---|
174 | print - "Wait for the next question ..." |
---|
175 | #- default ProjectID |
---|
176 | ProjectID=$( ccc_myproject | grep -i irene |grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 ) |
---|
177 | answer="" |
---|
178 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) " |
---|
179 | read answer |
---|
180 | |
---|
181 | if [ "X${answer}" != "X" ] ; then |
---|
182 | ProjectID=${answer} |
---|
183 | fi |
---|
184 | |
---|
185 | fi # if ( ! ${x_p} ) |
---|
186 | |
---|
187 | echo ProjectID is ${ProjectID} at Irene |
---|
188 | |
---|
189 | |
---|
190 | # set ProjectNode if required |
---|
191 | if ( ! ${x_q} ) ; then |
---|
192 | #- default ProjectNode |
---|
193 | ProjectNode="xlarge" |
---|
194 | #- is xlarge possible for ${ProjectID} ? |
---|
195 | echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1 || ProjectNode="xlarge" |
---|
196 | |
---|
197 | if [ "X${ProjectNode}" == "Xxlarge" ] ; then |
---|
198 | answerOK=false |
---|
199 | |
---|
200 | while ( ! ${answerOK} ) ; do |
---|
201 | answer="" |
---|
202 | print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"skylake\" or \"xlarge\" : " |
---|
203 | read answer |
---|
204 | [ "X${answer}" == "X" ] || [ "X${answer}" == "Xskylake" ] || [ "X${answer}" == "Xxlarge" ] && answerOK=true |
---|
205 | done |
---|
206 | |
---|
207 | if [ "X${answer}" != "X" ] ; then |
---|
208 | ProjectNode=${answer} |
---|
209 | fi |
---|
210 | |
---|
211 | else |
---|
212 | print - "PostProcessing will be done on ${ProjectNode}" |
---|
213 | fi |
---|
214 | |
---|
215 | fi # if ( ! ${x_q} ) |
---|
216 | echo ProjectNode for post-processing is ${ProjectNode} at Irene |
---|
217 | |
---|
218 | #- ProjectNode is known (option or answer) set ProjectCoreMax |
---|
219 | [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" |
---|
220 | #- ProjectCoreMax is 48 for standard and 112 for xlarge |
---|
221 | |
---|
222 | if ( ! ${x_c} ) ; then |
---|
223 | #- ProjectNode is known (option or answer), set ProjectCore default |
---|
224 | [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" |
---|
225 | |
---|
226 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
227 | |
---|
228 | answerOK=false |
---|
229 | |
---|
230 | while ( ! ${answerOK} ) ; do |
---|
231 | answer="" |
---|
232 | print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : " |
---|
233 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")" |
---|
234 | read answer |
---|
235 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
236 | done |
---|
237 | |
---|
238 | if [ "X${answer}" != "X" ] ; then |
---|
239 | ProjectCore=${answer} |
---|
240 | fi |
---|
241 | |
---|
242 | fi # if ( ! ${x_c} ) |
---|
243 | |
---|
244 | echo ProjectCore for post-processing is ${ProjectCore} |
---|
245 | #- ProjectCore is set (option or answer) |
---|
246 | |
---|
247 | #- set WallTime if required |
---|
248 | if ( ! ${x_t} ) ; then |
---|
249 | #- default WallTime 1800 s |
---|
250 | WallTime=1800 |
---|
251 | answer="" |
---|
252 | print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) " |
---|
253 | read answer |
---|
254 | |
---|
255 | if [ "X${answer}" != "X" ] ; then |
---|
256 | WallTime=${answer} |
---|
257 | fi |
---|
258 | |
---|
259 | fi # if ( ! ${x_t} ) |
---|
260 | |
---|
261 | echo Wall time limit is ${WallTime} seconds |
---|
262 | |
---|
263 | elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then |
---|
264 | |
---|
265 | #- set ProjectID if required |
---|
266 | if ( ! ${x_p} ) ; then |
---|
267 | print - "Wait for the next question ..." |
---|
268 | #- default ProjectID |
---|
269 | ProjectID=$( ccc_myproject | grep -i irene |grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 ) |
---|
270 | answer="" |
---|
271 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) " |
---|
272 | read answer |
---|
273 | |
---|
274 | if [ "X${answer}" != "X" ] ; then |
---|
275 | ProjectID=${answer} |
---|
276 | fi |
---|
277 | |
---|
278 | fi # if ( ! ${x_p} ) |
---|
279 | |
---|
280 | echo ProjectID is ${ProjectID} at Irene-amd |
---|
281 | |
---|
282 | # set ProjectNode if required |
---|
283 | if ( ! ${x_q} ) ; then |
---|
284 | #- default ProjectNode |
---|
285 | ProjectNode="rome" |
---|
286 | #- is xlarge possible for ${ProjectID} ? |
---|
287 | echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1 || ProjectNode="rome" |
---|
288 | |
---|
289 | if [ "X${ProjectNode}" == "Xxlarge" ] ; then |
---|
290 | answerOK=false |
---|
291 | |
---|
292 | while ( ! ${answerOK} ) ; do |
---|
293 | answer="" |
---|
294 | print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"rome\" : " |
---|
295 | read answer |
---|
296 | [ "X${answer}" == "X" ] || [ "X${answer}" == "Xrome" ] && answerOK=true |
---|
297 | done |
---|
298 | |
---|
299 | if [ "X${answer}" != "X" ] ; then |
---|
300 | ProjectNode=${answer} |
---|
301 | fi |
---|
302 | |
---|
303 | else |
---|
304 | print - "PostProcessing will be done on ${ProjectNode}" |
---|
305 | fi |
---|
306 | |
---|
307 | fi # if ( ! ${x_q} ) |
---|
308 | echo ProjectNode for post-processing is ${ProjectNode} at Irene-amd |
---|
309 | |
---|
310 | #- ProjectNode is known (option or answer) set ProjectCoreMax |
---|
311 | [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" |
---|
312 | #- ProjectCoreMax is 48 for standard and 112 for xlarge |
---|
313 | |
---|
314 | if ( ! ${x_c} ) ; then |
---|
315 | #- ProjectNode is known (option or answer), set ProjectCore default |
---|
316 | [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" |
---|
317 | |
---|
318 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
319 | |
---|
320 | answerOK=false |
---|
321 | |
---|
322 | while ( ! ${answerOK} ) ; do |
---|
323 | answer="" |
---|
324 | print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : " |
---|
325 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")" |
---|
326 | read answer |
---|
327 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
328 | done |
---|
329 | |
---|
330 | if [ "X${answer}" != "X" ] ; then |
---|
331 | ProjectCore=${answer} |
---|
332 | fi |
---|
333 | |
---|
334 | fi # if ( ! ${x_c} ) |
---|
335 | |
---|
336 | echo ProjectCore for post-processing is ${ProjectCore} |
---|
337 | #- ProjectCore is set (option or answer) |
---|
338 | |
---|
339 | #- set WallTime if required |
---|
340 | if ( ! ${x_t} ) ; then |
---|
341 | #- default WallTime 1800 s |
---|
342 | WallTime=1800 |
---|
343 | answer="" |
---|
344 | print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) " |
---|
345 | read answer |
---|
346 | |
---|
347 | if [ "X${answer}" != "X" ] ; then |
---|
348 | WallTime=${answer} |
---|
349 | fi |
---|
350 | |
---|
351 | fi # if ( ! ${x_t} ) |
---|
352 | |
---|
353 | echo Wall time limit is ${WallTime} seconds |
---|
354 | |
---|
355 | elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then |
---|
356 | |
---|
357 | #- set ProjectID if required |
---|
358 | if ( ! ${x_p} ) ; then |
---|
359 | print - "Wait for the next question ..." |
---|
360 | #- default ProjectID |
---|
361 | ProjectID=$( echo $IDRPROJ ) |
---|
362 | answer="" |
---|
363 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are: $( groups ; echo ) " |
---|
364 | read answer |
---|
365 | |
---|
366 | if [ "X${answer}" != "X" ] ; then |
---|
367 | ProjectID=${answer} |
---|
368 | fi |
---|
369 | |
---|
370 | fi # if ( ! ${x_p} ) |
---|
371 | |
---|
372 | echo ProjectID is ${ProjectID} at Jean-Zay |
---|
373 | |
---|
374 | #- set WallTime if required |
---|
375 | if ( ! ${x_t} ) ; then |
---|
376 | #- default WallTime 30 minutes |
---|
377 | WallTime=30 |
---|
378 | answer="" |
---|
379 | print - "Hit Enter or give required wall time in minutes for computing job (default is \"${WallTime}\" minutes, maximum is 1200 minutes) " |
---|
380 | read answer |
---|
381 | |
---|
382 | if [ "X${answer}" != "X" ] ; then |
---|
383 | WallTime=${answer} |
---|
384 | fi |
---|
385 | |
---|
386 | fi # if ( ! ${x_t} ) |
---|
387 | |
---|
388 | echo Wall time limit is ${WallTime} minutes |
---|
389 | |
---|
390 | elif [ X"${SYSTEM}" == "Xada" ] ; then |
---|
391 | if ( ! ${x_m} ) ; then |
---|
392 | MPIEnvironment=IBM |
---|
393 | # Intel MPI Environment. |
---|
394 | answerOK=false |
---|
395 | while ( ! ${answerOK} ) ; do |
---|
396 | answer="" |
---|
397 | print - "Hit Enter or give MPI Environement (default is ${MPIEnvironment}), possible MPI environments are IBM (MPI IBM) and Intel (MPI Intel) :" |
---|
398 | read answer |
---|
399 | [ "X${answer}" == "X" ] || [ "X${answer}" == "XIBM" ] || [ "X${answer}" == "XIntel" ] && answerOK=true |
---|
400 | done |
---|
401 | |
---|
402 | if [ "X${answer}" != "X" ] ; then |
---|
403 | MPIEnvironment=${answer} |
---|
404 | fi |
---|
405 | fi # if ( ! ${x_pm} ) |
---|
406 | echo MPIEnvironment is ${MPIEnvironment} |
---|
407 | |
---|
408 | elif [ X"${SYSTEM}" == "Xobelix" ] || [ X"${SYSTEM}" == "Xifort_CICLAD" ] ; then |
---|
409 | # obelix, ciclad, climserv |
---|
410 | echo "" |
---|
411 | echo "You need to check and maybe adapt headers in the main job especially the line: " |
---|
412 | echo " #PBS -l nodes=x:ppn=y " |
---|
413 | echo "where x is the number of nodes, y the number of cores per node and x*y is the total number of cores for the job. " |
---|
414 | echo "y must not be bigger than the maximum numer of cores per node on the machine (often 8 or 16)." |
---|
415 | fi # if [ X"${SYSTEM}" == "Xirene" ] |
---|
416 | |
---|
417 | #- |
---|
418 | # Define the pattern string to substitute |
---|
419 | #- |
---|
420 | W_P='#-Q- '; W_W=${W_P}${SYSTEM}' '; |
---|
421 | #- |
---|
422 | # Extract list of 'config.card' files |
---|
423 | # and create jobs with AA_job |
---|
424 | #- |
---|
425 | F_CFG='config.card'; |
---|
426 | F_CFG_ENS='ensemble.card'; |
---|
427 | SUBMIT_DIR_ENS=$( pwd ) |
---|
428 | for i in $( pwd )/config.card |
---|
429 | do |
---|
430 | if [ ! -f $i ] ; then |
---|
431 | echo "" |
---|
432 | echo "################## WARNING ##################" |
---|
433 | echo "No config.card available in current directory" |
---|
434 | echo "" |
---|
435 | continue |
---|
436 | fi |
---|
437 | |
---|
438 | |
---|
439 | j=$(cd ${i%/*};/bin/pwd;) |
---|
440 | n_f=${F_RCI##*/}; |
---|
441 | |
---|
442 | if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then |
---|
443 | # Do not treat config.card if it is in sub-directory of EXPERIMENTS |
---|
444 | # Continue to next config.card |
---|
445 | continue |
---|
446 | else |
---|
447 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
448 | fi |
---|
449 | |
---|
450 | # Find out if new structure and set .resol filename |
---|
451 | if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then |
---|
452 | # New Structure |
---|
453 | [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure" |
---|
454 | new_struct=yes |
---|
455 | resolfile=$j/.resol |
---|
456 | else |
---|
457 | # Old Structure |
---|
458 | new_struct=no |
---|
459 | resolfile=$j/../.resol |
---|
460 | fi |
---|
461 | |
---|
462 | # Get all variables declared in section UserChoices in config.card |
---|
463 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices |
---|
464 | # Set default values |
---|
465 | config_UserChoices_ExpType="" |
---|
466 | RESOL_ATM_3D=this_is_a_test_string |
---|
467 | RESOL=this_is_another_test_string |
---|
468 | ResolAtm=this_is_a_new_another_test |
---|
469 | typeset option |
---|
470 | for option in ${config_UserChoices[*]} ; do |
---|
471 | IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option} |
---|
472 | done |
---|
473 | |
---|
474 | # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file |
---|
475 | if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then |
---|
476 | TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' ) |
---|
477 | echo TRUERESOL = $TRUERESOL |
---|
478 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" ) |
---|
479 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
480 | elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then |
---|
481 | TRUERESOL=$( head -1 $resolfile ) |
---|
482 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" ) |
---|
483 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
484 | elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${ResolAtm} ) = X ] ; then |
---|
485 | TRUERESOL=${config_UserChoices_ResolAtm} |
---|
486 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${ResolAtm}/${TRUERESOL}/" ) |
---|
487 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
488 | else |
---|
489 | JobName=${config_UserChoices_JobName} |
---|
490 | fi |
---|
491 | |
---|
492 | # Check JobName validity : only alphanumerical characters, "-" and "." are authorized |
---|
493 | ins_job_Check_JobName |
---|
494 | RetCode=$? |
---|
495 | [[ $RetCode -gt 0 ]] && continue |
---|
496 | |
---|
497 | [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" |
---|
498 | |
---|
499 | # Add specific treatment for new type of directory structure |
---|
500 | if [ ${new_struct} == yes ] ; then |
---|
501 | |
---|
502 | if [ "X${config_UserChoices_ExpType}" = X ] ; then |
---|
503 | echo "\nERROR in ${j}/config.card" |
---|
504 | echo "ins_job stops here" |
---|
505 | echo "=> The variable ExpType must be added in config.card in section UserChoices" |
---|
506 | echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" |
---|
507 | exit 4 |
---|
508 | else |
---|
509 | [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" |
---|
510 | fi |
---|
511 | |
---|
512 | if [ -d ${j}/${JobName} ] ; then |
---|
513 | echo "Directory ${j}/${JobName} exists already. It will not be overwritten." |
---|
514 | echo "Remove the existing directory or change JobName before relaunching ins_job." |
---|
515 | #continue |
---|
516 | exit |
---|
517 | fi |
---|
518 | echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" |
---|
519 | cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} |
---|
520 | cp -r ${j}/GENERAL/* ${j}/${JobName}/. |
---|
521 | cp -f ${j}/${F_CFG} ${j}/${JobName}/. |
---|
522 | if [ -f ${F_CFG_ENS} ] ; then |
---|
523 | cp -f ${j}/${F_CFG_ENS} ${j}/${JobName}/. |
---|
524 | SUBMIT_DIR_ENS=${j}/${JobName} |
---|
525 | fi |
---|
526 | rm -f ${j}/${F_CFG} |
---|
527 | # rm -f ${j}/${F_CFG_ENS} |
---|
528 | rm -f ${j}/${F_CFG}.bak |
---|
529 | j=${j}/${JobName} |
---|
530 | [[ ${x_v} = 'verbose' ]] && echo new j=$j |
---|
531 | fi |
---|
532 | # end specific treatment for new type directory structure |
---|
533 | |
---|
534 | [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ |
---|
535 | { |
---|
536 | [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; |
---|
537 | \cp ${F_RCI} ${j}; |
---|
538 | } |
---|
539 | |
---|
540 | #================================== |
---|
541 | # Read ListOfComponents section: |
---|
542 | #echo |
---|
543 | #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
544 | |
---|
545 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} ListOfComponents |
---|
546 | for comp in ${config_ListOfComponents[*]} ; do |
---|
547 | IGCM_card_DefineArrayFromOption ${j}'/'${F_CFG} ListOfComponents ${comp} |
---|
548 | done |
---|
549 | #IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
550 | |
---|
551 | #================================== |
---|
552 | # Read Executable section: |
---|
553 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable |
---|
554 | |
---|
555 | # Define the execution context (MPMD, SPMD, MPI/OMP ...) |
---|
556 | IGCM_config_ConfigureExecution ${j}'/'${F_CFG} |
---|
557 | |
---|
558 | # coreNumber : TOTAL NUMBER OF CORES |
---|
559 | # mpiTasks : TOTAL NUMBER OF MPI TASKS |
---|
560 | # openMPthreads : NUMBER OF OpenMP THREADS |
---|
561 | |
---|
562 | # File name for Job |
---|
563 | n_f='Job_'${JobName}; |
---|
564 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
565 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
566 | sed -e "/^${W_W} */ s///" \ |
---|
567 | -e "/^${W_P}/d" \ |
---|
568 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
569 | -e "s/::Jobname::/${JobName}/" \ |
---|
570 | -e "s/::default_project::/${ProjectID}/" \ |
---|
571 | -e "s/::WallTime::/${WallTime}/" \ |
---|
572 | ${F_JOB} > ${j}'/'${n_f} |
---|
573 | chmod u+x ${j}'/'${n_f} |
---|
574 | |
---|
575 | # update Headers so that ressources description are accurate (MPMD/SPMD/...) |
---|
576 | IGCM_sys_updateHeaders ${j}'/'${n_f} |
---|
577 | |
---|
578 | n_f='Job_debug_'${JobName}; |
---|
579 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
580 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
581 | sed -e "/^${W_W} */ s///" \ |
---|
582 | -e "/^${W_P}/d" \ |
---|
583 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
584 | -e "s/::Jobname::/${JobName}/" \ |
---|
585 | -e "s/::default_project::/${ProjectID}/" \ |
---|
586 | -e "s/::WallTime::/${WallTime}/" \ |
---|
587 | ${F_JOB_DEBUG} > ${libIGCM}'/'${n_f} |
---|
588 | chmod u+x ${libIGCM}'/'${n_f} |
---|
589 | |
---|
590 | # update Headers so that ressources description are accurate (MPMD/SPMD/...) |
---|
591 | IGCM_sys_updateHeaders ${libIGCM}'/'${n_f} |
---|
592 | |
---|
593 | done |
---|
594 | |
---|
595 | #- |
---|
596 | # Extract list of AA_* files in libIGCM |
---|
597 | # and create jobs (for all except AA_job) |
---|
598 | #- |
---|
599 | for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print) |
---|
600 | do |
---|
601 | i_f=${i##*/}; |
---|
602 | [[ ${i_f} = 'AA_job' ]] && { continue; } |
---|
603 | j=${i%/*}; n_f=${i_f#AA_}'.job'; |
---|
604 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
605 | [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" |
---|
606 | sed -e "/^${W_W} */ s///" \ |
---|
607 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
608 | -e "/^${W_P}/d" \ |
---|
609 | -e "s/::default_node::/${ProjectNode}/" \ |
---|
610 | -e "s/::default_core::/${ProjectCore}/" \ |
---|
611 | -e "s/::default_project::/${ProjectID}/" \ |
---|
612 | -e "s/::default_post_project::/${ProjectID}/" \ |
---|
613 | ${i} > ${j}'/'${n_f} |
---|
614 | chmod u+x ${j}'/'${n_f} |
---|
615 | done |
---|
616 | #- |
---|
617 | # set default_project in libIGCM_sys_irene and libIGCM_sys_jeanzay. |
---|
618 | #- |
---|
619 | if [ X"${SYSTEM}" == "Xirene" ] ; then |
---|
620 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh |
---|
621 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
622 | elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then |
---|
623 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh |
---|
624 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
625 | elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then |
---|
626 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh |
---|
627 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
628 | fi |
---|
629 | #- |
---|
630 | # Limited to hindcast/forecast and date restart Ensemble for the time being |
---|
631 | if [ ${x_e} = 'true' ] ; then |
---|
632 | if [ ! -f ${F_CFG_ENS} ] ; then |
---|
633 | echo "" |
---|
634 | echo "################## WARNING ##################" |
---|
635 | echo "No ensemble.card available in current directory" |
---|
636 | echo "" |
---|
637 | exit |
---|
638 | # continue |
---|
639 | fi |
---|
640 | |
---|
641 | #.. Read input data from ensemble.card .. |
---|
642 | SUBMIT_DIR=${SUBMIT_DIR_ENS} |
---|
643 | RUN_DIR="${CCCWORKDIR}/ENSEMBLE_TMP" |
---|
644 | # |
---|
645 | # Copy initial things around and define variables (hindcast/forecast case) |
---|
646 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
647 | IGCM_ensemble_Init |
---|
648 | |
---|
649 | if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then |
---|
650 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
651 | IGCM_ensemble_DateInit |
---|
652 | # As it says |
---|
653 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
654 | IGCM_ensemble_DateNonPeriodicStarts |
---|
655 | fi |
---|
656 | |
---|
657 | if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then |
---|
658 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
659 | IGCM_ensemble_CastInit |
---|
660 | # As it says |
---|
661 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
662 | IGCM_ensemble_CastPeriodicStarts |
---|
663 | # As it says |
---|
664 | #IGCM_sys_Cd ${SUBMIT_DIR} |
---|
665 | #IGCM_ensemble_CastMemberList |
---|
666 | fi |
---|
667 | # Done |
---|
668 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
669 | # Clean |
---|
670 | IGCM_sys_Rm -rf ${RUN_DIR} |
---|
671 | |
---|
672 | fi |
---|
673 | #- |
---|
674 | [[ ${x_v} = 'verbose' ]] && print - ""; |
---|
675 | #- |
---|
676 | # That's all folks |
---|
677 | #- |
---|
678 | |
---|
679 | if [ ${NbErr} -ne 0 ] ; then |
---|
680 | echo "################ ERROR ################" |
---|
681 | echo "${NbErr} invalid JobName(s) found, check the log" |
---|
682 | fi |
---|
683 | |
---|
684 | |
---|
685 | exit 0; |
---|