1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel |
---|
5 | # Contact: Arnaud.Caubel__at__lsce.ipsl.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 Curie |
---|
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 | | | | |
---|
46 | # | | Chmod 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 | # $hostname of the MASTER job |
---|
70 | typeset MASTER=curie |
---|
71 | |
---|
72 | #D- |
---|
73 | #D-#================================================== |
---|
74 | #D-Program used in libIGCM |
---|
75 | #D-#================================================== |
---|
76 | |
---|
77 | # Submit command |
---|
78 | typeset SUBMIT=${SUBMIT:=ccc_msub} |
---|
79 | # rsync with path |
---|
80 | typeset -r RSYNC=/usr/bin/rsync |
---|
81 | # RSYNC_opt args to rsync |
---|
82 | typeset -r RSYNC_opt="-va" |
---|
83 | # ie storage filesystem |
---|
84 | typeset -r STOREHOST=${MASTER} |
---|
85 | |
---|
86 | #==================================================== |
---|
87 | # Source default environment |
---|
88 | #==================================================== |
---|
89 | ##. /etc/profile |
---|
90 | |
---|
91 | #==================================================== |
---|
92 | # Set environment tools (ferret, nco, cdo) |
---|
93 | #==================================================== |
---|
94 | if [ X${TaskType} = Xcomputing ] ; then |
---|
95 | . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_calcul_curie_ksh |
---|
96 | export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddNoise/src_X64/bin |
---|
97 | else |
---|
98 | . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_post_curie_ksh |
---|
99 | fi |
---|
100 | |
---|
101 | #==================================================== |
---|
102 | # Specific for ocean additionnal diagnostic |
---|
103 | export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO" |
---|
104 | export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET" |
---|
105 | |
---|
106 | #==================================================== |
---|
107 | # Host specific DIRECTORIES |
---|
108 | #==================================================== |
---|
109 | |
---|
110 | # ============ CESIUM START ============ # |
---|
111 | |
---|
112 | #==================================================== |
---|
113 | #- Mirror libIGCM from titane to cesium if needed |
---|
114 | #ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' ) |
---|
115 | #if [ ! ${ROOTSYS} = "home" ] ; then |
---|
116 | # typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} |
---|
117 | #else |
---|
118 | # typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
119 | #fi |
---|
120 | |
---|
121 | #==================================================== |
---|
122 | #- libIGCM_POST |
---|
123 | #if ( ${MirrorlibIGCM} ) ; then |
---|
124 | # PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) |
---|
125 | # typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM |
---|
126 | #else |
---|
127 | # typeset -r libIGCM_POST=${libIGCM} |
---|
128 | #fi |
---|
129 | |
---|
130 | # ============ CESIUM END ============ # |
---|
131 | |
---|
132 | #==================================================== |
---|
133 | #- MirrorlibIGCM for frontend |
---|
134 | typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
135 | |
---|
136 | #==================================================== |
---|
137 | #- libIGCM_POST for frontend |
---|
138 | typeset -r libIGCM_POST=${libIGCM} |
---|
139 | |
---|
140 | #==================================================== |
---|
141 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
142 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
143 | |
---|
144 | #==================================================== |
---|
145 | #- SUBMIT_DIR : submission dir |
---|
146 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}} |
---|
147 | |
---|
148 | #==================================================== |
---|
149 | #- IN |
---|
150 | typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} |
---|
151 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data} |
---|
152 | |
---|
153 | #==================================================== |
---|
154 | #- ARCHIVE (dedicated to large files) |
---|
155 | typeset ARCHIVE=${CCCSTOREDIR} |
---|
156 | |
---|
157 | #==================================================== |
---|
158 | #- STORAGE (dedicated to small/medium files) |
---|
159 | typeset STORAGE=${CCCWORKDIR} |
---|
160 | |
---|
161 | #==================================================== |
---|
162 | #- R_OUT |
---|
163 | typeset R_OUT=${ARCHIVE}/IGCM_OUT |
---|
164 | |
---|
165 | #==================================================== |
---|
166 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
167 | typeset R_FIG=${STORAGE}/IGCM_OUT |
---|
168 | |
---|
169 | #==================================================== |
---|
170 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
171 | typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT |
---|
172 | |
---|
173 | #==================================================== |
---|
174 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
175 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}} |
---|
176 | |
---|
177 | #==================================================== |
---|
178 | #- HOST_MPIRUN_COMMAND |
---|
179 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time ccc_mprun -E-K1"} |
---|
180 | |
---|
181 | #==================================================== |
---|
182 | #- Max number of arguments passed to nco operator or demigration command |
---|
183 | UNIX_MAX_LIMIT=360 |
---|
184 | |
---|
185 | #==================================================== |
---|
186 | #- set PackDefault true on curie |
---|
187 | PackDefault=true |
---|
188 | |
---|
189 | #==================================================== |
---|
190 | #- Number of core per node (max number of OpenMP task) |
---|
191 | NUM_COREPERNODE=8 |
---|
192 | |
---|
193 | #==================================================== |
---|
194 | #- Default number of MPI task for IPSL coupled model |
---|
195 | #- required for backward compatibility |
---|
196 | #- |
---|
197 | DEFAULT_NUM_PROC_OCE=5 |
---|
198 | DEFAULT_NUM_PROC_CPL=1 |
---|
199 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
200 | DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} |
---|
201 | |
---|
202 | #D-#================================================== |
---|
203 | #D-function IGCM_sys_ChangeArchive |
---|
204 | #D-* Purpose: if SpaceName=TEST everything is stored on SCRATCHDIR |
---|
205 | #D-* Examples: |
---|
206 | #D- |
---|
207 | function IGCM_sys_ChangeArchive { |
---|
208 | IGCM_debug_PushStack "IGCM_sys_ChangeArchive" |
---|
209 | |
---|
210 | R_OUT=${SCRATCHDIR}/IGCM_OUT |
---|
211 | R_FIG=${SCRATCHDIR}/IGCM_OUT |
---|
212 | |
---|
213 | IGCM_debug_Print 1 "R_OUT has been redefined = ${R_OUT}" |
---|
214 | IGCM_debug_Print 1 "R_FIG has been redefined = ${R_FIG}" |
---|
215 | |
---|
216 | IGCM_debug_PopStack "IGCM_sys_ChangeArchive" |
---|
217 | } |
---|
218 | |
---|
219 | #D-#================================================== |
---|
220 | #D-function IGCM_sys_RshMaster |
---|
221 | #D-* Purpose: Connection to frontend machine. |
---|
222 | #D-* Examples: |
---|
223 | #D- |
---|
224 | function IGCM_sys_RshMaster { |
---|
225 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
226 | /bin/ksh <<-EOF |
---|
227 | export libIGCM=${libIGCM} |
---|
228 | export DEBUG_debug=${DEBUG_debug} |
---|
229 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
230 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
231 | ${@} |
---|
232 | EOF |
---|
233 | if [ $? -gt 0 ] ; then |
---|
234 | echo "IGCM_sys_RshMaster : erreur." |
---|
235 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
236 | fi |
---|
237 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
238 | } |
---|
239 | |
---|
240 | #D-#================================================== |
---|
241 | #D-function IGCM_sys_RshArchive |
---|
242 | #D-* Purpose: Archive rsh command |
---|
243 | #D-* Examples: |
---|
244 | #D- |
---|
245 | function IGCM_sys_RshArchive { |
---|
246 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
247 | /bin/ksh <<-EOF |
---|
248 | ${@} |
---|
249 | EOF |
---|
250 | if [ $? -gt 0 ] ; then |
---|
251 | echo "IGCM_sys_RshArchive : erreur." |
---|
252 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
253 | fi |
---|
254 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
255 | } |
---|
256 | |
---|
257 | #D-#================================================== |
---|
258 | #D-function IGCM_sys_RshPost |
---|
259 | #D-* Purpose: Post-process rsh command |
---|
260 | #D-* Examples: |
---|
261 | #D- |
---|
262 | function IGCM_sys_RshPost { |
---|
263 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
264 | if ( $DEBUG_sys ) ; then |
---|
265 | echo "IGCM_sys_RshPost :" $@ |
---|
266 | fi |
---|
267 | |
---|
268 | #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL |
---|
269 | #cat tmp_IGCM_sys_RshPost_$$ |
---|
270 | # keep standard input (stdin) for the loop onto temporary file |
---|
271 | cat >tmp_IGCM_sys_RshPost_$$ |
---|
272 | |
---|
273 | # ============ FRONTEND START ============ # |
---|
274 | |
---|
275 | /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
276 | if [ $? -gt 0 ] ; then |
---|
277 | echo "IGCM_sys_RshPost : erreur." |
---|
278 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
279 | fi |
---|
280 | # delete temporary file |
---|
281 | \rm tmp_IGCM_sys_RshPost_$$ |
---|
282 | |
---|
283 | # ============ FRONTEND END ============ # |
---|
284 | |
---|
285 | # ============ CESIUM START ============ # |
---|
286 | # typeset NB_ESSAI DELAI status i |
---|
287 | # if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then |
---|
288 | # #little hack so that rebuild submission is done on titane not an cesium |
---|
289 | # |
---|
290 | # libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) |
---|
291 | # POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) |
---|
292 | # sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt |
---|
293 | # sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ |
---|
294 | # sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt |
---|
295 | # sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ |
---|
296 | # \mv tmp.txt tmp_IGCM_sys_RshPost_$$ |
---|
297 | # |
---|
298 | # echo cat tmp_IGCM_sys_RshPost_$$ AFTER |
---|
299 | # cat tmp_IGCM_sys_RshPost_$$ |
---|
300 | # |
---|
301 | # /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
302 | # if [ $? -gt 0 ] ; then |
---|
303 | # echo "IGCM_sys_RshPost : erreur." |
---|
304 | # IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
305 | # fi |
---|
306 | # # delete temporary file |
---|
307 | # \rm tmp_IGCM_sys_RshPost_$$ |
---|
308 | # |
---|
309 | # else |
---|
310 | # # number of tentative |
---|
311 | # NB_ESSAI=10 |
---|
312 | # # time delay between tentative |
---|
313 | # DELAI=10 |
---|
314 | # i=0 |
---|
315 | # while [ $i -ne $NB_ESSAI ] ; do |
---|
316 | # ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
317 | # status=$? |
---|
318 | # if [ ${status} -ne 0 ]; |
---|
319 | # then |
---|
320 | # sleep $DELAI |
---|
321 | # else |
---|
322 | # break |
---|
323 | # fi |
---|
324 | # let i=$i+1 |
---|
325 | # done |
---|
326 | # # delete temporary file |
---|
327 | # \rm tmp_IGCM_sys_RshPost_$$ |
---|
328 | # |
---|
329 | # if [ ${status} -gt 0 ] ; then |
---|
330 | # echo "IGCM_sys_RshPost : erreur." |
---|
331 | # IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
332 | # fi |
---|
333 | # fi |
---|
334 | |
---|
335 | # ============ CESIUM END ============ # |
---|
336 | |
---|
337 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
338 | } |
---|
339 | |
---|
340 | #D-#================================================== |
---|
341 | #D-function IGCM_sys_SendMail |
---|
342 | #D-* Purpose: Send mail when simulation is over |
---|
343 | #D-* Examples: |
---|
344 | #D- |
---|
345 | function IGCM_sys_SendMail { |
---|
346 | IGCM_debug_PushStack "IGCM_sys_SendMail" $@ |
---|
347 | if ( $DEBUG_sys ) ; then |
---|
348 | echo "IGCM_sys_SendMail :" $@ |
---|
349 | fi |
---|
350 | |
---|
351 | if ( ${ExitFlag} ) ; then |
---|
352 | status=failed |
---|
353 | else |
---|
354 | status=completed |
---|
355 | fi |
---|
356 | |
---|
357 | cat << END_MAIL > job_end.mail |
---|
358 | Dear ${LOGIN}, |
---|
359 | |
---|
360 | Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. |
---|
361 | Job started : ${DateBegin} |
---|
362 | Job ended : ${DateEnd} |
---|
363 | Output files are available in ${R_SAVE} |
---|
364 | Files to be rebuild are temporarily available in ${REBUILD_DIR} |
---|
365 | Pre-packed files are temporarily available in ${R_BUFR} |
---|
366 | Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR} |
---|
367 | END_MAIL |
---|
368 | |
---|
369 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
370 | mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail |
---|
371 | elif [ -f ~/.forward ] ; then |
---|
372 | mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail |
---|
373 | fi |
---|
374 | sleep 10 |
---|
375 | rm -f job_end.mail |
---|
376 | |
---|
377 | if [ $? -gt 0 ] ; then |
---|
378 | echo "IGCM_sys_SendMail : erreur." |
---|
379 | IGCM_debug_Exit "IGCM_sys_SendMail" |
---|
380 | fi |
---|
381 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
382 | } |
---|
383 | |
---|
384 | #D-#================================================== |
---|
385 | #D-function IGCM_sys_Mkdir |
---|
386 | #D-* Purpose: Master locale mkdir command |
---|
387 | #D-* Examples: |
---|
388 | #D- |
---|
389 | function IGCM_sys_Mkdir { |
---|
390 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
391 | if ( $DEBUG_sys ) ; then |
---|
392 | echo "IGCM_sys_Mkdir :" $@ |
---|
393 | fi |
---|
394 | if [ ! -d ${1} ]; then |
---|
395 | \mkdir -p $1 |
---|
396 | if [ $? -gt 0 ] ; then |
---|
397 | echo "IGCM_sys_Mkdir : erreur." |
---|
398 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
399 | fi |
---|
400 | fi |
---|
401 | # vérification : |
---|
402 | if [ ! -d ${1} ] ; then |
---|
403 | echo "IGCM_sys_Mkdir : erreur." |
---|
404 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
405 | fi |
---|
406 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
407 | } |
---|
408 | |
---|
409 | #D-#================================================== |
---|
410 | #D-function IGCM_sys_MkdirArchive |
---|
411 | #D-* Purpose: Mkdir on Archive |
---|
412 | #D-* Examples: |
---|
413 | #D- |
---|
414 | function IGCM_sys_MkdirArchive { |
---|
415 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
416 | if ( $DEBUG_sys ) ; then |
---|
417 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
418 | fi |
---|
419 | #- creation de repertoire sur le serveur fichier |
---|
420 | if [ ! -d ${1} ]; then |
---|
421 | \mkdir -p $1 |
---|
422 | if [ $? -gt 0 ] ; then |
---|
423 | echo "IGCM_sys_MkdirArchive : erreur." |
---|
424 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
425 | fi |
---|
426 | fi |
---|
427 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
428 | } |
---|
429 | |
---|
430 | #D-#================================================== |
---|
431 | #D-function IGCM_sys_MkdirWork |
---|
432 | #D-* Purpose: Mkdir on Work |
---|
433 | #D-* Examples: |
---|
434 | #D- |
---|
435 | function IGCM_sys_MkdirWork { |
---|
436 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
437 | if ( $DEBUG_sys ) ; then |
---|
438 | echo "IGCM_sys_MkdirWork :" $@ |
---|
439 | fi |
---|
440 | #- creation de repertoire sur le serveur fichier |
---|
441 | if [ ! -d ${1} ]; then |
---|
442 | \mkdir -p $1 |
---|
443 | if [ $? -gt 0 ] ; then |
---|
444 | echo "IGCM_sys_MkdirWork : erreur." |
---|
445 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
446 | fi |
---|
447 | fi |
---|
448 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
449 | } |
---|
450 | |
---|
451 | #D-#================================================== |
---|
452 | #D-function IGCM_sys_Cd |
---|
453 | #D-* Purpose: master cd command |
---|
454 | #D-* Examples: |
---|
455 | #D- |
---|
456 | function IGCM_sys_Cd { |
---|
457 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
458 | if ( $DEBUG_sys ) ; then |
---|
459 | echo "IGCM_sys_Cd :" $@ |
---|
460 | fi |
---|
461 | \cd $1 |
---|
462 | if [ $? -gt 0 ] ; then |
---|
463 | echo "IGCM_sys_Cd : erreur." |
---|
464 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
465 | fi |
---|
466 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
467 | } |
---|
468 | |
---|
469 | #D-#================================================== |
---|
470 | #D-function IGCM_sys_Chmod |
---|
471 | #D-* Purpose: Chmod |
---|
472 | #D-* Examples: |
---|
473 | #D- |
---|
474 | function IGCM_sys_Chmod { |
---|
475 | IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ |
---|
476 | if ( $DEBUG_sys ) ; then |
---|
477 | echo "IGCM_sys_Chmod :" $@ |
---|
478 | fi |
---|
479 | \chmod $@ |
---|
480 | if [ $? -gt 0 ] ; then |
---|
481 | echo "IGCM_sys_Chmod : erreur." |
---|
482 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
483 | fi |
---|
484 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
485 | } |
---|
486 | |
---|
487 | #D-#================================================== |
---|
488 | #D-function IGCM_sys_FileSize |
---|
489 | #D-* Purpose: Filesize |
---|
490 | #D-* Examples: |
---|
491 | #D- |
---|
492 | function IGCM_sys_FileSize { |
---|
493 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
494 | |
---|
495 | typeset sizeF |
---|
496 | set +A sizeF -- $( ls -la ${1} ) |
---|
497 | if [ $? -gt 0 ] ; then |
---|
498 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
499 | fi |
---|
500 | eval ${2}=${sizeF[4]} |
---|
501 | |
---|
502 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
503 | } |
---|
504 | |
---|
505 | #D-#================================================== |
---|
506 | #D-function IGCM_sys_TestDir |
---|
507 | #D-* Purpose: Test Directory that must exists |
---|
508 | #D-* Examples: |
---|
509 | #D- |
---|
510 | function IGCM_sys_TestDir { |
---|
511 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
512 | if ( $DEBUG_sys ) ; then |
---|
513 | echo "IGCM_sys_TestDir :" $@ |
---|
514 | fi |
---|
515 | typeset ExistFlag |
---|
516 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
517 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
518 | |
---|
519 | return ${ExistFlag} |
---|
520 | } |
---|
521 | |
---|
522 | #D-#================================================== |
---|
523 | #D-function IGCM_sys_TestDirArchive |
---|
524 | #D-* Purpose: Test Directory that must exists on Archive |
---|
525 | #D-* Examples: |
---|
526 | #D- |
---|
527 | function IGCM_sys_TestDirArchive { |
---|
528 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
529 | if ( $DEBUG_sys ) ; then |
---|
530 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
531 | fi |
---|
532 | typeset ExistFlag |
---|
533 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
534 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
535 | |
---|
536 | return ${ExistFlag} |
---|
537 | } |
---|
538 | |
---|
539 | #D-#================================================== |
---|
540 | #D-function IGCM_sys_IsFileArchived |
---|
541 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
542 | #D-* Examples: |
---|
543 | #D- |
---|
544 | function IGCM_sys_IsFileArchived { |
---|
545 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
546 | if ( $DEBUG_sys ) ; then |
---|
547 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
548 | fi |
---|
549 | typeset IsArchivedFlag |
---|
550 | IsArchivedFlag=$( [ X$( echo $1 | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 ) |
---|
551 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
552 | |
---|
553 | return ${IsArchivedFlag} |
---|
554 | } |
---|
555 | |
---|
556 | #D-#================================================== |
---|
557 | #D-function IGCM_sys_TestFileArchive |
---|
558 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
559 | #D-* Examples: |
---|
560 | #D- |
---|
561 | function IGCM_sys_TestFileArchive { |
---|
562 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
563 | typeset ExistFlag |
---|
564 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
565 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
566 | |
---|
567 | return ${ExistFlag} |
---|
568 | } |
---|
569 | |
---|
570 | #D-#================================================== |
---|
571 | #D-function IGCM_sys_TestFileBuffer |
---|
572 | #D-* Purpose: Test file that must NOT EXISTS on Buffer |
---|
573 | #D-* Examples: |
---|
574 | #D- |
---|
575 | function IGCM_sys_TestFileBuffer { |
---|
576 | IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ |
---|
577 | typeset ExistFlag |
---|
578 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
579 | IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" |
---|
580 | |
---|
581 | return ${ExistFlag} |
---|
582 | } |
---|
583 | |
---|
584 | #D-#================================================== |
---|
585 | #D-function IGCM_sys_CountFileArchive |
---|
586 | #D-* Purpose: Count files on Archive filesystem |
---|
587 | #D-* Examples: |
---|
588 | #D- |
---|
589 | function IGCM_sys_CountFileArchive { |
---|
590 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
591 | ls ${@} 2>/dev/null | wc -l |
---|
592 | if [ $? -gt 0 ] ; then |
---|
593 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
594 | fi |
---|
595 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
596 | } |
---|
597 | |
---|
598 | #D-#================================================== |
---|
599 | #D-function IGCM_sys_CountFileBuffer |
---|
600 | #D-* Purpose: Count files on Scratch filesystem |
---|
601 | #D-* Examples: |
---|
602 | #D- |
---|
603 | function IGCM_sys_CountFileBuffer { |
---|
604 | IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ |
---|
605 | ls ${@} 2>/dev/null | wc -l |
---|
606 | if [ $? -gt 0 ] ; then |
---|
607 | echo "IGCM_sys_CountFileBuffer : erreur." |
---|
608 | fi |
---|
609 | IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" |
---|
610 | } |
---|
611 | |
---|
612 | #D-#================================================== |
---|
613 | #D-function IGCM_sys_Tree |
---|
614 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
615 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
616 | #D- |
---|
617 | function IGCM_sys_Tree { |
---|
618 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
619 | if ( $DEBUG_sys ) ; then |
---|
620 | echo "IGCM_sys_Tree :" $@ |
---|
621 | fi |
---|
622 | |
---|
623 | \ls -lR ${@} |
---|
624 | |
---|
625 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
626 | } |
---|
627 | |
---|
628 | #D-#================================================== |
---|
629 | #D-function IGCM_sys_Tar |
---|
630 | #D-* Purpose: master tar command |
---|
631 | #D-* Examples: |
---|
632 | #D- |
---|
633 | function IGCM_sys_Tar { |
---|
634 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
635 | if ( $DEBUG_sys ) ; then |
---|
636 | echo "IGCM_sys_Tar :" $@ |
---|
637 | fi |
---|
638 | \tar cf $@ |
---|
639 | if [ $? -gt 0 ] ; then |
---|
640 | echo "IGCM_sys_Tar : erreur." |
---|
641 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
642 | fi |
---|
643 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
644 | } |
---|
645 | |
---|
646 | #D-#================================================== |
---|
647 | #D-function IGCM_sys_UnTar |
---|
648 | #D-* Purpose: master un-tar command |
---|
649 | #D-* Examples: |
---|
650 | #D- |
---|
651 | function IGCM_sys_UnTar { |
---|
652 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
653 | if ( $DEBUG_sys ) ; then |
---|
654 | echo "IGCM_sys_UnTar :" $@ |
---|
655 | fi |
---|
656 | \tar xvf $1 |
---|
657 | if [ $? -gt 0 ] ; then |
---|
658 | echo "IGCM_sys_UnTar : erreur." |
---|
659 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
660 | fi |
---|
661 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
662 | } |
---|
663 | |
---|
664 | #D-#================================================== |
---|
665 | #D-function IGCM_sys_Qsub |
---|
666 | #D-* Purpose: Qsub new job |
---|
667 | #D-* Examples: |
---|
668 | #D- |
---|
669 | function IGCM_sys_Qsub { |
---|
670 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
671 | if ( $DEBUG_sys ) ; then |
---|
672 | echo "IGCM_sys_Qsub :" $@ |
---|
673 | fi |
---|
674 | typeset options |
---|
675 | if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then |
---|
676 | options=" -o ${Script_Output} -e ${Script_Output}" |
---|
677 | else |
---|
678 | options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}" |
---|
679 | fi |
---|
680 | |
---|
681 | /usr/bin/ccc_msub ${options} < $1 |
---|
682 | if [ $? -gt 0 ] ; then |
---|
683 | echo "IGCM_sys_Qsub : erreur ${options} $1" |
---|
684 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
685 | fi |
---|
686 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
687 | } |
---|
688 | |
---|
689 | #D-#================================================== |
---|
690 | #D-function IGCM_sys_QsubPost |
---|
691 | #D-* Purpose: Qsub new job on scalaire |
---|
692 | #D-* Examples: |
---|
693 | #D- |
---|
694 | function IGCM_sys_QsubPost { |
---|
695 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
696 | if ( $DEBUG_sys ) ; then |
---|
697 | echo "IGCM_sys_QsubPost :" $@ |
---|
698 | fi |
---|
699 | MY_PROJECT=$(echo ${BRIDGE_MSUB_PROJECT} | cut -d@ -f1 ) |
---|
700 | /usr/bin/ccc_msub -Q normal -A ${MY_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job |
---|
701 | if [ $? -gt 0 ] ; then |
---|
702 | echo "IGCM_sys_QsubPost : erreur " $@ |
---|
703 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
704 | fi |
---|
705 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
706 | } |
---|
707 | |
---|
708 | #D-************************* |
---|
709 | #D- File transfer functions |
---|
710 | #D-************************* |
---|
711 | #D- |
---|
712 | |
---|
713 | #D-#================================================== |
---|
714 | #D-function IGCM_sys_Rsync_out |
---|
715 | #D-* Purpose: treat return val of rsync |
---|
716 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
717 | #D- Error values and explanations can depend on your system version. |
---|
718 | function IGCM_sys_Rsync_out { |
---|
719 | status=$1 |
---|
720 | if [ ! $status ] ; then |
---|
721 | echo "rsync error !" |
---|
722 | fi |
---|
723 | |
---|
724 | if [ $MYLANG = "fr" ]; then |
---|
725 | case $status in |
---|
726 | 0) return ;; |
---|
727 | 1) echo "Erreur de rsync ; RERR_SYNTAX : " |
---|
728 | echo "Erreur de syntaxe ou d'utilisation." |
---|
729 | return;; |
---|
730 | 2) echo "Erreur de rsync ; RERR_PROTOCOL : " |
---|
731 | echo "Incompatibilité de protocole." |
---|
732 | return;; |
---|
733 | 3) echo "Erreur de rsync ; RERR_FILESELECT 3" |
---|
734 | echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" |
---|
735 | echo "répertoires" |
---|
736 | return;; |
---|
737 | 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" |
---|
738 | echo "Action demandée non supportée : une tentative de manipulation de" |
---|
739 | echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" |
---|
740 | echo "été faite ; ou une option qui est supportée par le client mais" |
---|
741 | echo "pas par le serveur a été spécifiée." |
---|
742 | return;; |
---|
743 | 10) echo "Erreur de rsync ; RERR_SOCKETIO" |
---|
744 | echo "Erreur dans le socket d'entrée sortie" |
---|
745 | return;; |
---|
746 | 11) echo "Erreur de rsync ; RERR_FILEIO" |
---|
747 | echo "Erreur d'entrée sortie fichier" |
---|
748 | return;; |
---|
749 | 12) echo "Erreur de rsync ; RERR_STREAMIO" |
---|
750 | echo "Erreur dans flux de donnée du protocole rsync" |
---|
751 | return;; |
---|
752 | 13) echo "Erreur de rsync ; RERR_MESSAGEIO" |
---|
753 | echo "Erreur avec les diagnostics du programme" |
---|
754 | return;; |
---|
755 | 14) echo "Erreur de rsync ; RERR_IPC" |
---|
756 | echo "Erreur dans le code IPC" |
---|
757 | return;; |
---|
758 | 20) echo "Erreur de rsync ; RERR_SIGNAL" |
---|
759 | echo "SIGUSR1 ou SIGINT reçu" |
---|
760 | return;; |
---|
761 | 21) echo "Erreur de rsync ; RERR_WAITCHILD" |
---|
762 | echo "Une erreur retournée par waitpid()" |
---|
763 | return;; |
---|
764 | 22) echo "Erreur de rsync ; RERR_MALLOC" |
---|
765 | echo "Erreur lors de l'allocation des tampons de mémoire de coeur" |
---|
766 | return;; |
---|
767 | 23) echo "" |
---|
768 | echo "Erreur fichier inexistant" |
---|
769 | return;; |
---|
770 | 30) echo "Erreur de rsync ; RERR_TIMEOUT" |
---|
771 | echo "Temps d'attente écoulé dans l'envoi/réception de données" |
---|
772 | return;; |
---|
773 | *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status |
---|
774 | return;; |
---|
775 | esac |
---|
776 | elif [ $MYLANG = "en" ] ; then |
---|
777 | case $status in |
---|
778 | 0) return;; |
---|
779 | 1) echo "rsync error : Syntax or usage error " |
---|
780 | return;; |
---|
781 | 2) echo "rsync error : Protocol incompatibility " |
---|
782 | return;; |
---|
783 | 3) echo "rsync error : Errors selecting input/output files, dirs" |
---|
784 | return;; |
---|
785 | 4) echo "rsync error : Requested action not supported: an attempt" |
---|
786 | echo "was made to manipulate 64-bit files on a platform that cannot support" |
---|
787 | echo "them; or an option was specified that is supported by the client and" |
---|
788 | echo "not by the server." |
---|
789 | return;; |
---|
790 | 5) echo "rsync error : Error starting client-server protocol" |
---|
791 | return;; |
---|
792 | 10) echo "rsync error : Error in socket I/O " |
---|
793 | return;; |
---|
794 | 11) echo "rsync error : Error in file I/O " |
---|
795 | return;; |
---|
796 | 12) echo "rsync error : Error in rsync protocol data stream " |
---|
797 | return;; |
---|
798 | 13) echo "rsync error : Errors with program diagnostics " |
---|
799 | return;; |
---|
800 | 14) echo "rsync error : Error in IPC code " |
---|
801 | return;; |
---|
802 | 20) echo "rsync error : Received SIGUSR1 or SIGINT " |
---|
803 | return;; |
---|
804 | 21) echo "rsync error : Some error returned by waitpid() " |
---|
805 | return;; |
---|
806 | 22) echo "rsync error : Error allocating core memory buffers " |
---|
807 | return;; |
---|
808 | 23) echo "rsync error : Partial transfer due to error" |
---|
809 | return;; |
---|
810 | 24) echo "rsync error : Partial transfer due to vanished source files" |
---|
811 | return;; |
---|
812 | 30) echo "rsync error : Timeout in data send/receive " |
---|
813 | return;; |
---|
814 | *) echo "rsync error : return code of rsync unknown :" $status |
---|
815 | return;; |
---|
816 | esac |
---|
817 | else |
---|
818 | echo "unknown language $MYLANG." |
---|
819 | return |
---|
820 | fi |
---|
821 | } |
---|
822 | |
---|
823 | #D-#================================================== |
---|
824 | #D-function IGCM_sys_Miror_libIGCM |
---|
825 | #D-* Purpose: Mirror libIGCM PATH and lib to cesium |
---|
826 | #D-* Examples: |
---|
827 | #D- |
---|
828 | function IGCM_sys_Mirror_libIGCM { |
---|
829 | IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" |
---|
830 | if ( $DEBUG_sys ) ; then |
---|
831 | echo "IGCM_sys_Mirror_libIGCM" |
---|
832 | fi |
---|
833 | |
---|
834 | typeset status |
---|
835 | |
---|
836 | mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} |
---|
837 | |
---|
838 | echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 |
---|
839 | ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 |
---|
840 | status=$? |
---|
841 | |
---|
842 | if [ ${status} -gt 0 ] ; then |
---|
843 | echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." |
---|
844 | cat out_rsync |
---|
845 | fi |
---|
846 | IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" |
---|
847 | } |
---|
848 | |
---|
849 | #D-#================================================== |
---|
850 | #D-function IGCM_sys_Cp |
---|
851 | #D-* Purpose: generic cp |
---|
852 | #D-* Examples: |
---|
853 | #D- |
---|
854 | function IGCM_sys_Cp { |
---|
855 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
856 | if ( $DEBUG_sys ) ; then |
---|
857 | echo "IGCM_sys_Cp :" $@ |
---|
858 | fi |
---|
859 | |
---|
860 | typeset status |
---|
861 | |
---|
862 | echo cp $@ > out_rsync 2>&1 |
---|
863 | \cp $@ >> out_rsync 2>&1 |
---|
864 | status=$? |
---|
865 | |
---|
866 | if [ ${status} -gt 0 ] ; then |
---|
867 | echo "IGCM_sys_Cp : error code ${status}" |
---|
868 | cat out_rsync |
---|
869 | IGCM_debug_Exit "IGCM_sys_Cp" |
---|
870 | else |
---|
871 | \rm out_rsync |
---|
872 | fi |
---|
873 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
874 | } |
---|
875 | |
---|
876 | #D-#================================================== |
---|
877 | #D-function IGCM_sys_Rm |
---|
878 | #D-* Purpose: generic rm |
---|
879 | #D-* Examples: |
---|
880 | #D- |
---|
881 | function IGCM_sys_Rm { |
---|
882 | IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ |
---|
883 | if ( $DEBUG_sys ) ; then |
---|
884 | echo "IGCM_sys_Rm :" $@ |
---|
885 | fi |
---|
886 | |
---|
887 | typeset status |
---|
888 | |
---|
889 | echo rm $@ > out_rsync 2>&1 |
---|
890 | \rm $@ >> out_rsync 2>&1 |
---|
891 | status=$? |
---|
892 | |
---|
893 | if [ ${status} -gt 0 ] ; then |
---|
894 | echo "IGCM_sys_Rm : error code ${status}" |
---|
895 | cat out_rsync |
---|
896 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
897 | else |
---|
898 | \rm out_rsync |
---|
899 | fi |
---|
900 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
901 | } |
---|
902 | |
---|
903 | #D-#================================================== |
---|
904 | #D-function IGCM_sys_RmRunDir |
---|
905 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
906 | #D- scheduler will do the job) |
---|
907 | #D-* Examples: |
---|
908 | #D- |
---|
909 | function IGCM_sys_RmRunDir { |
---|
910 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ |
---|
911 | if ( $DEBUG_sys ) ; then |
---|
912 | echo "IGCM_sys_RmRunDir :" $@ |
---|
913 | fi |
---|
914 | |
---|
915 | typeset status |
---|
916 | |
---|
917 | echo rm $@ > out_rsync 2>&1 |
---|
918 | \rm $@ >> out_rsync 2>&1 |
---|
919 | status=$? |
---|
920 | |
---|
921 | if [ ${status} -gt 0 ] ; then |
---|
922 | echo "IGCM_sys_RmRunDir : error code ${status}" |
---|
923 | cat out_rsync |
---|
924 | IGCM_debug_Exit "IGCM_sys_RmRunDir" |
---|
925 | else |
---|
926 | \rm out_rsync |
---|
927 | fi |
---|
928 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
929 | } |
---|
930 | |
---|
931 | #D-#================================================== |
---|
932 | #D-function IGCM_sys_Mv |
---|
933 | #D-* Purpose: generic move |
---|
934 | #D-* Examples: |
---|
935 | #D- |
---|
936 | function IGCM_sys_Mv { |
---|
937 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
938 | if ( $DEBUG_sys ) ; then |
---|
939 | echo "IGCM_sys_Mv :" $@ |
---|
940 | fi |
---|
941 | |
---|
942 | if [ $DRYRUN = 0 ]; then |
---|
943 | |
---|
944 | typeset status |
---|
945 | |
---|
946 | echo mv $@ > out_rsync 2>&1 |
---|
947 | \mv $@ >> out_rsync 2>&1 |
---|
948 | status=$? |
---|
949 | |
---|
950 | if [ ${status} -gt 0 ] ; then |
---|
951 | echo "IGCM_sys_Mv : error code ${status}" |
---|
952 | cat out_rsync |
---|
953 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
954 | else |
---|
955 | \rm out_rsync |
---|
956 | fi |
---|
957 | else |
---|
958 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
959 | fi |
---|
960 | |
---|
961 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
962 | } |
---|
963 | |
---|
964 | #D-#================================================== |
---|
965 | #D-function IGCM_sys_Put_Dir |
---|
966 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
967 | #D-* Examples: |
---|
968 | #D- |
---|
969 | function IGCM_sys_Put_Dir { |
---|
970 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
971 | if ( $DEBUG_sys ) ; then |
---|
972 | echo "IGCM_sys_Put_Dir :" $@ |
---|
973 | fi |
---|
974 | if [ $DRYRUN = 0 ]; then |
---|
975 | if [ ! -d ${1} ] ; then |
---|
976 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
977 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
978 | return |
---|
979 | fi |
---|
980 | |
---|
981 | typeset status |
---|
982 | |
---|
983 | # Only if we use rsync |
---|
984 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
985 | # |
---|
986 | #USUAL WAY |
---|
987 | \cp -r $1 $2 > out_rsync 2>&1 |
---|
988 | status=$? |
---|
989 | |
---|
990 | if [ ${status} -gt 0 ] ; then |
---|
991 | echo "IGCM_sys_Put_Dir : error code ${status}" |
---|
992 | cat out_rsync |
---|
993 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
994 | else |
---|
995 | \rm out_rsync |
---|
996 | fi |
---|
997 | else |
---|
998 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
999 | fi |
---|
1000 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
1001 | } |
---|
1002 | |
---|
1003 | #D-#================================================== |
---|
1004 | #D-function IGCM_sys_Get_Dir |
---|
1005 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
1006 | #D-* Examples: |
---|
1007 | #D- |
---|
1008 | function IGCM_sys_Get_Dir { |
---|
1009 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
1010 | if ( $DEBUG_sys ) ; then |
---|
1011 | echo "IGCM_sys_Get_Dir :" $@ |
---|
1012 | fi |
---|
1013 | if [ $DRYRUN = 0 ]; then |
---|
1014 | # if [ ! -d ${1} ] ; then |
---|
1015 | # echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
1016 | # IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
1017 | # return |
---|
1018 | # fi |
---|
1019 | |
---|
1020 | typeset NB_ESSAI DELAI status i |
---|
1021 | # number of tentative |
---|
1022 | NB_ESSAI=3 |
---|
1023 | # time delay between tentative |
---|
1024 | DELAI=2 |
---|
1025 | |
---|
1026 | # Only if we use rsync |
---|
1027 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
1028 | # |
---|
1029 | # USUAL WAY |
---|
1030 | # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command : |
---|
1031 | ccc_hsm get -r $1 |
---|
1032 | |
---|
1033 | i=0 |
---|
1034 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1035 | \cp -ur $1 $2 >> out_rsync 2>&1 |
---|
1036 | status=$? |
---|
1037 | if [ ${status} -gt 0 ]; then |
---|
1038 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1039 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again." |
---|
1040 | sleep $DELAI |
---|
1041 | else |
---|
1042 | break |
---|
1043 | fi |
---|
1044 | (( i = i + 1 )) |
---|
1045 | done |
---|
1046 | |
---|
1047 | if [ ${status} -gt 0 ] ; then |
---|
1048 | echo "IGCM_sys_Get_Dir : error." |
---|
1049 | cat out_rsync |
---|
1050 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
1051 | else |
---|
1052 | \rm out_rsync |
---|
1053 | fi |
---|
1054 | else |
---|
1055 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1056 | fi |
---|
1057 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
1058 | } |
---|
1059 | |
---|
1060 | #D-#================================================== |
---|
1061 | #D-function IGCM_sys_Get_Master |
---|
1062 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
1063 | #D-* Examples: |
---|
1064 | #D- |
---|
1065 | function IGCM_sys_Get_Master { |
---|
1066 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
1067 | if ( $DEBUG_sys ) ; then |
---|
1068 | echo "IGCM_sys_Get_Master :" $@ |
---|
1069 | fi |
---|
1070 | if [ $DRYRUN = 0 ]; then |
---|
1071 | if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then |
---|
1072 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." |
---|
1073 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
1074 | return |
---|
1075 | fi |
---|
1076 | |
---|
1077 | typeset NB_ESSAI DELAI status i |
---|
1078 | # number of tentative |
---|
1079 | NB_ESSAI=3 |
---|
1080 | # time delay between tentative |
---|
1081 | DELAI=2 |
---|
1082 | |
---|
1083 | i=0 |
---|
1084 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1085 | \cp -urL $1 $2 > out_rsync 2>&1 |
---|
1086 | status=$? |
---|
1087 | if [ ${status} -gt 0 ]; then |
---|
1088 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1089 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." |
---|
1090 | sleep $DELAI |
---|
1091 | else |
---|
1092 | break |
---|
1093 | fi |
---|
1094 | (( i = i + 1 )) |
---|
1095 | done |
---|
1096 | |
---|
1097 | if [ ${status} -gt 0 ] ; then |
---|
1098 | echo "IGCM_sys_Get_Master : error." |
---|
1099 | cat out_rsync |
---|
1100 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
1101 | else |
---|
1102 | \rm out_rsync |
---|
1103 | fi |
---|
1104 | else |
---|
1105 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1106 | fi |
---|
1107 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
1108 | } |
---|
1109 | |
---|
1110 | #==================================================== |
---|
1111 | #- Call IGCM_sys_Mirror_libIGCM now ! |
---|
1112 | if ( $MirrorlibIGCM ) ; then |
---|
1113 | IGCM_sys_Mirror_libIGCM |
---|
1114 | fi |
---|
1115 | |
---|
1116 | #D-#================================================== |
---|
1117 | #D-function IGCM_sys_Put_Rest |
---|
1118 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
1119 | #D- File and target directory must exist. |
---|
1120 | #D-* Examples: |
---|
1121 | #D- |
---|
1122 | function IGCM_sys_Put_Rest { |
---|
1123 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
1124 | if ( $DEBUG_sys ) ; then |
---|
1125 | echo "IGCM_sys_Put_Rest :" $@ |
---|
1126 | fi |
---|
1127 | if [ $DRYRUN = 0 ]; then |
---|
1128 | if [ ! -f ${1} ] ; then |
---|
1129 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
1130 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
1131 | fi |
---|
1132 | |
---|
1133 | typeset status |
---|
1134 | # |
---|
1135 | # USUAL WAY |
---|
1136 | \cp $1 $2 > out_rsync 2>&1 |
---|
1137 | status=$? |
---|
1138 | |
---|
1139 | # #RSYNC WITH NETWORK SSH CALL |
---|
1140 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 |
---|
1141 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 |
---|
1142 | |
---|
1143 | # #RSYNC WITH NFS USE |
---|
1144 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 |
---|
1145 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 |
---|
1146 | |
---|
1147 | # status=$? |
---|
1148 | # IGCM_sys_Rsync_out $status |
---|
1149 | |
---|
1150 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
1151 | # (( status=status+$? )) |
---|
1152 | |
---|
1153 | if [ ${status} -gt 0 ] ; then |
---|
1154 | echo "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
1155 | [ -f ${1} ] && ls -l ${1} |
---|
1156 | [ -f ${2} ] && ls -l ${2} |
---|
1157 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1158 | cat out_rsync |
---|
1159 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
1160 | else |
---|
1161 | |
---|
1162 | if [ X${JobType} = XRUN ] ; then |
---|
1163 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
1164 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
1165 | fi |
---|
1166 | |
---|
1167 | \rm out_rsync |
---|
1168 | fi |
---|
1169 | else |
---|
1170 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1171 | fi |
---|
1172 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
1173 | } |
---|
1174 | |
---|
1175 | #D-#================================================== |
---|
1176 | #D-function IGCM_sys_PutBuffer_Rest |
---|
1177 | #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. |
---|
1178 | #D- File and target directory must exist. |
---|
1179 | #D-* Examples: |
---|
1180 | #D- |
---|
1181 | function IGCM_sys_PutBuffer_Rest { |
---|
1182 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ |
---|
1183 | if ( $DEBUG_sys ) ; then |
---|
1184 | echo "IGCM_sys_PutBuffer_Rest :" $@ |
---|
1185 | fi |
---|
1186 | if [ $DRYRUN = 0 ]; then |
---|
1187 | if [ ! -f ${1} ] ; then |
---|
1188 | echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." |
---|
1189 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
1190 | fi |
---|
1191 | |
---|
1192 | typeset status |
---|
1193 | # |
---|
1194 | # USUAL WAY |
---|
1195 | \cp $1 $2 > out_rsync 2>&1 |
---|
1196 | status=$? |
---|
1197 | |
---|
1198 | if [ ${status} -gt 0 ] ; then |
---|
1199 | echo "IGCM_sys_PutBuffer_Rest : error code ${status}" |
---|
1200 | [ -f ${2} ] && ls -l ${2} |
---|
1201 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1202 | cat out_rsync |
---|
1203 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
1204 | else |
---|
1205 | |
---|
1206 | if [ X${JobType} = XRUN ] ; then |
---|
1207 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
1208 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
1209 | fi |
---|
1210 | |
---|
1211 | \rm out_rsync |
---|
1212 | fi |
---|
1213 | else |
---|
1214 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1215 | fi |
---|
1216 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" |
---|
1217 | } |
---|
1218 | |
---|
1219 | #D-#================================================== |
---|
1220 | #D-function IGCM_sys_PrepareTaredRestart |
---|
1221 | #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. |
---|
1222 | #D-* Examples: |
---|
1223 | #D- |
---|
1224 | function IGCM_sys_PrepareTaredRestart { |
---|
1225 | IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ |
---|
1226 | if [ $DRYRUN = 0 ]; then |
---|
1227 | [ ! -f $( basename $1 ) ] && DEBUG_sys=false IGCM_sys_Get $1 . |
---|
1228 | else |
---|
1229 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1230 | fi |
---|
1231 | echo $( basename $1 ) |
---|
1232 | IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" |
---|
1233 | } |
---|
1234 | |
---|
1235 | #D-#================================================== |
---|
1236 | #D-function IGCM_sys_Put_Out |
---|
1237 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
1238 | #D-* Examples: |
---|
1239 | #D- |
---|
1240 | function IGCM_sys_Put_Out { |
---|
1241 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
1242 | if ( $DEBUG_sys ) ; then |
---|
1243 | echo "IGCM_sys_Put_Out :" $@ |
---|
1244 | fi |
---|
1245 | |
---|
1246 | typeset NB_ESSAI DELAI status i exist skip |
---|
1247 | |
---|
1248 | # number of tentative |
---|
1249 | NB_ESSAI=3 |
---|
1250 | # time delay between tentative |
---|
1251 | DELAI=2 |
---|
1252 | |
---|
1253 | if [ $DRYRUN = 0 ]; then |
---|
1254 | if [ ! -f ${1} ] ; then |
---|
1255 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
1256 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
1257 | return 1 |
---|
1258 | fi |
---|
1259 | # |
---|
1260 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
1261 | # |
---|
1262 | |
---|
1263 | #===================================================== |
---|
1264 | # COMMENT OUT DOUBLE COPY ON SCRATCHDIR |
---|
1265 | #===================================================== |
---|
1266 | |
---|
1267 | #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 |
---|
1268 | #if [ $? -eq 0 ] ; then |
---|
1269 | # typeset WORKPATH FILEPATH |
---|
1270 | # WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) |
---|
1271 | # IGCM_sys_MkdirWork ${WORKPATH} |
---|
1272 | # FILEPATH=${WORKPATH}/$( basename $2 ) |
---|
1273 | # # |
---|
1274 | # IGCM_sys_Cp ${1} ${FILEPATH} |
---|
1275 | #fi |
---|
1276 | |
---|
1277 | exist=false |
---|
1278 | skip=false |
---|
1279 | if [ -f $2 ] ; then |
---|
1280 | IGCM_debug_Print 1 "$2 already exist" |
---|
1281 | #dmget $2 |
---|
1282 | ccc_hsm get $2 |
---|
1283 | exist=true |
---|
1284 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
1285 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
1286 | skip=true |
---|
1287 | else |
---|
1288 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
1289 | skip=false |
---|
1290 | fi |
---|
1291 | fi |
---|
1292 | # |
---|
1293 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
1294 | IGCM_sys_Chmod u+w $2 |
---|
1295 | fi |
---|
1296 | |
---|
1297 | if [ X${skip} = Xfalse ] ; then |
---|
1298 | i=0 |
---|
1299 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1300 | # USUAL WAY |
---|
1301 | \cp $1 $2 > out_rsync 2>&1 |
---|
1302 | status=$? |
---|
1303 | if [ ${status} -gt 0 ]; then |
---|
1304 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1305 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." |
---|
1306 | [ -f ${1} ] && ls -l ${1} |
---|
1307 | [ -f ${2} ] && ls -l ${2} |
---|
1308 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1309 | sleep $DELAI |
---|
1310 | else |
---|
1311 | break |
---|
1312 | fi |
---|
1313 | (( i = i + 1 )) |
---|
1314 | done |
---|
1315 | fi |
---|
1316 | |
---|
1317 | # #RSYNC WITH NETWORK SSH CALL |
---|
1318 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 |
---|
1319 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 |
---|
1320 | |
---|
1321 | # #RSYNC WITH NFS USE |
---|
1322 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 |
---|
1323 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 |
---|
1324 | |
---|
1325 | # status=$? |
---|
1326 | # IGCM_sys_Rsync_out $status |
---|
1327 | |
---|
1328 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
1329 | # (( status=status+$? )) |
---|
1330 | |
---|
1331 | if [ ${status} -gt 0 ] ; then |
---|
1332 | echo "IGCM_sys_Put_Out : error." |
---|
1333 | [ -f ${1} ] && ls -l ${1} |
---|
1334 | [ -f ${2} ] && ls -l ${2} |
---|
1335 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1336 | cat out_rsync |
---|
1337 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
1338 | else |
---|
1339 | |
---|
1340 | if [ X${JobType} = XRUN ] ; then |
---|
1341 | if [ X${3} = X ] ; then |
---|
1342 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
1343 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
1344 | fi |
---|
1345 | fi |
---|
1346 | |
---|
1347 | \rm out_rsync |
---|
1348 | fi |
---|
1349 | else |
---|
1350 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1351 | fi |
---|
1352 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
1353 | return 0 |
---|
1354 | } |
---|
1355 | |
---|
1356 | #D-#================================================== |
---|
1357 | #D-function IGCM_sys_PutBuffer_Out |
---|
1358 | #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly |
---|
1359 | #D-* Examples: |
---|
1360 | #D- |
---|
1361 | function IGCM_sys_PutBuffer_Out { |
---|
1362 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ |
---|
1363 | if ( $DEBUG_sys ) ; then |
---|
1364 | echo "IGCM_sys_PutBuffer_Out :" $@ |
---|
1365 | fi |
---|
1366 | |
---|
1367 | typeset NB_ESSAI DELAI status i exist skip |
---|
1368 | |
---|
1369 | # number of tentative |
---|
1370 | NB_ESSAI=3 |
---|
1371 | # time delay between tentative |
---|
1372 | DELAI=2 |
---|
1373 | |
---|
1374 | if [ $DRYRUN = 0 ]; then |
---|
1375 | if [ ! -f ${1} ] ; then |
---|
1376 | echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." |
---|
1377 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
1378 | return 1 |
---|
1379 | fi |
---|
1380 | # |
---|
1381 | IGCM_sys_Mkdir $( dirname $2 ) |
---|
1382 | # |
---|
1383 | |
---|
1384 | exist=false |
---|
1385 | skip=false |
---|
1386 | if [ -f $2 ] ; then |
---|
1387 | IGCM_debug_Print 1 "$2 already exist" |
---|
1388 | exist=true |
---|
1389 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
1390 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
1391 | skip=true |
---|
1392 | else |
---|
1393 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
1394 | skip=false |
---|
1395 | fi |
---|
1396 | fi |
---|
1397 | # |
---|
1398 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
1399 | IGCM_sys_Chmod u+w $2 |
---|
1400 | fi |
---|
1401 | |
---|
1402 | if [ X${skip} = Xfalse ] ; then |
---|
1403 | i=0 |
---|
1404 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1405 | # USUAL WAY |
---|
1406 | \cp $1 $2 > out_rsync 2>&1 |
---|
1407 | status=$? |
---|
1408 | if [ ${status} -gt 0 ]; then |
---|
1409 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1410 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." |
---|
1411 | [ -f ${2} ] && ls -l ${2} |
---|
1412 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1413 | sleep $DELAI |
---|
1414 | else |
---|
1415 | break |
---|
1416 | fi |
---|
1417 | (( i = i + 1 )) |
---|
1418 | done |
---|
1419 | fi |
---|
1420 | |
---|
1421 | if [ ${status} -gt 0 ] ; then |
---|
1422 | echo "IGCM_sys_PutBuffer_Out : error." |
---|
1423 | [ -f ${2} ] && ls -l ${2} |
---|
1424 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
1425 | cat out_rsync |
---|
1426 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
1427 | else |
---|
1428 | |
---|
1429 | if [ X${JobType} = XRUN ] ; then |
---|
1430 | if [ X${3} = X ] ; then |
---|
1431 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
1432 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
1433 | fi |
---|
1434 | fi |
---|
1435 | |
---|
1436 | \rm out_rsync |
---|
1437 | fi |
---|
1438 | else |
---|
1439 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1440 | fi |
---|
1441 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
1442 | return 0 |
---|
1443 | } |
---|
1444 | |
---|
1445 | #D-#================================================== |
---|
1446 | #D-function IGCM_sys_Get |
---|
1447 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
1448 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
1449 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
1450 | function IGCM_sys_Get { |
---|
1451 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
1452 | |
---|
1453 | typeset DEST dm_liste target file_work |
---|
1454 | typeset NB_ESSAI DELAI status i |
---|
1455 | |
---|
1456 | if ( $DEBUG_sys ) ; then |
---|
1457 | echo "IGCM_sys_Get :" $@ |
---|
1458 | fi |
---|
1459 | |
---|
1460 | # number of tentative |
---|
1461 | NB_ESSAI=3 |
---|
1462 | # time delay between tentative |
---|
1463 | DELAI=2 |
---|
1464 | |
---|
1465 | if [ $DRYRUN -le 2 ]; then |
---|
1466 | if [ X${1} = X'/l' ] ; then |
---|
1467 | # test if the first file is present in the old computation : |
---|
1468 | eval set +A dm_liste \${${2}} |
---|
1469 | else |
---|
1470 | eval set +A dm_liste ${1} |
---|
1471 | fi |
---|
1472 | eval DEST=\${${#}} |
---|
1473 | |
---|
1474 | #===================================================== |
---|
1475 | # COMMENT OUT DOUBLE COPY ON SCRATCHDIR |
---|
1476 | #===================================================== |
---|
1477 | |
---|
1478 | # Is it an R_OUT file (not R_IN) ? |
---|
1479 | #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 |
---|
1480 | #if [ $? -eq 0 ] ; then |
---|
1481 | # # Yes ? then we try to get it in SCRATCHDIR |
---|
1482 | # set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) |
---|
1483 | # if [ -f ${file_work[0]} ] ; then |
---|
1484 | # IGCM_sys_Cp ${file_work[*]} ${DEST} |
---|
1485 | # IGCM_debug_PopStack "IGCM_sys_Get" |
---|
1486 | # return |
---|
1487 | # fi |
---|
1488 | #fi |
---|
1489 | |
---|
1490 | ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1 |
---|
1491 | status=$? |
---|
1492 | if [ ${status} -gt 0 ] ; then |
---|
1493 | echo "WARNING IGCM_sys_Get : error code ${status}" |
---|
1494 | cat out_rsync |
---|
1495 | echo "WARNING IGCM_sys_Get : will stop later if the cp fails." |
---|
1496 | fi |
---|
1497 | |
---|
1498 | #if [ ${status} -gt 0 ] ; then |
---|
1499 | # if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then |
---|
1500 | # cat out_rsync |
---|
1501 | # echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " |
---|
1502 | # sleep 30 |
---|
1503 | # echo "We try another time" |
---|
1504 | ## dmget ${dm_liste[*]} > out_rsync 2>&1 |
---|
1505 | # ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1 |
---|
1506 | # status=$? |
---|
1507 | # if [ ${status} -gt 0 ] ; then |
---|
1508 | # echo "ERROR IGCM_sys_Get : again demigration error :" |
---|
1509 | # cat out_rsync |
---|
1510 | # IGCM_debug_Exit "IGCM_sys_Get" |
---|
1511 | # fi |
---|
1512 | # else |
---|
1513 | # echo "ERROR IGCM_sys_Get : demigration error :" |
---|
1514 | # cat out_rsync |
---|
1515 | # IGCM_debug_Exit "IGCM_sys_Get" |
---|
1516 | # fi |
---|
1517 | #fi |
---|
1518 | |
---|
1519 | # #RSYNC WITH NETWORK SSH CALL |
---|
1520 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 |
---|
1521 | # ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 |
---|
1522 | |
---|
1523 | # #RSYNC WITH NFS USE |
---|
1524 | # echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1 |
---|
1525 | # ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1 |
---|
1526 | |
---|
1527 | # status=$? |
---|
1528 | # IGCM_sys_Rsync_out $status |
---|
1529 | |
---|
1530 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
1531 | # (( status=status+$? )) |
---|
1532 | |
---|
1533 | #USUAL WAY |
---|
1534 | if [ X${1} = X'/l' ] ; then |
---|
1535 | for target in ${dm_liste[*]} ; do |
---|
1536 | local_file=$( basename ${target} ) |
---|
1537 | # test if the target file is present before the loop |
---|
1538 | IGCM_sys_TestFileArchive ${target} |
---|
1539 | status=$? |
---|
1540 | if [ ${status} -gt 0 ] ; then |
---|
1541 | echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ." |
---|
1542 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1543 | else |
---|
1544 | i=0 |
---|
1545 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1546 | \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 |
---|
1547 | status=$? |
---|
1548 | if [ ${status} -gt 0 ]; then |
---|
1549 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1550 | IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again." |
---|
1551 | sleep $DELAI |
---|
1552 | else |
---|
1553 | break |
---|
1554 | fi |
---|
1555 | (( i = i + 1 )) |
---|
1556 | done |
---|
1557 | if [ ${status} -gt 0 ] ; then |
---|
1558 | echo "IGCM_sys_Get : error" |
---|
1559 | cat out_rsync |
---|
1560 | \rm out_rsync |
---|
1561 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1562 | else |
---|
1563 | \rm out_rsync |
---|
1564 | fi |
---|
1565 | fi |
---|
1566 | done |
---|
1567 | else |
---|
1568 | i=0 |
---|
1569 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1570 | \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 |
---|
1571 | status=$? |
---|
1572 | if [ ${status} -gt 0 ]; then |
---|
1573 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1574 | IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again." |
---|
1575 | sleep $DELAI |
---|
1576 | else |
---|
1577 | break |
---|
1578 | fi |
---|
1579 | (( i = i + 1 )) |
---|
1580 | done |
---|
1581 | if [ ${status} -gt 0 ] ; then |
---|
1582 | echo "IGCM_sys_Get : error" |
---|
1583 | cat out_rsync |
---|
1584 | \rm out_rsync |
---|
1585 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
1586 | else |
---|
1587 | \rm out_rsync |
---|
1588 | fi |
---|
1589 | fi |
---|
1590 | else |
---|
1591 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1592 | fi |
---|
1593 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
1594 | } |
---|
1595 | |
---|
1596 | #D-#================================================== |
---|
1597 | #D-function IGCM_sys_GetBuffer |
---|
1598 | #D-* Purpose: Get a file from ${SCRATCHDIR} |
---|
1599 | #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX |
---|
1600 | #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ |
---|
1601 | function IGCM_sys_GetBuffer { |
---|
1602 | IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ |
---|
1603 | |
---|
1604 | typeset DEST buf_liste target file_work |
---|
1605 | typeset NB_ESSAI DELAI status i |
---|
1606 | |
---|
1607 | if ( $DEBUG_sys ) ; then |
---|
1608 | echo "IGCM_sys_GetBuffer :" $@ |
---|
1609 | fi |
---|
1610 | |
---|
1611 | # number of tentative |
---|
1612 | NB_ESSAI=3 |
---|
1613 | # time delay between tentative |
---|
1614 | DELAI=2 |
---|
1615 | |
---|
1616 | if [ $DRYRUN -le 2 ]; then |
---|
1617 | if [ X${1} = X'/l' ] ; then |
---|
1618 | # test if the first file is present in the old computation : |
---|
1619 | eval set +A buf_liste \${${2}} |
---|
1620 | else |
---|
1621 | eval set +A buf_liste ${1} |
---|
1622 | fi |
---|
1623 | eval DEST=\${${#}} |
---|
1624 | |
---|
1625 | #USUAL WAY |
---|
1626 | if [ X${1} = X'/l' ] ; then |
---|
1627 | for target in ${buf_liste[*]} ; do |
---|
1628 | local_file=$( basename ${target} ) |
---|
1629 | i=0 |
---|
1630 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1631 | \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 |
---|
1632 | status=$? |
---|
1633 | if [ ${status} -gt 0 ]; then |
---|
1634 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1635 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
1636 | sleep $DELAI |
---|
1637 | else |
---|
1638 | break |
---|
1639 | fi |
---|
1640 | (( i = i + 1 )) |
---|
1641 | done |
---|
1642 | if [ ${status} -gt 0 ] ; then |
---|
1643 | echo "IGCM_sys_Get : error" |
---|
1644 | cat out_rsync |
---|
1645 | \rm out_rsync |
---|
1646 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
1647 | else |
---|
1648 | \rm out_rsync |
---|
1649 | fi |
---|
1650 | done |
---|
1651 | else |
---|
1652 | i=0 |
---|
1653 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1654 | \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 |
---|
1655 | status=$? |
---|
1656 | if [ ${status} -gt 0 ]; then |
---|
1657 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
1658 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
1659 | sleep $DELAI |
---|
1660 | else |
---|
1661 | break |
---|
1662 | fi |
---|
1663 | (( i = i + 1 )) |
---|
1664 | done |
---|
1665 | if [ ${status} -gt 0 ] ; then |
---|
1666 | echo "IGCM_sys_Get : error" |
---|
1667 | cat out_rsync |
---|
1668 | \rm out_rsync |
---|
1669 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
1670 | else |
---|
1671 | \rm out_rsync |
---|
1672 | fi |
---|
1673 | fi |
---|
1674 | else |
---|
1675 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1676 | fi |
---|
1677 | IGCM_debug_PopStack "IGCM_sys_GetBuffer" |
---|
1678 | } |
---|
1679 | |
---|
1680 | #D-#================================================== |
---|
1681 | #D-function IGCM_sys_GetDate_FichWork |
---|
1682 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
1683 | #D-* Examples: |
---|
1684 | #D- |
---|
1685 | function IGCM_sys_GetDate_FichWork { |
---|
1686 | IGCM_debug_PushStack "IGCM_sys_FichWork" $@ |
---|
1687 | if ( $DEBUG_sys ) ; then |
---|
1688 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
1689 | fi |
---|
1690 | typeset dateF |
---|
1691 | set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) |
---|
1692 | eval ${2}=${dateF[5]} |
---|
1693 | |
---|
1694 | # donne la date filesys d'un fichier sur la machine work |
---|
1695 | IGCM_debug_PopStack "IGCM_sys_FichWork" |
---|
1696 | } |
---|
1697 | |
---|
1698 | #D-#================================================== |
---|
1699 | #D-function IGCM_sys_GetDate_FichArchive |
---|
1700 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE |
---|
1701 | #D-* Examples: |
---|
1702 | #D- |
---|
1703 | function IGCM_sys_GetDate_FichArchive { |
---|
1704 | IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ |
---|
1705 | if ( $DEBUG_sys ) ; then |
---|
1706 | echo "IGCM_sys_GetDate_FichArchive :" $@ |
---|
1707 | fi |
---|
1708 | typeset dateF |
---|
1709 | set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) |
---|
1710 | eval ${2}=${dateF[5]} |
---|
1711 | |
---|
1712 | IGCM_debug_PopStack "IGCM_sys_FichArchive" |
---|
1713 | } |
---|
1714 | |
---|
1715 | #D-#================================================== |
---|
1716 | #D-function IGCM_sys_Dods_Rm |
---|
1717 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
1718 | #D-* Examples: |
---|
1719 | #D- |
---|
1720 | function IGCM_sys_Dods_Rm { |
---|
1721 | if ( $DEBUG_sys ) ; then |
---|
1722 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
1723 | fi |
---|
1724 | typeset status |
---|
1725 | if [ $DRYRUN = 0 ]; then |
---|
1726 | |
---|
1727 | # if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then |
---|
1728 | # echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." |
---|
1729 | # echo "Nothing has been done." |
---|
1730 | # return |
---|
1731 | # fi |
---|
1732 | |
---|
1733 | /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 |
---|
1734 | status=$? |
---|
1735 | |
---|
1736 | # if [ ${status} -gt 0 ] ; then |
---|
1737 | # echo "IGCM_sys_Dods_Rm : error." |
---|
1738 | # cat out_dods_rm |
---|
1739 | # IGCM_debug_Exit "IGCM_sys_Dods_Rm" |
---|
1740 | # else |
---|
1741 | # rm out_dods_rm |
---|
1742 | # fi |
---|
1743 | |
---|
1744 | else |
---|
1745 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1746 | fi |
---|
1747 | return $status |
---|
1748 | } |
---|
1749 | |
---|
1750 | #D-#================================================== |
---|
1751 | #D-function IGCM_sys_Dods_Cp |
---|
1752 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
1753 | #D-* Examples: |
---|
1754 | #D- |
---|
1755 | function IGCM_sys_Dods_Cp { |
---|
1756 | if ( $DEBUG_sys ) ; then |
---|
1757 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
1758 | fi |
---|
1759 | typeset status |
---|
1760 | if [ $DRYRUN = 0 ]; then |
---|
1761 | |
---|
1762 | # if [ ! -d ${R_SAVE}/${1} ] ; then |
---|
1763 | # echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." |
---|
1764 | # echo "Nothing has been done." |
---|
1765 | # return |
---|
1766 | # fi |
---|
1767 | |
---|
1768 | /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 |
---|
1769 | status=$? |
---|
1770 | |
---|
1771 | # if [ ${status} -gt 0 ] ; then |
---|
1772 | # echo "IGCM_sys_Dods_Cp : error." |
---|
1773 | # cat out_dods_cp |
---|
1774 | # IGCM_debug_Exit "IGCM_sys_Dods_Cp" |
---|
1775 | # else |
---|
1776 | # rm out_dods_cp |
---|
1777 | # fi |
---|
1778 | |
---|
1779 | else |
---|
1780 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1781 | fi |
---|
1782 | return $status |
---|
1783 | } |
---|
1784 | |
---|
1785 | #D-#================================================== |
---|
1786 | #D-function IGCM_sys_Put_Dods |
---|
1787 | #D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole. |
---|
1788 | #D-* Examples: |
---|
1789 | #D- |
---|
1790 | function IGCM_sys_Put_Dods { |
---|
1791 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
1792 | if ( $DEBUG_sys ) ; then |
---|
1793 | echo "IGCM_sys_Put_Dods :" $@ |
---|
1794 | fi |
---|
1795 | #set -vx |
---|
1796 | typeset status |
---|
1797 | if [ $DRYRUN = 0 ]; then |
---|
1798 | if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then |
---|
1799 | echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should." |
---|
1800 | echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST." |
---|
1801 | echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST." |
---|
1802 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1803 | return |
---|
1804 | fi |
---|
1805 | |
---|
1806 | if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then |
---|
1807 | echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should." |
---|
1808 | echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS." |
---|
1809 | echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS." |
---|
1810 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1811 | return |
---|
1812 | fi |
---|
1813 | # |
---|
1814 | if [ -d ${R_SAVE}/${1} ] ; then |
---|
1815 | cd ${R_SAVE} |
---|
1816 | elif [ -d ${R_FIGR}/${1} ] ; then |
---|
1817 | cd ${R_FIGR} |
---|
1818 | fi |
---|
1819 | |
---|
1820 | IGCM_sys_Dods_Rm ${1} |
---|
1821 | IGCM_sys_Dods_Cp ${1} |
---|
1822 | status=0 |
---|
1823 | |
---|
1824 | if [ ${status} -gt 0 ] ; then |
---|
1825 | echo "IGCM_sys_Put_Dods : error." |
---|
1826 | IGCM_debug_Exit "IGCM_sys_Put_Dods" |
---|
1827 | fi |
---|
1828 | else |
---|
1829 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
1830 | fi |
---|
1831 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
1832 | } |
---|
1833 | |
---|
1834 | ############################################################## |
---|
1835 | # REBUILD OPERATOR |
---|
1836 | |
---|
1837 | function IGCM_sys_rebuild { |
---|
1838 | IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ |
---|
1839 | if ( $DEBUG_sys ) ; then |
---|
1840 | echo "IGCM_sys_rebuild :" $@ |
---|
1841 | fi |
---|
1842 | |
---|
1843 | typeset NB_ESSAI DELAI status i firstArg |
---|
1844 | # number of tentative |
---|
1845 | NB_ESSAI=3 |
---|
1846 | # time delay between tentative |
---|
1847 | DELAI=2 |
---|
1848 | |
---|
1849 | i=0 |
---|
1850 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1851 | ~p86ipsl/CESIUM/bin/rebuild -f -o $@ > out_rsync 2>&1 |
---|
1852 | status=$? |
---|
1853 | if [ ${status} -gt 0 ] ; then |
---|
1854 | IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" |
---|
1855 | cat out_rsync |
---|
1856 | \rm out_rsync |
---|
1857 | IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1858 | firstArg=${1} |
---|
1859 | \rm ${firstArg} |
---|
1860 | sleep $DELAI |
---|
1861 | else |
---|
1862 | \rm out_rsync |
---|
1863 | break |
---|
1864 | fi |
---|
1865 | (( i = i + 1 )) |
---|
1866 | done |
---|
1867 | |
---|
1868 | if [ ${status} -gt 0 ] ; then |
---|
1869 | echo "IGCM_sys_rebuild : rebuild error code is ${status}" |
---|
1870 | IGCM_debug_Exit "rebuild" |
---|
1871 | fi |
---|
1872 | |
---|
1873 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
1874 | } |
---|
1875 | |
---|
1876 | function IGCM_sys_rebuild_station { |
---|
1877 | IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@ |
---|
1878 | typeset i list_opt file_in file_out prefix_invert list_invert |
---|
1879 | if ( $DEBUG_sys ) ; then |
---|
1880 | echo "IGCM_sys_rebuild_station :" $@ |
---|
1881 | fi |
---|
1882 | list_opt=$@ |
---|
1883 | |
---|
1884 | # Invert Axis : t,x -> x,t |
---|
1885 | # t,pres,x -> x,t,pres |
---|
1886 | # So that we can concatenate along x |
---|
1887 | i=0 |
---|
1888 | for file_in in ${list_opt} ; do |
---|
1889 | (( i = i + 1)) |
---|
1890 | [ ${i} = 1 ] && file_out=${file_in} && continue |
---|
1891 | prefix_invert=$( basename ${file_in} .nc ) |
---|
1892 | IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc |
---|
1893 | list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc |
---|
1894 | done |
---|
1895 | |
---|
1896 | # Concatenate |
---|
1897 | IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc |
---|
1898 | |
---|
1899 | # Re-ivert file |
---|
1900 | IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} |
---|
1901 | |
---|
1902 | # Station re-ordering is too expansive to be run within libICGM |
---|
1903 | # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. |
---|
1904 | # This re-ordering must be done "in memory" by the cmorization process |
---|
1905 | # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) |
---|
1906 | # BEGIN reordering |
---|
1907 | |
---|
1908 | # Only LMDZ text output contains the exact ordering of the station. |
---|
1909 | # We isolate this in the code below: |
---|
1910 | # 0 38 -157.5000000000000 70.98591549295774 |
---|
1911 | # 0 54 27.49999999999999 67.18309859154928 |
---|
1912 | # 0 56 -62.50000000000001 82.39436619718309 |
---|
1913 | # 0 79 12.49999999999999 78.59154929577466 |
---|
1914 | # 0 116 -165.0000000000000 76.05633802816901 |
---|
1915 | # 0 117 130.0000000000000 70.98591549295774 |
---|
1916 | # 0 118 110.0000000000000 87.46478873239437 |
---|
1917 | # 1 40 4.999999999999995 51.97183098591550 |
---|
1918 | # typeset iStation iProc list_opt file_in file_out prefix_invert |
---|
1919 | # typeset -Z4 j4 |
---|
1920 | # typeset -Z3 j3 |
---|
1921 | |
---|
1922 | # unset list_opt |
---|
1923 | # set +A list_opt $@ |
---|
1924 | |
---|
1925 | # Filename after rebuild |
---|
1926 | # file_out=${list_opt[0]} |
---|
1927 | # Prefix of output files |
---|
1928 | # prefix_invert=$( basename ${file_out} .nc ) |
---|
1929 | # Number of procs |
---|
1930 | # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) |
---|
1931 | |
---|
1932 | # iProc=0 |
---|
1933 | # while [ ${iProc} -lt ${num_proc} ] ; do |
---|
1934 | # Array containing Station as a number |
---|
1935 | # unset proc_stn |
---|
1936 | # 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}' ) |
---|
1937 | # Number of stations produced by processor proc |
---|
1938 | # stationLast=${#proc_stn[*]} |
---|
1939 | # Proc number on 4 digits |
---|
1940 | # j4=${iProc} |
---|
1941 | # Init |
---|
1942 | # iStation=0 |
---|
1943 | # while [ ${iStation} -lt ${stationLast} ] ; do |
---|
1944 | # Station number on 3 digits |
---|
1945 | # j3=${proc_stn[${iStation}]} |
---|
1946 | # Extract station |
---|
1947 | # Invert Axis : t,x -> x,t |
---|
1948 | # t,pres,x -> x,t,pres |
---|
1949 | # So that we can concatenate along x |
---|
1950 | # 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 |
---|
1951 | # (( iStation = iStation + 1 )) |
---|
1952 | # done |
---|
1953 | # (( iProc = iProc + 1 )) |
---|
1954 | # done |
---|
1955 | |
---|
1956 | # Concatenate all station along x |
---|
1957 | # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc |
---|
1958 | |
---|
1959 | # Re-invert file |
---|
1960 | # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} |
---|
1961 | |
---|
1962 | # END reordering |
---|
1963 | |
---|
1964 | IGCM_debug_PopStack "IGCM_sys_rebuild_station" |
---|
1965 | } |
---|
1966 | |
---|
1967 | ############################################################ |
---|
1968 | # Activate Running Environnment Variables |
---|
1969 | |
---|
1970 | function IGCM_sys_activ_variables { |
---|
1971 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
1972 | if ( $DEBUG_sys ) ; then |
---|
1973 | echo "IGCM_sys_activ_variables" |
---|
1974 | fi |
---|
1975 | |
---|
1976 | ulimit -s unlimited |
---|
1977 | |
---|
1978 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
1979 | } |
---|
1980 | |
---|
1981 | ############################################################ |
---|
1982 | # Desactivate Running Environnment Variables |
---|
1983 | |
---|
1984 | function IGCM_sys_desactiv_variables { |
---|
1985 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
1986 | if ( $DEBUG_sys ) ; then |
---|
1987 | echo "IGCM_sys_desactiv_variables" |
---|
1988 | fi |
---|
1989 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
1990 | } |
---|
1991 | |
---|
1992 | ############################################################ |
---|
1993 | # Build MPI/OMP scripts run file (dummy function) |
---|
1994 | |
---|
1995 | function IGCM_sys_build_run_file { |
---|
1996 | |
---|
1997 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
1998 | |
---|
1999 | } |
---|
2000 | |
---|
2001 | ############################################################ |
---|
2002 | # Build MPI/OMP scripts |
---|
2003 | function IGCM_sys_build_execution_scripts |
---|
2004 | { |
---|
2005 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
2006 | if ( $DEBUG_sys ) ; then |
---|
2007 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
2008 | fi |
---|
2009 | |
---|
2010 | # Verification with MSUB parameter |
---|
2011 | EXECUTION=${HOST_MPIRUN_COMMAND} |
---|
2012 | |
---|
2013 | if ( ${OK_PARA_MPMD} ) ; then |
---|
2014 | |
---|
2015 | if [ -f run_file ] ; then |
---|
2016 | IGCM_sys_Rm -f run_file |
---|
2017 | fi |
---|
2018 | touch run_file |
---|
2019 | |
---|
2020 | # run_file construction |
---|
2021 | |
---|
2022 | # Then first loop on the components for the coupler ie oasis |
---|
2023 | |
---|
2024 | ### the coupler ie oasis must be the first one |
---|
2025 | for comp in ${config_ListOfComponents[*]} ; do |
---|
2026 | |
---|
2027 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
2028 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
2029 | |
---|
2030 | # for CPL component only |
---|
2031 | if [ "X${comp}" = "XCPL" ] ; then |
---|
2032 | |
---|
2033 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
2034 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
2035 | echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
2036 | fi |
---|
2037 | done |
---|
2038 | |
---|
2039 | # Then second loop on the components |
---|
2040 | |
---|
2041 | for comp in ${config_ListOfComponents[*]} ; do |
---|
2042 | |
---|
2043 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
2044 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
2045 | |
---|
2046 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
2047 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
2048 | |
---|
2049 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
2050 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
2051 | echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
2052 | fi |
---|
2053 | done |
---|
2054 | |
---|
2055 | EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file" |
---|
2056 | |
---|
2057 | IGCM_sys_Chmod u+x run_file |
---|
2058 | if ( $DEBUG_sys ) ; then |
---|
2059 | echo "run_file contains : " |
---|
2060 | cat run_file |
---|
2061 | fi |
---|
2062 | |
---|
2063 | else # Only one executable. launch it. |
---|
2064 | |
---|
2065 | # |
---|
2066 | for comp in ${config_ListOfComponents[*]} ; do |
---|
2067 | |
---|
2068 | # Only if we really have an executable for the component : |
---|
2069 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
2070 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
2071 | |
---|
2072 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
2073 | echo "" >> script_${ExeNameOut}.ksh |
---|
2074 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
2075 | |
---|
2076 | if ( ${OK_PARA_OMP} ) ; then |
---|
2077 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
2078 | echo "" >> script_${ExeNameOut}.ksh |
---|
2079 | echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
2080 | echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
2081 | echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
2082 | echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
2083 | fi |
---|
2084 | |
---|
2085 | if ( ${OK_PARA_MPI} ) ; then |
---|
2086 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
2087 | # Default : ccc_mprun used if nb_proc gt 1 |
---|
2088 | # to have out/err per process on different files |
---|
2089 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}" >> script_${ExeNameOut}.ksh |
---|
2090 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
2091 | EXECUTION="${HOST_MPIRUN_COMMAND} -n ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
2092 | else |
---|
2093 | # Default : ccc_mprun is NOT used if nb_proc eq 1 |
---|
2094 | # to have out/err per process on different files |
---|
2095 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
2096 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
2097 | EXECUTION="/usr/bin/time ./script_${ExeNameOut}.ksh" |
---|
2098 | fi |
---|
2099 | |
---|
2100 | IGCM_debug_Print 1 "sys Curie : script_${ExeNameOut}.ksh contains" |
---|
2101 | cat script_${ExeNameOut}.ksh |
---|
2102 | |
---|
2103 | fi |
---|
2104 | |
---|
2105 | done |
---|
2106 | |
---|
2107 | fi |
---|
2108 | |
---|
2109 | IGCM_debug_Print 1 "sys Curie : execution command is " |
---|
2110 | IGCM_debug_Print 1 "$EXECUTION" |
---|
2111 | |
---|
2112 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
2113 | } |
---|
2114 | |
---|
2115 | ############################################################ |
---|
2116 | # Check of space available on temporary filesytems |
---|
2117 | function IGCM_sys_check_quota { |
---|
2118 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
2119 | if ( $DEBUG_sys ) ; then |
---|
2120 | echo "IGCM_sys_check_quota" |
---|
2121 | fi |
---|
2122 | # Limit of quota (in %) |
---|
2123 | limit_quota=90 |
---|
2124 | |
---|
2125 | # Check of the volume |
---|
2126 | volume_quota=$(ccc_quota | grep ' scratch' | awk '{print $2}') |
---|
2127 | volume_avail=$(ccc_quota | grep ' scratch' | awk '{print $3}') |
---|
2128 | |
---|
2129 | if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then |
---|
2130 | |
---|
2131 | unit_avail=${volume_avail: -1} |
---|
2132 | unit_quota=${volume_quota: -1} |
---|
2133 | |
---|
2134 | if [ "${unit_quota}" = "*" ] ; then |
---|
2135 | IGCM_debug_Print 1 "Please, check your quota of volume on scratch" |
---|
2136 | IGCM_debug_Print 1 "More than 100% of your quota is used" |
---|
2137 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
2138 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
2139 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
2140 | IGCM_debug_Verif_Exit |
---|
2141 | fi |
---|
2142 | |
---|
2143 | temp_avail=${volume_avail%%${volume_avail: -1}*} |
---|
2144 | temp_quota=${volume_quota%%${volume_quota: -1}*} |
---|
2145 | |
---|
2146 | if [ ! ${unit_avail} = ${unit_quota} ] ; then |
---|
2147 | |
---|
2148 | # Convertion |
---|
2149 | if [ ${volume_avail: -1} = "T" ] ; then |
---|
2150 | (( temp_avail = temp_avail * 1000000000000 )) |
---|
2151 | elif [ ${volume_avail: -1} = "G" ] ; then |
---|
2152 | (( temp_avail = temp_avail * 1000000000 )) |
---|
2153 | elif [ ${volume_avail: -1} = "M" ] ; then |
---|
2154 | (( temp_avail = temp_avail * 1000000 )) |
---|
2155 | elif [ ${volume_avail: -1} = "k" ] ; then |
---|
2156 | (( temp_avail = temp_avail * 1000 )) |
---|
2157 | else |
---|
2158 | (( temp_avail = volume_avail )) |
---|
2159 | fi |
---|
2160 | if [ ${volume_quota: -1} = "T" ] ; then |
---|
2161 | (( temp_quota = temp_quota * 1000000000000 )) |
---|
2162 | elif [ ${volume_quota: -1} = "G" ] ; then |
---|
2163 | (( temp_quota = temp_quota * 1000000000 )) |
---|
2164 | elif [ ${volume_quota: -1} = "M" ] ; then |
---|
2165 | (( temp_quota = temp_quota * 1000000 )) |
---|
2166 | elif [ ${volume_quota: -1} = "k" ] ; then |
---|
2167 | (( temp_quota = temp_quota * 1000 )) |
---|
2168 | else |
---|
2169 | (( temp_quota = volume_quota )) |
---|
2170 | fi |
---|
2171 | fi |
---|
2172 | |
---|
2173 | quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc) |
---|
2174 | # echo "volume ratio is " $quota_volume |
---|
2175 | |
---|
2176 | if [ ${quota_volume} -ge ${limit_quota} ] ; then |
---|
2177 | IGCM_debug_Print 1 "Please, check your quota of volume on scratch" |
---|
2178 | IGCM_debug_Print 1 "${quota_volume}% of your quota is used" |
---|
2179 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
2180 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
2181 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
2182 | IGCM_debug_Verif_Exit |
---|
2183 | fi |
---|
2184 | |
---|
2185 | fi |
---|
2186 | |
---|
2187 | # Check of the number of inodes |
---|
2188 | |
---|
2189 | inode_quota=$(ccc_quota | grep ' scratch' | awk '{print $6}') |
---|
2190 | inode_avail=$(ccc_quota | grep ' scratch' | awk '{print $7}') |
---|
2191 | |
---|
2192 | if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then |
---|
2193 | |
---|
2194 | unit_avail=${inode_avail: -1} |
---|
2195 | unit_quota=${inode_quota: -1} |
---|
2196 | |
---|
2197 | if [ "${unit_quota}" = "*" ] ; then |
---|
2198 | IGCM_debug_Print 1 "Please, check your quota of inode on scratch" |
---|
2199 | IGCM_debug_Print 1 "More than 100% of your quota is used" |
---|
2200 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
2201 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
2202 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
2203 | IGCM_debug_Verif_Exit |
---|
2204 | fi |
---|
2205 | |
---|
2206 | temp_avail=${inode_avail%%${inode_avail: -1}*} |
---|
2207 | temp_quota=${inode_quota%%${inode_quota: -1}*} |
---|
2208 | |
---|
2209 | if [ ! ${unit_avail} = ${unit_quota} ] ; then |
---|
2210 | |
---|
2211 | # Convertion |
---|
2212 | if [ ${inode_avail: -1} = "T" ] ; then |
---|
2213 | (( temp_avail = temp_avail * 1000000000000 )) |
---|
2214 | elif [ ${inode_avail: -1} = "G" ] ; then |
---|
2215 | (( temp_avail = temp_avail * 1000000000 )) |
---|
2216 | elif [ ${inode_avail: -1} = "M" ] ; then |
---|
2217 | (( temp_avail = temp_avail * 1000000 )) |
---|
2218 | elif [ ${inode_avail: -1} = "k" ] ; then |
---|
2219 | (( temp_avail = temp_avail * 1000 )) |
---|
2220 | else |
---|
2221 | (( temp_avail = inode_avail )) |
---|
2222 | fi |
---|
2223 | |
---|
2224 | if [ ${inode_quota: -1} = "T" ] ; then |
---|
2225 | (( temp_quota = temp_quota * 1000000000000 )) |
---|
2226 | elif [ ${inode_quota: -1} = "G" ] ; then |
---|
2227 | (( temp_quota = temp_quota * 1000000000 )) |
---|
2228 | elif [ ${inode_quota: -1} = "M" ] ; then |
---|
2229 | (( temp_quota = temp_quota * 1000000 )) |
---|
2230 | elif [ ${inode_quota: -1} = "k" ] ; then |
---|
2231 | (( temp_quota = temp_quota * 1000 )) |
---|
2232 | else |
---|
2233 | (( temp_quota = inode_quota )) |
---|
2234 | fi |
---|
2235 | fi |
---|
2236 | quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc) |
---|
2237 | # echo "inode ratio is " $quota_inode |
---|
2238 | |
---|
2239 | if [ ${quota_inode} -ge ${limit_quota} ] ; then |
---|
2240 | IGCM_debug_Print 1 "Please, check your quota of inode on scratch" |
---|
2241 | IGCM_debug_Print 1 "${quota_inode}% of your quota is used" |
---|
2242 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
2243 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
2244 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
2245 | IGCM_debug_Verif_Exit |
---|
2246 | fi |
---|
2247 | fi |
---|
2248 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
2249 | } |
---|
2250 | |
---|
2251 | #D-#================================================== |
---|
2252 | #D-function IGCM_sys_CountJobInQueue |
---|
2253 | #D-* Purpose: Check if job_name is currently |
---|
2254 | #D- running or in queue |
---|
2255 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
2256 | #D- |
---|
2257 | |
---|
2258 | function IGCM_sys_CountJobInQueue { |
---|
2259 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
2260 | if ( $DEBUG_sys ) ; then |
---|
2261 | echo "IGCM_sys_CountJobInQueue" |
---|
2262 | fi |
---|
2263 | |
---|
2264 | #NbRun=$( ccc_mstat -f | grep -c ${JobName} ) |
---|
2265 | |
---|
2266 | # With -f option, the full job name is given in the last column |
---|
2267 | NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ($NF~String) { x=x+1 } END { print x }' ) |
---|
2268 | |
---|
2269 | eval ${2}=${NbRun} |
---|
2270 | |
---|
2271 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
2272 | } |
---|
2273 | |
---|
2274 | ############################################################## |
---|
2275 | # NCO OPERATOR |
---|
2276 | |
---|
2277 | function IGCM_sys_ncap2 { |
---|
2278 | IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ |
---|
2279 | if ( $DEBUG_sys ) ; then |
---|
2280 | echo "IGCM_sys_ncap2 :" $@ |
---|
2281 | fi |
---|
2282 | |
---|
2283 | typeset NB_ESSAI DELAI status i |
---|
2284 | # number of tentative |
---|
2285 | NB_ESSAI=3 |
---|
2286 | # time delay between tentative |
---|
2287 | DELAI=2 |
---|
2288 | |
---|
2289 | i=0 |
---|
2290 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2291 | ncap2 "$@" > out_rsync 2>&1 |
---|
2292 | status=$? |
---|
2293 | if [ ${status} -gt 0 ] ; then |
---|
2294 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" |
---|
2295 | cat out_rsync |
---|
2296 | \rm out_rsync |
---|
2297 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2298 | sleep $DELAI |
---|
2299 | else |
---|
2300 | \rm out_rsync |
---|
2301 | break |
---|
2302 | fi |
---|
2303 | (( i = i + 1 )) |
---|
2304 | done |
---|
2305 | |
---|
2306 | if [ ${status} -gt 0 ] ; then |
---|
2307 | echo "IGCM_sys_ncap2 : ncap2 error" |
---|
2308 | IGCM_debug_Exit "ncap2" |
---|
2309 | fi |
---|
2310 | |
---|
2311 | IGCM_debug_PopStack "IGCM_sys_ncap2" |
---|
2312 | } |
---|
2313 | |
---|
2314 | function IGCM_sys_ncatted { |
---|
2315 | IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ |
---|
2316 | if ( $DEBUG_sys ) ; then |
---|
2317 | echo "IGCM_sys_ncatted :" $@ |
---|
2318 | fi |
---|
2319 | |
---|
2320 | typeset NB_ESSAI DELAI status i |
---|
2321 | # number of tentative |
---|
2322 | NB_ESSAI=3 |
---|
2323 | # time delay between tentative |
---|
2324 | DELAI=2 |
---|
2325 | |
---|
2326 | i=0 |
---|
2327 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2328 | ncatted "$@" > out_rsync 2>&1 |
---|
2329 | status=$? |
---|
2330 | if [ ${status} -gt 0 ] ; then |
---|
2331 | IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" |
---|
2332 | cat out_rsync |
---|
2333 | \rm out_rsync |
---|
2334 | IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2335 | sleep $DELAI |
---|
2336 | else |
---|
2337 | \rm out_rsync |
---|
2338 | break |
---|
2339 | fi |
---|
2340 | (( i = i + 1 )) |
---|
2341 | done |
---|
2342 | |
---|
2343 | if [ ${status} -gt 0 ] ; then |
---|
2344 | echo "IGCM_sys_ncatted : ncatted error" |
---|
2345 | IGCM_debug_Exit "ncatted" |
---|
2346 | fi |
---|
2347 | |
---|
2348 | IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
2349 | } |
---|
2350 | |
---|
2351 | function IGCM_sys_ncbo { |
---|
2352 | IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ |
---|
2353 | if ( $DEBUG_sys ) ; then |
---|
2354 | echo "IGCM_sys_ncbo :" $@ |
---|
2355 | fi |
---|
2356 | |
---|
2357 | typeset NB_ESSAI DELAI status i |
---|
2358 | # number of tentative |
---|
2359 | NB_ESSAI=3 |
---|
2360 | # time delay between tentative |
---|
2361 | DELAI=2 |
---|
2362 | |
---|
2363 | i=0 |
---|
2364 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2365 | ncbo $@ > out_rsync 2>&1 |
---|
2366 | status=$? |
---|
2367 | if [ ${status} -gt 0 ] ; then |
---|
2368 | IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" |
---|
2369 | cat out_rsync |
---|
2370 | \rm out_rsync |
---|
2371 | IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2372 | sleep $DELAI |
---|
2373 | else |
---|
2374 | \rm out_rsync |
---|
2375 | break |
---|
2376 | fi |
---|
2377 | (( i = i + 1 )) |
---|
2378 | done |
---|
2379 | |
---|
2380 | if [ ${status} -gt 0 ] ; then |
---|
2381 | echo "IGCM_sys_ncbo : ncbo error" |
---|
2382 | IGCM_debug_Exit "ncbo" |
---|
2383 | fi |
---|
2384 | |
---|
2385 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
2386 | } |
---|
2387 | |
---|
2388 | function IGCM_sys_ncdiff { |
---|
2389 | IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ |
---|
2390 | if ( $DEBUG_sys ) ; then |
---|
2391 | echo "IGCM_sys_ncdiff :" $@ |
---|
2392 | fi |
---|
2393 | |
---|
2394 | typeset NB_ESSAI DELAI status i |
---|
2395 | # number of tentative |
---|
2396 | NB_ESSAI=3 |
---|
2397 | # time delay between tentative |
---|
2398 | DELAI=2 |
---|
2399 | |
---|
2400 | i=0 |
---|
2401 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2402 | ncdiff $@ > out_rsync 2>&1 |
---|
2403 | status=$? |
---|
2404 | if [ ${status} -gt 0 ] ; then |
---|
2405 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" |
---|
2406 | cat out_rsync |
---|
2407 | \rm out_rsync |
---|
2408 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2409 | sleep $DELAI |
---|
2410 | else |
---|
2411 | \rm out_rsync |
---|
2412 | break |
---|
2413 | fi |
---|
2414 | (( i = i + 1 )) |
---|
2415 | done |
---|
2416 | |
---|
2417 | if [ ${status} -gt 0 ] ; then |
---|
2418 | echo "IGCM_sys_ncdiff : ncdiff error" |
---|
2419 | IGCM_debug_Exit "ncdiff" |
---|
2420 | fi |
---|
2421 | |
---|
2422 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
2423 | } |
---|
2424 | |
---|
2425 | function IGCM_sys_ncea { |
---|
2426 | IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ |
---|
2427 | if ( $DEBUG_sys ) ; then |
---|
2428 | echo "IGCM_sys_ncea :" $@ |
---|
2429 | fi |
---|
2430 | |
---|
2431 | typeset NB_ESSAI DELAI status i |
---|
2432 | # number of tentative |
---|
2433 | NB_ESSAI=3 |
---|
2434 | # time delay between tentative |
---|
2435 | DELAI=2 |
---|
2436 | |
---|
2437 | i=0 |
---|
2438 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2439 | ncea $@ > out_rsync 2>&1 |
---|
2440 | status=$? |
---|
2441 | if [ ${status} -gt 0 ] ; then |
---|
2442 | IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" |
---|
2443 | cat out_rsync |
---|
2444 | \rm out_rsync |
---|
2445 | IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2446 | sleep $DELAI |
---|
2447 | else |
---|
2448 | \rm out_rsync |
---|
2449 | break |
---|
2450 | fi |
---|
2451 | (( i = i + 1 )) |
---|
2452 | done |
---|
2453 | |
---|
2454 | if [ ${status} -gt 0 ] ; then |
---|
2455 | echo "IGCM_sys_ncea : ncea error" |
---|
2456 | IGCM_debug_Exit "ncea" |
---|
2457 | fi |
---|
2458 | |
---|
2459 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
2460 | } |
---|
2461 | |
---|
2462 | function IGCM_sys_ncecat { |
---|
2463 | IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ |
---|
2464 | if ( $DEBUG_sys ) ; then |
---|
2465 | echo "IGCM_sys_ncecat :" $@ |
---|
2466 | fi |
---|
2467 | |
---|
2468 | typeset NB_ESSAI DELAI status i |
---|
2469 | # number of tentative |
---|
2470 | NB_ESSAI=3 |
---|
2471 | # time delay between tentative |
---|
2472 | DELAI=2 |
---|
2473 | |
---|
2474 | i=0 |
---|
2475 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2476 | ncecat $@ > out_rsync 2>&1 |
---|
2477 | status=$? |
---|
2478 | if [ ${status} -gt 0 ] ; then |
---|
2479 | IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" |
---|
2480 | cat out_rsync |
---|
2481 | \rm out_rsync |
---|
2482 | IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2483 | sleep $DELAI |
---|
2484 | else |
---|
2485 | \rm out_rsync |
---|
2486 | break |
---|
2487 | fi |
---|
2488 | (( i = i + 1 )) |
---|
2489 | done |
---|
2490 | |
---|
2491 | if [ ${status} -gt 0 ] ; then |
---|
2492 | echo "IGCM_sys_ncecat : ncecat error" |
---|
2493 | IGCM_debug_Exit "ncecat" |
---|
2494 | fi |
---|
2495 | |
---|
2496 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
2497 | } |
---|
2498 | |
---|
2499 | function IGCM_sys_ncflint { |
---|
2500 | IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ |
---|
2501 | if ( $DEBUG_sys ) ; then |
---|
2502 | echo "IGCM_sys_ncflint :" $@ |
---|
2503 | fi |
---|
2504 | |
---|
2505 | typeset NB_ESSAI DELAI status i |
---|
2506 | # number of tentative |
---|
2507 | NB_ESSAI=3 |
---|
2508 | # time delay between tentative |
---|
2509 | DELAI=2 |
---|
2510 | |
---|
2511 | i=0 |
---|
2512 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2513 | ncflint $@ > out_rsync 2>&1 |
---|
2514 | status=$? |
---|
2515 | if [ ${status} -gt 0 ] ; then |
---|
2516 | IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" |
---|
2517 | cat out_rsync |
---|
2518 | \rm out_rsync |
---|
2519 | IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2520 | sleep $DELAI |
---|
2521 | else |
---|
2522 | \rm out_rsync |
---|
2523 | break |
---|
2524 | fi |
---|
2525 | (( i = i + 1 )) |
---|
2526 | done |
---|
2527 | |
---|
2528 | if [ ${status} -gt 0 ] ; then |
---|
2529 | echo "IGCM_sys_ncflint : ncflint error" |
---|
2530 | IGCM_debug_Exit "ncflint" |
---|
2531 | fi |
---|
2532 | |
---|
2533 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
2534 | } |
---|
2535 | |
---|
2536 | function IGCM_sys_ncks { |
---|
2537 | IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ |
---|
2538 | if ( $DEBUG_sys ) ; then |
---|
2539 | echo "IGCM_sys_ncks :" $@ |
---|
2540 | fi |
---|
2541 | |
---|
2542 | typeset NB_ESSAI DELAI status i |
---|
2543 | # number of tentative |
---|
2544 | NB_ESSAI=3 |
---|
2545 | # time delay between tentative |
---|
2546 | DELAI=2 |
---|
2547 | |
---|
2548 | i=0 |
---|
2549 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2550 | ncks $@ > out_rsync 2>&1 |
---|
2551 | status=$? |
---|
2552 | if [ ${status} -gt 0 ] ; then |
---|
2553 | IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" |
---|
2554 | cat out_rsync |
---|
2555 | \rm out_rsync |
---|
2556 | IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2557 | sleep $DELAI |
---|
2558 | else |
---|
2559 | \rm out_rsync |
---|
2560 | break |
---|
2561 | fi |
---|
2562 | (( i = i + 1 )) |
---|
2563 | done |
---|
2564 | |
---|
2565 | if [ ${status} -gt 0 ] ; then |
---|
2566 | echo "IGCM_sys_ncks : ncks error" |
---|
2567 | IGCM_debug_Exit "ncks" |
---|
2568 | fi |
---|
2569 | |
---|
2570 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
2571 | } |
---|
2572 | |
---|
2573 | function IGCM_sys_ncpdq { |
---|
2574 | IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ |
---|
2575 | if ( $DEBUG_sys ) ; then |
---|
2576 | echo "IGCM_sys_ncpdq :" $@ |
---|
2577 | fi |
---|
2578 | |
---|
2579 | typeset NB_ESSAI DELAI status i |
---|
2580 | # number of tentative |
---|
2581 | NB_ESSAI=3 |
---|
2582 | # time delay between tentative |
---|
2583 | DELAI=2 |
---|
2584 | |
---|
2585 | i=0 |
---|
2586 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2587 | ncpdq $@ > out_rsync 2>&1 |
---|
2588 | status=$? |
---|
2589 | if [ ${status} -gt 0 ] ; then |
---|
2590 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" |
---|
2591 | cat out_rsync |
---|
2592 | \rm out_rsync |
---|
2593 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2594 | sleep $DELAI |
---|
2595 | else |
---|
2596 | \rm out_rsync |
---|
2597 | break |
---|
2598 | fi |
---|
2599 | (( i = i + 1 )) |
---|
2600 | done |
---|
2601 | |
---|
2602 | if [ ${status} -gt 0 ] ; then |
---|
2603 | echo "IGCM_sys_ncpdq : ncpdq error" |
---|
2604 | IGCM_debug_Exit "ncpdq" |
---|
2605 | fi |
---|
2606 | |
---|
2607 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
2608 | } |
---|
2609 | |
---|
2610 | function IGCM_sys_ncra { |
---|
2611 | IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ |
---|
2612 | if ( $DEBUG_sys ) ; then |
---|
2613 | echo "IGCM_sys_ncra :" $@ |
---|
2614 | fi |
---|
2615 | |
---|
2616 | typeset NB_ESSAI DELAI status i |
---|
2617 | # number of tentative |
---|
2618 | NB_ESSAI=3 |
---|
2619 | # time delay between tentative |
---|
2620 | DELAI=2 |
---|
2621 | |
---|
2622 | i=0 |
---|
2623 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2624 | ncra $@ > out_rsync 2>&1 |
---|
2625 | status=$? |
---|
2626 | if [ ${status} -gt 0 ] ; then |
---|
2627 | IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" |
---|
2628 | cat out_rsync |
---|
2629 | \rm out_rsync |
---|
2630 | IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2631 | sleep $DELAI |
---|
2632 | else |
---|
2633 | \rm out_rsync |
---|
2634 | break |
---|
2635 | fi |
---|
2636 | (( i = i + 1 )) |
---|
2637 | done |
---|
2638 | |
---|
2639 | if [ ${status} -gt 0 ] ; then |
---|
2640 | echo "IGCM_sys_ncra : ncra error" |
---|
2641 | IGCM_debug_Exit "ncra" |
---|
2642 | fi |
---|
2643 | |
---|
2644 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
2645 | } |
---|
2646 | |
---|
2647 | function IGCM_sys_ncrcat { |
---|
2648 | IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ |
---|
2649 | if ( $DEBUG_sys ) ; then |
---|
2650 | echo "IGCM_sys_ncrcat :" $@ |
---|
2651 | fi |
---|
2652 | |
---|
2653 | typeset NB_ESSAI DELAI status i lastArg |
---|
2654 | # number of tentative |
---|
2655 | NB_ESSAI=3 |
---|
2656 | # time delay between tentative |
---|
2657 | DELAI=2 |
---|
2658 | |
---|
2659 | i=0 |
---|
2660 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2661 | ncrcat $@ > out_rsync 2>&1 |
---|
2662 | status=$? |
---|
2663 | if [ ${status} -gt 0 ] ; then |
---|
2664 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" |
---|
2665 | cat out_rsync |
---|
2666 | \rm out_rsync |
---|
2667 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2668 | sleep $DELAI |
---|
2669 | elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" out_rsync )" = "X" ] ; then |
---|
2670 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" |
---|
2671 | cat out_rsync |
---|
2672 | # remove files having corrupted time axis |
---|
2673 | eval lastArg=\${$#} |
---|
2674 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" |
---|
2675 | \rm ${lastArg} |
---|
2676 | \rm out_rsync |
---|
2677 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2678 | sleep $DELAI |
---|
2679 | else |
---|
2680 | \rm out_rsync |
---|
2681 | break |
---|
2682 | fi |
---|
2683 | (( i = i + 1 )) |
---|
2684 | done |
---|
2685 | |
---|
2686 | if [ ${status} -gt 0 ] ; then |
---|
2687 | echo "IGCM_sys_ncrcat : ncrcat error" |
---|
2688 | #IGCM_debug_Exit "ncrcat" |
---|
2689 | fi |
---|
2690 | |
---|
2691 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
2692 | } |
---|
2693 | |
---|
2694 | function IGCM_sys_ncrename { |
---|
2695 | IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ |
---|
2696 | if ( $DEBUG_sys ) ; then |
---|
2697 | echo "IGCM_sys_ncrename :" $@ |
---|
2698 | fi |
---|
2699 | |
---|
2700 | typeset NB_ESSAI DELAI status i |
---|
2701 | # number of tentative |
---|
2702 | NB_ESSAI=3 |
---|
2703 | # time delay between tentative |
---|
2704 | DELAI=2 |
---|
2705 | |
---|
2706 | i=0 |
---|
2707 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2708 | ncrename $@ > out_rsync 2>&1 |
---|
2709 | status=$? |
---|
2710 | if [ ${status} -gt 0 ] ; then |
---|
2711 | IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" |
---|
2712 | cat out_rsync |
---|
2713 | \rm out_rsync |
---|
2714 | IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2715 | sleep $DELAI |
---|
2716 | else |
---|
2717 | \rm out_rsync |
---|
2718 | break |
---|
2719 | fi |
---|
2720 | (( i = i + 1 )) |
---|
2721 | done |
---|
2722 | |
---|
2723 | if [ ${status} -gt 0 ] ; then |
---|
2724 | echo "IGCM_sys_ncrename : ncrename error" |
---|
2725 | IGCM_debug_Exit "ncrename" |
---|
2726 | fi |
---|
2727 | |
---|
2728 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
2729 | } |
---|
2730 | |
---|
2731 | function IGCM_sys_ncwa { |
---|
2732 | IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ |
---|
2733 | if ( $DEBUG_sys ) ; then |
---|
2734 | echo "IGCM_sys_ncwa :" $@ |
---|
2735 | fi |
---|
2736 | |
---|
2737 | typeset NB_ESSAI DELAI status i |
---|
2738 | # number of tentative |
---|
2739 | NB_ESSAI=3 |
---|
2740 | # time delay between tentative |
---|
2741 | DELAI=2 |
---|
2742 | |
---|
2743 | i=0 |
---|
2744 | while [ $i -lt $NB_ESSAI ] ; do |
---|
2745 | ncwa $@ > out_rsync 2>&1 |
---|
2746 | status=$? |
---|
2747 | if [ ${status} -gt 0 ] ; then |
---|
2748 | IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" |
---|
2749 | cat out_rsync |
---|
2750 | \rm out_rsync |
---|
2751 | IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
2752 | sleep $DELAI |
---|
2753 | else |
---|
2754 | \rm out_rsync |
---|
2755 | break |
---|
2756 | fi |
---|
2757 | (( i = i + 1 )) |
---|
2758 | done |
---|
2759 | |
---|
2760 | if [ ${status} -gt 0 ] ; then |
---|
2761 | echo "IGCM_sys_ncwa : ncwa error" |
---|
2762 | IGCM_debug_Exit "ncwa" |
---|
2763 | fi |
---|
2764 | |
---|
2765 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
2766 | } |
---|
2767 | |
---|
2768 | ############################################################## |
---|
2769 | # CDO OPERATOR |
---|
2770 | |
---|
2771 | function IGCM_sys_cdo { |
---|
2772 | IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ |
---|
2773 | if ( $DEBUG_sys ) ; then |
---|
2774 | echo "IGCM_sys_cdo :" $@ |
---|
2775 | fi |
---|
2776 | |
---|
2777 | typeset status |
---|
2778 | |
---|
2779 | \cdo $@ > out_rsync 2>&1 |
---|
2780 | status=$? |
---|
2781 | if [ ${status} -gt 0 ] ; then |
---|
2782 | echo "IGCM_sys_cdo : error code ${status}" |
---|
2783 | cat out_rsync |
---|
2784 | \rm out_rsync |
---|
2785 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2786 | return 1 |
---|
2787 | else |
---|
2788 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2789 | return 0 |
---|
2790 | fi |
---|
2791 | |
---|
2792 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
2793 | } |
---|