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