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