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