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