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