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 and user names |
---|
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 | |
---|
72 | #D- |
---|
73 | #D-#================================================== |
---|
74 | #D-Program used in libIGCM |
---|
75 | #D-#================================================== |
---|
76 | |
---|
77 | # Submit command |
---|
78 | typeset SUBMIT=${SUBMIT:=qsub} |
---|
79 | # rsync with path |
---|
80 | typeset -r RSYNC=/usr/bin/rsync |
---|
81 | # RSYNC_opt args to rsync |
---|
82 | typeset -r RSYNC_opt="-va" |
---|
83 | # ie storage filesystem |
---|
84 | typeset -r STOREHOST=${MASTER} |
---|
85 | |
---|
86 | #==================================================== |
---|
87 | # Set environment tools (ferret, nco, cdo) |
---|
88 | #==================================================== |
---|
89 | . /home/users/brock/.atlas_env_asterix_ksh |
---|
90 | |
---|
91 | #==================================================== |
---|
92 | # Set lf95 environment |
---|
93 | #==================================================== |
---|
94 | . /usr/local/install/lf6481/bash_laheyfort_setup |
---|
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 SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}} |
---|
116 | else |
---|
117 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}} |
---|
118 | fi |
---|
119 | |
---|
120 | #==================================================== |
---|
121 | #- IN |
---|
122 | typeset -r R_IN=${R_IN:=/home/orchideeshare/igcmg/IGCM} |
---|
123 | |
---|
124 | #==================================================== |
---|
125 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
126 | if [ X${PBS_JOBID} != X ] ; then |
---|
127 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/scratch/$PBS_O_LOGNAME.$PBS_JOBID} |
---|
128 | else |
---|
129 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$} |
---|
130 | fi |
---|
131 | |
---|
132 | #==================================================== |
---|
133 | #- HOST_MPIRUN_COMMAND |
---|
134 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"} |
---|
135 | |
---|
136 | #==================================================== |
---|
137 | #- Max number of arguments passed to nco operator or demigration command |
---|
138 | UNIX_MAX_LIMIT=360 |
---|
139 | |
---|
140 | #==================================================== |
---|
141 | #- Number of core per node (max number of OpenMP task) |
---|
142 | NUM_COREPERNODE=1 |
---|
143 | |
---|
144 | #==================================================== |
---|
145 | #- Default number of MPI task for IPSL coupled model |
---|
146 | #- required for backward compatibility |
---|
147 | #- |
---|
148 | DEFAULT_NUM_PROC_OCE=1 |
---|
149 | DEFAULT_NUM_PROC_CPL=1 |
---|
150 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
151 | DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} |
---|
152 | |
---|
153 | #D-#================================================== |
---|
154 | #D-function IGCM_sys_defineArchives |
---|
155 | #D-* Purpose: |
---|
156 | #D-* Define ARCHIVE : Dedicated to large files |
---|
157 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
158 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
159 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
160 | #D-* Define R_BUF : Output tree located on STORAGE hosting files waiting for rebuild or pack processes |
---|
161 | #D-* if SpaceName=TEST nothing special will hapen |
---|
162 | #D-* Examples: |
---|
163 | #D- |
---|
164 | function IGCM_sys_defineArchives { |
---|
165 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
166 | |
---|
167 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
168 | #==================================================== |
---|
169 | #- ARCHIVE (dedicated to large files) |
---|
170 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
171 | else |
---|
172 | #==================================================== |
---|
173 | #- ARCHIVE (dedicated to large files) |
---|
174 | ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}} |
---|
175 | fi |
---|
176 | |
---|
177 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
178 | #==================================================== |
---|
179 | #- STORAGE (dedicated to small/medium files) |
---|
180 | STORAGE=${config_UserChoices_STORAGE} |
---|
181 | else |
---|
182 | #==================================================== |
---|
183 | #- STORAGE (dedicated to small/medium files) |
---|
184 | STORAGE=${ARCHIVE} |
---|
185 | fi |
---|
186 | |
---|
187 | # ON OBELIX NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST |
---|
188 | |
---|
189 | #==================================================== |
---|
190 | #- R_OUT |
---|
191 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
192 | |
---|
193 | #==================================================== |
---|
194 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
195 | R_FIG=${STORAGE}/IGCM_OUT |
---|
196 | |
---|
197 | #==================================================== |
---|
198 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
199 | R_BUF=${STORAGE}/IGCM_OUT |
---|
200 | |
---|
201 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
202 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
203 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
204 | |
---|
205 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
206 | } |
---|
207 | |
---|
208 | #D-#================================================== |
---|
209 | #D-function IGCM_sys_RshMaster |
---|
210 | #D-* Purpose: Connection to frontend machine. |
---|
211 | #D-* Examples: |
---|
212 | #D- |
---|
213 | function IGCM_sys_RshMaster { |
---|
214 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
215 | /bin/ksh <<-EOF |
---|
216 | export libIGCM=${libIGCM} |
---|
217 | export DEBUG_debug=${DEBUG_debug} |
---|
218 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
219 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
220 | ${@} |
---|
221 | EOF |
---|
222 | if [ $? -gt 0 ] ; then |
---|
223 | echo "IGCM_sys_RshMaster : erreur." |
---|
224 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
225 | fi |
---|
226 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
227 | } |
---|
228 | |
---|
229 | #D-#================================================== |
---|
230 | #D-function IGCM_sys_RshArchive |
---|
231 | #D-* Purpose: Archive rsh command |
---|
232 | #D-* Examples: |
---|
233 | #D- |
---|
234 | function IGCM_sys_RshArchive { |
---|
235 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
236 | /bin/ksh <<-EOF |
---|
237 | ${@} |
---|
238 | EOF |
---|
239 | status=$? |
---|
240 | if [ ${status} -gt 0 ] ; then |
---|
241 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
242 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
243 | fi |
---|
244 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
245 | } |
---|
246 | |
---|
247 | #D-#================================================== |
---|
248 | #D-function IGCM_sys_RshPost |
---|
249 | #D-* Purpose: Post-process rsh command |
---|
250 | #D-* Examples: |
---|
251 | #D- |
---|
252 | function IGCM_sys_RshPost { |
---|
253 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
254 | if ( $DEBUG_sys ) ; then |
---|
255 | echo "IGCM_sys_RshPost :" $@ |
---|
256 | fi |
---|
257 | |
---|
258 | # keep standard input (stdin) for the loop onto temporary file |
---|
259 | cat >tmp_IGCM_sys_RshPost_$$ |
---|
260 | |
---|
261 | # ============ FRONTEND START ============ # |
---|
262 | |
---|
263 | /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
264 | if [ $? -gt 0 ] ; then |
---|
265 | echo "IGCM_sys_RshPost : erreur." |
---|
266 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
267 | fi |
---|
268 | # delete temporary file |
---|
269 | \rm tmp_IGCM_sys_RshPost_$$ |
---|
270 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
271 | } |
---|
272 | |
---|
273 | #D-#================================================== |
---|
274 | #D-function IGCM_sys_SendMail |
---|
275 | #D-* Purpose: Send mail when simulation is over |
---|
276 | #D-* Examples: |
---|
277 | #D- |
---|
278 | function IGCM_sys_SendMail { |
---|
279 | IGCM_debug_PushStack "IGCM_sys_SendMail" $@ |
---|
280 | if ( $DEBUG_sys ) ; then |
---|
281 | echo "IGCM_sys_SendMail :" $@ |
---|
282 | fi |
---|
283 | |
---|
284 | if [ X${1} = XAccounting ] ; then |
---|
285 | status=Accounting |
---|
286 | mailText=jobAccounting.mail |
---|
287 | elif ( ${ExitFlag} ) ; then |
---|
288 | status=failed |
---|
289 | mailText=jobEnd.mail |
---|
290 | else |
---|
291 | status=completed |
---|
292 | mailText=jobEnd.mail |
---|
293 | fi |
---|
294 | |
---|
295 | # Update selected mail template |
---|
296 | while read -r line; do |
---|
297 | eval echo $line >> mail.txt ; |
---|
298 | done < ${libIGCM}/libIGCM_sys/${mailText} |
---|
299 | |
---|
300 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
301 | mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt |
---|
302 | elif [ -f ~/.forward ] ; then |
---|
303 | mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt |
---|
304 | fi |
---|
305 | |
---|
306 | sleep 10 |
---|
307 | rm -f mail.txt |
---|
308 | |
---|
309 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
310 | } |
---|
311 | |
---|
312 | #D-#================================================== |
---|
313 | #D-function IGCM_sys_Mkdir |
---|
314 | #D-* Purpose: Master locale mkdir command |
---|
315 | #D-* Examples: |
---|
316 | #D- |
---|
317 | function IGCM_sys_Mkdir { |
---|
318 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
319 | if ( $DEBUG_sys ) ; then |
---|
320 | echo "IGCM_sys_Mkdir :" $@ |
---|
321 | fi |
---|
322 | if [ ! -d ${1} ]; then |
---|
323 | \mkdir -p $1 |
---|
324 | if [ $? -gt 0 ] ; then |
---|
325 | echo "IGCM_sys_Mkdir : erreur." |
---|
326 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
327 | fi |
---|
328 | fi |
---|
329 | # vérification : |
---|
330 | if [ ! -d ${1} ] ; then |
---|
331 | echo "IGCM_sys_Mkdir : erreur." |
---|
332 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
333 | fi |
---|
334 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
335 | } |
---|
336 | |
---|
337 | #D-#================================================== |
---|
338 | #D-function IGCM_sys_MkdirArchive |
---|
339 | #D-* Purpose: Mkdir on Archive |
---|
340 | #D-* Examples: |
---|
341 | #D- |
---|
342 | function IGCM_sys_MkdirArchive { |
---|
343 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
344 | if ( $DEBUG_sys ) ; then |
---|
345 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
346 | fi |
---|
347 | #- creation de repertoire sur le serveur fichier |
---|
348 | if [ ! -d ${1} ]; then |
---|
349 | mkdir -p $1 |
---|
350 | status=$? |
---|
351 | |
---|
352 | if [ ${status} -gt 0 ] ; then |
---|
353 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
354 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
355 | fi |
---|
356 | fi |
---|
357 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
358 | } |
---|
359 | |
---|
360 | #D-#================================================== |
---|
361 | #D-function IGCM_sys_MkdirWork |
---|
362 | #D-* Purpose: Mkdir on Work |
---|
363 | #D-* Examples: |
---|
364 | #D- |
---|
365 | function IGCM_sys_MkdirWork { |
---|
366 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
367 | if ( $DEBUG_sys ) ; then |
---|
368 | echo "IGCM_sys_MkdirWork :" $@ |
---|
369 | fi |
---|
370 | #- creation de repertoire sur le serveur fichier |
---|
371 | if [ ! -d ${1} ]; then |
---|
372 | \mkdir -p $1 |
---|
373 | if [ $? -gt 0 ] ; then |
---|
374 | echo "IGCM_sys_MkdirWork : erreur." |
---|
375 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
376 | fi |
---|
377 | fi |
---|
378 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
379 | } |
---|
380 | |
---|
381 | #D-#================================================== |
---|
382 | #D-function IGCM_sys_Cd |
---|
383 | #D-* Purpose: master cd command |
---|
384 | #D-* Examples: |
---|
385 | #D- |
---|
386 | function IGCM_sys_Cd { |
---|
387 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
388 | if ( $DEBUG_sys ) ; then |
---|
389 | echo "IGCM_sys_Cd :" $@ |
---|
390 | fi |
---|
391 | \cd $1 |
---|
392 | if [ $? -gt 0 ] ; then |
---|
393 | echo "IGCM_sys_Cd : erreur." |
---|
394 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
395 | fi |
---|
396 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
397 | } |
---|
398 | |
---|
399 | #D-#================================================== |
---|
400 | #D-function IGCM_sys_Chmod |
---|
401 | #D-* Purpose: Chmod |
---|
402 | #D-* Examples: |
---|
403 | #D- |
---|
404 | function IGCM_sys_Chmod { |
---|
405 | IGCM_debug_PushStack "IGCM_sys_Chmod" $@ |
---|
406 | if ( $DEBUG_sys ) ; then |
---|
407 | echo "IGCM_sys_Chmod :" $@ |
---|
408 | fi |
---|
409 | \chmod $@ |
---|
410 | if [ $? -gt 0 ] ; then |
---|
411 | echo "IGCM_sys_Chmod : erreur." |
---|
412 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
413 | fi |
---|
414 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
415 | } |
---|
416 | |
---|
417 | #D-#================================================== |
---|
418 | #D-function IGCM_sys_FileSize |
---|
419 | #D-* Purpose: Filesize |
---|
420 | #D-* Examples: |
---|
421 | #D- |
---|
422 | function IGCM_sys_FileSize { |
---|
423 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
424 | |
---|
425 | typeset sizeF |
---|
426 | set +A sizeF -- $( ls -la ${1} ) |
---|
427 | if [ $? -gt 0 ] ; then |
---|
428 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
429 | fi |
---|
430 | eval ${2}=${sizeF[4]} |
---|
431 | |
---|
432 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
433 | } |
---|
434 | |
---|
435 | #D-#================================================== |
---|
436 | #D-function IGCM_sys_TestDir |
---|
437 | #D-* Purpose: Test Directory that must exists |
---|
438 | #D-* Examples: |
---|
439 | #D- |
---|
440 | function IGCM_sys_TestDir { |
---|
441 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
442 | if ( $DEBUG_sys ) ; then |
---|
443 | echo "IGCM_sys_TestDir :" $@ |
---|
444 | fi |
---|
445 | typeset ExistFlag |
---|
446 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
447 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
448 | |
---|
449 | return ${ExistFlag} |
---|
450 | } |
---|
451 | |
---|
452 | #D-#================================================== |
---|
453 | #D-function IGCM_sys_TestDirArchive |
---|
454 | #D-* Purpose: Test Directory that must exists on Archive |
---|
455 | #D-* Examples: |
---|
456 | #D- |
---|
457 | function IGCM_sys_TestDirArchive { |
---|
458 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
459 | if ( $DEBUG_sys ) ; then |
---|
460 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
461 | fi |
---|
462 | typeset ExistFlag |
---|
463 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
464 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
465 | return ${ExistFlag} |
---|
466 | } |
---|
467 | |
---|
468 | #D-#================================================== |
---|
469 | #D-function IGCM_sys_IsFileArchived |
---|
470 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
471 | #D-* Examples: |
---|
472 | #D- |
---|
473 | function IGCM_sys_IsFileArchived { |
---|
474 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
475 | if ( $DEBUG_sys ) ; then |
---|
476 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
477 | fi |
---|
478 | typeset IsArchivedFlag |
---|
479 | # Never archived for this system |
---|
480 | IsArchivedFlag=1 |
---|
481 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
482 | |
---|
483 | return ${IsArchivedFlag} |
---|
484 | } |
---|
485 | |
---|
486 | #D-#================================================== |
---|
487 | #D-function IGCM_sys_TestFileArchive |
---|
488 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
489 | #D-* Examples: |
---|
490 | #D- |
---|
491 | function IGCM_sys_TestFileArchive { |
---|
492 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
493 | typeset ExistFlag |
---|
494 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
495 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
496 | |
---|
497 | return ${ExistFlag} |
---|
498 | } |
---|
499 | |
---|
500 | #D-#================================================== |
---|
501 | #D-function IGCM_sys_TestFileBuffer |
---|
502 | #D-* Purpose: Test file that must NOT EXISTS on Buffer |
---|
503 | #D-* Examples: |
---|
504 | #D- |
---|
505 | function IGCM_sys_TestFileBuffer { |
---|
506 | IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ |
---|
507 | typeset ExistFlag |
---|
508 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
509 | IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" |
---|
510 | |
---|
511 | return ${ExistFlag} |
---|
512 | } |
---|
513 | |
---|
514 | #D-#================================================== |
---|
515 | #D-function IGCM_sys_CountFileArchive |
---|
516 | #D-* Purpose: Count files on Archive filesystem |
---|
517 | #D-* Examples: |
---|
518 | #D- |
---|
519 | function IGCM_sys_CountFileArchive { |
---|
520 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
521 | ls ${@} 2>/dev/null | wc -l |
---|
522 | if [ $? -gt 0 ] ; then |
---|
523 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
524 | fi |
---|
525 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
526 | } |
---|
527 | |
---|
528 | #D-#================================================== |
---|
529 | #D-function IGCM_sys_CountFileBuffer |
---|
530 | #D-* Purpose: Count files on Scratch filesystem |
---|
531 | #D-* Examples: |
---|
532 | #D- |
---|
533 | function IGCM_sys_CountFileBuffer { |
---|
534 | IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ |
---|
535 | ls ${@} 2>/dev/null | wc -l |
---|
536 | if [ $? -gt 0 ] ; then |
---|
537 | echo "IGCM_sys_CountFileBuffer : erreur." |
---|
538 | fi |
---|
539 | IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" |
---|
540 | } |
---|
541 | |
---|
542 | #D-#================================================== |
---|
543 | #D-function IGCM_sys_Tree |
---|
544 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
545 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
546 | #D- |
---|
547 | function IGCM_sys_Tree { |
---|
548 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
549 | if ( $DEBUG_sys ) ; then |
---|
550 | echo "IGCM_sys_Tree :" $@ |
---|
551 | fi |
---|
552 | |
---|
553 | \tree -f $@ |
---|
554 | |
---|
555 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
556 | } |
---|
557 | |
---|
558 | #D-#================================================== |
---|
559 | #D-function IGCM_sys_Tar |
---|
560 | #D-* Purpose: master tar command |
---|
561 | #D-* Examples: |
---|
562 | #D- |
---|
563 | function IGCM_sys_Tar { |
---|
564 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
565 | if ( $DEBUG_sys ) ; then |
---|
566 | echo "IGCM_sys_Tar :" $@ |
---|
567 | fi |
---|
568 | \tar cf $@ |
---|
569 | if [ $? -gt 0 ] ; then |
---|
570 | echo "IGCM_sys_Tar : erreur." |
---|
571 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
572 | fi |
---|
573 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
574 | } |
---|
575 | |
---|
576 | #D-#================================================== |
---|
577 | #D-function IGCM_sys_UnTar |
---|
578 | #D-* Purpose: master un-tar command |
---|
579 | #D-* Examples: |
---|
580 | #D- |
---|
581 | function IGCM_sys_UnTar { |
---|
582 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
583 | if ( $DEBUG_sys ) ; then |
---|
584 | echo "IGCM_sys_UnTar :" $@ |
---|
585 | fi |
---|
586 | \tar xvf $1 |
---|
587 | if [ $? -gt 0 ] ; then |
---|
588 | echo "IGCM_sys_UnTar : erreur." |
---|
589 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
590 | fi |
---|
591 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
592 | } |
---|
593 | |
---|
594 | #D-#================================================== |
---|
595 | #D-function IGCM_sys_Qsub |
---|
596 | #D-* Purpose: Qsub new job |
---|
597 | #D-* Examples: |
---|
598 | #D- |
---|
599 | function IGCM_sys_Qsub { |
---|
600 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
601 | if ( $DEBUG_sys ) ; then |
---|
602 | echo "IGCM_sys_Qsub :" $@ |
---|
603 | fi |
---|
604 | typeset options status |
---|
605 | options="-o ${SUBMIT_DIR}/${Script_Output}" |
---|
606 | /usr/local/bin/qsub ${options} $1 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
607 | status=$? |
---|
608 | |
---|
609 | cat /tmp/out_command_${LOGIN}.$$ |
---|
610 | if [ ${status} -gt 0 ] ; then |
---|
611 | IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}" |
---|
612 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
613 | else |
---|
614 | JobID=$( gawk {'print $1'} /tmp/out_command_${LOGIN}.$$ ) |
---|
615 | fi |
---|
616 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
617 | } |
---|
618 | |
---|
619 | #D-#================================================== |
---|
620 | #D-function IGCM_sys_QsubPost |
---|
621 | #D-* Purpose: Qsub new job on scalaire |
---|
622 | #D-* Examples: |
---|
623 | #D- |
---|
624 | function IGCM_sys_QsubPost { |
---|
625 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
626 | if ( $DEBUG_sys ) ; then |
---|
627 | echo "IGCM_sys_QsubPost :" $@ |
---|
628 | fi |
---|
629 | typeset options status |
---|
630 | options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}" |
---|
631 | /usr/local/bin/qsub ${options} ${libIGCM_POST}/$1.job > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
632 | status=$? |
---|
633 | |
---|
634 | cat /tmp/out_command_${LOGIN}.$$ |
---|
635 | if [ ${status} -gt 0 ] ; then |
---|
636 | IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}" |
---|
637 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
638 | else |
---|
639 | JobID=$( gawk {'print $1'} /tmp/out_command_${LOGIN}.$$ ) |
---|
640 | fi |
---|
641 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
642 | } |
---|
643 | |
---|
644 | #D-************************* |
---|
645 | #D- File transfer functions |
---|
646 | #D-************************* |
---|
647 | #D- |
---|
648 | |
---|
649 | #D-#================================================== |
---|
650 | #D-function IGCM_sys_Rsync_out |
---|
651 | #D-* Purpose: treat return val of rsync |
---|
652 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
653 | #D- Error values and explanations can depend on your system version. |
---|
654 | function IGCM_sys_Rsync_out { |
---|
655 | status=$1 |
---|
656 | if [ ! $status ] ; then |
---|
657 | echo "rsync error !" |
---|
658 | fi |
---|
659 | |
---|
660 | if [ $MYLANG = "fr" ]; then |
---|
661 | case $status in |
---|
662 | 0) return ;; |
---|
663 | 1) echo "Erreur de rsync ; RERR_SYNTAX : " |
---|
664 | echo "Erreur de syntaxe ou d'utilisation." |
---|
665 | return;; |
---|
666 | 2) echo "Erreur de rsync ; RERR_PROTOCOL : " |
---|
667 | echo "Incompatibilité de protocole." |
---|
668 | return;; |
---|
669 | 3) echo "Erreur de rsync ; RERR_FILESELECT 3" |
---|
670 | echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" |
---|
671 | echo "répertoires" |
---|
672 | return;; |
---|
673 | 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" |
---|
674 | echo "Action demandée non supportée : une tentative de manipulation de" |
---|
675 | echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" |
---|
676 | echo "été faite ; ou une option qui est supportée par le client mais" |
---|
677 | echo "pas par le serveur a été spécifiée." |
---|
678 | return;; |
---|
679 | 10) echo "Erreur de rsync ; RERR_SOCKETIO" |
---|
680 | echo "Erreur dans le socket d'entrée sortie" |
---|
681 | return;; |
---|
682 | 11) echo "Erreur de rsync ; RERR_FILEIO" |
---|
683 | echo "Erreur d'entrée sortie fichier" |
---|
684 | return;; |
---|
685 | 12) echo "Erreur de rsync ; RERR_STREAMIO" |
---|
686 | echo "Erreur dans flux de donnée du protocole rsync" |
---|
687 | return;; |
---|
688 | 13) echo "Erreur de rsync ; RERR_MESSAGEIO" |
---|
689 | echo "Erreur avec les diagnostics du programme" |
---|
690 | return;; |
---|
691 | 14) echo "Erreur de rsync ; RERR_IPC" |
---|
692 | echo "Erreur dans le code IPC" |
---|
693 | return;; |
---|
694 | 20) echo "Erreur de rsync ; RERR_SIGNAL" |
---|
695 | echo "SIGUSR1 ou SIGINT reçu" |
---|
696 | return;; |
---|
697 | 21) echo "Erreur de rsync ; RERR_WAITCHILD" |
---|
698 | echo "Une erreur retournée par waitpid()" |
---|
699 | return;; |
---|
700 | 22) echo "Erreur de rsync ; RERR_MALLOC" |
---|
701 | echo "Erreur lors de l'allocation des tampons de mémoire de coeur" |
---|
702 | return;; |
---|
703 | 23) echo "" |
---|
704 | echo "Erreur fichier inexistant" |
---|
705 | return;; |
---|
706 | 30) echo "Erreur de rsync ; RERR_TIMEOUT" |
---|
707 | echo "Temps d'attente écoulé dans l'envoi/réception de données" |
---|
708 | return;; |
---|
709 | *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status |
---|
710 | return;; |
---|
711 | esac |
---|
712 | elif [ $MYLANG = "en" ] ; then |
---|
713 | case $status in |
---|
714 | 0) return;; |
---|
715 | 1) echo "rsync error : Syntax or usage error " |
---|
716 | return;; |
---|
717 | 2) echo "rsync error : Protocol incompatibility " |
---|
718 | return;; |
---|
719 | 3) echo "rsync error : Errors selecting input/output files, dirs" |
---|
720 | return;; |
---|
721 | 4) echo "rsync error : Requested action not supported: an attempt" |
---|
722 | echo "was made to manipulate 64-bit files on a platform that cannot support" |
---|
723 | echo "them; or an option was specified that is supported by the client and" |
---|
724 | echo "not by the server." |
---|
725 | return;; |
---|
726 | 5) echo "rsync error : Error starting client-server protocol" |
---|
727 | return;; |
---|
728 | 10) echo "rsync error : Error in socket I/O " |
---|
729 | return;; |
---|
730 | 11) echo "rsync error : Error in file I/O " |
---|
731 | return;; |
---|
732 | 12) echo "rsync error : Error in rsync protocol data stream " |
---|
733 | return;; |
---|
734 | 13) echo "rsync error : Errors with program diagnostics " |
---|
735 | return;; |
---|
736 | 14) echo "rsync error : Error in IPC code " |
---|
737 | return;; |
---|
738 | 20) echo "rsync error : Received SIGUSR1 or SIGINT " |
---|
739 | return;; |
---|
740 | 21) echo "rsync error : Some error returned by waitpid() " |
---|
741 | return;; |
---|
742 | 22) echo "rsync error : Error allocating core memory buffers " |
---|
743 | return;; |
---|
744 | 23) echo "rsync error : Partial transfer due to error" |
---|
745 | return;; |
---|
746 | 24) echo "rsync error : Partial transfer due to vanished source files" |
---|
747 | return;; |
---|
748 | 30) echo "rsync error : Timeout in data send/receive " |
---|
749 | return;; |
---|
750 | *) echo "rsync error : return code of rsync unknown :" $status |
---|
751 | return;; |
---|
752 | esac |
---|
753 | else |
---|
754 | echo "unknown language $MYLANG." |
---|
755 | return |
---|
756 | fi |
---|
757 | } |
---|
758 | |
---|
759 | #D-#================================================== |
---|
760 | #D-function IGCM_sys_Miror_libIGCM |
---|
761 | #D-* Purpose: Mirror libIGCM PATH and lib to frontend |
---|
762 | #D-* Examples: |
---|
763 | #D- |
---|
764 | function IGCM_sys_Mirror_libIGCM { |
---|
765 | IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" |
---|
766 | if ( $DEBUG_sys ) ; then |
---|
767 | echo "IGCM_sys_Mirror_libIGCM" |
---|
768 | fi |
---|
769 | |
---|
770 | typeset status |
---|
771 | |
---|
772 | mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} |
---|
773 | |
---|
774 | echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
775 | ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
776 | status=$? |
---|
777 | |
---|
778 | if [ ${status} -gt 0 ] ; then |
---|
779 | echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." |
---|
780 | cat /tmp/out_command_${LOGIN}.$$ |
---|
781 | fi |
---|
782 | IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" |
---|
783 | } |
---|
784 | |
---|
785 | #D-#================================================== |
---|
786 | #D-function IGCM_sys_Cp |
---|
787 | #D-* Purpose: generic cp |
---|
788 | #D-* Examples: |
---|
789 | #D- |
---|
790 | function IGCM_sys_Cp { |
---|
791 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
792 | if ( $DEBUG_sys ) ; then |
---|
793 | echo "IGCM_sys_Cp :" $@ |
---|
794 | fi |
---|
795 | |
---|
796 | typeset status |
---|
797 | |
---|
798 | echo cp $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
799 | \cp $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
800 | status=$? |
---|
801 | |
---|
802 | if [ ${status} -gt 0 ] ; then |
---|
803 | echo "IGCM_sys_Cp : error code ${status}" |
---|
804 | cat /tmp/out_command_${LOGIN}.$$ |
---|
805 | IGCM_debug_Exit "IGCM_sys_Cp" |
---|
806 | else |
---|
807 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
808 | fi |
---|
809 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
810 | } |
---|
811 | |
---|
812 | #D-#================================================== |
---|
813 | #D-function IGCM_sys_Rm |
---|
814 | #D-* Purpose: generic rm |
---|
815 | #D-* Examples: |
---|
816 | #D- |
---|
817 | function IGCM_sys_Rm { |
---|
818 | IGCM_debug_PushStack "IGCM_sys_Rm" $@ |
---|
819 | if ( $DEBUG_sys ) ; then |
---|
820 | echo "IGCM_sys_Rm :" $@ |
---|
821 | fi |
---|
822 | |
---|
823 | typeset status |
---|
824 | |
---|
825 | echo rm $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
826 | \rm $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
827 | status=$? |
---|
828 | |
---|
829 | if [ ${status} -gt 0 ] ; then |
---|
830 | echo "IGCM_sys_Rm : error code ${status}" |
---|
831 | cat /tmp/out_command_${LOGIN}.$$ |
---|
832 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
833 | else |
---|
834 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
835 | fi |
---|
836 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
837 | } |
---|
838 | |
---|
839 | #D-#================================================== |
---|
840 | #D-function IGCM_sys_RmRunDir |
---|
841 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
842 | #D- scheduler will do the job) |
---|
843 | #D-* Examples: |
---|
844 | #D- |
---|
845 | function IGCM_sys_RmRunDir { |
---|
846 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
847 | if ( $DEBUG_sys ) ; then |
---|
848 | echo "IGCM_sys_RmRunDir :" $@ |
---|
849 | echo "Dummy call, let the scheduler do that." |
---|
850 | fi |
---|
851 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
852 | } |
---|
853 | |
---|
854 | #D-#================================================== |
---|
855 | #D-function IGCM_sys_Mv |
---|
856 | #D-* Purpose: generic move |
---|
857 | #D-* Examples: |
---|
858 | #D- |
---|
859 | function IGCM_sys_Mv { |
---|
860 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
861 | if ( $DEBUG_sys ) ; then |
---|
862 | echo "IGCM_sys_Mv :" $@ |
---|
863 | fi |
---|
864 | |
---|
865 | if [ $DRYRUN = 0 ]; then |
---|
866 | |
---|
867 | typeset status |
---|
868 | |
---|
869 | echo mv $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
870 | \mv $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
871 | status=$? |
---|
872 | |
---|
873 | if [ ${status} -gt 0 ] ; then |
---|
874 | echo "IGCM_sys_Mv : error code ${status}" |
---|
875 | cat /tmp/out_command_${LOGIN}.$$ |
---|
876 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
877 | else |
---|
878 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
879 | fi |
---|
880 | fi |
---|
881 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
882 | } |
---|
883 | |
---|
884 | #D-#================================================== |
---|
885 | #D-function IGCM_sys_Put_Dir |
---|
886 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
887 | #D-* Examples: |
---|
888 | #D- |
---|
889 | function IGCM_sys_Put_Dir { |
---|
890 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
891 | if ( $DEBUG_sys ) ; then |
---|
892 | echo "IGCM_sys_Put_Dir :" $@ |
---|
893 | fi |
---|
894 | if [ $DRYRUN = 0 ]; then |
---|
895 | if [ ! -d ${1} ] ; then |
---|
896 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
897 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
898 | return |
---|
899 | fi |
---|
900 | |
---|
901 | typeset status |
---|
902 | |
---|
903 | # Only if we use rsync |
---|
904 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
905 | # |
---|
906 | #USUAL WAY |
---|
907 | \cp -r $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
908 | status=$? |
---|
909 | |
---|
910 | if [ ${status} -gt 0 ] ; then |
---|
911 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
912 | cat /tmp/out_command_${LOGIN}.$$ |
---|
913 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
914 | else |
---|
915 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
916 | fi |
---|
917 | fi |
---|
918 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
919 | } |
---|
920 | |
---|
921 | #D-#================================================== |
---|
922 | #D-function IGCM_sys_Get_Dir |
---|
923 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
924 | #D-* Examples: |
---|
925 | #D- |
---|
926 | function IGCM_sys_Get_Dir { |
---|
927 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
928 | if ( $DEBUG_sys ) ; then |
---|
929 | echo "IGCM_sys_Get_Dir :" $@ |
---|
930 | fi |
---|
931 | if [ $DRYRUN = 0 ]; then |
---|
932 | if [ ! -d ${1} ] ; then |
---|
933 | echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
934 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
935 | return |
---|
936 | fi |
---|
937 | |
---|
938 | typeset status |
---|
939 | |
---|
940 | #USUAL WAY |
---|
941 | \cp -ur $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
942 | status=$? |
---|
943 | |
---|
944 | if [ ${status} -gt 0 ] ; then |
---|
945 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
946 | cat /tmp/out_command_${LOGIN}.$$ |
---|
947 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
948 | else |
---|
949 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
950 | fi |
---|
951 | fi |
---|
952 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
953 | } |
---|
954 | |
---|
955 | #D-#================================================== |
---|
956 | #D-function IGCM_sys_Get_Master |
---|
957 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
958 | #D-* Examples: |
---|
959 | #D- |
---|
960 | function IGCM_sys_Get_Master { |
---|
961 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
962 | if ( $DEBUG_sys ) ; then |
---|
963 | echo "IGCM_sys_Get_Master :" $@ |
---|
964 | fi |
---|
965 | if [ $DRYRUN = 0 ]; then |
---|
966 | if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then |
---|
967 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." |
---|
968 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
969 | return |
---|
970 | fi |
---|
971 | |
---|
972 | typeset NB_ESSAI DELAI status i |
---|
973 | # number of tentative |
---|
974 | NB_ESSAI=3 |
---|
975 | # time delay between tentative |
---|
976 | DELAI=2 |
---|
977 | |
---|
978 | i=0 |
---|
979 | while [ $i -lt $NB_ESSAI ] ; do |
---|
980 | \cp -urL $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
981 | status=$? |
---|
982 | if [ ${status} -gt 0 ]; then |
---|
983 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
984 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." |
---|
985 | sleep $DELAI |
---|
986 | else |
---|
987 | break |
---|
988 | fi |
---|
989 | (( i = i + 1 )) |
---|
990 | done |
---|
991 | |
---|
992 | if [ ${status} -gt 0 ] ; then |
---|
993 | echo "IGCM_sys_Get_Master : error." |
---|
994 | cat /tmp/out_command_${LOGIN}.$$ |
---|
995 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
996 | else |
---|
997 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
998 | fi |
---|
999 | fi |
---|
1000 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
1001 | } |
---|
1002 | |
---|
1003 | #==================================================== |
---|
1004 | #- Call IGCM_sys_Mirror_libIGCM now ! |
---|
1005 | if ( $MirrorlibIGCM ) ; then |
---|
1006 | IGCM_sys_Mirror_libIGCM |
---|
1007 | fi |
---|
1008 | |
---|
1009 | #D-#================================================== |
---|
1010 | #D-function IGCM_sys_Put_Rest |
---|
1011 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
1012 | #D- File and target directory must exist. |
---|
1013 | #D-* Examples: |
---|
1014 | #D- |
---|
1015 | function IGCM_sys_Put_Rest { |
---|
1016 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
1017 | if ( $DEBUG_sys ) ; then |
---|
1018 | echo "IGCM_sys_Put_Rest :" $@ |
---|
1019 | fi |
---|
1020 | if [ $DRYRUN = 0 ]; then |
---|
1021 | if [ ! -f ${1} ] ; then |
---|
1022 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
1023 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
1024 | fi |
---|
1025 | |
---|
1026 | typeset status |
---|
1027 | # |
---|
1028 | if [ X${JobType} = XRUN ] ; then |
---|
1029 | IGCM_sys_Chmod 444 ${1} |
---|
1030 | fi |
---|
1031 | # |
---|
1032 | # Only if we use rsync |
---|
1033 | #IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
1034 | # |
---|
1035 | #USUAL WAY |
---|
1036 | \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1037 | status=$? |
---|
1038 | |
---|
1039 | # #RSYNC WITH NETWORK SSH CALL |
---|
1040 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1041 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1042 | |
---|
1043 | # #RSYNC WITH NFS USE |
---|
1044 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1045 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1046 | |
---|
1047 | # status=$? |
---|
1048 | # IGCM_sys_Rsync_out $status |
---|
1049 | |
---|
1050 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command_${LOGIN}.$$ |
---|
1051 | # (( status=status+$? )) |
---|
1052 | |
---|
1053 | if [ ${status} -gt 0 ] ; then |
---|
1054 | echo "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
1055 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1056 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
1057 | else |
---|
1058 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1059 | fi |
---|
1060 | fi |
---|
1061 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
1062 | } |
---|
1063 | |
---|
1064 | #D-#================================================== |
---|
1065 | #D-function IGCM_sys_PutBuffer_Rest |
---|
1066 | #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. |
---|
1067 | #D- File and target directory must exist. |
---|
1068 | #D-* Examples: |
---|
1069 | #D- |
---|
1070 | function IGCM_sys_PutBuffer_Rest { |
---|
1071 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ |
---|
1072 | if ( $DEBUG_sys ) ; then |
---|
1073 | echo "IGCM_sys_PutBuffer_Rest :" $@ |
---|
1074 | fi |
---|
1075 | if [ $DRYRUN = 0 ]; then |
---|
1076 | if [ ! -f ${1} ] ; then |
---|
1077 | echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." |
---|
1078 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
1079 | fi |
---|
1080 | |
---|
1081 | typeset status |
---|
1082 | # |
---|
1083 | if [ X${JobType} = XRUN ] ; then |
---|
1084 | IGCM_sys_Chmod 444 ${1} |
---|
1085 | fi |
---|
1086 | |
---|
1087 | # |
---|
1088 | # USUAL WAY |
---|
1089 | \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1090 | status=$? |
---|
1091 | |
---|
1092 | if [ ${status} -gt 0 ] ; then |
---|
1093 | echo "IGCM_sys_PutBuffer_Rest : error code ${status}" |
---|
1094 | [ -f ${2} ] && ls -l ${2} |
---|
1095 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1096 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1097 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
1098 | else |
---|
1099 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1100 | fi |
---|
1101 | fi |
---|
1102 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" |
---|
1103 | } |
---|
1104 | |
---|
1105 | #D-#================================================== |
---|
1106 | #D-function IGCM_sys_PrepareTaredRestart |
---|
1107 | #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. |
---|
1108 | #D-* Examples: |
---|
1109 | #D- |
---|
1110 | function IGCM_sys_PrepareTaredRestart { |
---|
1111 | IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ |
---|
1112 | |
---|
1113 | IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" |
---|
1114 | } |
---|
1115 | |
---|
1116 | #D-#================================================== |
---|
1117 | #D-function IGCM_sys_Put_Out |
---|
1118 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
1119 | #D-* Examples: |
---|
1120 | #D- |
---|
1121 | function IGCM_sys_Put_Out { |
---|
1122 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
1123 | if ( $DEBUG_sys ) ; then |
---|
1124 | echo "IGCM_sys_Put_Out :" $@ |
---|
1125 | fi |
---|
1126 | |
---|
1127 | typeset status |
---|
1128 | |
---|
1129 | if [ $DRYRUN = 0 ]; then |
---|
1130 | if [ ! -f ${1} ] ; then |
---|
1131 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
1132 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
1133 | return 1 |
---|
1134 | fi |
---|
1135 | # |
---|
1136 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
1137 | # |
---|
1138 | if [ X${JobType} = XRUN ] ; then |
---|
1139 | if [ X${3} = X ] ; then |
---|
1140 | IGCM_sys_Chmod 444 ${1} |
---|
1141 | fi |
---|
1142 | fi |
---|
1143 | # |
---|
1144 | |
---|
1145 | echo ${RSYNC} ${RSYNC_opt} $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1146 | ${RSYNC} ${RSYNC_opt} $1 $2 >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1147 | status=$? |
---|
1148 | IGCM_sys_Rsync_out $status |
---|
1149 | |
---|
1150 | ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command_${LOGIN}.$$ |
---|
1151 | (( status=status+$? )) |
---|
1152 | |
---|
1153 | if [ ${status} -gt 0 ] ; then |
---|
1154 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}" |
---|
1155 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1156 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
1157 | else |
---|
1158 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1159 | fi |
---|
1160 | fi |
---|
1161 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
1162 | return 0 |
---|
1163 | } |
---|
1164 | |
---|
1165 | #D-#================================================== |
---|
1166 | #D-function IGCM_sys_PutBuffer_Out |
---|
1167 | #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly |
---|
1168 | #D-* Examples: |
---|
1169 | #D- |
---|
1170 | function IGCM_sys_PutBuffer_Out { |
---|
1171 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ |
---|
1172 | if ( $DEBUG_sys ) ; then |
---|
1173 | echo "IGCM_sys_PutBuffer_Out :" $@ |
---|
1174 | fi |
---|
1175 | |
---|
1176 | typeset NB_ESSAI DELAI status i exist skip |
---|
1177 | |
---|
1178 | # number of tentative |
---|
1179 | NB_ESSAI=3 |
---|
1180 | # time delay between tentative |
---|
1181 | DELAI=2 |
---|
1182 | |
---|
1183 | if [ $DRYRUN = 0 ]; then |
---|
1184 | if [ ! -f ${1} ] ; then |
---|
1185 | echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." |
---|
1186 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
1187 | return 1 |
---|
1188 | fi |
---|
1189 | # |
---|
1190 | IGCM_sys_Mkdir $( dirname $2 ) |
---|
1191 | # |
---|
1192 | |
---|
1193 | exist=false |
---|
1194 | skip=false |
---|
1195 | if [ -f $2 ] ; then |
---|
1196 | IGCM_debug_Print 1 "$2 already exist" |
---|
1197 | exist=true |
---|
1198 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
1199 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
1200 | status=0 |
---|
1201 | skip=true |
---|
1202 | else |
---|
1203 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
1204 | skip=false |
---|
1205 | fi |
---|
1206 | fi |
---|
1207 | # |
---|
1208 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
1209 | IGCM_sys_Chmod u+w $2 |
---|
1210 | fi |
---|
1211 | |
---|
1212 | if [ X${skip} = Xfalse ] ; then |
---|
1213 | i=0 |
---|
1214 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1215 | # USUAL WAY |
---|
1216 | \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1217 | status=$? |
---|
1218 | if [ ${status} -gt 0 ]; then |
---|
1219 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1220 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." |
---|
1221 | [ -f ${2} ] && ls -l ${2} |
---|
1222 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1223 | sleep $DELAI |
---|
1224 | else |
---|
1225 | break |
---|
1226 | fi |
---|
1227 | (( i = i + 1 )) |
---|
1228 | done |
---|
1229 | fi |
---|
1230 | |
---|
1231 | if [ ${status} -gt 0 ] ; then |
---|
1232 | echo "IGCM_sys_PutBuffer_Out : error." |
---|
1233 | [ -f ${2} ] && ls -l ${2} |
---|
1234 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1235 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1236 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
1237 | else |
---|
1238 | |
---|
1239 | if [ X${JobType} = XRUN ] ; then |
---|
1240 | if [ X${3} = X ] ; then |
---|
1241 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
1242 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
1243 | fi |
---|
1244 | fi |
---|
1245 | |
---|
1246 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1247 | fi |
---|
1248 | fi |
---|
1249 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
1250 | return 0 |
---|
1251 | } |
---|
1252 | |
---|
1253 | #D-#================================================== |
---|
1254 | #D-function IGCM_sys_Get |
---|
1255 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
1256 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
1257 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
1258 | function IGCM_sys_Get { |
---|
1259 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
1260 | |
---|
1261 | typeset DEST status dm_liste |
---|
1262 | |
---|
1263 | if ( $DEBUG_sys ) ; then |
---|
1264 | echo "IGCM_sys_Get :" $@ |
---|
1265 | fi |
---|
1266 | if [ $DRYRUN -le 2 ]; then |
---|
1267 | if [ X${1} = X'/l' ] ; then |
---|
1268 | eval set +A dm_liste \${${2}} |
---|
1269 | else |
---|
1270 | dm_liste=${1} |
---|
1271 | fi |
---|
1272 | eval DEST=\${${#}} |
---|
1273 | |
---|
1274 | # test if the (first) file is present in the old computation : |
---|
1275 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
1276 | status=$? |
---|
1277 | if [ ${status} -gt 0 ] ; then |
---|
1278 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
1279 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1280 | return |
---|
1281 | fi |
---|
1282 | |
---|
1283 | #USUAL WAY |
---|
1284 | \cp ${dm_liste[*]} ${DEST} > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1285 | status=$? |
---|
1286 | |
---|
1287 | if [ ${status} -gt 0 ] ; then |
---|
1288 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
1289 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1290 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1291 | else |
---|
1292 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1293 | fi |
---|
1294 | fi |
---|
1295 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
1296 | } |
---|
1297 | |
---|
1298 | #D-#================================================== |
---|
1299 | #D-function IGCM_sys_GetBuffer |
---|
1300 | #D-* Purpose: Get a file from ${SCRATCHDIR} |
---|
1301 | #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX |
---|
1302 | #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ |
---|
1303 | function IGCM_sys_GetBuffer { |
---|
1304 | IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ |
---|
1305 | |
---|
1306 | typeset DEST buf_liste target file_work |
---|
1307 | typeset NB_ESSAI DELAI status i |
---|
1308 | |
---|
1309 | if ( $DEBUG_sys ) ; then |
---|
1310 | echo "IGCM_sys_GetBuffer :" $@ |
---|
1311 | fi |
---|
1312 | |
---|
1313 | # number of tentative |
---|
1314 | NB_ESSAI=3 |
---|
1315 | # time delay between tentative |
---|
1316 | DELAI=2 |
---|
1317 | |
---|
1318 | if [ $DRYRUN -le 2 ]; then |
---|
1319 | if [ X${1} = X'/l' ] ; then |
---|
1320 | eval set +A buf_liste \${${2}} |
---|
1321 | else |
---|
1322 | eval set +A buf_liste ${1} |
---|
1323 | fi |
---|
1324 | eval DEST=\${${#}} |
---|
1325 | |
---|
1326 | #USUAL WAY |
---|
1327 | if [ X${1} = X'/l' ] ; then |
---|
1328 | for target in ${buf_liste[*]} ; do |
---|
1329 | local_file=$( basename ${target} ) |
---|
1330 | i=0 |
---|
1331 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1332 | \cp ${target} ${DEST}/${local_file} >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1333 | status=$? |
---|
1334 | if [ ${status} -gt 0 ]; then |
---|
1335 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1336 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
1337 | sleep $DELAI |
---|
1338 | else |
---|
1339 | break |
---|
1340 | fi |
---|
1341 | (( i = i + 1 )) |
---|
1342 | done |
---|
1343 | if [ ${status} -gt 0 ] ; then |
---|
1344 | echo "IGCM_sys_Get : error" |
---|
1345 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1346 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1347 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
1348 | else |
---|
1349 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1350 | fi |
---|
1351 | done |
---|
1352 | else |
---|
1353 | i=0 |
---|
1354 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1355 | \cp ${buf_liste} ${DEST} >> /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1356 | status=$? |
---|
1357 | if [ ${status} -gt 0 ]; then |
---|
1358 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1359 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
1360 | sleep $DELAI |
---|
1361 | else |
---|
1362 | break |
---|
1363 | fi |
---|
1364 | (( i = i + 1 )) |
---|
1365 | done |
---|
1366 | if [ ${status} -gt 0 ] ; then |
---|
1367 | echo "IGCM_sys_Get : error" |
---|
1368 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1369 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1370 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
1371 | else |
---|
1372 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1373 | fi |
---|
1374 | fi |
---|
1375 | fi |
---|
1376 | IGCM_debug_PopStack "IGCM_sys_GetBuffer" |
---|
1377 | } |
---|
1378 | |
---|
1379 | #D-#================================================== |
---|
1380 | #D-function IGCM_sys_GetDate_FichWork |
---|
1381 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
1382 | #D-* Examples: |
---|
1383 | #D- |
---|
1384 | function IGCM_sys_GetDate_FichWork { |
---|
1385 | IGCM_debug_PushStack "IGCM_sys_FichWork" $@ |
---|
1386 | if ( $DEBUG_sys ) ; then |
---|
1387 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
1388 | fi |
---|
1389 | typeset dateF |
---|
1390 | set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) |
---|
1391 | eval ${2}=${dateF[5]} |
---|
1392 | |
---|
1393 | # donne la date filesys d'un fichier sur la machine work |
---|
1394 | IGCM_debug_PopStack "IGCM_sys_FichWork" |
---|
1395 | } |
---|
1396 | |
---|
1397 | #D-#================================================== |
---|
1398 | #D-function IGCM_sys_GetDate_FichArchive |
---|
1399 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE |
---|
1400 | #D-* Examples: |
---|
1401 | #D- |
---|
1402 | function IGCM_sys_GetDate_FichArchive { |
---|
1403 | IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ |
---|
1404 | if ( $DEBUG_sys ) ; then |
---|
1405 | echo "IGCM_sys_GetDate_FichArchive :" $@ |
---|
1406 | fi |
---|
1407 | typeset dateF |
---|
1408 | set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) |
---|
1409 | eval ${2}=${dateF[5]} |
---|
1410 | |
---|
1411 | IGCM_debug_PopStack "IGCM_sys_FichArchive" |
---|
1412 | } |
---|
1413 | |
---|
1414 | #D-#================================================== |
---|
1415 | #D-function IGCM_sys_Dods_Rm |
---|
1416 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
1417 | #D-* Examples: |
---|
1418 | #D- |
---|
1419 | function IGCM_sys_Dods_Rm { |
---|
1420 | if ( $DEBUG_sys ) ; then |
---|
1421 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
1422 | fi |
---|
1423 | return 0 |
---|
1424 | } |
---|
1425 | |
---|
1426 | #D-#================================================== |
---|
1427 | #D-function IGCM_sys_Dods_Cp |
---|
1428 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
1429 | #D-* Examples: |
---|
1430 | #D- |
---|
1431 | function IGCM_sys_Dods_Cp { |
---|
1432 | if ( $DEBUG_sys ) ; then |
---|
1433 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
1434 | fi |
---|
1435 | return 0 |
---|
1436 | } |
---|
1437 | |
---|
1438 | #D-#================================================== |
---|
1439 | #D-function IGCM_sys_Put_Dods |
---|
1440 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
1441 | #D-* Examples: |
---|
1442 | #D- |
---|
1443 | function IGCM_sys_Put_Dods { |
---|
1444 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
1445 | if ( $DEBUG_sys ) ; then |
---|
1446 | echo "IGCM_sys_Put_Dods :" $@ |
---|
1447 | fi |
---|
1448 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1449 | } |
---|
1450 | |
---|
1451 | ############################################################## |
---|
1452 | # REBUILD OPERATOR |
---|
1453 | |
---|
1454 | #D-#================================================== |
---|
1455 | #D-function IGCM_sys_rebuild |
---|
1456 | #D-* Purpose: rebuild parallel files |
---|
1457 | #D-* Examples: |
---|
1458 | #D- |
---|
1459 | function IGCM_sys_rebuild { |
---|
1460 | IGCM_debug_PushStack "IGCM_sys_rebuild" $@ |
---|
1461 | if ( $DEBUG_sys ) ; then |
---|
1462 | echo "IGCM_sys_rebuild :" $@ |
---|
1463 | fi |
---|
1464 | |
---|
1465 | typeset NB_ESSAI DELAI status i firstArg |
---|
1466 | # number of tentative |
---|
1467 | NB_ESSAI=3 |
---|
1468 | # time delay between tentative |
---|
1469 | DELAI=2 |
---|
1470 | |
---|
1471 | i=0 |
---|
1472 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1473 | /home/users/igcmg/rebuild/bin/rebuild -f -o $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
1474 | status=$? |
---|
1475 | if [ ${status} -gt 0 ] ; then |
---|
1476 | IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" |
---|
1477 | cat /tmp/out_command_${LOGIN}.$$ |
---|
1478 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1479 | IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1480 | firstArg=${1} |
---|
1481 | \rm ${firstArg} |
---|
1482 | sleep $DELAI |
---|
1483 | else |
---|
1484 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
1485 | break |
---|
1486 | fi |
---|
1487 | (( i = i + 1 )) |
---|
1488 | done |
---|
1489 | |
---|
1490 | if [ ${status} -gt 0 ] ; then |
---|
1491 | echo "IGCM_sys_rebuild : rebuild error code is ${status}" |
---|
1492 | IGCM_debug_Exit "rebuild" |
---|
1493 | fi |
---|
1494 | |
---|
1495 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
1496 | } |
---|
1497 | |
---|
1498 | #D-#================================================== |
---|
1499 | #D-function IGCM_sys_rebuild_station |
---|
1500 | #D-* Purpose: rebuild parallel files describing station |
---|
1501 | #D-* Examples: |
---|
1502 | #D- |
---|
1503 | function IGCM_sys_rebuild_station { |
---|
1504 | IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ |
---|
1505 | typeset i list_opt file_in file_out prefix_invert list_invert |
---|
1506 | if ( $DEBUG_sys ) ; then |
---|
1507 | echo "IGCM_sys_rebuild_station :" $@ |
---|
1508 | fi |
---|
1509 | list_opt=$@ |
---|
1510 | |
---|
1511 | # Invert Axis : t,x -> x,t |
---|
1512 | # t,pres,x -> x,t,pres |
---|
1513 | # So that we can concatenate along x |
---|
1514 | i=0 |
---|
1515 | for file_in in ${list_opt} ; do |
---|
1516 | (( i = i + 1)) |
---|
1517 | [ ${i} = 1 ] && file_out=${file_in} && continue |
---|
1518 | # detect time counter and do the job only if present |
---|
1519 | var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1) |
---|
1520 | if [ X${var_unlim} = Xtime_counter ] ; then |
---|
1521 | prefix_invert=$( basename ${file_in} .nc ) |
---|
1522 | IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc |
---|
1523 | list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc |
---|
1524 | fi |
---|
1525 | done |
---|
1526 | |
---|
1527 | # Concatenate |
---|
1528 | IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc |
---|
1529 | |
---|
1530 | # Re-ivert file |
---|
1531 | IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} |
---|
1532 | |
---|
1533 | # Station re-ordering is too expansive to be run within libIGCM |
---|
1534 | # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. |
---|
1535 | # This re-ordering must be done "in memory" by the cmorization process |
---|
1536 | # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) |
---|
1537 | # BEGIN reordering |
---|
1538 | |
---|
1539 | # Only LMDZ text output contains the exact ordering of the station. |
---|
1540 | # We isolate this in the code below: |
---|
1541 | # 0 38 -157.5000000000000 70.98591549295774 |
---|
1542 | # 0 54 27.49999999999999 67.18309859154928 |
---|
1543 | # 0 56 -62.50000000000001 82.39436619718309 |
---|
1544 | # 0 79 12.49999999999999 78.59154929577466 |
---|
1545 | # 0 116 -165.0000000000000 76.05633802816901 |
---|
1546 | # 0 117 130.0000000000000 70.98591549295774 |
---|
1547 | # 0 118 110.0000000000000 87.46478873239437 |
---|
1548 | # 1 40 4.999999999999995 51.97183098591550 |
---|
1549 | # typeset iStation iProc list_opt file_in file_out prefix_invert |
---|
1550 | # typeset -Z4 j4 |
---|
1551 | # typeset -Z3 j3 |
---|
1552 | |
---|
1553 | # unset list_opt |
---|
1554 | # set +A list_opt $@ |
---|
1555 | |
---|
1556 | # Filename after rebuild |
---|
1557 | # file_out=${list_opt[0]} |
---|
1558 | # Prefix of output files |
---|
1559 | # prefix_invert=$( basename ${file_out} .nc ) |
---|
1560 | # Number of procs |
---|
1561 | # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) |
---|
1562 | |
---|
1563 | # iProc=0 |
---|
1564 | # while [ ${iProc} -lt ${num_proc} ] ; do |
---|
1565 | # Array containing Station as a number |
---|
1566 | # unset proc_stn |
---|
1567 | # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' ) |
---|
1568 | # Number of stations produced by processor proc |
---|
1569 | # stationLast=${#proc_stn[*]} |
---|
1570 | # Proc number on 4 digits |
---|
1571 | # j4=${iProc} |
---|
1572 | # Init |
---|
1573 | # iStation=0 |
---|
1574 | # while [ ${iStation} -lt ${stationLast} ] ; do |
---|
1575 | # Station number on 3 digits |
---|
1576 | # j3=${proc_stn[${iStation}]} |
---|
1577 | # Extract station |
---|
1578 | # Invert Axis : t,x -> x,t |
---|
1579 | # t,pres,x -> x,t,pres |
---|
1580 | # So that we can concatenate along x |
---|
1581 | # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc |
---|
1582 | # (( iStation = iStation + 1 )) |
---|
1583 | # done |
---|
1584 | # (( iProc = iProc + 1 )) |
---|
1585 | # done |
---|
1586 | |
---|
1587 | # Concatenate all station along x |
---|
1588 | # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc |
---|
1589 | |
---|
1590 | # Re-invert file |
---|
1591 | # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} |
---|
1592 | |
---|
1593 | # END reordering |
---|
1594 | |
---|
1595 | IGCM_debug_PopStack "IGCM_sys_rebuild_station" |
---|
1596 | } |
---|
1597 | |
---|
1598 | ############################################################ |
---|
1599 | # Activate Running Environnment Variables |
---|
1600 | |
---|
1601 | #D-#================================================== |
---|
1602 | #D-function IGCM_sys_desactiv_variables |
---|
1603 | #D-* Purpose: set environement variables prior to execution |
---|
1604 | #D-* Examples: |
---|
1605 | #D- |
---|
1606 | function IGCM_sys_activ_variables { |
---|
1607 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
1608 | if ( $DEBUG_sys ) ; then |
---|
1609 | echo "IGCM_sys_activ_variables" |
---|
1610 | fi |
---|
1611 | |
---|
1612 | # -------------------------------------------------------------------- |
---|
1613 | #D- MPI specifications |
---|
1614 | # -------------------------------------------------------------------- |
---|
1615 | |
---|
1616 | # -------------------------------------------------------------------- |
---|
1617 | #D- Other specifications |
---|
1618 | # -------------------------------------------------------------------- |
---|
1619 | |
---|
1620 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
1621 | } |
---|
1622 | |
---|
1623 | ############################################################ |
---|
1624 | # Desactivate Running Environnment Variables |
---|
1625 | |
---|
1626 | #D-#================================================== |
---|
1627 | #D-function IGCM_sys_desactiv_variables |
---|
1628 | #D-* Purpose: unset environement variables after execution |
---|
1629 | #D-* Examples: |
---|
1630 | #D- |
---|
1631 | function IGCM_sys_desactiv_variables { |
---|
1632 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
1633 | if ( $DEBUG_sys ) ; then |
---|
1634 | echo "IGCM_sys_desactiv_variables" |
---|
1635 | fi |
---|
1636 | # -------------------------------------------------------------------- |
---|
1637 | #D- MPI specifications |
---|
1638 | # -------------------------------------------------------------------- |
---|
1639 | |
---|
1640 | # -------------------------------------------------------------------- |
---|
1641 | #D- Other specifications |
---|
1642 | # -------------------------------------------------------------------- |
---|
1643 | |
---|
1644 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
1645 | } |
---|
1646 | |
---|
1647 | ############################################################ |
---|
1648 | # Build MPI/OMP scripts run file (dummy function) |
---|
1649 | |
---|
1650 | #D-#================================================== |
---|
1651 | #D-function IGCM_sys_build_run_file |
---|
1652 | #D-* Purpose: build run file (deprecated) |
---|
1653 | #D-* Examples: |
---|
1654 | #D- |
---|
1655 | function IGCM_sys_build_run_file { |
---|
1656 | |
---|
1657 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
1658 | |
---|
1659 | } |
---|
1660 | |
---|
1661 | ############################################################ |
---|
1662 | # Build MPI/OMP scripts |
---|
1663 | |
---|
1664 | #D-#================================================== |
---|
1665 | #D-function IGCM_sys_build_execution_scripts |
---|
1666 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
1667 | #D-* Examples: |
---|
1668 | #D- |
---|
1669 | function IGCM_sys_build_execution_scripts |
---|
1670 | { |
---|
1671 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
1672 | if ( $DEBUG_sys ) ; then |
---|
1673 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
1674 | fi |
---|
1675 | typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut |
---|
1676 | typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc |
---|
1677 | typeset num_corempi nombre_restant_node nombre_restant_comp |
---|
1678 | |
---|
1679 | if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then |
---|
1680 | IGCM_debug_Exit "IGCM_sys_obelix build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} " |
---|
1681 | fi |
---|
1682 | |
---|
1683 | if ( ${OK_PARA_MPMD} ) ; then |
---|
1684 | |
---|
1685 | if [ -f run_file ] ; then |
---|
1686 | IGCM_sys_Rm -f run_file |
---|
1687 | fi |
---|
1688 | touch run_file |
---|
1689 | |
---|
1690 | if ( ${OK_PARA_OMP} ) ; then |
---|
1691 | |
---|
1692 | # Hosts treatment |
---|
1693 | |
---|
1694 | ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp |
---|
1695 | |
---|
1696 | i=0 |
---|
1697 | rm -f hosts |
---|
1698 | IGCM_debug_Print 1 "sys Obelix, Hosts avaible :" |
---|
1699 | for nodes in `cat hosts.tmp` ; do |
---|
1700 | host[$i]=$nodes |
---|
1701 | echo "${host[$i]} slots=1 max_slots=1" >> hosts |
---|
1702 | IGCM_debug_Print 1 ${host[$i]} |
---|
1703 | i=$((i+1)) |
---|
1704 | done |
---|
1705 | rm -f hosts.tmp |
---|
1706 | |
---|
1707 | listnodes=${host[*]} |
---|
1708 | |
---|
1709 | EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts" |
---|
1710 | |
---|
1711 | # Initialisation |
---|
1712 | |
---|
1713 | init_node=y |
---|
1714 | node_num_current=0 |
---|
1715 | start_num=0 |
---|
1716 | init_exec=n |
---|
1717 | |
---|
1718 | # Test : if oasis is there, we put it at the first position |
---|
1719 | |
---|
1720 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1721 | |
---|
1722 | if [ "X${comp}" = "XCPL" ] ; then |
---|
1723 | |
---|
1724 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1725 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1726 | |
---|
1727 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1728 | echo "" >> script_${ExeNameOut}.ksh |
---|
1729 | #echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
1730 | #echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
1731 | #echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
1732 | echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
1733 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1734 | |
---|
1735 | init_node=n |
---|
1736 | |
---|
1737 | (( nombre_restant_node = NUM_COREPERNODE - 1 )) |
---|
1738 | node_num_current=0 |
---|
1739 | node_current=${host[${node_num_current}]} |
---|
1740 | |
---|
1741 | EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh" |
---|
1742 | |
---|
1743 | init_exec=y |
---|
1744 | start_num=1 |
---|
1745 | |
---|
1746 | fi |
---|
1747 | |
---|
1748 | done |
---|
1749 | |
---|
1750 | # Then loop on the components (except for oasis) |
---|
1751 | |
---|
1752 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1753 | |
---|
1754 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1755 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1756 | |
---|
1757 | # Only if we really have an executable for the component : |
---|
1758 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
1759 | |
---|
1760 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1761 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1762 | |
---|
1763 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1764 | # echo "set -vx" >> script_${ExeNameOut}.ksh |
---|
1765 | echo "" >> script_${ExeNameOut}.ksh |
---|
1766 | #echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
1767 | #echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
1768 | #echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
1769 | echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
1770 | echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >> script_${ExeNameOut}.ksh |
---|
1771 | echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh |
---|
1772 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1773 | |
---|
1774 | node_num=0 |
---|
1775 | |
---|
1776 | # We define the number of MPI process to be assigned for the component |
---|
1777 | |
---|
1778 | nombre_restant_comp=${comp_proc_mpi_loc} |
---|
1779 | |
---|
1780 | # Loop on the allocated nodes |
---|
1781 | |
---|
1782 | for node in ${listnodes} ; do |
---|
1783 | |
---|
1784 | # We go to the current node |
---|
1785 | if [ ${node_num} = ${node_num_current} ] ; then |
---|
1786 | |
---|
1787 | node_current=${host[${node_num_current}]} |
---|
1788 | |
---|
1789 | # If first time on the node : initialisation |
---|
1790 | |
---|
1791 | if [ ${init_node} = y ] ; then |
---|
1792 | nombre_restant_node=${NUM_COREPERNODE} |
---|
1793 | fi |
---|
1794 | |
---|
1795 | # Test on the number of OMP threads |
---|
1796 | |
---|
1797 | if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then |
---|
1798 | (( node_num = node_num + 1 )) |
---|
1799 | node_num_current=${node_num} |
---|
1800 | init_node=y |
---|
1801 | continue |
---|
1802 | fi |
---|
1803 | |
---|
1804 | # Number of MPI process to assign |
---|
1805 | |
---|
1806 | (( num_corempi = nombre_restant_node / comp_proc_omp_loc )) |
---|
1807 | |
---|
1808 | if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then |
---|
1809 | num_corempi=${nombre_restant_comp} |
---|
1810 | fi |
---|
1811 | |
---|
1812 | (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc )) |
---|
1813 | (( nombre_restant_comp = nombre_restant_comp - num_corempi )) |
---|
1814 | |
---|
1815 | if [ ${init_exec} = y ] ; then |
---|
1816 | EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" |
---|
1817 | else |
---|
1818 | EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" |
---|
1819 | init_exec=y |
---|
1820 | fi |
---|
1821 | |
---|
1822 | (( start_num = num_corempi + start_num )) |
---|
1823 | |
---|
1824 | else |
---|
1825 | |
---|
1826 | (( node_num = node_num + 1 )) |
---|
1827 | continue |
---|
1828 | fi |
---|
1829 | |
---|
1830 | # Test on the number of core/process remaining on the node/component |
---|
1831 | |
---|
1832 | if [ ${nombre_restant_node} = 0 ] ; then |
---|
1833 | (( node_num = node_num + 1 )) |
---|
1834 | node_num_current=${node_num} |
---|
1835 | init_node=y |
---|
1836 | |
---|
1837 | if [ ${nombre_restant_comp} = 0 ] ; then |
---|
1838 | break 1 |
---|
1839 | fi |
---|
1840 | else |
---|
1841 | |
---|
1842 | node_num_current=${node_num} |
---|
1843 | init_node=n |
---|
1844 | |
---|
1845 | if [ ${nombre_restant_comp} = 0 ] ; then |
---|
1846 | break 1 |
---|
1847 | fi |
---|
1848 | fi |
---|
1849 | done |
---|
1850 | fi |
---|
1851 | done |
---|
1852 | |
---|
1853 | else |
---|
1854 | |
---|
1855 | # Then first loop on the components for the coupler ie oasis |
---|
1856 | |
---|
1857 | ## the coupler ie oasis must be the first one |
---|
1858 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1859 | |
---|
1860 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1861 | |
---|
1862 | # for CPL component only |
---|
1863 | if [ "X${comp}" = "XCPL" ] ; then |
---|
1864 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1865 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file |
---|
1866 | fi |
---|
1867 | done |
---|
1868 | |
---|
1869 | # Then second loop on the components |
---|
1870 | |
---|
1871 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1872 | |
---|
1873 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1874 | |
---|
1875 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
1876 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
1877 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1878 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
1879 | fi |
---|
1880 | done |
---|
1881 | IGCM_sys_Chmod u+x run_file |
---|
1882 | |
---|
1883 | EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file" |
---|
1884 | |
---|
1885 | fi |
---|
1886 | |
---|
1887 | else # Only one executable. launch it. |
---|
1888 | |
---|
1889 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1890 | |
---|
1891 | # Only if we really have an executable for the component : |
---|
1892 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1893 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
1894 | |
---|
1895 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1896 | echo "" >> script_${ExeNameOut}.ksh |
---|
1897 | if ( ${OK_PARA_OMP} ) ; then |
---|
1898 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1899 | echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
1900 | fi |
---|
1901 | if ( ${OK_PARA_MPI} ) ; then |
---|
1902 | # Default : mpirun used if nb_proc gt 1 |
---|
1903 | # pour sortie out/err par process |
---|
1904 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}" >> script_${ExeNameOut}.ksh |
---|
1905 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1906 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1907 | EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh" |
---|
1908 | else |
---|
1909 | # Default : mpirun is NOT used if nb_proc eq 1 |
---|
1910 | # pour sortie out/err par process |
---|
1911 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
1912 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1913 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1914 | EXECUTION="time ./script_${ExeNameOut}.ksh" |
---|
1915 | fi |
---|
1916 | |
---|
1917 | IGCM_debug_Print 1 "sys Obelix : script_${ExeNameOut}.ksh contains" |
---|
1918 | cat script_${ExeNameOut}.ksh |
---|
1919 | |
---|
1920 | fi |
---|
1921 | done |
---|
1922 | |
---|
1923 | fi |
---|
1924 | |
---|
1925 | IGCM_debug_Print 1 "sys Obelix : execution command is" |
---|
1926 | IGCM_debug_Print 1 "$EXECUTION" |
---|
1927 | |
---|
1928 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
1929 | } |
---|
1930 | |
---|
1931 | #D-#================================================== |
---|
1932 | #D-function IGCM_sys_check_path |
---|
1933 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
1934 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
1935 | #D-* Examples: |
---|
1936 | #D- |
---|
1937 | function IGCM_sys_check_path { |
---|
1938 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
1939 | if ( $DEBUG_sys ) ; then |
---|
1940 | echo "IGCM_sys_check_path" |
---|
1941 | fi |
---|
1942 | |
---|
1943 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then |
---|
1944 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
1945 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
1946 | IGCM_debug_Exit "This will stop the job" |
---|
1947 | fi |
---|
1948 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
1949 | } |
---|
1950 | |
---|
1951 | #D-#================================================== |
---|
1952 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
1953 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
1954 | #D-* Examples: |
---|
1955 | #D- |
---|
1956 | function IGCM_sys_check_quota { |
---|
1957 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
1958 | if ( $DEBUG_sys ) ; then |
---|
1959 | echo "IGCM_sys_check_quota" |
---|
1960 | fi |
---|
1961 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
1962 | } |
---|
1963 | |
---|
1964 | #D-#================================================== |
---|
1965 | #D-function IGCM_sys_CountJobInQueue |
---|
1966 | #D-* Purpose: Check if job_name is currently |
---|
1967 | #D- running or in queue |
---|
1968 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
1969 | #D- |
---|
1970 | function IGCM_sys_CountJobInQueue { |
---|
1971 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
1972 | if ( $DEBUG_sys ) ; then |
---|
1973 | echo "IGCM_sys_CountJobInQueue" |
---|
1974 | fi |
---|
1975 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
1976 | } |
---|
1977 | |
---|
1978 | ############################################################## |
---|
1979 | # NCO OPERATOR |
---|
1980 | |
---|
1981 | #D-#================================================== |
---|
1982 | #D-function IGCM_sys_ncap2 |
---|
1983 | #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry |
---|
1984 | #D-* Examples: |
---|
1985 | #D- |
---|
1986 | function IGCM_sys_ncap2 { |
---|
1987 | IGCM_debug_PushStack "IGCM_sys_ncap2" $@ |
---|
1988 | if ( $DEBUG_sys ) ; then |
---|
1989 | echo "IGCM_sys_ncap2 :" $@ |
---|
1990 | fi |
---|
1991 | |
---|
1992 | typeset NB_ESSAI DELAI status i |
---|
1993 | # number of tentative |
---|
1994 | NB_ESSAI=3 |
---|
1995 | # time delay between tentative |
---|
1996 | DELAI=2 |
---|
1997 | |
---|
1998 | i=0 |
---|
1999 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2000 | ncap2 "$@" > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2001 | status=$? |
---|
2002 | if [ ${status} -gt 0 ] ; then |
---|
2003 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" |
---|
2004 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2005 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2006 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2007 | sleep $DELAI |
---|
2008 | else |
---|
2009 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2010 | break |
---|
2011 | fi |
---|
2012 | (( i = i + 1 )) |
---|
2013 | done |
---|
2014 | |
---|
2015 | if [ ${status} -gt 0 ] ; then |
---|
2016 | echo "IGCM_sys_ncap2 : ncap2 error" |
---|
2017 | IGCM_debug_Exit "ncap2" |
---|
2018 | fi |
---|
2019 | |
---|
2020 | IGCM_debug_PopStack "IGCM_sys_ncap2" |
---|
2021 | } |
---|
2022 | |
---|
2023 | #D-#================================================== |
---|
2024 | #D-function IGCM_sys_ncatted |
---|
2025 | #D-* Purpose: encapsulate ncatted call so as to manage error code and retry |
---|
2026 | #D-* Examples: |
---|
2027 | #D- |
---|
2028 | function IGCM_sys_ncatted { |
---|
2029 | IGCM_debug_PushStack "IGCM_sys_ncatted" $@ |
---|
2030 | if ( $DEBUG_sys ) ; then |
---|
2031 | echo "IGCM_sys_ncatted :" $@ |
---|
2032 | fi |
---|
2033 | |
---|
2034 | typeset NB_ESSAI DELAI status i |
---|
2035 | # number of tentative |
---|
2036 | NB_ESSAI=3 |
---|
2037 | # time delay between tentative |
---|
2038 | DELAI=2 |
---|
2039 | |
---|
2040 | i=0 |
---|
2041 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2042 | ncatted "$@" > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2043 | status=$? |
---|
2044 | if [ ${status} -gt 0 ] ; then |
---|
2045 | IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" |
---|
2046 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2047 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2048 | IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2049 | sleep $DELAI |
---|
2050 | else |
---|
2051 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2052 | break |
---|
2053 | fi |
---|
2054 | (( i = i + 1 )) |
---|
2055 | done |
---|
2056 | |
---|
2057 | if [ ${status} -gt 0 ] ; then |
---|
2058 | echo "IGCM_sys_ncatted : ncatted error" |
---|
2059 | IGCM_debug_Exit "ncatted" |
---|
2060 | fi |
---|
2061 | |
---|
2062 | IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
2063 | } |
---|
2064 | |
---|
2065 | #D-#================================================== |
---|
2066 | #D-function IGCM_sys_ncbo |
---|
2067 | #D-* Purpose: encapsulate ncbo call so as to manage error code and retry |
---|
2068 | #D-* Examples: |
---|
2069 | #D- |
---|
2070 | function IGCM_sys_ncbo { |
---|
2071 | IGCM_debug_PushStack "IGCM_sys_ncbo" $@ |
---|
2072 | if ( $DEBUG_sys ) ; then |
---|
2073 | echo "IGCM_sys_ncbo :" $@ |
---|
2074 | fi |
---|
2075 | |
---|
2076 | typeset NB_ESSAI DELAI status i |
---|
2077 | # number of tentative |
---|
2078 | NB_ESSAI=3 |
---|
2079 | # time delay between tentative |
---|
2080 | DELAI=2 |
---|
2081 | |
---|
2082 | i=0 |
---|
2083 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2084 | ncbo $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2085 | status=$? |
---|
2086 | if [ ${status} -gt 0 ] ; then |
---|
2087 | IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" |
---|
2088 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2089 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2090 | IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2091 | sleep $DELAI |
---|
2092 | else |
---|
2093 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2094 | break |
---|
2095 | fi |
---|
2096 | (( i = i + 1 )) |
---|
2097 | done |
---|
2098 | |
---|
2099 | if [ ${status} -gt 0 ] ; then |
---|
2100 | echo "IGCM_sys_ncbo : ncbo error" |
---|
2101 | IGCM_debug_Exit "ncbo" |
---|
2102 | fi |
---|
2103 | |
---|
2104 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
2105 | } |
---|
2106 | |
---|
2107 | #D-#================================================== |
---|
2108 | #D-function IGCM_sys_ncdif |
---|
2109 | #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry |
---|
2110 | #D-* Examples: |
---|
2111 | #D- |
---|
2112 | function IGCM_sys_ncdiff { |
---|
2113 | IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ |
---|
2114 | if ( $DEBUG_sys ) ; then |
---|
2115 | echo "IGCM_sys_ncdiff :" $@ |
---|
2116 | fi |
---|
2117 | |
---|
2118 | typeset NB_ESSAI DELAI status i |
---|
2119 | # number of tentative |
---|
2120 | NB_ESSAI=3 |
---|
2121 | # time delay between tentative |
---|
2122 | DELAI=2 |
---|
2123 | |
---|
2124 | i=0 |
---|
2125 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2126 | ncdiff $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2127 | status=$? |
---|
2128 | if [ ${status} -gt 0 ] ; then |
---|
2129 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" |
---|
2130 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2131 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2132 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2133 | sleep $DELAI |
---|
2134 | else |
---|
2135 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2136 | break |
---|
2137 | fi |
---|
2138 | (( i = i + 1 )) |
---|
2139 | done |
---|
2140 | |
---|
2141 | if [ ${status} -gt 0 ] ; then |
---|
2142 | echo "IGCM_sys_ncdiff : ncdiff error" |
---|
2143 | IGCM_debug_Exit "ncdiff" |
---|
2144 | fi |
---|
2145 | |
---|
2146 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
2147 | } |
---|
2148 | |
---|
2149 | #D-#================================================== |
---|
2150 | #D-function IGCM_sys_ncea |
---|
2151 | #D-* Purpose: encapsulate ncea call so as to manage error code and retry |
---|
2152 | #D-* Examples: |
---|
2153 | #D- |
---|
2154 | function IGCM_sys_ncea { |
---|
2155 | IGCM_debug_PushStack "IGCM_sys_ncea" $@ |
---|
2156 | if ( $DEBUG_sys ) ; then |
---|
2157 | echo "IGCM_sys_ncea :" $@ |
---|
2158 | fi |
---|
2159 | |
---|
2160 | typeset NB_ESSAI DELAI status i |
---|
2161 | # number of tentative |
---|
2162 | NB_ESSAI=3 |
---|
2163 | # time delay between tentative |
---|
2164 | DELAI=2 |
---|
2165 | |
---|
2166 | i=0 |
---|
2167 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2168 | ncea $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2169 | status=$? |
---|
2170 | if [ ${status} -gt 0 ] ; then |
---|
2171 | IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" |
---|
2172 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2173 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2174 | IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2175 | sleep $DELAI |
---|
2176 | else |
---|
2177 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2178 | break |
---|
2179 | fi |
---|
2180 | (( i = i + 1 )) |
---|
2181 | done |
---|
2182 | |
---|
2183 | if [ ${status} -gt 0 ] ; then |
---|
2184 | echo "IGCM_sys_ncea : ncea error" |
---|
2185 | IGCM_debug_Exit "ncea" |
---|
2186 | fi |
---|
2187 | |
---|
2188 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
2189 | } |
---|
2190 | |
---|
2191 | #D-#================================================== |
---|
2192 | #D-function IGCM_sys_ncecat |
---|
2193 | #D-* Purpose: encapsulate ncecat call so as to manage error code and retry |
---|
2194 | #D-* Examples: |
---|
2195 | #D- |
---|
2196 | function IGCM_sys_ncecat { |
---|
2197 | IGCM_debug_PushStack "IGCM_sys_ncecat" $@ |
---|
2198 | if ( $DEBUG_sys ) ; then |
---|
2199 | echo "IGCM_sys_ncecat :" $@ |
---|
2200 | fi |
---|
2201 | |
---|
2202 | typeset NB_ESSAI DELAI status i |
---|
2203 | # number of tentative |
---|
2204 | NB_ESSAI=3 |
---|
2205 | # time delay between tentative |
---|
2206 | DELAI=2 |
---|
2207 | |
---|
2208 | i=0 |
---|
2209 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2210 | ncecat $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2211 | status=$? |
---|
2212 | if [ ${status} -gt 0 ] ; then |
---|
2213 | IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" |
---|
2214 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2215 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2216 | IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2217 | sleep $DELAI |
---|
2218 | else |
---|
2219 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2220 | break |
---|
2221 | fi |
---|
2222 | (( i = i + 1 )) |
---|
2223 | done |
---|
2224 | |
---|
2225 | if [ ${status} -gt 0 ] ; then |
---|
2226 | echo "IGCM_sys_ncecat : ncecat error" |
---|
2227 | IGCM_debug_Exit "ncecat" |
---|
2228 | fi |
---|
2229 | |
---|
2230 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
2231 | } |
---|
2232 | |
---|
2233 | #D-#================================================== |
---|
2234 | #D-function IGCM_sys_ncflint |
---|
2235 | #D-* Purpose: encapsulate ncflint call so as to manage error code and retry |
---|
2236 | #D-* Examples: |
---|
2237 | #D- |
---|
2238 | function IGCM_sys_ncflint { |
---|
2239 | IGCM_debug_PushStack "IGCM_sys_ncflint" $@ |
---|
2240 | if ( $DEBUG_sys ) ; then |
---|
2241 | echo "IGCM_sys_ncflint :" $@ |
---|
2242 | fi |
---|
2243 | |
---|
2244 | typeset NB_ESSAI DELAI status i |
---|
2245 | # number of tentative |
---|
2246 | NB_ESSAI=3 |
---|
2247 | # time delay between tentative |
---|
2248 | DELAI=2 |
---|
2249 | |
---|
2250 | i=0 |
---|
2251 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2252 | ncflint $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2253 | status=$? |
---|
2254 | if [ ${status} -gt 0 ] ; then |
---|
2255 | IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" |
---|
2256 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2257 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2258 | IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2259 | sleep $DELAI |
---|
2260 | else |
---|
2261 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2262 | break |
---|
2263 | fi |
---|
2264 | (( i = i + 1 )) |
---|
2265 | done |
---|
2266 | |
---|
2267 | if [ ${status} -gt 0 ] ; then |
---|
2268 | echo "IGCM_sys_ncflint : ncflint error" |
---|
2269 | IGCM_debug_Exit "ncflint" |
---|
2270 | fi |
---|
2271 | |
---|
2272 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
2273 | } |
---|
2274 | |
---|
2275 | #D-#================================================== |
---|
2276 | #D-function IGCM_sys_ncks |
---|
2277 | #D-* Purpose: encapsulate ncks call so as to manage error code and retry |
---|
2278 | #D-* Examples: |
---|
2279 | #D- |
---|
2280 | function IGCM_sys_ncks { |
---|
2281 | IGCM_debug_PushStack "IGCM_sys_ncks" $@ |
---|
2282 | if ( $DEBUG_sys ) ; then |
---|
2283 | echo "IGCM_sys_ncks :" $@ |
---|
2284 | fi |
---|
2285 | |
---|
2286 | typeset NB_ESSAI DELAI status i |
---|
2287 | # number of tentative |
---|
2288 | NB_ESSAI=3 |
---|
2289 | # time delay between tentative |
---|
2290 | DELAI=2 |
---|
2291 | |
---|
2292 | i=0 |
---|
2293 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2294 | ncks $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2295 | status=$? |
---|
2296 | if [ ${status} -gt 0 ] ; then |
---|
2297 | IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" |
---|
2298 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2299 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2300 | IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2301 | sleep $DELAI |
---|
2302 | else |
---|
2303 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2304 | break |
---|
2305 | fi |
---|
2306 | (( i = i + 1 )) |
---|
2307 | done |
---|
2308 | |
---|
2309 | if [ ${status} -gt 0 ] ; then |
---|
2310 | echo "IGCM_sys_ncks : ncks error" |
---|
2311 | IGCM_debug_Exit "ncks" |
---|
2312 | fi |
---|
2313 | |
---|
2314 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
2315 | } |
---|
2316 | |
---|
2317 | #D-#================================================== |
---|
2318 | #D-function IGCM_sys_ncpdq |
---|
2319 | #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry |
---|
2320 | #D-* Examples: |
---|
2321 | #D- |
---|
2322 | function IGCM_sys_ncpdq { |
---|
2323 | IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ |
---|
2324 | if ( $DEBUG_sys ) ; then |
---|
2325 | echo "IGCM_sys_ncpdq :" $@ |
---|
2326 | fi |
---|
2327 | |
---|
2328 | typeset NB_ESSAI DELAI status i |
---|
2329 | # number of tentative |
---|
2330 | NB_ESSAI=3 |
---|
2331 | # time delay between tentative |
---|
2332 | DELAI=2 |
---|
2333 | |
---|
2334 | i=0 |
---|
2335 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2336 | ncpdq $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2337 | status=$? |
---|
2338 | if [ ${status} -gt 0 ] ; then |
---|
2339 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" |
---|
2340 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2341 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2342 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2343 | sleep $DELAI |
---|
2344 | else |
---|
2345 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2346 | break |
---|
2347 | fi |
---|
2348 | (( i = i + 1 )) |
---|
2349 | done |
---|
2350 | |
---|
2351 | if [ ${status} -gt 0 ] ; then |
---|
2352 | echo "IGCM_sys_ncpdq : ncpdq error" |
---|
2353 | IGCM_debug_Exit "ncpdq" |
---|
2354 | fi |
---|
2355 | |
---|
2356 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
2357 | } |
---|
2358 | |
---|
2359 | #D-#================================================== |
---|
2360 | #D-function IGCM_sys_ncra |
---|
2361 | #D-* Purpose: encapsulate ncra call so as to manage error code and retry |
---|
2362 | #D-* Examples: |
---|
2363 | #D- |
---|
2364 | function IGCM_sys_ncra { |
---|
2365 | IGCM_debug_PushStack "IGCM_sys_ncra" $@ |
---|
2366 | if ( $DEBUG_sys ) ; then |
---|
2367 | echo "IGCM_sys_ncra :" $@ |
---|
2368 | fi |
---|
2369 | |
---|
2370 | typeset NB_ESSAI DELAI status i |
---|
2371 | # number of tentative |
---|
2372 | NB_ESSAI=3 |
---|
2373 | # time delay between tentative |
---|
2374 | DELAI=2 |
---|
2375 | |
---|
2376 | i=0 |
---|
2377 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2378 | ncra $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2379 | status=$? |
---|
2380 | if [ ${status} -gt 0 ] ; then |
---|
2381 | IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" |
---|
2382 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2383 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2384 | IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2385 | sleep $DELAI |
---|
2386 | else |
---|
2387 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2388 | break |
---|
2389 | fi |
---|
2390 | (( i = i + 1 )) |
---|
2391 | done |
---|
2392 | |
---|
2393 | if [ ${status} -gt 0 ] ; then |
---|
2394 | echo "IGCM_sys_ncra : ncra error" |
---|
2395 | IGCM_debug_Exit "ncra" |
---|
2396 | fi |
---|
2397 | |
---|
2398 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
2399 | } |
---|
2400 | |
---|
2401 | #D-#================================================== |
---|
2402 | #D-function IGCM_sys_ncrcat |
---|
2403 | #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry |
---|
2404 | #D-* Examples: |
---|
2405 | #D- |
---|
2406 | function IGCM_sys_ncrcat { |
---|
2407 | IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ |
---|
2408 | if ( $DEBUG_sys ) ; then |
---|
2409 | echo "IGCM_sys_ncrcat :" $@ |
---|
2410 | fi |
---|
2411 | |
---|
2412 | typeset NB_ESSAI DELAI status i lastArg |
---|
2413 | # number of tentative |
---|
2414 | NB_ESSAI=3 |
---|
2415 | # time delay between tentative |
---|
2416 | DELAI=2 |
---|
2417 | |
---|
2418 | i=0 |
---|
2419 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2420 | ncrcat $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2421 | status=$? |
---|
2422 | if [ ${status} -gt 0 ] ; then |
---|
2423 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" |
---|
2424 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2425 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2426 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2427 | sleep $DELAI |
---|
2428 | elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command_${LOGIN}.$$ )" = "X" ] ; then |
---|
2429 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" |
---|
2430 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2431 | # remove files having corrupted time axis |
---|
2432 | eval lastArg=\${$#} |
---|
2433 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" |
---|
2434 | \rm ${lastArg} |
---|
2435 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2436 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2437 | sleep $DELAI |
---|
2438 | else |
---|
2439 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2440 | break |
---|
2441 | fi |
---|
2442 | (( i = i + 1 )) |
---|
2443 | done |
---|
2444 | |
---|
2445 | if [ ${status} -gt 0 ] ; then |
---|
2446 | echo "IGCM_sys_ncrcat : ncrcat error" |
---|
2447 | #IGCM_debug_Exit "ncrcat" |
---|
2448 | fi |
---|
2449 | |
---|
2450 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
2451 | } |
---|
2452 | |
---|
2453 | #D-#================================================== |
---|
2454 | #D-function IGCM_sys_ncrename |
---|
2455 | #D-* Purpose: encapsulate ncrename call so as to manage error code and retry |
---|
2456 | #D-* Examples: |
---|
2457 | #D- |
---|
2458 | function IGCM_sys_ncrename { |
---|
2459 | IGCM_debug_PushStack "IGCM_sys_ncrename" $@ |
---|
2460 | if ( $DEBUG_sys ) ; then |
---|
2461 | echo "IGCM_sys_ncrename :" $@ |
---|
2462 | fi |
---|
2463 | |
---|
2464 | typeset NB_ESSAI DELAI status i |
---|
2465 | # number of tentative |
---|
2466 | NB_ESSAI=3 |
---|
2467 | # time delay between tentative |
---|
2468 | DELAI=2 |
---|
2469 | |
---|
2470 | i=0 |
---|
2471 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2472 | ncrename $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2473 | status=$? |
---|
2474 | if [ ${status} -gt 0 ] ; then |
---|
2475 | IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" |
---|
2476 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2477 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2478 | IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2479 | sleep $DELAI |
---|
2480 | else |
---|
2481 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2482 | break |
---|
2483 | fi |
---|
2484 | (( i = i + 1 )) |
---|
2485 | done |
---|
2486 | |
---|
2487 | if [ ${status} -gt 0 ] ; then |
---|
2488 | echo "IGCM_sys_ncrename : ncrename error" |
---|
2489 | IGCM_debug_Exit "ncrename" |
---|
2490 | fi |
---|
2491 | |
---|
2492 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
2493 | } |
---|
2494 | |
---|
2495 | #D-#================================================== |
---|
2496 | #D-function IGCM_sys_ncwa |
---|
2497 | #D-* Purpose: encapsulate ncwa call so as to manage error code and retry |
---|
2498 | #D-* Examples: |
---|
2499 | #D- |
---|
2500 | function IGCM_sys_ncwa { |
---|
2501 | IGCM_debug_PushStack "IGCM_sys_ncwa" $@ |
---|
2502 | if ( $DEBUG_sys ) ; then |
---|
2503 | echo "IGCM_sys_ncwa :" $@ |
---|
2504 | fi |
---|
2505 | |
---|
2506 | typeset NB_ESSAI DELAI status i |
---|
2507 | # number of tentative |
---|
2508 | NB_ESSAI=3 |
---|
2509 | # time delay between tentative |
---|
2510 | DELAI=2 |
---|
2511 | |
---|
2512 | i=0 |
---|
2513 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2514 | ncwa $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2515 | status=$? |
---|
2516 | if [ ${status} -gt 0 ] ; then |
---|
2517 | IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" |
---|
2518 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2519 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2520 | IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2521 | sleep $DELAI |
---|
2522 | else |
---|
2523 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2524 | break |
---|
2525 | fi |
---|
2526 | (( i = i + 1 )) |
---|
2527 | done |
---|
2528 | |
---|
2529 | if [ ${status} -gt 0 ] ; then |
---|
2530 | echo "IGCM_sys_ncwa : ncwa error" |
---|
2531 | IGCM_debug_Exit "ncwa" |
---|
2532 | fi |
---|
2533 | |
---|
2534 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
2535 | } |
---|
2536 | |
---|
2537 | ############################################################## |
---|
2538 | # CDO OPERATOR |
---|
2539 | |
---|
2540 | #D-#================================================== |
---|
2541 | #D-function IGCM_sys_cdo |
---|
2542 | #D-* Purpose: encapsulate cdo call so as to manage error code and retry |
---|
2543 | #D-* Examples: |
---|
2544 | #D- |
---|
2545 | function IGCM_sys_cdo { |
---|
2546 | IGCM_debug_PushStack "IGCM_sys_cdo" $@ |
---|
2547 | if ( $DEBUG_sys ) ; then |
---|
2548 | echo "IGCM_sys_cdo :" $@ |
---|
2549 | fi |
---|
2550 | |
---|
2551 | typeset status |
---|
2552 | |
---|
2553 | \cdo $@ > /tmp/out_command_${LOGIN}.$$ 2>&1 |
---|
2554 | status=$? |
---|
2555 | if [ ${status} -gt 0 ] ; then |
---|
2556 | echo "IGCM_sys_cdo : error code ${status}" |
---|
2557 | cat /tmp/out_command_${LOGIN}.$$ |
---|
2558 | \rm /tmp/out_command_${LOGIN}.$$ |
---|
2559 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2560 | return 1 |
---|
2561 | else |
---|
2562 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2563 | return 0 |
---|
2564 | fi |
---|
2565 | |
---|
2566 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2567 | } |
---|