1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip |
---|
5 | # Contact: Martial.Mancip_ipsl.jussieu.fr |
---|
6 | # $Date$ |
---|
7 | # $Author$ |
---|
8 | # $Revision$ |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # History: |
---|
12 | # Modification: |
---|
13 | # |
---|
14 | #************************************************************** |
---|
15 | |
---|
16 | #========================================================= |
---|
17 | # The documentation of this file can be automatically generated |
---|
18 | # if you use the prefix #D- for comments to be extracted. |
---|
19 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
20 | #========================================================= |
---|
21 | |
---|
22 | #D-#================================================== |
---|
23 | #D-LibIGCM_sys Default host |
---|
24 | #D-#================================================== |
---|
25 | #D- |
---|
26 | #D- This ksh library if a layer under some usefull |
---|
27 | #D- environment variables and shell commands. |
---|
28 | #D- All those definitions depend on host particularities. |
---|
29 | #D- It manages a stack mechanism and test validity of operations. |
---|
30 | #D- All function described bellow must be prefixed by IGCM_sys. |
---|
31 | |
---|
32 | #==================================================== |
---|
33 | # libIGCM_sys PARAMETERS |
---|
34 | #==================================================== |
---|
35 | |
---|
36 | #==================================================== |
---|
37 | #set DEBUG_sys to true to output calls of function |
---|
38 | typeset -r DEBUG_sys=${DEBUG_sys:=true} |
---|
39 | |
---|
40 | #==================================================== |
---|
41 | # Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get) |
---|
42 | typeset -r DRYRUN=${DRYRUN:=0} |
---|
43 | |
---|
44 | # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! |
---|
45 | # ------------------------------------------------------------------------------------- |
---|
46 | # | DRYRUN= | Date computations, | sys_Get | Exe | sys_Put_Out; sys_Put_Rest | |
---|
47 | # | | Cp/Exe param files | | Chmod | | |
---|
48 | # | | Qsub | | | | |
---|
49 | # ------------------------------------------------------------------------------------- |
---|
50 | # | 0 | yes | yes | yes | yes | |
---|
51 | # ------------------------------------------------------------------------------------- |
---|
52 | # | 1 | yes | yes | yes | no | |
---|
53 | # ------------------------------------------------------------------------------------- |
---|
54 | # | 2 | yes | yes | no | no | |
---|
55 | # ------------------------------------------------------------------------------------- |
---|
56 | # | 3 | yes | no | no | no | |
---|
57 | # ------------------------------------------------------------------------------------- |
---|
58 | |
---|
59 | #===================================================== |
---|
60 | #Global Variables : |
---|
61 | #===================================================== |
---|
62 | # Language : "fr" or "en" |
---|
63 | typeset -r MYLANG="fr" |
---|
64 | |
---|
65 | #===================================================== |
---|
66 | # Host and user names |
---|
67 | # $hostname ou hostname |
---|
68 | typeset HOST=${HOST:=$( hostname )} |
---|
69 | # $username ou whoami |
---|
70 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
71 | # $hostname of the MASTER job |
---|
72 | typeset -r MASTER=${HOST} |
---|
73 | |
---|
74 | #D- |
---|
75 | #D-#================================================== |
---|
76 | #D-Program used in libIGCM |
---|
77 | #D-#================================================== |
---|
78 | |
---|
79 | # rsync with path |
---|
80 | typeset -r RSYNC=/usr/bin/rsync |
---|
81 | #RSYNC_opt args to rsync |
---|
82 | typeset -r RSYNC_opt="-va" |
---|
83 | #"-Lt -v" |
---|
84 | |
---|
85 | #==================================================== |
---|
86 | # Set environment tools (ferret, nco, cdo) |
---|
87 | #==================================================== |
---|
88 | #. /home/${LOGIN}/.atlas_env_${HOST}_ksh |
---|
89 | |
---|
90 | #==================================================== |
---|
91 | # Host specific DIRECTORIES |
---|
92 | #==================================================== |
---|
93 | |
---|
94 | #==================================================== |
---|
95 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
96 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
97 | |
---|
98 | #==================================================== |
---|
99 | #- libIGCM_POST |
---|
100 | typeset -r libIGCM_POST=${libIGCM} |
---|
101 | |
---|
102 | #==================================================== |
---|
103 | #- SCRATCHDIR (=> ${R_DONNEES}) |
---|
104 | typeset -r SCRATCHDIR=/tmp |
---|
105 | |
---|
106 | #==================================================== |
---|
107 | #- SUBMIT_DIR : submission dir |
---|
108 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}} |
---|
109 | |
---|
110 | #==================================================== |
---|
111 | #- ARCHIVE |
---|
112 | typeset -r ARCHIVE=/home/${LOGIN} |
---|
113 | |
---|
114 | #==================================================== |
---|
115 | #- IN |
---|
116 | typeset -r R_IN=${R_IN:=${ARCHIVE}/IGCM} |
---|
117 | |
---|
118 | #==================================================== |
---|
119 | #- OUT |
---|
120 | IGCM_OUT=${IGCM_OUT:=IGCM_OUT} |
---|
121 | typeset -r R_OUT=${ARCHIVE}/${IGCM_OUT} |
---|
122 | |
---|
123 | #==================================================== |
---|
124 | #- OUT_POST |
---|
125 | typeset -r R_OUT_POST=${R_OUT} |
---|
126 | |
---|
127 | #==================================================== |
---|
128 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
129 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/tmp$$} |
---|
130 | |
---|
131 | #==================================================== |
---|
132 | #- BIG_DIR : BIG_DIR to store files waiting for rebuild |
---|
133 | typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} |
---|
134 | |
---|
135 | #==================================================== |
---|
136 | #- HOST_MPIRUN_COMMAND |
---|
137 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"} |
---|
138 | |
---|
139 | #========================================================= |
---|
140 | #- Add "time" before mpirun command |
---|
141 | MPIRUN_COMMAND="time "${MPIRUN_COMMAND} |
---|
142 | echo ${MPIRUN_COMMAND} |
---|
143 | |
---|
144 | #==================================================== |
---|
145 | #- Max number of arguments passed to nco operator or demigration command |
---|
146 | UNIX_MAX_LIMIT=360 |
---|
147 | |
---|
148 | #D-#================================================== |
---|
149 | #D-function IGCM_sys_RshMaster |
---|
150 | #D-* Purpose: Master rsh command |
---|
151 | #D-* Examples: |
---|
152 | #D- |
---|
153 | function IGCM_sys_RshMaster { |
---|
154 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
155 | ssh ${HOST} /bin/ksh <<-EOF |
---|
156 | export libIGCM=${libIGCM} |
---|
157 | export DEBUG_debug=${DEBUG_debug} |
---|
158 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
159 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
160 | ${@} |
---|
161 | EOF |
---|
162 | if [ $? -gt 0 ] ; then |
---|
163 | echo "IGCM_sys_RshMaster : erreur." |
---|
164 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
165 | fi |
---|
166 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
167 | } |
---|
168 | |
---|
169 | #D-#================================================== |
---|
170 | #D-function IGCM_sys_RshArchive |
---|
171 | #D-* Purpose: Archive rsh command |
---|
172 | #D-* Examples: |
---|
173 | #D- |
---|
174 | function IGCM_sys_RshArchive { |
---|
175 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
176 | /bin/ksh <<-EOF |
---|
177 | ${@} |
---|
178 | EOF |
---|
179 | if [ $? -gt 0 ] ; then |
---|
180 | echo "IGCM_sys_RshArchive : erreur." |
---|
181 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
182 | fi |
---|
183 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
184 | } |
---|
185 | |
---|
186 | #D-#================================================== |
---|
187 | #D-function IGCM_sys_RshPost |
---|
188 | #D-* Purpose: Post-process rsh command |
---|
189 | #D-* Examples: |
---|
190 | #D- |
---|
191 | (( RshPNum = 0 )) |
---|
192 | function IGCM_sys_RshPost { |
---|
193 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
194 | if ( $DEBUG_sys ) ; then |
---|
195 | echo "IGCM_sys_RshPost :" $@ |
---|
196 | fi |
---|
197 | #ssh ${HOST} exec /bin/ksh -vx $@ > out_RshPost.${RshPNum} |
---|
198 | ssh ${HOST} exec /bin/ksh $@ > out_RshPost.${RshPNum} |
---|
199 | if [ $? -gt 0 ] ; then |
---|
200 | echo "IGCM_sys_RshPost : erreur." |
---|
201 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
202 | fi |
---|
203 | (( RshPNum = RshPNum + 1 )) |
---|
204 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
205 | } |
---|
206 | |
---|
207 | #D-#================================================== |
---|
208 | #D-function IGCM_sys_SendMail |
---|
209 | #D-* Purpose: Send mail when simulation is over |
---|
210 | #D-* Examples: |
---|
211 | #D- |
---|
212 | function IGCM_sys_SendMail { |
---|
213 | IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@ |
---|
214 | if ( $DEBUG_sys ) ; then |
---|
215 | echo "IGCM_sys_SendMail :" $@ |
---|
216 | fi |
---|
217 | |
---|
218 | cat << END_MAIL > job_end.mail |
---|
219 | Dear ${LOGIN}, |
---|
220 | |
---|
221 | Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`. |
---|
222 | Job started : ${DateBegin} |
---|
223 | Job ended : ${DateEnd} |
---|
224 | Ouput files are available in ${R_SAVE} |
---|
225 | Script files and Script Outputs are available in ${SUBMIT_DIR} |
---|
226 | END_MAIL |
---|
227 | |
---|
228 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
229 | mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} < job_end.mail |
---|
230 | elif [ -f ~/.forward ] ; then |
---|
231 | mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail |
---|
232 | fi |
---|
233 | |
---|
234 | if [ $? -gt 0 ] ; then |
---|
235 | echo "IGCM_sys_SendMail : erreur." |
---|
236 | IGCM_debug_Exit "IGCM_sys_SendMail" |
---|
237 | fi |
---|
238 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
239 | } |
---|
240 | |
---|
241 | #D-#================================================== |
---|
242 | #D-function IGCM_sys_Mkdir |
---|
243 | #D-* Purpose: Master locale mkdir command |
---|
244 | #D-* Examples: |
---|
245 | #D- |
---|
246 | function IGCM_sys_Mkdir { |
---|
247 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
248 | if ( $DEBUG_sys ) ; then |
---|
249 | echo "IGCM_sys_Mkdir :" $@ |
---|
250 | fi |
---|
251 | if [ ! -d ${1} ]; then |
---|
252 | \mkdir -p $1 |
---|
253 | if [ $? -gt 0 ] ; then |
---|
254 | echo "IGCM_sys_Mkdir : erreur." |
---|
255 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
256 | fi |
---|
257 | fi |
---|
258 | # vérification : |
---|
259 | if [ ! -d ${1} ] ; then |
---|
260 | echo "IGCM_sys_Mkdir : erreur." |
---|
261 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
262 | fi |
---|
263 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
264 | } |
---|
265 | |
---|
266 | #D-#================================================== |
---|
267 | #D-function IGCM_sys_MkdirArchive |
---|
268 | #D-* Purpose: Mkdir on Archive |
---|
269 | #D-* Examples: |
---|
270 | #D- |
---|
271 | function IGCM_sys_MkdirArchive { |
---|
272 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
273 | if ( $DEBUG_sys ) ; then |
---|
274 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
275 | fi |
---|
276 | #- creation de repertoire sur le serveur fichier |
---|
277 | if [ ! -d ${1} ]; then |
---|
278 | \mkdir -p $1 |
---|
279 | if [ $? -gt 0 ] ; then |
---|
280 | echo "IGCM_sys_MkdirArchive : erreur." |
---|
281 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
282 | fi |
---|
283 | fi |
---|
284 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
285 | } |
---|
286 | |
---|
287 | #D-#================================================== |
---|
288 | #D-function IGCM_sys_MkdirWork |
---|
289 | #D-* Purpose: Mkdir on Work |
---|
290 | #D-* Examples: |
---|
291 | #D- |
---|
292 | function IGCM_sys_MkdirWork { |
---|
293 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
294 | if ( $DEBUG_sys ) ; then |
---|
295 | echo "IGCM_sys_MkdirWork :" $@ |
---|
296 | fi |
---|
297 | #- creation de repertoire sur le serveur fichier |
---|
298 | if [ ! -d ${1} ]; then |
---|
299 | \mkdir -p $1 |
---|
300 | if [ $? -gt 0 ] ; then |
---|
301 | echo "IGCM_sys_MkdirWork : erreur." |
---|
302 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
303 | fi |
---|
304 | fi |
---|
305 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
306 | } |
---|
307 | |
---|
308 | #D-#================================================== |
---|
309 | #D-function IGCM_sys_Cd |
---|
310 | #D-* Purpose: master cd command |
---|
311 | #D-* Examples: |
---|
312 | #D- |
---|
313 | function IGCM_sys_Cd { |
---|
314 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
315 | if ( $DEBUG_sys ) ; then |
---|
316 | echo "IGCM_sys_Cd :" $@ |
---|
317 | fi |
---|
318 | \cd $1 |
---|
319 | if [ $? -gt 0 ] ; then |
---|
320 | echo "IGCM_sys_Cd : erreur." |
---|
321 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
322 | fi |
---|
323 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
324 | } |
---|
325 | |
---|
326 | #D-#================================================== |
---|
327 | #D-function IGCM_sys_Chmod |
---|
328 | #D-* Purpose: Chmod |
---|
329 | #D-* Examples: |
---|
330 | #D- |
---|
331 | function IGCM_sys_Chmod { |
---|
332 | IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ |
---|
333 | if ( $DEBUG_sys ) ; then |
---|
334 | echo "IGCM_sys_Chmod :" $@ |
---|
335 | fi |
---|
336 | if [ $DRYRUN -le 1 ]; then |
---|
337 | \chmod $@ |
---|
338 | if [ $? -gt 0 ] ; then |
---|
339 | echo "IGCM_sys_Chmod : erreur." |
---|
340 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
341 | fi |
---|
342 | else |
---|
343 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
344 | fi |
---|
345 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
346 | } |
---|
347 | |
---|
348 | #D-#================================================== |
---|
349 | #D-function IGCM_sys_FileSize |
---|
350 | #D-* Purpose: Filesize |
---|
351 | #D-* Examples: |
---|
352 | #D- |
---|
353 | function IGCM_sys_FileSize { |
---|
354 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
355 | |
---|
356 | typeset sizeF |
---|
357 | set +A sizeF -- $( ls -la ${1} ) |
---|
358 | if [ $? -gt 0 ] ; then |
---|
359 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
360 | fi |
---|
361 | eval ${2}=${sizeF[4]} |
---|
362 | |
---|
363 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
364 | } |
---|
365 | |
---|
366 | #D-#================================================== |
---|
367 | #D-function IGCM_sys_TestDir |
---|
368 | #D-* Purpose: Test Directory that must exists |
---|
369 | #D-* Examples: |
---|
370 | #D- |
---|
371 | function IGCM_sys_TestDir { |
---|
372 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
373 | if ( $DEBUG_sys ) ; then |
---|
374 | echo "IGCM_sys_TestDir :" $@ |
---|
375 | fi |
---|
376 | typeset ExistFlag |
---|
377 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
378 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
379 | |
---|
380 | return ${ExistFlag} |
---|
381 | } |
---|
382 | |
---|
383 | #D-#================================================== |
---|
384 | #D-function IGCM_sys_TestDirArchive |
---|
385 | #D-* Purpose: Test Directory that must exists on Archive |
---|
386 | #D-* Examples: |
---|
387 | #D- |
---|
388 | function IGCM_sys_TestDirArchive { |
---|
389 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
390 | if ( $DEBUG_sys ) ; then |
---|
391 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
392 | fi |
---|
393 | typeset ExistFlag |
---|
394 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
395 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
396 | |
---|
397 | return ${ExistFlag} |
---|
398 | } |
---|
399 | |
---|
400 | #D-#================================================== |
---|
401 | #D-function IGCM_sys_TestFileArchive |
---|
402 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
403 | #D-* Examples: |
---|
404 | #D- |
---|
405 | function IGCM_sys_TestFileArchive { |
---|
406 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
407 | if ( $DEBUG_sys ) ; then |
---|
408 | echo "IGCM_sys_TestFileArchive :" $@ |
---|
409 | fi |
---|
410 | typeset ExistFlag |
---|
411 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
412 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
413 | |
---|
414 | return ${ExistFlag} |
---|
415 | } |
---|
416 | |
---|
417 | #D-#================================================== |
---|
418 | #D-function IGCM_sys_CountFileArchive |
---|
419 | #D-* Purpose: Count files on Archive filesystem |
---|
420 | #D-* Examples: |
---|
421 | #D- |
---|
422 | function IGCM_sys_CountFileArchive { |
---|
423 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
424 | ls ${@} 2>/dev/null | wc -l |
---|
425 | if [ $? -gt 0 ] ; then |
---|
426 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
427 | fi |
---|
428 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
429 | } |
---|
430 | |
---|
431 | #D-#================================================== |
---|
432 | #D-function IGCM_sys_Tree |
---|
433 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
434 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
435 | #D- |
---|
436 | function IGCM_sys_Tree { |
---|
437 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
438 | if ( $DEBUG_sys ) ; then |
---|
439 | echo "IGCM_sys_Tree :" $@ |
---|
440 | fi |
---|
441 | |
---|
442 | \tree -f $@ |
---|
443 | |
---|
444 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
445 | } |
---|
446 | |
---|
447 | #D-#================================================== |
---|
448 | #D-function IGCM_sys_Tar |
---|
449 | #D-* Purpose: master un-tar command |
---|
450 | #D-* Examples: |
---|
451 | #D- |
---|
452 | function IGCM_sys_Tar { |
---|
453 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
454 | if ( $DEBUG_sys ) ; then |
---|
455 | echo "IGCM_sys_Tar :" $@ |
---|
456 | fi |
---|
457 | \tar cvf $@ |
---|
458 | if [ $? -gt 0 ] ; then |
---|
459 | echo "IGCM_sys_Tar : erreur." |
---|
460 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
461 | fi |
---|
462 | \tar tvf $1 |
---|
463 | |
---|
464 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
465 | } |
---|
466 | |
---|
467 | #D-#================================================== |
---|
468 | #D-function IGCM_sys_UnTar |
---|
469 | #D-* Purpose: master un-tar command |
---|
470 | #D-* Examples: |
---|
471 | #D- |
---|
472 | function IGCM_sys_UnTar { |
---|
473 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
474 | if ( $DEBUG_sys ) ; then |
---|
475 | echo "IGCM_sys_UnTar :" $@ |
---|
476 | fi |
---|
477 | \tar xvf $1 |
---|
478 | if [ $? -gt 0 ] ; then |
---|
479 | echo "IGCM_sys_UnTar : erreur." |
---|
480 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
481 | fi |
---|
482 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
483 | } |
---|
484 | |
---|
485 | #D-#================================================== |
---|
486 | #D-function IGCM_sys_Qsub |
---|
487 | #D-* Purpose: Qsub new job |
---|
488 | #D-* Examples: |
---|
489 | #D- |
---|
490 | function IGCM_sys_Qsub { |
---|
491 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
492 | if ( $DEBUG_sys ) ; then |
---|
493 | echo "IGCM_sys_Qsub :" $@ |
---|
494 | fi |
---|
495 | echo "ssh -l ${LOGIN} ${HOST} ""cd ${SUBMIT_DIR} ; ${@}"" > ${Script_Output} 2>&1 &" |
---|
496 | ssh -l ${LOGIN} ${HOST} "cd ${SUBMIT_DIR} ; ${@}" > ${Script_Output} 2>&1 & |
---|
497 | if [ $? -gt 0 ] ; then |
---|
498 | echo "IGCM_sys_Qsub : erreur." |
---|
499 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
500 | fi |
---|
501 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
502 | } |
---|
503 | |
---|
504 | #D-#================================================== |
---|
505 | #D-function IGCM_sys_QsubPost |
---|
506 | #D-* Purpose: Qsub new job on scalaire |
---|
507 | #D-* Examples: |
---|
508 | #D- |
---|
509 | function IGCM_sys_QsubPost { |
---|
510 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
511 | if ( $DEBUG_sys ) ; then |
---|
512 | echo "IGCM_sys_QsubPost :" $@ |
---|
513 | fi |
---|
514 | #echo "ssh -x -l ${LOGIN} ${HOST} ${3} > ${2} 2>&1 &" |
---|
515 | # ssh -x -l ${LOGIN} ${HOST} |
---|
516 | echo "${libIGCM_POST}/$1.job > ${POST_DIR}/$1.${PeriodDateEnd}.out 2>&1 &" |
---|
517 | ${libIGCM_POST}/$1.job > ${POST_DIR}/$1.${PeriodDateEnd}.out 2>&1 & |
---|
518 | # ${3} > ${2} 2>&1 & |
---|
519 | if [ $? -gt 0 ] ; then |
---|
520 | echo "IGCM_sys_QsubPost : erreur " $@ |
---|
521 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
522 | fi |
---|
523 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
524 | } |
---|
525 | |
---|
526 | #D-************************* |
---|
527 | #D- File transfer functions |
---|
528 | #D-************************* |
---|
529 | #D- |
---|
530 | |
---|
531 | #D-#================================================== |
---|
532 | #D-function IGCM_sys_Rsync_out |
---|
533 | #D-* Purpose: treat return val of rsync |
---|
534 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
535 | #D- Error values and explanations can depend on your system version. |
---|
536 | function IGCM_sys_Rsync_out { |
---|
537 | RET=$1 |
---|
538 | if [ ! $RET ] ; then |
---|
539 | echo "rsync error !" |
---|
540 | fi |
---|
541 | |
---|
542 | if [ $MYLANG = "fr" ]; then |
---|
543 | case $RET in |
---|
544 | 0) return ;; |
---|
545 | 1) echo "Erreur de rsync ; RERR_SYNTAX : " |
---|
546 | echo "Erreur de syntaxe ou d'utilisation." |
---|
547 | return;; |
---|
548 | 2) echo "Erreur de rsync ; RERR_PROTOCOL : " |
---|
549 | echo "Incompatibilité de protocole." |
---|
550 | return;; |
---|
551 | 3) echo "Erreur de rsync ; RERR_FILESELECT 3" |
---|
552 | echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" |
---|
553 | echo "répertoires" |
---|
554 | return;; |
---|
555 | 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" |
---|
556 | echo "Action demandée non supportée : une tentative de manipulation de" |
---|
557 | echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" |
---|
558 | echo "été faite ; ou une option qui est supportée par le client mais" |
---|
559 | echo "pas par le serveur a été spécifiée." |
---|
560 | return;; |
---|
561 | 10) echo "Erreur de rsync ; RERR_SOCKETIO" |
---|
562 | echo "Erreur dans le socket d'entrée sortie" |
---|
563 | return;; |
---|
564 | 11) echo "Erreur de rsync ; RERR_FILEIO" |
---|
565 | echo "Erreur d'entrée sortie fichier" |
---|
566 | return;; |
---|
567 | 12) echo "Erreur de rsync ; RERR_STREAMIO" |
---|
568 | echo "Erreur dans flux de donnée du protocole rsync" |
---|
569 | return;; |
---|
570 | 13) echo "Erreur de rsync ; RERR_MESSAGEIO" |
---|
571 | echo "Erreur avec les diagnostics du programme" |
---|
572 | return;; |
---|
573 | 14) echo "Erreur de rsync ; RERR_IPC" |
---|
574 | echo "Erreur dans le code IPC" |
---|
575 | return;; |
---|
576 | 20) echo "Erreur de rsync ; RERR_SIGNAL" |
---|
577 | echo "SIGUSR1 ou SIGINT reçu" |
---|
578 | return;; |
---|
579 | 21) echo "Erreur de rsync ; RERR_WAITCHILD" |
---|
580 | echo "Une erreur retournée par waitpid()" |
---|
581 | return;; |
---|
582 | 22) echo "Erreur de rsync ; RERR_MALLOC" |
---|
583 | echo "Erreur lors de l'allocation des tampons de mémoire de coeur" |
---|
584 | return;; |
---|
585 | 23) echo "" |
---|
586 | echo "Erreur fichier inexistant" |
---|
587 | return;; |
---|
588 | 30) echo "Erreur de rsync ; RERR_TIMEOUT" |
---|
589 | echo "Temps d'attente écoulé dans l'envoi/réception de données" |
---|
590 | return;; |
---|
591 | *) echo "Erreur de rsync : code de retour de rsync inconnu :" $RET |
---|
592 | return;; |
---|
593 | esac |
---|
594 | elif [ $MYLANG = "en" ] ; then |
---|
595 | case $RET in |
---|
596 | 0) return;; |
---|
597 | 1) echo "rsync error : Syntax or usage error " |
---|
598 | return;; |
---|
599 | 2) echo "rsync error : Protocol incompatibility " |
---|
600 | return;; |
---|
601 | 3) echo "rsync error : Errors selecting input/output files, dirs" |
---|
602 | return;; |
---|
603 | 4) echo "rsync error : Requested action not supported: an attempt" |
---|
604 | echo "was made to manipulate 64-bit files on a platform that cannot support" |
---|
605 | echo "them; or an option was specified that is supported by the client and" |
---|
606 | echo "not by the server." |
---|
607 | return;; |
---|
608 | 5) echo "rsync error : Error starting client-server protocol" |
---|
609 | return;; |
---|
610 | 10) echo "rsync error : Error in socket I/O " |
---|
611 | return;; |
---|
612 | 11) echo "rsync error : Error in file I/O " |
---|
613 | return;; |
---|
614 | 12) echo "rsync error : Error in rsync protocol data stream " |
---|
615 | return;; |
---|
616 | 13) echo "rsync error : Errors with program diagnostics " |
---|
617 | return;; |
---|
618 | 14) echo "rsync error : Error in IPC code " |
---|
619 | return;; |
---|
620 | 20) echo "rsync error : Received SIGUSR1 or SIGINT " |
---|
621 | return;; |
---|
622 | 21) echo "rsync error : Some error returned by waitpid() " |
---|
623 | return;; |
---|
624 | 22) echo "rsync error : Error allocating core memory buffers " |
---|
625 | return;; |
---|
626 | 23) echo "rsync error : Partial transfer due to error" |
---|
627 | return;; |
---|
628 | 24) echo "rsync error : Partial transfer due to vanished source files" |
---|
629 | return;; |
---|
630 | 30) echo "rsync error : Timeout in data send/receive " |
---|
631 | return;; |
---|
632 | *) echo "rsync error : return code of rsync unknown :" $RET |
---|
633 | return;; |
---|
634 | esac |
---|
635 | else |
---|
636 | echo "unknown language $MYLANG." |
---|
637 | return |
---|
638 | fi |
---|
639 | } |
---|
640 | |
---|
641 | #D-#================================================== |
---|
642 | #D-function IGCM_sys_Cp |
---|
643 | #D-* Purpose: generic cp |
---|
644 | #D-* Examples: |
---|
645 | #D- |
---|
646 | function IGCM_sys_Cp { |
---|
647 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
648 | if ( $DEBUG_sys ) ; then |
---|
649 | echo "IGCM_sys_Cp :" $@ |
---|
650 | fi |
---|
651 | |
---|
652 | typeset RET |
---|
653 | |
---|
654 | echo cp --preserve=timestamps $@ > out_rsync 2>&1 |
---|
655 | \cp --preserve=timestamps $@ >> out_rsync 2>&1 |
---|
656 | RET=$? |
---|
657 | |
---|
658 | if [ ${RET} -gt 0 ] ; then |
---|
659 | echo "" |
---|
660 | # echo "IGCM_sys_Cp : error." |
---|
661 | # cat out_rsync |
---|
662 | # IGCM_debug_Exit "IGCM_sys_Cp" |
---|
663 | else |
---|
664 | rm out_rsync |
---|
665 | fi |
---|
666 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
667 | } |
---|
668 | |
---|
669 | #D-#================================================== |
---|
670 | #D-function IGCM_sys_Rm |
---|
671 | #D-* Purpose: generic rm |
---|
672 | #D-* Examples: |
---|
673 | #D- |
---|
674 | function IGCM_sys_Rm { |
---|
675 | IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ |
---|
676 | if ( $DEBUG_sys ) ; then |
---|
677 | echo "IGCM_sys_Rm :" $@ |
---|
678 | fi |
---|
679 | |
---|
680 | typeset RET |
---|
681 | |
---|
682 | echo rm $@ > out_rsync 2>&1 |
---|
683 | \rm $@ >> out_rsync 2>&1 |
---|
684 | RET=$? |
---|
685 | |
---|
686 | if [ ${RET} -gt 0 ] ; then |
---|
687 | echo "IGCM_sys_Rm : error." |
---|
688 | cat out_rsync |
---|
689 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
690 | else |
---|
691 | rm out_rsync |
---|
692 | fi |
---|
693 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
694 | } |
---|
695 | |
---|
696 | #D-#================================================== |
---|
697 | #D-function IGCM_sys_RmRunDir |
---|
698 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
699 | #D- scheduler will do the job) |
---|
700 | #D-* Examples: |
---|
701 | #D- |
---|
702 | function IGCM_sys_RmRunDir { |
---|
703 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ |
---|
704 | if ( $DEBUG_sys ) ; then |
---|
705 | echo "IGCM_sys_RmRunDir :" $@ |
---|
706 | echo "Dummy call, let the scheduler do that." |
---|
707 | # IGCM_sys_Rm -rf ${RUN_DIR} |
---|
708 | fi |
---|
709 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
710 | } |
---|
711 | |
---|
712 | #D-#================================================== |
---|
713 | #D-function IGCM_sys_Mv |
---|
714 | #D-* Purpose: generic move |
---|
715 | #D-* Examples: |
---|
716 | #D- |
---|
717 | function IGCM_sys_Mv { |
---|
718 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
719 | if ( $DEBUG_sys ) ; then |
---|
720 | echo "IGCM_sys_Mv :" $@ |
---|
721 | fi |
---|
722 | |
---|
723 | if [ $DRYRUN = 0 ]; then |
---|
724 | |
---|
725 | typeset RET |
---|
726 | |
---|
727 | echo mv $@ > out_rsync 2>&1 |
---|
728 | \mv $@ >> out_rsync 2>&1 |
---|
729 | RET=$? |
---|
730 | |
---|
731 | if [ ${RET} -gt 0 ] ; then |
---|
732 | echo "IGCM_sys_Mv : error in mv." |
---|
733 | cat out_rsync |
---|
734 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
735 | else |
---|
736 | rm out_rsync |
---|
737 | fi |
---|
738 | else |
---|
739 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
740 | fi |
---|
741 | |
---|
742 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
743 | } |
---|
744 | |
---|
745 | #D-#================================================== |
---|
746 | #D-function IGCM_sys_Put_Dir |
---|
747 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
748 | #D-* Examples: |
---|
749 | #D- |
---|
750 | function IGCM_sys_Put_Dir { |
---|
751 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
752 | if ( $DEBUG_sys ) ; then |
---|
753 | echo "IGCM_sys_Put_Dir :" $@ |
---|
754 | fi |
---|
755 | if [ $DRYRUN = 0 ]; then |
---|
756 | if [ ! -d ${1} ] ; then |
---|
757 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
758 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
759 | return |
---|
760 | fi |
---|
761 | |
---|
762 | typeset RET |
---|
763 | |
---|
764 | # Only if we use rsync |
---|
765 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
766 | # |
---|
767 | #USUAL WAY |
---|
768 | \cp -R $1 $2 > out_rsync 2>&1 |
---|
769 | RET=$? |
---|
770 | |
---|
771 | if [ ${RET} -gt 0 ] ; then |
---|
772 | echo "IGCM_sys_Put_Dir : error." |
---|
773 | cat out_rsync |
---|
774 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
775 | else |
---|
776 | rm out_rsync |
---|
777 | fi |
---|
778 | else |
---|
779 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
780 | fi |
---|
781 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
782 | } |
---|
783 | |
---|
784 | #D-#================================================== |
---|
785 | #D-function IGCM_sys_Get_Dir |
---|
786 | #D-* Purpose: Copy a complete directory from $(ARCHIVE) |
---|
787 | #D-* Examples: |
---|
788 | #D- |
---|
789 | function IGCM_sys_Get_Dir { |
---|
790 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
791 | if ( $DEBUG_sys ) ; then |
---|
792 | echo "IGCM_sys_Get_Dir :" $@ |
---|
793 | fi |
---|
794 | if [ $DRYRUN = 0 ]; then |
---|
795 | if [ ! -d ${1} ] ; then |
---|
796 | echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
797 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
798 | return |
---|
799 | fi |
---|
800 | |
---|
801 | typeset RET |
---|
802 | |
---|
803 | #USUAL WAY |
---|
804 | \cp -R $1 $2 > out_rsync 2>&1 |
---|
805 | RET=$? |
---|
806 | |
---|
807 | if [ ${RET} -gt 0 ] ; then |
---|
808 | echo "IGCM_sys_Get_Dir : error." |
---|
809 | cat out_rsync |
---|
810 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
811 | else |
---|
812 | rm out_rsync |
---|
813 | fi |
---|
814 | else |
---|
815 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
816 | fi |
---|
817 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
818 | } |
---|
819 | |
---|
820 | #D-#================================================== |
---|
821 | #D-function IGCM_sys_Get_Master |
---|
822 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
823 | #D-* Examples: |
---|
824 | #D- |
---|
825 | function IGCM_sys_Get_Master { |
---|
826 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
827 | if ( $DEBUG_sys ) ; then |
---|
828 | echo "IGCM_sys_Get_Master :" $@ |
---|
829 | fi |
---|
830 | if [ $DRYRUN = 0 ]; then |
---|
831 | if [ ! -d ${1} ] ; then |
---|
832 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." |
---|
833 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
834 | return |
---|
835 | fi |
---|
836 | |
---|
837 | typeset RET |
---|
838 | sleep 60 |
---|
839 | |
---|
840 | #USUAL WAY |
---|
841 | cp -R $1 $2 > out_rsync 2>&1 |
---|
842 | RET=$? |
---|
843 | |
---|
844 | if [ ${RET} -gt 0 ] ; then |
---|
845 | echo "IGCM_sys_Get_Master : error." |
---|
846 | cat out_rsync |
---|
847 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
848 | else |
---|
849 | rm out_rsync |
---|
850 | fi |
---|
851 | else |
---|
852 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
853 | fi |
---|
854 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
855 | } |
---|
856 | |
---|
857 | #D-#================================================== |
---|
858 | #D-function IGCM_sys_Put_Rest |
---|
859 | #D-* Purpose: Put computied restarts on $(ARCHIVE). |
---|
860 | #D- File and target directory must exist. |
---|
861 | #D-* Examples: |
---|
862 | #D- |
---|
863 | function IGCM_sys_Put_Rest { |
---|
864 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
865 | if ( $DEBUG_sys ) ; then |
---|
866 | echo "IGCM_sys_Put_Rest :" $@ |
---|
867 | fi |
---|
868 | if [ $DRYRUN = 0 ]; then |
---|
869 | |
---|
870 | IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
871 | |
---|
872 | if [ ! -f ${1} ] ; then |
---|
873 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
874 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
875 | fi |
---|
876 | if [ X${JobType} = XRUN ] ; then |
---|
877 | IGCM_sys_Chmod 444 ${1} |
---|
878 | fi |
---|
879 | |
---|
880 | typeset RET |
---|
881 | |
---|
882 | echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1 |
---|
883 | ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1 |
---|
884 | RET=$? |
---|
885 | IGCM_sys_Rsync_out $RET |
---|
886 | |
---|
887 | ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
888 | (( RET=RET+$? )) |
---|
889 | |
---|
890 | if [ ${RET} -gt 0 ] ; then |
---|
891 | echo "IGCM_sys_Put_Rest : error." |
---|
892 | cat out_rsync |
---|
893 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
894 | else |
---|
895 | rm out_rsync |
---|
896 | fi |
---|
897 | else |
---|
898 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
899 | fi |
---|
900 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
901 | } |
---|
902 | |
---|
903 | #D-#================================================== |
---|
904 | #D-function IGCM_sys_Put_Out |
---|
905 | #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly |
---|
906 | #D-* Examples: |
---|
907 | #D- |
---|
908 | function IGCM_sys_Put_Out { |
---|
909 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
910 | if ( $DEBUG_sys ) ; then |
---|
911 | echo "IGCM_sys_Put_Out :" $@ |
---|
912 | fi |
---|
913 | if [ $DRYRUN = 0 ]; then |
---|
914 | if [ -f ${1} ] ; then |
---|
915 | if [ ! -d $( dirname $2 ) ] ; then |
---|
916 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
917 | fi |
---|
918 | else |
---|
919 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
920 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
921 | return 1 |
---|
922 | fi |
---|
923 | |
---|
924 | typeset RET |
---|
925 | # |
---|
926 | if [ X${JobType} = XRUN ] ; then |
---|
927 | if [ X${3} = X ] ; then |
---|
928 | IGCM_sys_Chmod 444 ${1} |
---|
929 | fi |
---|
930 | fi |
---|
931 | # |
---|
932 | |
---|
933 | echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1 |
---|
934 | ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1 |
---|
935 | RET=$? |
---|
936 | IGCM_sys_Rsync_out $RET |
---|
937 | |
---|
938 | ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
939 | (( RET=RET+$? )) |
---|
940 | |
---|
941 | if [ ${RET} -gt 0 ] ; then |
---|
942 | echo "IGCM_sys_Put_Out : error." |
---|
943 | cat out_rsync |
---|
944 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
945 | else |
---|
946 | rm out_rsync |
---|
947 | fi |
---|
948 | else |
---|
949 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
950 | fi |
---|
951 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
952 | return 0 |
---|
953 | } |
---|
954 | |
---|
955 | #D-#================================================== |
---|
956 | #D-function IGCM_sys_Get |
---|
957 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
958 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
959 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
960 | function IGCM_sys_Get { |
---|
961 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
962 | |
---|
963 | typeset DEST RET dm_liste ifile target |
---|
964 | |
---|
965 | if ( $DEBUG_sys ) ; then |
---|
966 | echo "IGCM_sys_Get :" $@ |
---|
967 | fi |
---|
968 | if [ $DRYRUN -le 2 ]; then |
---|
969 | if [ X${1} = X'/l' ] ; then |
---|
970 | # test if the first file is present in the old computation : |
---|
971 | eval set +A dm_liste \${${2}} |
---|
972 | else |
---|
973 | dm_liste=${1} |
---|
974 | fi |
---|
975 | eval DEST=\${${#}} |
---|
976 | |
---|
977 | # test if the (first) file is present in the old computation : |
---|
978 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
979 | RET=$? |
---|
980 | if [ ${RET} -gt 0 ] ; then |
---|
981 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
982 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
983 | #return |
---|
984 | fi |
---|
985 | |
---|
986 | (( RET=0 )) |
---|
987 | for target in ${dm_liste[*]} ; do |
---|
988 | \cp ${target} ${DEST} >> out_rsync 2>&1 |
---|
989 | (( RET=RET+$? )) |
---|
990 | done |
---|
991 | |
---|
992 | # echo ${RSYNC} ${RSYNC_opt} $@ > out_rsync 2>&1 |
---|
993 | # ${RSYNC} ${RSYNC_opt} $@ >> out_rsync 2>&1 |
---|
994 | # RET=$? |
---|
995 | # IGCM_sys_Rsync_out $RET |
---|
996 | |
---|
997 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
998 | # (( RET=RET+$? )) |
---|
999 | |
---|
1000 | if [ ${RET} -gt 0 ] ; then |
---|
1001 | echo "IGCM_sys_Get : copy error." |
---|
1002 | cat out_rsync |
---|
1003 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1004 | else |
---|
1005 | rm out_rsync |
---|
1006 | fi |
---|
1007 | else |
---|
1008 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1009 | fi |
---|
1010 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
1011 | } |
---|
1012 | |
---|
1013 | #D-#================================================== |
---|
1014 | #D-function IGCM_sys_Dods_Rm |
---|
1015 | #D-* Purpose: Suppress files in /tmp/DODS for simulation of internet protocole. |
---|
1016 | #D-* Examples: |
---|
1017 | #D- |
---|
1018 | function IGCM_sys_Dods_Rm { |
---|
1019 | if ( $DEBUG_sys ) ; then |
---|
1020 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
1021 | fi |
---|
1022 | typeset RET |
---|
1023 | RET=0 |
---|
1024 | if [ $DRYRUN = 0 ]; then |
---|
1025 | if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then |
---|
1026 | echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." |
---|
1027 | echo "Nothing has been done." |
---|
1028 | return |
---|
1029 | fi |
---|
1030 | IGCM_sys_Rm -Rf /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} |
---|
1031 | RET=$? |
---|
1032 | |
---|
1033 | if [ ${RET} -gt 0 ] ; then |
---|
1034 | echo "IGCM_sys_Put_Dods : error." |
---|
1035 | cat out_dods_rm |
---|
1036 | IGCM_debug_Exit "IGCM_sys_Dods_Rm" |
---|
1037 | else |
---|
1038 | rm out_dods_rm |
---|
1039 | fi |
---|
1040 | else |
---|
1041 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1042 | fi |
---|
1043 | return $RET |
---|
1044 | } |
---|
1045 | |
---|
1046 | |
---|
1047 | #D-#================================================== |
---|
1048 | #D-function IGCM_sys_Dods_Cp |
---|
1049 | #D-* Purpose: Copy from $(ARCHIVE) files to /tmp/DODS for simulation of internet protocole. |
---|
1050 | #D-* Examples: |
---|
1051 | #D- |
---|
1052 | function IGCM_sys_Dods_Cp { |
---|
1053 | if ( $DEBUG_sys ) ; then |
---|
1054 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
1055 | fi |
---|
1056 | typeset RET |
---|
1057 | RET=0 |
---|
1058 | if [ $DRYRUN = 0 ]; then |
---|
1059 | if [ ! -d ${R_SAVE}/${1} ] ; then |
---|
1060 | echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." |
---|
1061 | echo "Nothing has been done." |
---|
1062 | return |
---|
1063 | fi |
---|
1064 | # |
---|
1065 | IGCM_sys_Mkdir /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
1066 | IGCM_sys_Cp -Rp --parents ${1} /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
1067 | RET=$? |
---|
1068 | |
---|
1069 | if [ ${RET} -gt 0 ] ; then |
---|
1070 | echo "IGCM_sys_Dods_Cp : error." |
---|
1071 | cat out_dods_cp |
---|
1072 | IGCM_debug_Exit "IGCM_sys_Dods_Cp" |
---|
1073 | else |
---|
1074 | rm out_dods_cp |
---|
1075 | fi |
---|
1076 | else |
---|
1077 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1078 | fi |
---|
1079 | return $RET |
---|
1080 | } |
---|
1081 | |
---|
1082 | #D-#================================================== |
---|
1083 | #D-function IGCM_sys_Put_Dods |
---|
1084 | #D-* Purpose: Put $(ARCHIVE) files on /tmp/DODS for simulation of internet protocole. |
---|
1085 | #D-* Examples: |
---|
1086 | #D- |
---|
1087 | function IGCM_sys_Put_Dods { |
---|
1088 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
1089 | if ( $DEBUG_sys ) ; then |
---|
1090 | echo "IGCM_sys_Put_Dods :" $@ |
---|
1091 | fi |
---|
1092 | if [ $DRYRUN = 0 ]; then |
---|
1093 | if [ ! -d ${R_SAVE}/${1} ] ; then |
---|
1094 | echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." |
---|
1095 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1096 | return |
---|
1097 | fi |
---|
1098 | |
---|
1099 | typeset RET |
---|
1100 | # |
---|
1101 | cd ${R_SAVE} |
---|
1102 | IGCM_sys_Dods_Rm ${1} |
---|
1103 | IGCM_sys_Dods_Cp ${1} |
---|
1104 | RET=0 |
---|
1105 | |
---|
1106 | if [ ${RET} -gt 0 ] ; then |
---|
1107 | echo "IGCM_sys_Put_Dods : error." |
---|
1108 | IGCM_debug_Exit "IGCM_sys_Put_Dods" |
---|
1109 | fi |
---|
1110 | else |
---|
1111 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1112 | fi |
---|
1113 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1114 | } |
---|
1115 | |
---|
1116 | ############################################################## A FINIR !! |
---|
1117 | |
---|
1118 | #D-#================================================== |
---|
1119 | #D-function IGCM_sys_GetDate_FichWork |
---|
1120 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
1121 | #D-* Examples: |
---|
1122 | #D- |
---|
1123 | function IGCM_sys_GetDate_FichWork { |
---|
1124 | IGCM_debug_PushStack "IGCM_sys_FichWork" $@ |
---|
1125 | if ( $DEBUG_sys ) ; then |
---|
1126 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
1127 | fi |
---|
1128 | # donne la date filesys d'un fichier sur la machine work |
---|
1129 | IGCM_debug_PopStack "IGCM_sys_FichWork" |
---|
1130 | } |
---|
1131 | |
---|
1132 | #D-#================================================== |
---|
1133 | #D-function IGCM_sys_GetDate_FichArchive |
---|
1134 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE |
---|
1135 | #D-* Examples: |
---|
1136 | #D- |
---|
1137 | function IGCM_sys_GetDate_FichArchive { |
---|
1138 | IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ |
---|
1139 | if ( $DEBUG_sys ) ; then |
---|
1140 | echo "IGCM_sys_GetDate_FichArchive :" $@ |
---|
1141 | fi |
---|
1142 | IGCM_debug_PopStack "IGCM_sys_FichArchive" |
---|
1143 | } |
---|
1144 | |
---|
1145 | ############################################################## |
---|
1146 | # REBUILD OPERATOR |
---|
1147 | |
---|
1148 | function IGCM_sys_rebuild { |
---|
1149 | IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ |
---|
1150 | if ( $DEBUG_sys ) ; then |
---|
1151 | echo "IGCM_sys_rebuild :" $@ |
---|
1152 | fi |
---|
1153 | rebuild -f -o $@ |
---|
1154 | if [ $? -gt 0 ] ; then |
---|
1155 | echo "IGCM_sys_rebuild : erreur ${@}." |
---|
1156 | IGCM_debug_Exit "rebuild" |
---|
1157 | fi |
---|
1158 | |
---|
1159 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
1160 | } |
---|
1161 | |
---|
1162 | ############################################################## |
---|
1163 | # NCO OPERATOR |
---|
1164 | |
---|
1165 | function IGCM_sys_ncap { |
---|
1166 | IGCM_debug_PushStack "IGCM_sys_ncap" -- $@ |
---|
1167 | if ( $DEBUG_sys ) ; then |
---|
1168 | echo "IGCM_sys_ncap :" $@ |
---|
1169 | fi |
---|
1170 | /usr/local/bin/ncap $@ |
---|
1171 | if [ $? -gt 0 ] ; then |
---|
1172 | echo "IGCM_sys_ncap : erreur ${@}." |
---|
1173 | # IGCM_debug_Exit "ncap" |
---|
1174 | fi |
---|
1175 | |
---|
1176 | IGCM_debug_PopStack "IGCM_sys_ncap" |
---|
1177 | } |
---|
1178 | |
---|
1179 | ncatted=/usr/local/bin/ncatted |
---|
1180 | # Problem with ksh and string passed in this function to ncatted ! |
---|
1181 | # function IGCM_sys_ncatted { |
---|
1182 | # IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ |
---|
1183 | # if ( $DEBUG_sys ) ; then |
---|
1184 | # echo "IGCM_sys_ncatted :" $@ |
---|
1185 | # fi |
---|
1186 | # /usr/local/bin/ncatted $@ |
---|
1187 | # if [ $? -gt 0 ] ; then |
---|
1188 | # echo "IGCM_sys_ncatted : erreur ${@}." |
---|
1189 | # IGCM_debug_Exit "ncatted" |
---|
1190 | # fi |
---|
1191 | |
---|
1192 | # IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
1193 | # } |
---|
1194 | |
---|
1195 | function IGCM_sys_ncbo { |
---|
1196 | IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ |
---|
1197 | if ( $DEBUG_sys ) ; then |
---|
1198 | echo "IGCM_sys_ncbo :" $@ |
---|
1199 | fi |
---|
1200 | /usr/local/bin/ncbo $@ |
---|
1201 | if [ $? -gt 0 ] ; then |
---|
1202 | echo "IGCM_sys_ncbo : erreur ${@}." |
---|
1203 | # IGCM_debug_Exit "ncbo" |
---|
1204 | fi |
---|
1205 | |
---|
1206 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
1207 | } |
---|
1208 | |
---|
1209 | function IGCM_sys_ncdiff { |
---|
1210 | IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ |
---|
1211 | if ( $DEBUG_sys ) ; then |
---|
1212 | echo "IGCM_sys_ncdiff :" $@ |
---|
1213 | fi |
---|
1214 | /usr/local/bin/ncdiff $@ |
---|
1215 | if [ $? -gt 0 ] ; then |
---|
1216 | echo "IGCM_sys_ncdiff : erreur ${@}." |
---|
1217 | # IGCM_debug_Exit "ncdiff" |
---|
1218 | fi |
---|
1219 | |
---|
1220 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
1221 | } |
---|
1222 | |
---|
1223 | function IGCM_sys_ncea { |
---|
1224 | IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ |
---|
1225 | if ( $DEBUG_sys ) ; then |
---|
1226 | echo "IGCM_sys_ncea :" $@ |
---|
1227 | fi |
---|
1228 | /usr/local/bin/ncea $@ |
---|
1229 | if [ $? -gt 0 ] ; then |
---|
1230 | echo "IGCM_sys_ncea : erreur ${@}." |
---|
1231 | # IGCM_debug_Exit "ncea" |
---|
1232 | fi |
---|
1233 | |
---|
1234 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
1235 | } |
---|
1236 | |
---|
1237 | function IGCM_sys_ncecat { |
---|
1238 | IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ |
---|
1239 | if ( $DEBUG_sys ) ; then |
---|
1240 | echo "IGCM_sys_ncecat :" $@ |
---|
1241 | fi |
---|
1242 | /usr/local/bin/ncecat $@ |
---|
1243 | if [ $? -gt 0 ] ; then |
---|
1244 | echo "IGCM_sys_ncecat : erreur ${@}." |
---|
1245 | # IGCM_debug_Exit "ncecat" |
---|
1246 | fi |
---|
1247 | |
---|
1248 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
1249 | } |
---|
1250 | |
---|
1251 | function IGCM_sys_ncflint { |
---|
1252 | IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ |
---|
1253 | if ( $DEBUG_sys ) ; then |
---|
1254 | echo "IGCM_sys_ncflint :" $@ |
---|
1255 | fi |
---|
1256 | /usr/local/bin/ncflint $@ |
---|
1257 | if [ $? -gt 0 ] ; then |
---|
1258 | echo "IGCM_sys_ncflint : erreur ${@}." |
---|
1259 | # IGCM_debug_Exit "ncflint" |
---|
1260 | fi |
---|
1261 | |
---|
1262 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
1263 | } |
---|
1264 | |
---|
1265 | function IGCM_sys_ncks { |
---|
1266 | IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ |
---|
1267 | if ( $DEBUG_sys ) ; then |
---|
1268 | echo "IGCM_sys_ncks :" $@ |
---|
1269 | fi |
---|
1270 | /usr/local/bin/ncks $@ |
---|
1271 | if [ $? -gt 0 ] ; then |
---|
1272 | echo "IGCM_sys_ncks : erreur ${@}." |
---|
1273 | # IGCM_debug_Exit "ncks" |
---|
1274 | fi |
---|
1275 | |
---|
1276 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
1277 | } |
---|
1278 | |
---|
1279 | function IGCM_sys_ncpdq { |
---|
1280 | IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ |
---|
1281 | if ( $DEBUG_sys ) ; then |
---|
1282 | echo "IGCM_sys_ncpdq :" $@ |
---|
1283 | fi |
---|
1284 | /usr/local/bin/ncpdq $@ |
---|
1285 | if [ $? -gt 0 ] ; then |
---|
1286 | echo "IGCM_sys_ncpdq : erreur ${@}." |
---|
1287 | # IGCM_debug_Exit "ncpdq" |
---|
1288 | fi |
---|
1289 | |
---|
1290 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
1291 | } |
---|
1292 | |
---|
1293 | function IGCM_sys_ncra { |
---|
1294 | IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ |
---|
1295 | if ( $DEBUG_sys ) ; then |
---|
1296 | echo "IGCM_sys_ncra :" $@ |
---|
1297 | fi |
---|
1298 | /usr/local/bin/ncra $@ |
---|
1299 | if [ $? -gt 0 ] ; then |
---|
1300 | echo "IGCM_sys_ncra : erreur ${@}." |
---|
1301 | # IGCM_debug_Exit "ncra" |
---|
1302 | fi |
---|
1303 | |
---|
1304 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
1305 | } |
---|
1306 | |
---|
1307 | function IGCM_sys_ncrcat { |
---|
1308 | IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ |
---|
1309 | if ( $DEBUG_sys ) ; then |
---|
1310 | echo "IGCM_sys_ncrcat :" $@ |
---|
1311 | fi |
---|
1312 | /usr/local/bin/ncrcat $@ |
---|
1313 | if [ $? -gt 0 ] ; then |
---|
1314 | echo "IGCM_sys_ncrcat : erreur ${@}." |
---|
1315 | # IGCM_debug_Exit "ncrcat" |
---|
1316 | fi |
---|
1317 | |
---|
1318 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
1319 | } |
---|
1320 | |
---|
1321 | function IGCM_sys_ncrename { |
---|
1322 | IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ |
---|
1323 | if ( $DEBUG_sys ) ; then |
---|
1324 | echo "IGCM_sys_ncrename :" $@ |
---|
1325 | fi |
---|
1326 | /usr/local/bin/ncrename $@ |
---|
1327 | if [ $? -gt 0 ] ; then |
---|
1328 | echo "IGCM_sys_ncrename : erreur ${@}." |
---|
1329 | # IGCM_debug_Exit "ncrename" |
---|
1330 | fi |
---|
1331 | |
---|
1332 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
1333 | } |
---|
1334 | |
---|
1335 | function IGCM_sys_ncwa { |
---|
1336 | IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ |
---|
1337 | if ( $DEBUG_sys ) ; then |
---|
1338 | echo "IGCM_sys_ncwa :" $@ |
---|
1339 | fi |
---|
1340 | /usr/local/bin/ncwa $@ |
---|
1341 | if [ $? -gt 0 ] ; then |
---|
1342 | echo "IGCM_sys_ncwa : erreur ${@}." |
---|
1343 | # IGCM_debug_Exit "ncwa" |
---|
1344 | fi |
---|
1345 | |
---|
1346 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
1347 | } |
---|
1348 | |
---|
1349 | ############################################################## |
---|
1350 | # CDO OPERATOR |
---|
1351 | |
---|
1352 | function IGCM_sys_cdo { |
---|
1353 | IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ |
---|
1354 | |
---|
1355 | \cdo $@ |
---|
1356 | if [ $? -gt 0 ] ; then |
---|
1357 | echo "IGCM_sys_cdo : erreur ${@}." |
---|
1358 | # IGCM_debug_Exit "cdo" |
---|
1359 | fi |
---|
1360 | |
---|
1361 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
1362 | } |
---|
1363 | |
---|
1364 | ############################################################ |
---|
1365 | # Activate Running Environnment Variables |
---|
1366 | |
---|
1367 | function IGCM_sys_activ_variables { |
---|
1368 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
1369 | if ( $DEBUG_sys ) ; then |
---|
1370 | echo "IGCM_sys_activ_variables" |
---|
1371 | fi |
---|
1372 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
1373 | } |
---|
1374 | |
---|
1375 | ############################################################ |
---|
1376 | # Desactivate Running Environnment Variables |
---|
1377 | |
---|
1378 | function IGCM_sys_desactiv_variables { |
---|
1379 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
1380 | if ( $DEBUG_sys ) ; then |
---|
1381 | echo "IGCM_sys_desactiv_variables" |
---|
1382 | fi |
---|
1383 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
1384 | } |
---|
1385 | |
---|
1386 | ############################################################ |
---|
1387 | # Build run file |
---|
1388 | |
---|
1389 | function IGCM_sys_build_run_file { |
---|
1390 | IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ |
---|
1391 | if ( $DEBUG_sys ) ; then |
---|
1392 | echo "IGCM_sys_build_run_file" $@ |
---|
1393 | fi |
---|
1394 | IGCM_debug_PopStack "IGCM_sys_build_run_file" |
---|
1395 | } |
---|