1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip, Christian Laguerre |
---|
5 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
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 | #========================================================= |
---|
15 | # The documentation of this file can be automatically generated |
---|
16 | # if you use the prefix #D- for comments to be extracted. |
---|
17 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
18 | #========================================================= |
---|
19 | |
---|
20 | #D-#================================================== |
---|
21 | #D-LibIGCM_sys for obelix |
---|
22 | #D-#================================================== |
---|
23 | #D- |
---|
24 | #D- This ksh library if a layer under some usefull |
---|
25 | #D-environment variables and shell commands. |
---|
26 | #D-All those definitions depend on host particularities. |
---|
27 | #D-It manages a stack mechanism and test validity of operations. |
---|
28 | #D-All function described bellow must be prefixed by IGCM_sys. |
---|
29 | |
---|
30 | #==================================================== |
---|
31 | # libIGCM_sys PARAMETERS |
---|
32 | #==================================================== |
---|
33 | |
---|
34 | #==================================================== |
---|
35 | # set DEBUG_sys to true to output calls of function |
---|
36 | typeset -r DEBUG_sys=${DEBUG_sys:=true} |
---|
37 | |
---|
38 | #==================================================== |
---|
39 | # Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get) |
---|
40 | typeset -r DRYRUN=${DRYRUN:=0} |
---|
41 | |
---|
42 | # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! |
---|
43 | # ------------------------------------------------------------------------------------- |
---|
44 | # | DRYRUN= | Date computations, | sys_Get | Exe | sys_Put_Out; sys_Put_Rest | |
---|
45 | # | | Cp/Exe/param/files | | | | |
---|
46 | # | | Chmod Qsub | | | | |
---|
47 | # ------------------------------------------------------------------------------------- |
---|
48 | # | 0 | yes | yes | yes | yes | |
---|
49 | # ------------------------------------------------------------------------------------- |
---|
50 | # | 1 | yes | yes | yes | no | |
---|
51 | # ------------------------------------------------------------------------------------- |
---|
52 | # | 2 | yes | yes | no | no | |
---|
53 | # ------------------------------------------------------------------------------------- |
---|
54 | # | 3 | yes | no | no | no | |
---|
55 | # ------------------------------------------------------------------------------------- |
---|
56 | |
---|
57 | #===================================================== |
---|
58 | # Global Variables : |
---|
59 | #===================================================== |
---|
60 | # Language : "fr" or "en" |
---|
61 | typeset -r MYLANG="fr" |
---|
62 | |
---|
63 | #===================================================== |
---|
64 | # Host user names project maxCpuTime |
---|
65 | # $hostname ou hostname |
---|
66 | typeset HOST=${HOST:=$( hostname )} |
---|
67 | # $username ou whoami |
---|
68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
69 | # $hostname of the MASTER job |
---|
70 | typeset MASTER=${MASTER:=$( hostname )} |
---|
71 | # project name |
---|
72 | typeset PROJECT=NONE |
---|
73 | # jobWarningDelay in seconds |
---|
74 | typeset jobWarningDelay=${PBS_WALLTIME} |
---|
75 | |
---|
76 | #D- |
---|
77 | #D-#================================================== |
---|
78 | #D-Program used in libIGCM |
---|
79 | #D-#================================================== |
---|
80 | |
---|
81 | # Submit command |
---|
82 | typeset SUBMIT=${SUBMIT:=qsub} |
---|
83 | # rsync with path |
---|
84 | typeset -r RSYNC=/usr/bin/rsync |
---|
85 | # RSYNC_opt args to rsync |
---|
86 | typeset -r RSYNC_opt="-va" |
---|
87 | # ie storage filesystem |
---|
88 | typeset -r STOREHOST=${MASTER} |
---|
89 | |
---|
90 | #==================================================== |
---|
91 | # Set environment tools (ferret, nco, cdo, rebuild, ...) |
---|
92 | #==================================================== |
---|
93 | . /home/users/igcmg/.atlas_env_asterix_ksh |
---|
94 | export PATH=${PATH}:/home/users/igcmg/rebuild/bin/ |
---|
95 | |
---|
96 | #==================================================== |
---|
97 | # Host specific DIRECTORIES |
---|
98 | #==================================================== |
---|
99 | |
---|
100 | #==================================================== |
---|
101 | #- MirrorlibIGCM for frontend |
---|
102 | typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
103 | |
---|
104 | #==================================================== |
---|
105 | #- libIGCM_POST for frontend |
---|
106 | typeset -r libIGCM_POST=${libIGCM} |
---|
107 | |
---|
108 | #==================================================== |
---|
109 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
110 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
111 | |
---|
112 | #==================================================== |
---|
113 | #- SUBMIT_DIR : submission dir |
---|
114 | if [ X${PBS_O_WORKDIR} != X ] ; then |
---|
115 | typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}} |
---|
116 | else |
---|
117 | typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PWD}} |
---|
118 | fi |
---|
119 | |
---|
120 | #==================================================== |
---|
121 | #- IN |
---|
122 | typeset -r R_IN=${R_IN:=/home/orchideeshare/igcmg/IGCM} |
---|
123 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/home/orchideeshare/igcmg/IGCM} |
---|
124 | |
---|
125 | #==================================================== |
---|
126 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
127 | if [ X${PBS_JOBID} != X ] ; then |
---|
128 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/scratch/$PBS_O_LOGNAME.$PBS_JOBID} |
---|
129 | else |
---|
130 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$} |
---|
131 | fi |
---|
132 | |
---|
133 | #==================================================== |
---|
134 | #- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs |
---|
135 | typeset -r OUTCOMMAND_PATH=/tmp |
---|
136 | |
---|
137 | #==================================================== |
---|
138 | #- HOST_MPIRUN_COMMAND |
---|
139 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"} |
---|
140 | |
---|
141 | #==================================================== |
---|
142 | #- Max number of arguments passed to nco operator or demigration command |
---|
143 | UNIX_MAX_LIMIT=360 |
---|
144 | |
---|
145 | #==================================================== |
---|
146 | #- set PackDefault to false on obelix |
---|
147 | PackDefault=false |
---|
148 | |
---|
149 | #==================================================== |
---|
150 | #- Default number of MPI task for IPSL coupled model |
---|
151 | #- required for backward compatibility |
---|
152 | #- |
---|
153 | DEFAULT_NUM_PROC_OCE=5 |
---|
154 | DEFAULT_NUM_PROC_CPL=1 |
---|
155 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
156 | |
---|
157 | #D-#================================================== |
---|
158 | #D-function IGCM_sys_defineArchives |
---|
159 | #D-* Purpose: |
---|
160 | #D-* Define ARCHIVE : Dedicated to large files |
---|
161 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
162 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
163 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
164 | #D-* Define R_BUF : Output tree located on STORAGE hosting files waiting for rebuild or pack processes |
---|
165 | #D-* if SpaceName=TEST nothing special will hapen |
---|
166 | #D-* Examples: |
---|
167 | #D- |
---|
168 | function IGCM_sys_defineArchives { |
---|
169 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
170 | |
---|
171 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
172 | #==================================================== |
---|
173 | #- ARCHIVE (dedicated to large files) |
---|
174 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
175 | else |
---|
176 | #==================================================== |
---|
177 | #- ARCHIVE (dedicated to large files) |
---|
178 | ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}} |
---|
179 | fi |
---|
180 | |
---|
181 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
182 | #==================================================== |
---|
183 | #- STORAGE (dedicated to small/medium files) |
---|
184 | STORAGE=${config_UserChoices_STORAGE} |
---|
185 | else |
---|
186 | #==================================================== |
---|
187 | #- STORAGE (dedicated to small/medium files) |
---|
188 | STORAGE=${ARCHIVE} |
---|
189 | fi |
---|
190 | |
---|
191 | # ON OBELIX NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST |
---|
192 | |
---|
193 | #==================================================== |
---|
194 | #- R_OUT |
---|
195 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
196 | |
---|
197 | #==================================================== |
---|
198 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
199 | R_FIG=${STORAGE}/IGCM_OUT |
---|
200 | |
---|
201 | #==================================================== |
---|
202 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
203 | R_BUF=${STORAGE}/IGCM_OUT |
---|
204 | |
---|
205 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
206 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
207 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
208 | |
---|
209 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
210 | } |
---|
211 | |
---|
212 | #D-#================================================== |
---|
213 | #D-function IGCM_sys_RshArchive |
---|
214 | #D-* Purpose: Archive rsh command |
---|
215 | #D-* Examples: |
---|
216 | #D- |
---|
217 | function IGCM_sys_RshArchive { |
---|
218 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
219 | /bin/ksh <<-EOF |
---|
220 | ${@} |
---|
221 | EOF |
---|
222 | status=$? |
---|
223 | if [ ${status} -gt 0 ] ; then |
---|
224 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
225 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
226 | fi |
---|
227 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
228 | } |
---|
229 | |
---|
230 | #D-#================================================== |
---|
231 | #D-function IGCM_sys_RshArchive_NoError |
---|
232 | #D-* Purpose: Archive rsh command, without error |
---|
233 | #D-* used only in monitoring.job |
---|
234 | #D-* Examples: |
---|
235 | #D- |
---|
236 | function IGCM_sys_RshArchive_NoError { |
---|
237 | IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ |
---|
238 | /bin/ksh <<-EOF |
---|
239 | ${@} 2> /dev/null |
---|
240 | EOF |
---|
241 | IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" |
---|
242 | } |
---|
243 | |
---|
244 | #D-#================================================== |
---|
245 | #D-function IGCM_sys_MkdirArchive |
---|
246 | #D-* Purpose: Mkdir on Archive |
---|
247 | #D-* Examples: |
---|
248 | #D- |
---|
249 | function IGCM_sys_MkdirArchive { |
---|
250 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
251 | if ( $DEBUG_sys ) ; then |
---|
252 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
253 | fi |
---|
254 | #- creation de repertoire sur le serveur fichier |
---|
255 | if [ ! -d ${1} ]; then |
---|
256 | \mkdir -p $1 |
---|
257 | status=$? |
---|
258 | |
---|
259 | if [ ${status} -gt 0 ] ; then |
---|
260 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
261 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
262 | fi |
---|
263 | fi |
---|
264 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
265 | } |
---|
266 | |
---|
267 | #D-#================================================== |
---|
268 | #D-function IGCM_sys_TestDirArchive |
---|
269 | #D-* Purpose: Test Directory that must exists on Archive |
---|
270 | #D-* Examples: |
---|
271 | #D- |
---|
272 | function IGCM_sys_TestDirArchive { |
---|
273 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
274 | if ( $DEBUG_sys ) ; then |
---|
275 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
276 | fi |
---|
277 | typeset ExistFlag |
---|
278 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
279 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
280 | return ${ExistFlag} |
---|
281 | } |
---|
282 | |
---|
283 | #D-#================================================== |
---|
284 | #D-function IGCM_sys_IsFileArchived |
---|
285 | #D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only |
---|
286 | #D-* Examples: |
---|
287 | #D- |
---|
288 | function IGCM_sys_IsFileArchived { |
---|
289 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
290 | if ( $DEBUG_sys ) ; then |
---|
291 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
292 | fi |
---|
293 | typeset IsArchivedFlag |
---|
294 | # Never archived for this system |
---|
295 | IsArchivedFlag=1 |
---|
296 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
297 | |
---|
298 | return ${IsArchivedFlag} |
---|
299 | } |
---|
300 | |
---|
301 | #D-#================================================== |
---|
302 | #D-function IGCM_sys_TestFileArchive |
---|
303 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
304 | #D-* Examples: |
---|
305 | #D- |
---|
306 | function IGCM_sys_TestFileArchive { |
---|
307 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
308 | typeset ExistFlag |
---|
309 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
310 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
311 | |
---|
312 | return ${ExistFlag} |
---|
313 | } |
---|
314 | |
---|
315 | #D-#================================================== |
---|
316 | #D-function IGCM_sys_CountFileArchive |
---|
317 | #D-* Purpose: Count files on Archive filesystem |
---|
318 | #D-* Examples: |
---|
319 | #D- |
---|
320 | function IGCM_sys_CountFileArchive { |
---|
321 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
322 | ls ${@} 2>/dev/null | wc -l |
---|
323 | if [ $? -gt 0 ] ; then |
---|
324 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
325 | fi |
---|
326 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
327 | } |
---|
328 | |
---|
329 | #D-#================================================== |
---|
330 | #D-function IGCM_sys_Tree |
---|
331 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
332 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
333 | #D- |
---|
334 | function IGCM_sys_Tree { |
---|
335 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
336 | if ( $DEBUG_sys ) ; then |
---|
337 | echo "IGCM_sys_Tree :" $@ |
---|
338 | fi |
---|
339 | |
---|
340 | \ls -lR ${@} |
---|
341 | |
---|
342 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
343 | } |
---|
344 | |
---|
345 | #D-#================================================== |
---|
346 | #D-function IGCM_sys_Qsub |
---|
347 | #D-* Purpose: Qsub new job |
---|
348 | #D-* Examples: |
---|
349 | #D- |
---|
350 | function IGCM_sys_Qsub { |
---|
351 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
352 | if ( $DEBUG_sys ) ; then |
---|
353 | echo "IGCM_sys_Qsub :" $@ |
---|
354 | fi |
---|
355 | typeset options status |
---|
356 | options="-o ${SUBMIT_DIR}/${Script_Output}" |
---|
357 | /usr/local/bin/qsub ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
358 | status=$? |
---|
359 | |
---|
360 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
361 | if [ ${status} -gt 0 ] ; then |
---|
362 | IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}" |
---|
363 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
364 | else |
---|
365 | JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ ) |
---|
366 | fi |
---|
367 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
368 | } |
---|
369 | |
---|
370 | #D-#================================================== |
---|
371 | #D-function IGCM_sys_QsubPost |
---|
372 | #D-* Purpose: Qsub new job on scalaire |
---|
373 | #D-* Examples: |
---|
374 | #D- |
---|
375 | function IGCM_sys_QsubPost { |
---|
376 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
377 | if ( $DEBUG_sys ) ; then |
---|
378 | echo "IGCM_sys_QsubPost :" $@ |
---|
379 | fi |
---|
380 | typeset options status |
---|
381 | options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}" |
---|
382 | /usr/local/bin/qsub ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
383 | status=$? |
---|
384 | |
---|
385 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
386 | if [ ${status} -gt 0 ] ; then |
---|
387 | IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}" |
---|
388 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
389 | else |
---|
390 | JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ ) |
---|
391 | fi |
---|
392 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
393 | } |
---|
394 | |
---|
395 | #D-************************* |
---|
396 | #D- File transfer functions |
---|
397 | #D-************************* |
---|
398 | #D- |
---|
399 | |
---|
400 | #D-#================================================== |
---|
401 | #D-function IGCM_sys_RmRunDir |
---|
402 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
403 | #D- scheduler will do the job) |
---|
404 | #D-* Examples: |
---|
405 | #D- |
---|
406 | function IGCM_sys_RmRunDir { |
---|
407 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
408 | if ( $DEBUG_sys ) ; then |
---|
409 | echo "IGCM_sys_RmRunDir :" $@ |
---|
410 | echo "Dummy call, let the scheduler do that." |
---|
411 | fi |
---|
412 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
413 | } |
---|
414 | |
---|
415 | #D-#================================================== |
---|
416 | #D-function IGCM_sys_Put_Dir |
---|
417 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
418 | #D-* Examples: |
---|
419 | #D- |
---|
420 | function IGCM_sys_Put_Dir { |
---|
421 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
422 | if ( $DEBUG_sys ) ; then |
---|
423 | echo "IGCM_sys_Put_Dir :" $@ |
---|
424 | fi |
---|
425 | if [ $DRYRUN = 0 ]; then |
---|
426 | if [ ! -d ${1} ] ; then |
---|
427 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
428 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
429 | return |
---|
430 | fi |
---|
431 | |
---|
432 | typeset status |
---|
433 | |
---|
434 | # Only if we use rsync |
---|
435 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
436 | # |
---|
437 | #USUAL WAY |
---|
438 | \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
439 | status=$? |
---|
440 | |
---|
441 | if [ ${status} -gt 0 ] ; then |
---|
442 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
443 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
444 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
445 | else |
---|
446 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
447 | fi |
---|
448 | fi |
---|
449 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
450 | } |
---|
451 | |
---|
452 | #D-#================================================== |
---|
453 | #D-function IGCM_sys_Get_Dir |
---|
454 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
455 | #D-* Examples: |
---|
456 | #D- |
---|
457 | function IGCM_sys_Get_Dir { |
---|
458 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
459 | if ( $DEBUG_sys ) ; then |
---|
460 | echo "IGCM_sys_Get_Dir :" $@ |
---|
461 | fi |
---|
462 | if [ $DRYRUN = 0 ]; then |
---|
463 | typeset NB_ESSAI DELAI status i |
---|
464 | # number of tentative |
---|
465 | NB_ESSAI=3 |
---|
466 | # time delay between tentative |
---|
467 | DELAI=2 |
---|
468 | |
---|
469 | # |
---|
470 | # USUAL WAY |
---|
471 | i=0 |
---|
472 | while [ $i -lt $NB_ESSAI ] ; do |
---|
473 | \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
474 | status=$? |
---|
475 | if [ ${status} -gt 0 ] ; then |
---|
476 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
477 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again." |
---|
478 | sleep $DELAI |
---|
479 | else |
---|
480 | break |
---|
481 | fi |
---|
482 | (( i = i + 1 )) |
---|
483 | done |
---|
484 | |
---|
485 | if [ ${status} -gt 0 ] ; then |
---|
486 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
487 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
488 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
489 | else |
---|
490 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
491 | fi |
---|
492 | fi |
---|
493 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
494 | } |
---|
495 | |
---|
496 | #D-#================================================== |
---|
497 | #D-function IGCM_sys_Put_Rest |
---|
498 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
499 | #D- File and target directory must exist. |
---|
500 | #D-* Examples: |
---|
501 | #D- |
---|
502 | function IGCM_sys_Put_Rest { |
---|
503 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
504 | if ( $DEBUG_sys ) ; then |
---|
505 | echo "IGCM_sys_Put_Rest :" $@ |
---|
506 | fi |
---|
507 | if [ $DRYRUN = 0 ]; then |
---|
508 | if [ ! -f ${1} ] ; then |
---|
509 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
510 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
511 | fi |
---|
512 | |
---|
513 | typeset status |
---|
514 | # |
---|
515 | # USUAL WAY |
---|
516 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
517 | status=$? |
---|
518 | |
---|
519 | # #RSYNC WITH NETWORK SSH CALL |
---|
520 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
521 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
522 | |
---|
523 | # #RSYNC WITH NFS USE |
---|
524 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
525 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
526 | |
---|
527 | # status=$? |
---|
528 | # IGCM_sys_Rsync_out $status |
---|
529 | |
---|
530 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
531 | # (( status=status+$? )) |
---|
532 | |
---|
533 | if [ ${status} -gt 0 ] ; then |
---|
534 | IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
535 | [ -f ${1} ] && ls -l ${1} |
---|
536 | [ -f ${2} ] && ls -l ${2} |
---|
537 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
538 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
539 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
540 | else |
---|
541 | |
---|
542 | if [ X${JobType} = XRUN ] ; then |
---|
543 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
544 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
545 | fi |
---|
546 | |
---|
547 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
548 | fi |
---|
549 | fi |
---|
550 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
551 | } |
---|
552 | |
---|
553 | #D-#================================================== |
---|
554 | #D-function IGCM_sys_Put_Out |
---|
555 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
556 | #D-* Examples: |
---|
557 | #D- |
---|
558 | function IGCM_sys_Put_Out { |
---|
559 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
560 | if ( $DEBUG_sys ) ; then |
---|
561 | echo "IGCM_sys_Put_Out :" $@ |
---|
562 | fi |
---|
563 | |
---|
564 | typeset status |
---|
565 | |
---|
566 | if [ $DRYRUN = 0 ]; then |
---|
567 | if [ ! -f ${1} ] ; then |
---|
568 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
569 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
570 | return 1 |
---|
571 | fi |
---|
572 | # |
---|
573 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
574 | # |
---|
575 | if [ X${JobType} = XRUN ] ; then |
---|
576 | if [ X${3} = X ] ; then |
---|
577 | IGCM_sys_Chmod 444 ${1} |
---|
578 | fi |
---|
579 | fi |
---|
580 | # |
---|
581 | |
---|
582 | echo ${RSYNC} ${RSYNC_opt} $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
583 | ${RSYNC} ${RSYNC_opt} $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
584 | status=$? |
---|
585 | IGCM_sys_Rsync_out $status |
---|
586 | |
---|
587 | ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
588 | (( status=status+$? )) |
---|
589 | |
---|
590 | if [ ${status} -gt 0 ] ; then |
---|
591 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}" |
---|
592 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
593 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
594 | else |
---|
595 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
596 | fi |
---|
597 | fi |
---|
598 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
599 | return 0 |
---|
600 | } |
---|
601 | |
---|
602 | #D-#================================================== |
---|
603 | #D-function IGCM_sys_Get |
---|
604 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
605 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
606 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
607 | function IGCM_sys_Get { |
---|
608 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
609 | |
---|
610 | typeset DEST status dm_liste |
---|
611 | |
---|
612 | if ( $DEBUG_sys ) ; then |
---|
613 | echo "IGCM_sys_Get :" $@ |
---|
614 | fi |
---|
615 | if [ $DRYRUN -le 2 ]; then |
---|
616 | if [ X${1} = X'/l' ] ; then |
---|
617 | eval set +A dm_liste \${${2}} |
---|
618 | else |
---|
619 | dm_liste=${1} |
---|
620 | fi |
---|
621 | eval DEST=\${${#}} |
---|
622 | |
---|
623 | # test if the (first) file is present in the old computation : |
---|
624 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
625 | status=$? |
---|
626 | if [ ${status} -gt 0 ] ; then |
---|
627 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
628 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
629 | return |
---|
630 | fi |
---|
631 | |
---|
632 | #USUAL WAY |
---|
633 | \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
634 | status=$? |
---|
635 | |
---|
636 | if [ ${status} -gt 0 ] ; then |
---|
637 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
638 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
639 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
640 | else |
---|
641 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
642 | fi |
---|
643 | fi |
---|
644 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
645 | } |
---|
646 | |
---|
647 | #D-#================================================== |
---|
648 | #D-function IGCM_sys_GetDate_Monitoring |
---|
649 | #D-* Purpose: get the last year for which the monitoring has been computed |
---|
650 | #D-* Examples: |
---|
651 | #D- |
---|
652 | function IGCM_sys_GetDate_Monitoring { |
---|
653 | IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@ |
---|
654 | if ( $DEBUG_sys ) ; then |
---|
655 | echo "IGCM_sys_GetDate_Monitoring :" $@ |
---|
656 | fi |
---|
657 | |
---|
658 | eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' ) |
---|
659 | |
---|
660 | IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring" |
---|
661 | } |
---|
662 | |
---|
663 | #D-#================================================== |
---|
664 | #D-function IGCM_sys_Dods_Rm |
---|
665 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
666 | #D-* Examples: |
---|
667 | #D- |
---|
668 | function IGCM_sys_Dods_Rm { |
---|
669 | if ( $DEBUG_sys ) ; then |
---|
670 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
671 | fi |
---|
672 | return 0 |
---|
673 | } |
---|
674 | |
---|
675 | #D-#================================================== |
---|
676 | #D-function IGCM_sys_Dods_Cp |
---|
677 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
678 | #D-* Examples: |
---|
679 | #D- |
---|
680 | function IGCM_sys_Dods_Cp { |
---|
681 | if ( $DEBUG_sys ) ; then |
---|
682 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
683 | fi |
---|
684 | return 0 |
---|
685 | } |
---|
686 | |
---|
687 | #D-#================================================== |
---|
688 | #D-function IGCM_sys_Put_Dods |
---|
689 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
690 | #D-* Examples: |
---|
691 | #D- |
---|
692 | function IGCM_sys_Put_Dods { |
---|
693 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
694 | if ( $DEBUG_sys ) ; then |
---|
695 | echo "IGCM_sys_Put_Dods :" $@ |
---|
696 | fi |
---|
697 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
698 | } |
---|
699 | |
---|
700 | ############################################################## |
---|
701 | # REBUILD OPERATOR |
---|
702 | |
---|
703 | #D-#================================================== |
---|
704 | #D-function IGCM_sys_sync |
---|
705 | #D-* Purpose: flush buffer on disk (dummy function on Obelix) |
---|
706 | #D-* Examples: |
---|
707 | #D- |
---|
708 | function IGCM_sys_sync { |
---|
709 | IGCM_debug_PushStack "IGCM_sys_sync" $@ |
---|
710 | if ( $DEBUG_sys ) ; then |
---|
711 | echo "IGCM_sys_sync :" $@ |
---|
712 | echo "Dummy call, let the system do that." |
---|
713 | fi |
---|
714 | IGCM_debug_PopStack "IGCM_sys_sync" |
---|
715 | } |
---|
716 | |
---|
717 | ############################################################ |
---|
718 | # Activate Running Environnment Variables |
---|
719 | |
---|
720 | #D-#================================================== |
---|
721 | #D-function IGCM_sys_activ_variables |
---|
722 | #D-* Purpose: set environement variables prior to execution |
---|
723 | #D-* Examples: |
---|
724 | #D- |
---|
725 | function IGCM_sys_activ_variables { |
---|
726 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
727 | if ( $DEBUG_sys ) ; then |
---|
728 | echo "IGCM_sys_activ_variables" |
---|
729 | fi |
---|
730 | |
---|
731 | # -------------------------------------------------------------------- |
---|
732 | #D- MPI specifications |
---|
733 | # -------------------------------------------------------------------- |
---|
734 | |
---|
735 | # -------------------------------------------------------------------- |
---|
736 | #D- Other specifications |
---|
737 | # -------------------------------------------------------------------- |
---|
738 | |
---|
739 | ulimit -s unlimited |
---|
740 | |
---|
741 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
742 | } |
---|
743 | |
---|
744 | ############################################################ |
---|
745 | # Desactivate Running Environnment Variables |
---|
746 | |
---|
747 | #D-#================================================== |
---|
748 | #D-function IGCM_sys_desactiv_variables |
---|
749 | #D-* Purpose: unset environement variables after execution |
---|
750 | #D-* Examples: |
---|
751 | #D- |
---|
752 | function IGCM_sys_desactiv_variables { |
---|
753 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
754 | if ( $DEBUG_sys ) ; then |
---|
755 | echo "IGCM_sys_desactiv_variables" |
---|
756 | fi |
---|
757 | # -------------------------------------------------------------------- |
---|
758 | #D- MPI specifications |
---|
759 | # -------------------------------------------------------------------- |
---|
760 | |
---|
761 | # -------------------------------------------------------------------- |
---|
762 | #D- Other specifications |
---|
763 | # -------------------------------------------------------------------- |
---|
764 | |
---|
765 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
766 | } |
---|
767 | |
---|
768 | ############################################################ |
---|
769 | # Update job headers to be used by the scheduler |
---|
770 | |
---|
771 | #D-#================================================== |
---|
772 | #D-function IGCM_sys_updateHeaders |
---|
773 | #D-* Purpose: Update job headers to be used by the scheduler |
---|
774 | #D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP |
---|
775 | #D- |
---|
776 | function IGCM_sys_updateHeaders { |
---|
777 | IGCM_debug_PushStack "IGCM_sys_updateHeaders" |
---|
778 | if ( $DEBUG_sys ) ; then |
---|
779 | echo "IGCM_sys_updateHeaders" |
---|
780 | fi |
---|
781 | typeset file |
---|
782 | file=$1 |
---|
783 | |
---|
784 | if [ ${executionType} -eq 1 ] ; then |
---|
785 | # MPMD + MPI |
---|
786 | sed -e "/::openMPthreads::/d" \ |
---|
787 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
788 | ${file} > ${file}.tmp |
---|
789 | |
---|
790 | elif [ ${executionType} -eq 2 ] ; then |
---|
791 | # MPMD + MPI + OMP |
---|
792 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
793 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
794 | ${file} > ${file}.tmp |
---|
795 | |
---|
796 | elif [ ${executionType} -eq 3 ] ; then |
---|
797 | # SPMD + MPI/OMP |
---|
798 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
799 | -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
800 | ${file} > ${file}.tmp |
---|
801 | |
---|
802 | elif [ ${executionType} -eq 4 ] ; then |
---|
803 | # SPMD + MPI only |
---|
804 | sed -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
805 | -e "/::openMPthreads::/d" \ |
---|
806 | ${file} > ${file}.tmp |
---|
807 | |
---|
808 | elif [ ${executionType} -eq 5 ] ; then |
---|
809 | # SPMD + OMP only |
---|
810 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
811 | -e "/::JobNumProcTot::/d" \ |
---|
812 | ${file} > ${file}.tmp |
---|
813 | |
---|
814 | elif [ ${executionType} -eq 6 ] ; then |
---|
815 | # SEQUENTIAL THEN |
---|
816 | sed -e "s/::JobNumProcTot::/1/" \ |
---|
817 | -e "/::openMPthreads::/d" \ |
---|
818 | ${file} > ${file}.tmp |
---|
819 | |
---|
820 | fi |
---|
821 | |
---|
822 | IGCM_sys_Mv ${file}.tmp ${file} |
---|
823 | |
---|
824 | IGCM_debug_PopStack "IGCM_sys_updateHeaders" |
---|
825 | } |
---|
826 | |
---|
827 | ############################################################ |
---|
828 | # Build MPI/OMP scripts run file (dummy function) |
---|
829 | |
---|
830 | #D-#================================================== |
---|
831 | #D-function IGCM_sys_build_run_file |
---|
832 | #D-* Purpose: build run file (deprecated) |
---|
833 | #D-* Examples: |
---|
834 | #D- |
---|
835 | function IGCM_sys_build_run_file { |
---|
836 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
837 | } |
---|
838 | |
---|
839 | ############################################################ |
---|
840 | # Build MPI/OMP scripts |
---|
841 | |
---|
842 | #D-#================================================== |
---|
843 | #D-function IGCM_sys_build_execution_scripts |
---|
844 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
845 | #D-* Examples: |
---|
846 | #D- |
---|
847 | function IGCM_sys_build_execution_scripts |
---|
848 | { |
---|
849 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
850 | if ( $DEBUG_sys ) ; then |
---|
851 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
852 | fi |
---|
853 | |
---|
854 | EXECUTION=${HOST_MPIRUN_COMMAND} |
---|
855 | |
---|
856 | # MPMD mode |
---|
857 | if ( ${OK_PARA_MPMD} ) ; then |
---|
858 | |
---|
859 | # Only MPI (MPMD) |
---|
860 | if ( ! ${OK_PARA_OMP} ) ; then |
---|
861 | |
---|
862 | if [ -f run_file ] ; then |
---|
863 | IGCM_sys_Rm -f run_file |
---|
864 | fi |
---|
865 | touch run_file |
---|
866 | |
---|
867 | # Build run_file |
---|
868 | |
---|
869 | # First loop on the components for the coupler ie oasis (only if oasis3) |
---|
870 | # the coupler ie oasis3 must be the first one |
---|
871 | for comp in ${config_ListOfComponents[*]} ; do |
---|
872 | |
---|
873 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
874 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
875 | |
---|
876 | # for CPL component only |
---|
877 | if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
878 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
879 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
880 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file |
---|
881 | fi |
---|
882 | done |
---|
883 | |
---|
884 | # Then second loop on the components |
---|
885 | for comp in ${config_ListOfComponents[*]} ; do |
---|
886 | |
---|
887 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
888 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
889 | |
---|
890 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
891 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
892 | |
---|
893 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
894 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
895 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
896 | fi |
---|
897 | done |
---|
898 | |
---|
899 | EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file" |
---|
900 | |
---|
901 | IGCM_sys_Chmod u+x run_file |
---|
902 | if ( $DEBUG_sys ) ; then |
---|
903 | echo "run_file contains : " |
---|
904 | cat run_file |
---|
905 | fi |
---|
906 | |
---|
907 | # MPI-OpenMP (MPMD) |
---|
908 | else |
---|
909 | |
---|
910 | # Hosts treatment |
---|
911 | ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp |
---|
912 | |
---|
913 | i=0 |
---|
914 | rm -f hosts |
---|
915 | IGCM_debug_Print 1 "sys Obelix, Hosts available :" |
---|
916 | for nodes in `cat hosts.tmp` ; do |
---|
917 | host[$i]=$nodes |
---|
918 | echo "${host[$i]} slots=1 max_slots=1" >> hosts |
---|
919 | IGCM_debug_Print 1 ${host[$i]} |
---|
920 | i=$((i+1)) |
---|
921 | done |
---|
922 | rm -f hosts.tmp |
---|
923 | |
---|
924 | listnodes=${host[*]} |
---|
925 | |
---|
926 | EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts" |
---|
927 | |
---|
928 | # Initialisation |
---|
929 | rank=0 |
---|
930 | current_core=0 |
---|
931 | core_per_node=6 |
---|
932 | init_exec=n |
---|
933 | |
---|
934 | # Loop on the components |
---|
935 | for comp in ${config_ListOfComponents[*]} ; do |
---|
936 | |
---|
937 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
938 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
939 | |
---|
940 | # Not possible if oasis has an executable (i.e old version of oasis3) |
---|
941 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" = "XCPL" ] ) ; then |
---|
942 | IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version" |
---|
943 | IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler" |
---|
944 | IGCM_debug_Verif_Exit |
---|
945 | fi |
---|
946 | |
---|
947 | # Only if we really have an executable for the component : |
---|
948 | if [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
949 | |
---|
950 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
951 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
952 | |
---|
953 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
954 | echo "" >> script_${ExeNameOut}.ksh |
---|
955 | if [ ${comp_proc_omp_loc} -gt 1 ] ; then |
---|
956 | |
---|
957 | # Check if the number of threads is correct |
---|
958 | case ${comp_proc_omp_loc} in |
---|
959 | 2|4|6) |
---|
960 | IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads" |
---|
961 | ;; |
---|
962 | *) |
---|
963 | IGCM_debug_Exit "ERROR with OMP parameters !" |
---|
964 | IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads" |
---|
965 | IGCM_debug_Print 2 "Only 2,4,6 as number of OMP threads are possible " |
---|
966 | IGCM_debug_Verif_Exit |
---|
967 | ;; |
---|
968 | esac |
---|
969 | #echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
970 | #echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
971 | #echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
972 | echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh |
---|
973 | echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
974 | fi |
---|
975 | |
---|
976 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
977 | echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK )) " >> script_${ExeNameOut}.ksh |
---|
978 | echo "MYMPIRANK=\$(printf '%3.3d\n' \${MYMPIRANK})" >> script_${ExeNameOut}.ksh |
---|
979 | echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh |
---|
980 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
981 | |
---|
982 | if [ ${init_exec} = y ] ; then |
---|
983 | EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
984 | else |
---|
985 | EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
986 | init_exec=y |
---|
987 | fi |
---|
988 | |
---|
989 | # Build rankfile : method used to assign cores and nodes for the MPI process |
---|
990 | # Ex : |
---|
991 | #rank 0=curie5296 slot=0,1,2,3 |
---|
992 | #rank 1=curie5296 slot=4,5,6,7 |
---|
993 | # Example of final command : |
---|
994 | # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh |
---|
995 | # with script_lmdz.x.ksh : |
---|
996 | # #!/bin/ksh |
---|
997 | #export OMP_STACKSIZE=200M |
---|
998 | #export OMP_NUM_THREADS=4 |
---|
999 | #./lmdz.x |
---|
1000 | |
---|
1001 | for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do |
---|
1002 | (( index_host = current_core / core_per_node )) |
---|
1003 | host_value=${host[${index_host}]} |
---|
1004 | (( slot = current_core % core_per_node )) |
---|
1005 | virg="," |
---|
1006 | string_final="" |
---|
1007 | for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do |
---|
1008 | string=$index$virg |
---|
1009 | string_final=$string_final$string |
---|
1010 | done |
---|
1011 | string_final=$( echo $string_final | sed "s/.$//" ) |
---|
1012 | echo "rank $rank=$host_value slot=$string_final" >> rankfile |
---|
1013 | (( rank = rank + 1 )) |
---|
1014 | (( current_core = current_core + comp_proc_omp_loc )) |
---|
1015 | done |
---|
1016 | fi |
---|
1017 | done |
---|
1018 | fi |
---|
1019 | |
---|
1020 | # Only one executable (SPMD mode). |
---|
1021 | else |
---|
1022 | |
---|
1023 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1024 | |
---|
1025 | # Only if we really have an executable for the component : |
---|
1026 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1027 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
1028 | |
---|
1029 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1030 | echo "" >> script_${ExeNameOut}.ksh |
---|
1031 | if ( ${OK_PARA_OMP} ) ; then |
---|
1032 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1033 | echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh |
---|
1034 | echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
1035 | fi |
---|
1036 | if ( ${OK_PARA_MPI} ) ; then |
---|
1037 | # Default : mpirun used if nb_proc gt 1 |
---|
1038 | # pour sortie out/err par process |
---|
1039 | echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}" >> script_${ExeNameOut}.ksh |
---|
1040 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1041 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1042 | EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh" |
---|
1043 | else |
---|
1044 | # Default : mpirun is NOT used if nb_proc eq 1 |
---|
1045 | # pour sortie out/err par process |
---|
1046 | echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
1047 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1048 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1049 | EXECUTION="time ./script_${ExeNameOut}.ksh" |
---|
1050 | fi |
---|
1051 | |
---|
1052 | IGCM_debug_Print 1 "sys Obelix : script_${ExeNameOut}.ksh contains" |
---|
1053 | cat script_${ExeNameOut}.ksh |
---|
1054 | |
---|
1055 | fi |
---|
1056 | |
---|
1057 | done |
---|
1058 | |
---|
1059 | fi |
---|
1060 | |
---|
1061 | IGCM_debug_Print 1 "sys Obelix : execution command is" |
---|
1062 | IGCM_debug_Print 1 "$EXECUTION" |
---|
1063 | |
---|
1064 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
1065 | } |
---|
1066 | |
---|
1067 | #D-#================================================== |
---|
1068 | #D-function IGCM_sys_check_path |
---|
1069 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
1070 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
1071 | #D-* Examples: |
---|
1072 | #D- |
---|
1073 | function IGCM_sys_check_path { |
---|
1074 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
1075 | if ( $DEBUG_sys ) ; then |
---|
1076 | echo "IGCM_sys_check_path" |
---|
1077 | fi |
---|
1078 | |
---|
1079 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then |
---|
1080 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
1081 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
1082 | IGCM_debug_Exit "This will stop the job" |
---|
1083 | fi |
---|
1084 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
1085 | } |
---|
1086 | |
---|
1087 | #D-#================================================== |
---|
1088 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
1089 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
1090 | #D-* Examples: |
---|
1091 | #D- |
---|
1092 | function IGCM_sys_check_quota { |
---|
1093 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
1094 | if ( $DEBUG_sys ) ; then |
---|
1095 | echo "IGCM_sys_check_quota" |
---|
1096 | fi |
---|
1097 | |
---|
1098 | # TO BE IMPLEMENTED |
---|
1099 | |
---|
1100 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
1101 | } |
---|
1102 | |
---|
1103 | #D-#================================================== |
---|
1104 | #D-function IGCM_sys_projectAccounting |
---|
1105 | #D-* Purpose: store project accounting information in a file |
---|
1106 | #D-* Examples: |
---|
1107 | #D- |
---|
1108 | function IGCM_sys_projectAccounting { |
---|
1109 | IGCM_debug_PushStack "IGCM_sys_projectAccounting" |
---|
1110 | if ( $DEBUG_sys ) ; then |
---|
1111 | echo "IGCM_sys_check_quota" |
---|
1112 | fi |
---|
1113 | |
---|
1114 | touch $1 |
---|
1115 | |
---|
1116 | IGCM_debug_PopStack "IGCM_sys_projectAccounting" |
---|
1117 | } |
---|
1118 | |
---|
1119 | #D-#================================================== |
---|
1120 | #D-function IGCM_sys_getJobSchedulerID |
---|
1121 | #D-* Purpose: Get the job ID during execution |
---|
1122 | #D-* Examples: IGCM_sys_getJobSchedulerID jobSchedulerID |
---|
1123 | #D- |
---|
1124 | function IGCM_sys_getJobSchedulerID { |
---|
1125 | IGCM_debug_PushStack "IGCM_sys_getJobSchedulerID" |
---|
1126 | if ( $DEBUG_sys ) ; then |
---|
1127 | echo "IGCM_sys_getJobSchedulerID" |
---|
1128 | fi |
---|
1129 | |
---|
1130 | eval ${1}=$( echo ${PBS_JOBID} | awk -F. '{print $1}' ) |
---|
1131 | |
---|
1132 | IGCM_debug_PopStack "IGCM_sys_getJobSchedulerID" |
---|
1133 | } |
---|
1134 | |
---|
1135 | #D-#================================================== |
---|
1136 | #D-function IGCM_sys_GetJobID |
---|
1137 | #D-* Purpose: Get the job ID from the JobName |
---|
1138 | #D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID |
---|
1139 | #D- |
---|
1140 | function IGCM_sys_GetJobID { |
---|
1141 | IGCM_debug_PushStack "IGCM_sys_GetJobID" |
---|
1142 | if ( $DEBUG_sys ) ; then |
---|
1143 | echo "IGCM_sys_GetJobID" |
---|
1144 | fi |
---|
1145 | |
---|
1146 | # With -f option, the full job name is given in the last column |
---|
1147 | ID="$( qstat -u $2 | grep -w $1 | gawk '-F ' '{print $10}' )" |
---|
1148 | |
---|
1149 | eval ${3}=${ID} |
---|
1150 | IGCM_debug_PopStack "IGCM_sys_GetJobID" |
---|
1151 | } |
---|
1152 | |
---|
1153 | #D-#================================================== |
---|
1154 | #D-function IGCM_sys_CountJobInQueue |
---|
1155 | #D-* Purpose: Count number of users job |
---|
1156 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
1157 | #D- |
---|
1158 | function IGCM_sys_CountJobInQueue { |
---|
1159 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
1160 | if ( $DEBUG_sys ) ; then |
---|
1161 | echo "IGCM_sys_CountJobInQueue" |
---|
1162 | fi |
---|
1163 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
1164 | } |
---|
1165 | |
---|
1166 | #D-#================================================== |
---|
1167 | #D-function IGCM_sys_atlas |
---|
1168 | #D-* Purpose: encapsulate atlas call so as to manage error code and curie specificity |
---|
1169 | #D-* Examples: |
---|
1170 | #D- |
---|
1171 | function IGCM_sys_atlas { |
---|
1172 | IGCM_debug_PushStack "IGCM_sys_atlas" $@ |
---|
1173 | if ( $DEBUG_sys ) ; then |
---|
1174 | echo "IGCM_sys_atlas :" $@ |
---|
1175 | fi |
---|
1176 | |
---|
1177 | typeset status |
---|
1178 | |
---|
1179 | \atlas $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1180 | status=$? |
---|
1181 | if [ ${status} -gt 0 ] ; then |
---|
1182 | echo "IGCM_sys_atlas : error code ${status}" |
---|
1183 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1184 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1185 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
1186 | return 1 |
---|
1187 | else |
---|
1188 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
1189 | return 0 |
---|
1190 | fi |
---|
1191 | |
---|
1192 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
1193 | } |
---|
1194 | |
---|