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