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