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