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