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