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