1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Martial Mancip |
---|
5 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | # bypass specific internationalization (for gawk) |
---|
14 | export LC_ALL="C" |
---|
15 | |
---|
16 | # By default, all libIGCM_sys save functions will protect output datas (RUN execution mode) |
---|
17 | # other values : DEB(ug), DEV(elopment). |
---|
18 | JobType=${JobType:=RUN} |
---|
19 | |
---|
20 | #==================================================== |
---|
21 | # set PackDefault false by default |
---|
22 | PackDefault=false |
---|
23 | |
---|
24 | #==================================================== |
---|
25 | # set BigBrother false by default |
---|
26 | BigBrother=${BigBrother:=false} |
---|
27 | |
---|
28 | #==================================================== |
---|
29 | # set BigBrother channel (AMQP or MAIL) |
---|
30 | # only MAIL working at present due to firewall constraint |
---|
31 | BigBrotherChannel=MAIL |
---|
32 | |
---|
33 | # no need to be so verbose in checking mode |
---|
34 | if [ ! X${TaskType} = Xchecking ] ; then |
---|
35 | echo |
---|
36 | echo "====================================================" |
---|
37 | echo "Where do we run ?" $( hostname ) |
---|
38 | uname -a |
---|
39 | echo "====================================================" |
---|
40 | echo |
---|
41 | fi |
---|
42 | |
---|
43 | if [ X${JobType} = XDEB ] ; then |
---|
44 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
45 | set -vx |
---|
46 | DEBUG_debug=true |
---|
47 | DEBUG_sys=true |
---|
48 | fi |
---|
49 | |
---|
50 | #==================================================== |
---|
51 | |
---|
52 | case $( hostname -s ) in |
---|
53 | ada*) |
---|
54 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for ada Intel X-64." |
---|
55 | CENTER=IDRIS |
---|
56 | SYSTEM=ada |
---|
57 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_ada.ksh;; |
---|
58 | curie*) |
---|
59 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for curie Intel X-64." |
---|
60 | CENTER=TGCC |
---|
61 | SYSTEM=curie |
---|
62 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_curie.ksh;; |
---|
63 | irene*) |
---|
64 | if [ "${SLURM_JOB_PARTITION}" = "rome" ] || [ "$( hostname -s)" = "irene172" ] || [ "$( hostname -s)" = "irene173" ] || [ "$( hostname -s)" = "irene194" ] || [ "$( hostname -s)" = "irene195" ] ; then |
---|
65 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for irene_amd Intel X-64 at TGCC" |
---|
66 | CENTER=TGCC |
---|
67 | SYSTEM=irene-amd |
---|
68 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh |
---|
69 | else |
---|
70 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for irene Intel X-64 at TGCC" |
---|
71 | CENTER=TGCC |
---|
72 | SYSTEM=irene |
---|
73 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh |
---|
74 | fi;; |
---|
75 | airain*) |
---|
76 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for airain Intel X-64." |
---|
77 | CENTER=TGCC |
---|
78 | SYSTEM=curie |
---|
79 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_curie.ksh;; |
---|
80 | asterix*|obelix*) |
---|
81 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for obelix or asterix." |
---|
82 | CENTER=LSCE |
---|
83 | SYSTEM=lxiv8 |
---|
84 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_obelix.ksh;; |
---|
85 | ciclad*) |
---|
86 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for ciclad for running at ciclad." |
---|
87 | CENTER=IPSL-ciclad |
---|
88 | SYSTEM=ifort_CICLAD |
---|
89 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_ciclad.ksh;; |
---|
90 | camelot*|loholt1*|loholt2*|merlin*) |
---|
91 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for ciclad for running at climserv." |
---|
92 | CENTER=IPSL-climserv |
---|
93 | SYSTEM=ifort_CICLAD |
---|
94 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_ciclad.ksh;; |
---|
95 | iitm*) |
---|
96 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for iitm." |
---|
97 | CENTER=IITM |
---|
98 | SYSTEM=iitm |
---|
99 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_iitm.ksh;; |
---|
100 | *) |
---|
101 | if [ "${SLURM_CLUSTER_NAME}" = "jean-zay" ] || [ "$( hostname -s | cut -c "1-8" )" = "jean-zay" ] ; then |
---|
102 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for Jean-Zay Intel X-64." |
---|
103 | CENTER=IDRIS |
---|
104 | SYSTEM=jeanzay |
---|
105 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh |
---|
106 | else |
---|
107 | [ ! X${TaskType} = Xchecking ] && echo "Source machine dependent settings for a default machine." |
---|
108 | CENTER=DEFAULT |
---|
109 | SYSTEM=default |
---|
110 | . ${libIGCM}/libIGCM_sys/libIGCM_sys_default.ksh |
---|
111 | fi;; |
---|
112 | esac |
---|
113 | # Set default umask (umask is 0027 on some machines : CCRT machine at least) |
---|
114 | umask 0022 |
---|
115 | |
---|
116 | #D--------------------------------------------------------------------== |
---|
117 | #D- |
---|
118 | #D- Define IGCM_sys functions that are common on every systems |
---|
119 | #D- |
---|
120 | #D--------------------------------------------------------------------== |
---|
121 | |
---|
122 | #D-#================================================== |
---|
123 | #D-function IGCM_sys_RshMaster |
---|
124 | #D-* Purpose: Connection to frontend machine. |
---|
125 | #D-* Examples: |
---|
126 | #D- |
---|
127 | function IGCM_sys_RshMaster { |
---|
128 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
129 | OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF |
---|
130 | export libIGCM=${libIGCM} |
---|
131 | export DEBUG_debug=${DEBUG_debug} |
---|
132 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
133 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
134 | ${@} |
---|
135 | EOF |
---|
136 | if [ $? -gt 0 ] ; then |
---|
137 | echo "IGCM_sys_RshMaster : erreur." |
---|
138 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
139 | fi |
---|
140 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
141 | } |
---|
142 | |
---|
143 | #D-#================================================== |
---|
144 | #D-function IGCM_sys_RshPost |
---|
145 | #D-* Purpose: Post-process rsh command |
---|
146 | #D-* Examples: |
---|
147 | #D- |
---|
148 | function IGCM_sys_RshPost { |
---|
149 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
150 | if ( $DEBUG_sys ) ; then |
---|
151 | echo "IGCM_sys_RshPost :" $@ |
---|
152 | fi |
---|
153 | # keep standard input (stdin) for the loop onto temporary file |
---|
154 | cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
155 | |
---|
156 | OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
157 | if [ $? -gt 0 ] ; then |
---|
158 | echo "IGCM_sys_RshPost : erreur." |
---|
159 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
160 | fi |
---|
161 | # delete temporary file |
---|
162 | \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
163 | |
---|
164 | # ============ FRONTEND END ============ # |
---|
165 | |
---|
166 | # ============ CESIUM START ============ # |
---|
167 | # typeset NB_ESSAI DELAI status i |
---|
168 | # if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then |
---|
169 | # #little hack so that rebuild submission is done on titane not an cesium |
---|
170 | # |
---|
171 | # libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) |
---|
172 | # POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) |
---|
173 | # sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt |
---|
174 | # sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ |
---|
175 | # sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt |
---|
176 | # sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ |
---|
177 | # \mv tmp.txt tmp_IGCM_sys_RshPost_$$ |
---|
178 | # |
---|
179 | # echo cat tmp_IGCM_sys_RshPost_$$ AFTER |
---|
180 | # cat tmp_IGCM_sys_RshPost_$$ |
---|
181 | # |
---|
182 | # /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
183 | # if [ $? -gt 0 ] ; then |
---|
184 | # echo "IGCM_sys_RshPost : erreur." |
---|
185 | # IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
186 | # fi |
---|
187 | # # delete temporary file |
---|
188 | # \rm tmp_IGCM_sys_RshPost_$$ |
---|
189 | # |
---|
190 | # else |
---|
191 | # # number of tentative |
---|
192 | # NB_ESSAI=10 |
---|
193 | # # time delay between tentative |
---|
194 | # DELAI=10 |
---|
195 | # i=0 |
---|
196 | # while [ $i -ne $NB_ESSAI ] ; do |
---|
197 | # ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ |
---|
198 | # status=$? |
---|
199 | # if [ ${status} -ne 0 ]; |
---|
200 | # then |
---|
201 | # sleep $DELAI |
---|
202 | # else |
---|
203 | # break |
---|
204 | # fi |
---|
205 | # let i=$i+1 |
---|
206 | # done |
---|
207 | # # delete temporary file |
---|
208 | # \rm tmp_IGCM_sys_RshPost_$$ |
---|
209 | # |
---|
210 | # if [ ${status} -gt 0 ] ; then |
---|
211 | # echo "IGCM_sys_RshPost : erreur." |
---|
212 | # IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
213 | # fi |
---|
214 | # fi |
---|
215 | |
---|
216 | # ============ CESIUM END ============ # |
---|
217 | |
---|
218 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
219 | } |
---|
220 | |
---|
221 | #D-#================================================== |
---|
222 | #D-function IGCM_sys_SendMail |
---|
223 | #D-* Purpose: Send mail when simulation is over |
---|
224 | #D-* Examples: |
---|
225 | #D- |
---|
226 | function IGCM_sys_SendMail { |
---|
227 | IGCM_debug_PushStack "IGCM_sys_SendMail" $@ |
---|
228 | if ( $DEBUG_sys ) ; then |
---|
229 | echo "IGCM_sys_SendMail :" $@ |
---|
230 | fi |
---|
231 | |
---|
232 | if [ X${1} = XAccounting ] ; then |
---|
233 | status=Accounting |
---|
234 | mailText=jobAccounting.mail |
---|
235 | elif ( ${ExitFlag} ) ; then |
---|
236 | status=failed |
---|
237 | mailText=jobEnd.mail |
---|
238 | else |
---|
239 | status=completed |
---|
240 | mailText=jobEnd.mail |
---|
241 | fi |
---|
242 | |
---|
243 | # Update selected mail template |
---|
244 | while read -r line; do |
---|
245 | eval echo $line >> mail.txt ; |
---|
246 | done < ${libIGCM}/libIGCM_sys/${mailText} |
---|
247 | |
---|
248 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
249 | mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt |
---|
250 | elif [ -f ~/.forward ] ; then |
---|
251 | mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt |
---|
252 | else |
---|
253 | mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt |
---|
254 | fi |
---|
255 | |
---|
256 | sleep 10 |
---|
257 | rm -f mail.txt |
---|
258 | |
---|
259 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
260 | } |
---|
261 | |
---|
262 | #D-#================================================== |
---|
263 | #D-function IGCM_sys_Mkdir |
---|
264 | #D-* Purpose: Master locale mkdir command |
---|
265 | #D-* Examples: |
---|
266 | #D- |
---|
267 | function IGCM_sys_Mkdir { |
---|
268 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
269 | if ( $DEBUG_sys ) ; then |
---|
270 | echo "IGCM_sys_Mkdir :" $@ |
---|
271 | fi |
---|
272 | if [ ! -d ${1} ]; then |
---|
273 | \mkdir -p $1 |
---|
274 | if [ $? -gt 0 ] ; then |
---|
275 | echo "IGCM_sys_Mkdir : erreur." |
---|
276 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
277 | fi |
---|
278 | fi |
---|
279 | # vérification : |
---|
280 | if [ ! -d ${1} ] ; then |
---|
281 | echo "IGCM_sys_Mkdir : erreur." |
---|
282 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
283 | fi |
---|
284 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
285 | } |
---|
286 | |
---|
287 | #D-#================================================== |
---|
288 | #D-function IGCM_sys_MkdirWork |
---|
289 | #D-* Purpose: Mkdir on Work |
---|
290 | #D-* Examples: |
---|
291 | #D- |
---|
292 | function IGCM_sys_MkdirWork { |
---|
293 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
294 | if ( $DEBUG_sys ) ; then |
---|
295 | echo "IGCM_sys_MkdirWork :" $@ |
---|
296 | fi |
---|
297 | #- creation de repertoire sur le serveur fichier |
---|
298 | if [ ! -d ${1} ]; then |
---|
299 | \mkdir -p $1 |
---|
300 | if [ $? -gt 0 ] ; then |
---|
301 | echo "IGCM_sys_MkdirWork : erreur." |
---|
302 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
303 | fi |
---|
304 | fi |
---|
305 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
306 | } |
---|
307 | |
---|
308 | #D-#================================================== |
---|
309 | #D-function IGCM_sys_Cd |
---|
310 | #D-* Purpose: master cd command |
---|
311 | #D-* Examples: |
---|
312 | #D- |
---|
313 | function IGCM_sys_Cd { |
---|
314 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
315 | if ( $DEBUG_sys ) ; then |
---|
316 | echo "IGCM_sys_Cd :" $@ |
---|
317 | fi |
---|
318 | \cd $1 |
---|
319 | if [ $? -gt 0 ] ; then |
---|
320 | echo "IGCM_sys_Cd : erreur." |
---|
321 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
322 | fi |
---|
323 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
324 | } |
---|
325 | |
---|
326 | #D-#================================================== |
---|
327 | #D-function IGCM_sys_Chmod |
---|
328 | #D-* Purpose: Chmod |
---|
329 | #D-* Examples: |
---|
330 | #D- |
---|
331 | function IGCM_sys_Chmod { |
---|
332 | IGCM_debug_PushStack "IGCM_sys_Chmod" $@ |
---|
333 | if ( $DEBUG_sys ) ; then |
---|
334 | echo "IGCM_sys_Chmod :" $@ |
---|
335 | fi |
---|
336 | \chmod $@ |
---|
337 | if [ $? -gt 0 ] ; then |
---|
338 | echo "IGCM_sys_Chmod : erreur." |
---|
339 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
340 | fi |
---|
341 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
342 | } |
---|
343 | |
---|
344 | #D-#================================================== |
---|
345 | #D-function IGCM_sys_FileSize |
---|
346 | #D-* Purpose: Filesize |
---|
347 | #D-* Examples: |
---|
348 | #D- |
---|
349 | function IGCM_sys_FileSize { |
---|
350 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
351 | |
---|
352 | typeset sizeF |
---|
353 | set +A sizeF -- $( ls -la ${1} ) |
---|
354 | if [ $? -gt 0 ] ; then |
---|
355 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
356 | fi |
---|
357 | eval ${2}=${sizeF[4]} |
---|
358 | |
---|
359 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
360 | } |
---|
361 | |
---|
362 | #D-#================================================== |
---|
363 | #D-function IGCM_sys_TestDir |
---|
364 | #D-* Purpose: Test Directory that must exists |
---|
365 | #D-* Examples: |
---|
366 | #D- |
---|
367 | function IGCM_sys_TestDir { |
---|
368 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
369 | if ( $DEBUG_sys ) ; then |
---|
370 | echo "IGCM_sys_TestDir :" $@ |
---|
371 | fi |
---|
372 | typeset ExistFlag |
---|
373 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
374 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
375 | |
---|
376 | return ${ExistFlag} |
---|
377 | } |
---|
378 | |
---|
379 | #D-#================================================== |
---|
380 | #D-function IGCM_sys_TestFileBuffer |
---|
381 | #D-* Purpose: Test file that must NOT EXISTS on Buffer |
---|
382 | #D-* Examples: |
---|
383 | #D- |
---|
384 | function IGCM_sys_TestFileBuffer { |
---|
385 | IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ |
---|
386 | typeset ExistFlag |
---|
387 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
388 | IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" |
---|
389 | |
---|
390 | return ${ExistFlag} |
---|
391 | } |
---|
392 | |
---|
393 | #D-#================================================== |
---|
394 | #D-function IGCM_sys_CountFileBuffer |
---|
395 | #D-* Purpose: Count files on Scratch filesystem |
---|
396 | #D-* Examples: |
---|
397 | #D- |
---|
398 | function IGCM_sys_CountFileBuffer { |
---|
399 | IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ |
---|
400 | ls ${@} 2>/dev/null | wc -l |
---|
401 | if [ $? -gt 0 ] ; then |
---|
402 | echo "IGCM_sys_CountFileBuffer : erreur." |
---|
403 | fi |
---|
404 | IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" |
---|
405 | } |
---|
406 | |
---|
407 | #D-#================================================== |
---|
408 | #D-function IGCM_sys_Tar |
---|
409 | #D-* Purpose: master tar command |
---|
410 | #D-* Examples: |
---|
411 | #D- |
---|
412 | function IGCM_sys_Tar { |
---|
413 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
414 | if ( $DEBUG_sys ) ; then |
---|
415 | echo "IGCM_sys_Tar :" $@ |
---|
416 | fi |
---|
417 | \tar cf $@ |
---|
418 | if [ $? -gt 0 ] ; then |
---|
419 | echo "IGCM_sys_Tar : erreur." |
---|
420 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
421 | fi |
---|
422 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
423 | } |
---|
424 | |
---|
425 | #D-#================================================== |
---|
426 | #D-function IGCM_sys_UnTar |
---|
427 | #D-* Purpose: master un-tar command |
---|
428 | #D-* Examples: |
---|
429 | #D- |
---|
430 | function IGCM_sys_UnTar { |
---|
431 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
432 | if ( $DEBUG_sys ) ; then |
---|
433 | echo "IGCM_sys_UnTar :" $@ |
---|
434 | fi |
---|
435 | \tar xvf $1 |
---|
436 | if [ $? -gt 0 ] ; then |
---|
437 | echo "IGCM_sys_UnTar : erreur." |
---|
438 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
439 | fi |
---|
440 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
441 | } |
---|
442 | |
---|
443 | #D-************************* |
---|
444 | #D- File transfer functions |
---|
445 | #D-************************* |
---|
446 | #D- |
---|
447 | |
---|
448 | #D-#================================================== |
---|
449 | #D-function IGCM_sys_Rsync_out |
---|
450 | #D-* Purpose: treat return val of rsync |
---|
451 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
452 | #D- Error values and explanations can depend on your system version. |
---|
453 | function IGCM_sys_Rsync_out { |
---|
454 | IGCM_debug_PushStack "IGCM_sys_Rsync_out" $@ |
---|
455 | if ( $DEBUG_sys ) ; then |
---|
456 | echo "IGCM_sys_UnTar :" $@ |
---|
457 | fi |
---|
458 | |
---|
459 | typeset status |
---|
460 | status=$1 |
---|
461 | |
---|
462 | if [ ! $status ] ; then |
---|
463 | IGCM_debug_Print 1 "IGCM_sys_Rsync_out need an argument" |
---|
464 | IGCM_debug_PopStack "IGCM_sys_Rsync_out" |
---|
465 | return |
---|
466 | fi |
---|
467 | |
---|
468 | case $status in |
---|
469 | 0) ;; |
---|
470 | 1) IGCM_debug_Print 1 "rsync error RERR_SYNTAX : Syntax or usage error";; |
---|
471 | 2) IGCM_debug_Print 1 "rsync error RERR_PROTOCOL : Protocol incompatibility";; |
---|
472 | 3) IGCM_debug_Print 1 "rsync error RERR_FILESELECT : Errors selecting input/output files, dirs";; |
---|
473 | 4) IGCM_debug_Print 1 "rsync error RERR_UNSUPPORTED : Requested action not supported." |
---|
474 | IGCM_debug_Print 1 "An attempt was made to manipulate 64-bit files on a platform that cannot support them" |
---|
475 | IGCM_debug_Print 1 "Or an option was specified that is supported by the client and not by the server.";; |
---|
476 | 5) IGCM_debug_Print 1 "rsync error : Error starting client-server protocol";; |
---|
477 | 10) IGCM_debug_Print 1 "rsync error RERR_SOCKETIO : Error in socket I/O";; |
---|
478 | 11) IGCM_debug_Print 1 "rsync error RERR_FILEIO: Error in file I/O";; |
---|
479 | 12) IGCM_debug_Print 1 "rsync error RERR_STREAMIO : Error in rsync protocol data stream";; |
---|
480 | 13) IGCM_debug_Print 1 "rsync error RERR_MESSAGEIO : Errors with program diagnostics";; |
---|
481 | 14) IGCM_debug_Print 1 "rsync error RERR_IPC : Error in IPC code";; |
---|
482 | 20) IGCM_debug_Print 1 "rsync error RERR_SIGNAL : Received SIGUSR1 or SIGINT";; |
---|
483 | 21) IGCM_debug_Print 1 "rsync error RERR_WAITCHILD : Some error returned by waitpid()";; |
---|
484 | 22) IGCM_debug_Print 1 "rsync error RERR_MALLOC : Error allocating core memory buffers";; |
---|
485 | 23) IGCM_debug_Print 1 "rsync error : Partial transfer due to error";; |
---|
486 | 24) IGCM_debug_Print 1 "rsync error : Partial transfer due to vanished source files";; |
---|
487 | 30) IGCM_debug_Print 1 "rsync error : Timeout in data send/receive";; |
---|
488 | *) IGCM_debug_Print 1 "rsync error : return code of rsync unknown :" $status;; |
---|
489 | esac |
---|
490 | |
---|
491 | IGCM_debug_PopStack "IGCM_sys_Rsync_out" |
---|
492 | } |
---|
493 | |
---|
494 | #D-#================================================== |
---|
495 | #D-function IGCM_sys_Miror_libIGCM |
---|
496 | #D-* Purpose: Mirror libIGCM PATH and lib to frontend |
---|
497 | #D-* Examples: |
---|
498 | #D- |
---|
499 | function IGCM_sys_Mirror_libIGCM { |
---|
500 | IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" |
---|
501 | if ( $DEBUG_sys ) ; then |
---|
502 | echo "IGCM_sys_Mirror_libIGCM" |
---|
503 | fi |
---|
504 | |
---|
505 | typeset status |
---|
506 | |
---|
507 | mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} |
---|
508 | |
---|
509 | echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
510 | ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
511 | status=$? |
---|
512 | |
---|
513 | if [ ${status} -gt 0 ] ; then |
---|
514 | echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." |
---|
515 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
516 | fi |
---|
517 | IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" |
---|
518 | } |
---|
519 | |
---|
520 | #D-#================================================== |
---|
521 | #D-function IGCM_sys_Cp |
---|
522 | #D-* Purpose: generic cp |
---|
523 | #D-* Examples: |
---|
524 | #D- |
---|
525 | function IGCM_sys_Cp { |
---|
526 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
527 | if ( $DEBUG_sys ) ; then |
---|
528 | echo "IGCM_sys_Cp :" $@ |
---|
529 | fi |
---|
530 | |
---|
531 | typeset status |
---|
532 | |
---|
533 | echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
534 | \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
535 | status=$? |
---|
536 | |
---|
537 | if [ ${status} -gt 0 ] ; then |
---|
538 | echo "IGCM_sys_Cp : error code ${status}" |
---|
539 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
540 | IGCM_debug_Exit "IGCM_sys_Cp" |
---|
541 | else |
---|
542 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
543 | fi |
---|
544 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
545 | } |
---|
546 | |
---|
547 | #D-#================================================== |
---|
548 | #D-function IGCM_sys_Rm |
---|
549 | #D-* Purpose: generic rm |
---|
550 | #D-* Examples: |
---|
551 | #D- |
---|
552 | function IGCM_sys_Rm { |
---|
553 | IGCM_debug_PushStack "IGCM_sys_Rm" $@ |
---|
554 | if ( $DEBUG_sys ) ; then |
---|
555 | echo "IGCM_sys_Rm :" $@ |
---|
556 | fi |
---|
557 | |
---|
558 | typeset status |
---|
559 | |
---|
560 | echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
561 | \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
562 | status=$? |
---|
563 | |
---|
564 | if [ ${status} -gt 0 ] ; then |
---|
565 | echo "IGCM_sys_Rm : error code ${status}" |
---|
566 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
567 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
568 | else |
---|
569 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
570 | fi |
---|
571 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
572 | } |
---|
573 | |
---|
574 | #D-#================================================== |
---|
575 | #D-function IGCM_sys_Mv |
---|
576 | #D-* Purpose: generic move |
---|
577 | #D-* Examples: |
---|
578 | #D- |
---|
579 | function IGCM_sys_Mv { |
---|
580 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
581 | if ( $DEBUG_sys ) ; then |
---|
582 | echo "IGCM_sys_Mv :" $@ |
---|
583 | fi |
---|
584 | |
---|
585 | if [ $DRYRUN = 0 ]; then |
---|
586 | |
---|
587 | typeset status |
---|
588 | |
---|
589 | echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
590 | \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
591 | status=$? |
---|
592 | |
---|
593 | if [ ${status} -gt 0 ] ; then |
---|
594 | echo "IGCM_sys_Mv : error code ${status}" |
---|
595 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
596 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
597 | else |
---|
598 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
599 | fi |
---|
600 | fi |
---|
601 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
602 | } |
---|
603 | |
---|
604 | #D-#================================================== |
---|
605 | #D-function IGCM_sys_Get_Master |
---|
606 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
607 | #D-* Examples: |
---|
608 | #D- |
---|
609 | function IGCM_sys_Get_Master { |
---|
610 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
611 | if ( $DEBUG_sys ) ; then |
---|
612 | echo "IGCM_sys_Get_Master :" $@ |
---|
613 | fi |
---|
614 | if [ $DRYRUN = 0 ]; then |
---|
615 | if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then |
---|
616 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." |
---|
617 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
618 | return |
---|
619 | fi |
---|
620 | |
---|
621 | typeset NB_ESSAI DELAI status i |
---|
622 | # number of tentative |
---|
623 | NB_ESSAI=3 |
---|
624 | # time delay between tentative |
---|
625 | DELAI=2 |
---|
626 | |
---|
627 | i=0 |
---|
628 | while [ $i -lt $NB_ESSAI ] ; do |
---|
629 | \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
630 | status=$? |
---|
631 | if [ ${status} -gt 0 ]; then |
---|
632 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
633 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." |
---|
634 | sleep $DELAI |
---|
635 | else |
---|
636 | break |
---|
637 | fi |
---|
638 | (( i = i + 1 )) |
---|
639 | done |
---|
640 | |
---|
641 | if [ ${status} -gt 0 ] ; then |
---|
642 | echo "IGCM_sys_Get_Master : error." |
---|
643 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
644 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
645 | else |
---|
646 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
647 | fi |
---|
648 | fi |
---|
649 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
650 | } |
---|
651 | |
---|
652 | #==================================================== |
---|
653 | #- Call IGCM_sys_Mirror_libIGCM now ! |
---|
654 | if ( $MirrorlibIGCM ) ; then |
---|
655 | IGCM_sys_Mirror_libIGCM |
---|
656 | fi |
---|
657 | |
---|
658 | #D-#================================================== |
---|
659 | #D-function IGCM_sys_PutBuffer_Rest |
---|
660 | #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. |
---|
661 | #D- File and target directory must exist. |
---|
662 | #D-* Examples: |
---|
663 | #D- |
---|
664 | function IGCM_sys_PutBuffer_Rest { |
---|
665 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ |
---|
666 | if ( $DEBUG_sys ) ; then |
---|
667 | echo "IGCM_sys_PutBuffer_Rest :" $@ |
---|
668 | fi |
---|
669 | if [ $DRYRUN = 0 ]; then |
---|
670 | if [ ! -f ${1} ] ; then |
---|
671 | echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." |
---|
672 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
673 | fi |
---|
674 | |
---|
675 | typeset status |
---|
676 | # |
---|
677 | # USUAL WAY |
---|
678 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
679 | status=$? |
---|
680 | |
---|
681 | if [ ${status} -gt 0 ] ; then |
---|
682 | echo "IGCM_sys_PutBuffer_Rest : error code ${status}" |
---|
683 | [ -f ${2} ] && ls -l ${2} |
---|
684 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
685 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
686 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
687 | else |
---|
688 | |
---|
689 | if [ X${JobType} = XRUN ] ; then |
---|
690 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
691 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
692 | fi |
---|
693 | |
---|
694 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
695 | fi |
---|
696 | fi |
---|
697 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" |
---|
698 | } |
---|
699 | |
---|
700 | #D-#================================================== |
---|
701 | #D-function IGCM_sys_PrepareTaredRestart |
---|
702 | #D-* Purpose: Prepare tared restart to be access by computing job. |
---|
703 | #D-* Examples: |
---|
704 | #D- |
---|
705 | function IGCM_sys_PrepareTaredRestart { |
---|
706 | IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ |
---|
707 | if [ $DRYRUN = 0 ]; then |
---|
708 | [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 . |
---|
709 | fi |
---|
710 | IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" |
---|
711 | } |
---|
712 | |
---|
713 | #D-#================================================== |
---|
714 | #D-function IGCM_sys_PutBuffer_Out |
---|
715 | #D-* Purpose: Copy a file on the buffer filesystem after having chmod it in readonly |
---|
716 | #D-* Examples: |
---|
717 | #D- |
---|
718 | function IGCM_sys_PutBuffer_Out { |
---|
719 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ |
---|
720 | if ( $DEBUG_sys ) ; then |
---|
721 | echo "IGCM_sys_PutBuffer_Out :" $@ |
---|
722 | fi |
---|
723 | |
---|
724 | typeset NB_ESSAI DELAI status i exist skip |
---|
725 | typeset fileDeviceNumberInHex directoryDeviceNumberInHex |
---|
726 | |
---|
727 | # number of tentative |
---|
728 | NB_ESSAI=3 |
---|
729 | # time delay between tentative |
---|
730 | DELAI=2 |
---|
731 | |
---|
732 | if [ $DRYRUN = 0 ]; then |
---|
733 | if [ ! -f ${1} ] ; then |
---|
734 | echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." |
---|
735 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
736 | return 1 |
---|
737 | fi |
---|
738 | # |
---|
739 | IGCM_sys_Mkdir $( dirname $2 ) |
---|
740 | # |
---|
741 | |
---|
742 | exist=false |
---|
743 | skip=false |
---|
744 | if [ -f $2 ] ; then |
---|
745 | IGCM_debug_Print 1 "$2 already exist" |
---|
746 | exist=true |
---|
747 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
748 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
749 | status=0 |
---|
750 | skip=true |
---|
751 | else |
---|
752 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
753 | skip=false |
---|
754 | fi |
---|
755 | fi |
---|
756 | # |
---|
757 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
758 | IGCM_sys_Chmod u+w $2 |
---|
759 | fi |
---|
760 | |
---|
761 | if [ X${skip} = Xfalse ] ; then |
---|
762 | i=0 |
---|
763 | while [ $i -lt $NB_ESSAI ] ; do |
---|
764 | # Identify file system |
---|
765 | fileDeviceNumberInHex=$( stat -c %d $1 ) |
---|
766 | status=$? |
---|
767 | if [ ${status} -gt 0 ] ; then |
---|
768 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
769 | fi |
---|
770 | # Identify file system |
---|
771 | directoryDeviceNumberInHex=$( stat -c %d $( dirname $2 ) ) |
---|
772 | status=$? |
---|
773 | if [ ${status} -gt 0 ] ; then |
---|
774 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
775 | fi |
---|
776 | |
---|
777 | if [ ${fileDeviceNumberInHex} -ne ${directoryDeviceNumberInHex} ] ; then |
---|
778 | # They are not on the same device. USUAL WAY |
---|
779 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
780 | status=$? |
---|
781 | else |
---|
782 | # They are on the same device. USUAL WAY |
---|
783 | \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
784 | status=$? |
---|
785 | fi |
---|
786 | if [ ${status} -gt 0 ]; then |
---|
787 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
788 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." |
---|
789 | [ -f ${2} ] && ls -l ${2} |
---|
790 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
791 | sleep $DELAI |
---|
792 | else |
---|
793 | break |
---|
794 | fi |
---|
795 | (( i = i + 1 )) |
---|
796 | done |
---|
797 | fi |
---|
798 | |
---|
799 | if [ ${status} -gt 0 ] ; then |
---|
800 | echo "IGCM_sys_PutBuffer_Out : error." |
---|
801 | [ -f ${2} ] && ls -l ${2} |
---|
802 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
803 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
804 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
805 | else |
---|
806 | |
---|
807 | if [ X${JobType} = XRUN ] ; then |
---|
808 | if [ X${3} = X ] ; then |
---|
809 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
810 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
811 | fi |
---|
812 | fi |
---|
813 | |
---|
814 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
815 | fi |
---|
816 | fi |
---|
817 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
818 | return 0 |
---|
819 | } |
---|
820 | |
---|
821 | #D-#================================================== |
---|
822 | #D-function IGCM_sys_GetBuffer |
---|
823 | #D-* Purpose: Get a file from ${SCRATCHDIR} |
---|
824 | #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX |
---|
825 | #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ |
---|
826 | function IGCM_sys_GetBuffer { |
---|
827 | IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ |
---|
828 | |
---|
829 | typeset DEST buf_liste target file_work |
---|
830 | typeset NB_ESSAI DELAI status i |
---|
831 | |
---|
832 | if ( $DEBUG_sys ) ; then |
---|
833 | echo "IGCM_sys_GetBuffer :" $@ |
---|
834 | fi |
---|
835 | |
---|
836 | # number of tentative |
---|
837 | NB_ESSAI=3 |
---|
838 | # time delay between tentative |
---|
839 | DELAI=2 |
---|
840 | |
---|
841 | if [ $DRYRUN -le 2 ]; then |
---|
842 | if [ X${1} = X'/l' ] ; then |
---|
843 | eval set +A buf_liste \${${2}} |
---|
844 | else |
---|
845 | eval set +A buf_liste ${1} |
---|
846 | fi |
---|
847 | eval DEST=\${${#}} |
---|
848 | |
---|
849 | #USUAL WAY |
---|
850 | if [ X${1} = X'/l' ] ; then |
---|
851 | for target in ${buf_liste[*]} ; do |
---|
852 | local_file=$( basename ${target} ) |
---|
853 | i=0 |
---|
854 | while [ $i -lt $NB_ESSAI ] ; do |
---|
855 | \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
856 | status=$? |
---|
857 | if [ ${status} -gt 0 ]; then |
---|
858 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
859 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
860 | sleep $DELAI |
---|
861 | else |
---|
862 | break |
---|
863 | fi |
---|
864 | (( i = i + 1 )) |
---|
865 | done |
---|
866 | if [ ${status} -gt 0 ] ; then |
---|
867 | echo "IGCM_sys_Get : error" |
---|
868 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
869 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
870 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
871 | else |
---|
872 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
873 | fi |
---|
874 | done |
---|
875 | else |
---|
876 | i=0 |
---|
877 | while [ $i -lt $NB_ESSAI ] ; do |
---|
878 | \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
879 | status=$? |
---|
880 | if [ ${status} -gt 0 ]; then |
---|
881 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
882 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
883 | sleep $DELAI |
---|
884 | else |
---|
885 | break |
---|
886 | fi |
---|
887 | (( i = i + 1 )) |
---|
888 | done |
---|
889 | if [ ${status} -gt 0 ] ; then |
---|
890 | echo "IGCM_sys_Get : error" |
---|
891 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
892 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
893 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
894 | else |
---|
895 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
896 | fi |
---|
897 | fi |
---|
898 | fi |
---|
899 | IGCM_debug_PopStack "IGCM_sys_GetBuffer" |
---|
900 | } |
---|
901 | |
---|
902 | #D-#================================================== |
---|
903 | #D-function IGCM_sys_GetDate_FichWork |
---|
904 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
905 | #D-* Examples: |
---|
906 | #D- |
---|
907 | function IGCM_sys_GetDate_FichWork { |
---|
908 | IGCM_debug_PushStack "IGCM_sys_GetDate_FichWork" $@ |
---|
909 | if ( $DEBUG_sys ) ; then |
---|
910 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
911 | fi |
---|
912 | |
---|
913 | if [ $# -ge 3 ] ; then |
---|
914 | mode=$3 |
---|
915 | TimeStyle=$4 |
---|
916 | else |
---|
917 | mode="default" |
---|
918 | TimeStyle="%Y%m%d%H%M%S" |
---|
919 | fi |
---|
920 | |
---|
921 | typeset dateF |
---|
922 | set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) |
---|
923 | |
---|
924 | case $mode in |
---|
925 | "default") |
---|
926 | eval ${2}=${dateF[5]} |
---|
927 | ;; |
---|
928 | "SplitFields") |
---|
929 | eval ${2}="${dateF[5]}\ ${dateF[6]}" |
---|
930 | ;; |
---|
931 | esac |
---|
932 | |
---|
933 | # donne la date filesys d'un fichier sur la machine work |
---|
934 | IGCM_debug_PopStack "IGCM_sys_GetDate_FichWork" |
---|
935 | } |
---|
936 | |
---|
937 | #D-#================================================== |
---|
938 | #D-function IGCM_sys_rebuild |
---|
939 | #D-* Purpose: rebuild parallel files |
---|
940 | #D-* Examples: |
---|
941 | #D- |
---|
942 | function IGCM_sys_rebuild { |
---|
943 | IGCM_debug_PushStack "IGCM_sys_rebuild" $@ |
---|
944 | if ( $DEBUG_sys ) ; then |
---|
945 | echo "IGCM_sys_rebuild :" $@ |
---|
946 | fi |
---|
947 | |
---|
948 | typeset NB_ESSAI DELAI status i firstArg |
---|
949 | # number of tentative |
---|
950 | NB_ESSAI=3 |
---|
951 | # time delay between tentative |
---|
952 | DELAI=2 |
---|
953 | |
---|
954 | i=0 |
---|
955 | while [ $i -lt $NB_ESSAI ] ; do |
---|
956 | rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
957 | status=$? |
---|
958 | if [ ${status} -gt 0 ] ; then |
---|
959 | IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" |
---|
960 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
961 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
962 | IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
963 | firstArg=${1} |
---|
964 | \rm ${firstArg} |
---|
965 | sleep $DELAI |
---|
966 | else |
---|
967 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
968 | break |
---|
969 | fi |
---|
970 | (( i = i + 1 )) |
---|
971 | done |
---|
972 | |
---|
973 | if [ ${status} -gt 0 ] ; then |
---|
974 | echo "IGCM_sys_rebuild : rebuild error code is ${status}" |
---|
975 | IGCM_debug_Exit "rebuild" |
---|
976 | fi |
---|
977 | |
---|
978 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
979 | } |
---|
980 | |
---|
981 | #D-#================================================== |
---|
982 | #D-function IGCM_sys_rebuild_station |
---|
983 | #D-* Purpose: rebuild parallel files describing station |
---|
984 | #D-* Examples: |
---|
985 | #D- |
---|
986 | function IGCM_sys_rebuild_station { |
---|
987 | IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ |
---|
988 | typeset i list_opt file_in file_out prefix_invert list_invert |
---|
989 | if ( $DEBUG_sys ) ; then |
---|
990 | echo "IGCM_sys_rebuild_station :" $@ |
---|
991 | fi |
---|
992 | |
---|
993 | # Station re-ordering is too expansive to be run within libIGCM |
---|
994 | # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. |
---|
995 | # This re-ordering must be done "in memory" by the cmorization process |
---|
996 | |
---|
997 | # Only LMDZ text output contains the exact ordering of the station. |
---|
998 | # We isolate this in the code below: |
---|
999 | # 0 38 -157.5000000000000 70.98591549295774 |
---|
1000 | # 0 54 27.49999999999999 67.18309859154928 |
---|
1001 | # 0 56 -62.50000000000001 82.39436619718309 |
---|
1002 | # 0 79 12.49999999999999 78.59154929577466 |
---|
1003 | # 0 116 -165.0000000000000 76.05633802816901 |
---|
1004 | # 0 117 130.0000000000000 70.98591549295774 |
---|
1005 | # 0 118 110.0000000000000 87.46478873239437 |
---|
1006 | # 1 40 4.999999999999995 51.97183098591550 |
---|
1007 | |
---|
1008 | list_opt=$@ |
---|
1009 | |
---|
1010 | # Invert Axis : t,x -> x,t |
---|
1011 | # t,pres,x -> x,t,pres |
---|
1012 | # So that we can concatenate along x |
---|
1013 | i=0 |
---|
1014 | for file_in in ${list_opt} ; do |
---|
1015 | (( i = i + 1)) |
---|
1016 | [ ${i} = 1 ] && file_out=${file_in} && continue |
---|
1017 | # detect time counter and do the job only if present |
---|
1018 | var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') |
---|
1019 | if [ X${var_unlim} = Xtime_counter ] ; then |
---|
1020 | prefix_invert=$( basename ${file_in} .nc ) |
---|
1021 | IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc |
---|
1022 | list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc |
---|
1023 | fi |
---|
1024 | done |
---|
1025 | |
---|
1026 | # Concatenate |
---|
1027 | IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc |
---|
1028 | |
---|
1029 | # Re-ivert file |
---|
1030 | IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} |
---|
1031 | |
---|
1032 | IGCM_debug_PopStack "IGCM_sys_rebuild_station" |
---|
1033 | } |
---|
1034 | |
---|
1035 | ############################################################## |
---|
1036 | # NCO OPERATOR |
---|
1037 | |
---|
1038 | #D-#================================================== |
---|
1039 | #D-function IGCM_sys_ncap2 |
---|
1040 | #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry |
---|
1041 | #D-* Examples: |
---|
1042 | #D- |
---|
1043 | function IGCM_sys_ncap2 { |
---|
1044 | IGCM_debug_PushStack "IGCM_sys_ncap2" $@ |
---|
1045 | if ( $DEBUG_sys ) ; then |
---|
1046 | echo "IGCM_sys_ncap2 :" $@ |
---|
1047 | fi |
---|
1048 | |
---|
1049 | typeset NB_ESSAI DELAI status i |
---|
1050 | # number of tentative |
---|
1051 | NB_ESSAI=3 |
---|
1052 | # time delay between tentative |
---|
1053 | DELAI=2 |
---|
1054 | |
---|
1055 | i=0 |
---|
1056 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1057 | ncap2 -C --buffer_size 838860800 "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1058 | status=$? |
---|
1059 | if [ ${status} -gt 0 ] ; then |
---|
1060 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" |
---|
1061 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1062 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1063 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1064 | sleep $DELAI |
---|
1065 | else |
---|
1066 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1067 | break |
---|
1068 | fi |
---|
1069 | (( i = i + 1 )) |
---|
1070 | done |
---|
1071 | |
---|
1072 | if [ ${status} -gt 0 ] ; then |
---|
1073 | echo "IGCM_sys_ncap2 : ncap2 error" |
---|
1074 | IGCM_debug_Exit "ncap2" |
---|
1075 | fi |
---|
1076 | |
---|
1077 | IGCM_debug_PopStack "IGCM_sys_ncap2" |
---|
1078 | } |
---|
1079 | |
---|
1080 | #D-#================================================== |
---|
1081 | #D-function IGCM_sys_ncatted |
---|
1082 | #D-* Purpose: encapsulate ncatted call so as to manage error code and retry |
---|
1083 | #D-* Examples: |
---|
1084 | #D- |
---|
1085 | function IGCM_sys_ncatted { |
---|
1086 | IGCM_debug_PushStack "IGCM_sys_ncatted" $@ |
---|
1087 | if ( $DEBUG_sys ) ; then |
---|
1088 | echo "IGCM_sys_ncatted :" $@ |
---|
1089 | fi |
---|
1090 | |
---|
1091 | typeset NB_ESSAI DELAI status i |
---|
1092 | # number of tentative |
---|
1093 | NB_ESSAI=3 |
---|
1094 | # time delay between tentative |
---|
1095 | DELAI=2 |
---|
1096 | |
---|
1097 | i=0 |
---|
1098 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1099 | ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1100 | status=$? |
---|
1101 | if [ ${status} -gt 0 ] ; then |
---|
1102 | IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" |
---|
1103 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1104 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1105 | IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1106 | sleep $DELAI |
---|
1107 | else |
---|
1108 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1109 | break |
---|
1110 | fi |
---|
1111 | (( i = i + 1 )) |
---|
1112 | done |
---|
1113 | |
---|
1114 | if [ ${status} -gt 0 ] ; then |
---|
1115 | echo "IGCM_sys_ncatted : ncatted error" |
---|
1116 | IGCM_debug_Exit "ncatted" |
---|
1117 | fi |
---|
1118 | |
---|
1119 | IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
1120 | } |
---|
1121 | |
---|
1122 | #D-#================================================== |
---|
1123 | #D-function IGCM_sys_ncbo |
---|
1124 | #D-* Purpose: encapsulate ncbo call so as to manage error code and retry |
---|
1125 | #D-* Examples: |
---|
1126 | #D- |
---|
1127 | function IGCM_sys_ncbo { |
---|
1128 | IGCM_debug_PushStack "IGCM_sys_ncbo" $@ |
---|
1129 | if ( $DEBUG_sys ) ; then |
---|
1130 | echo "IGCM_sys_ncbo :" $@ |
---|
1131 | fi |
---|
1132 | |
---|
1133 | typeset NB_ESSAI DELAI status i |
---|
1134 | # number of tentative |
---|
1135 | NB_ESSAI=3 |
---|
1136 | # time delay between tentative |
---|
1137 | DELAI=2 |
---|
1138 | |
---|
1139 | i=0 |
---|
1140 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1141 | ncbo -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1142 | status=$? |
---|
1143 | if [ ${status} -gt 0 ] ; then |
---|
1144 | IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" |
---|
1145 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1146 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1147 | IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1148 | sleep $DELAI |
---|
1149 | else |
---|
1150 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1151 | break |
---|
1152 | fi |
---|
1153 | (( i = i + 1 )) |
---|
1154 | done |
---|
1155 | |
---|
1156 | if [ ${status} -gt 0 ] ; then |
---|
1157 | echo "IGCM_sys_ncbo : ncbo error" |
---|
1158 | IGCM_debug_Exit "ncbo" |
---|
1159 | fi |
---|
1160 | |
---|
1161 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
1162 | } |
---|
1163 | |
---|
1164 | #D-#================================================== |
---|
1165 | #D-function IGCM_sys_ncdif |
---|
1166 | #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry |
---|
1167 | #D-* Examples: |
---|
1168 | #D- |
---|
1169 | function IGCM_sys_ncdiff { |
---|
1170 | IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ |
---|
1171 | if ( $DEBUG_sys ) ; then |
---|
1172 | echo "IGCM_sys_ncdiff :" $@ |
---|
1173 | fi |
---|
1174 | |
---|
1175 | typeset NB_ESSAI DELAI status i |
---|
1176 | # number of tentative |
---|
1177 | NB_ESSAI=3 |
---|
1178 | # time delay between tentative |
---|
1179 | DELAI=2 |
---|
1180 | |
---|
1181 | i=0 |
---|
1182 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1183 | ncdiff -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1184 | status=$? |
---|
1185 | if [ ${status} -gt 0 ] ; then |
---|
1186 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" |
---|
1187 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1188 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1189 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1190 | sleep $DELAI |
---|
1191 | else |
---|
1192 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1193 | break |
---|
1194 | fi |
---|
1195 | (( i = i + 1 )) |
---|
1196 | done |
---|
1197 | |
---|
1198 | if [ ${status} -gt 0 ] ; then |
---|
1199 | echo "IGCM_sys_ncdiff : ncdiff error" |
---|
1200 | IGCM_debug_Exit "ncdiff" |
---|
1201 | fi |
---|
1202 | |
---|
1203 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
1204 | } |
---|
1205 | |
---|
1206 | #D-#================================================== |
---|
1207 | #D-function IGCM_sys_ncea |
---|
1208 | #D-* Purpose: encapsulate ncea call so as to manage error code and retry |
---|
1209 | #D-* Examples: |
---|
1210 | #D- |
---|
1211 | function IGCM_sys_ncea { |
---|
1212 | IGCM_debug_PushStack "IGCM_sys_ncea" $@ |
---|
1213 | if ( $DEBUG_sys ) ; then |
---|
1214 | echo "IGCM_sys_ncea :" $@ |
---|
1215 | fi |
---|
1216 | |
---|
1217 | typeset NB_ESSAI DELAI status i |
---|
1218 | # number of tentative |
---|
1219 | NB_ESSAI=3 |
---|
1220 | # time delay between tentative |
---|
1221 | DELAI=2 |
---|
1222 | |
---|
1223 | i=0 |
---|
1224 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1225 | ncea -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1226 | status=$? |
---|
1227 | if [ ${status} -gt 0 ] ; then |
---|
1228 | IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" |
---|
1229 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1230 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1231 | IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1232 | sleep $DELAI |
---|
1233 | else |
---|
1234 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1235 | break |
---|
1236 | fi |
---|
1237 | (( i = i + 1 )) |
---|
1238 | done |
---|
1239 | |
---|
1240 | if [ ${status} -gt 0 ] ; then |
---|
1241 | echo "IGCM_sys_ncea : ncea error" |
---|
1242 | IGCM_debug_Exit "ncea" |
---|
1243 | fi |
---|
1244 | |
---|
1245 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
1246 | } |
---|
1247 | |
---|
1248 | #D-#================================================== |
---|
1249 | #D-function IGCM_sys_ncecat |
---|
1250 | #D-* Purpose: encapsulate ncecat call so as to manage error code and retry |
---|
1251 | #D-* Examples: |
---|
1252 | #D- |
---|
1253 | function IGCM_sys_ncecat { |
---|
1254 | IGCM_debug_PushStack "IGCM_sys_ncecat" $@ |
---|
1255 | if ( $DEBUG_sys ) ; then |
---|
1256 | echo "IGCM_sys_ncecat :" $@ |
---|
1257 | fi |
---|
1258 | |
---|
1259 | typeset NB_ESSAI DELAI status i |
---|
1260 | # number of tentative |
---|
1261 | NB_ESSAI=3 |
---|
1262 | # time delay between tentative |
---|
1263 | DELAI=2 |
---|
1264 | |
---|
1265 | i=0 |
---|
1266 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1267 | ncecat -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1268 | status=$? |
---|
1269 | if [ ${status} -gt 0 ] ; then |
---|
1270 | IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" |
---|
1271 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1272 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1273 | IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1274 | sleep $DELAI |
---|
1275 | else |
---|
1276 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1277 | break |
---|
1278 | fi |
---|
1279 | (( i = i + 1 )) |
---|
1280 | done |
---|
1281 | |
---|
1282 | if [ ${status} -gt 0 ] ; then |
---|
1283 | echo "IGCM_sys_ncecat : ncecat error" |
---|
1284 | IGCM_debug_Exit "ncecat" |
---|
1285 | fi |
---|
1286 | |
---|
1287 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
1288 | } |
---|
1289 | |
---|
1290 | #D-#================================================== |
---|
1291 | #D-function IGCM_sys_ncflint |
---|
1292 | #D-* Purpose: encapsulate ncflint call so as to manage error code and retry |
---|
1293 | #D-* Examples: |
---|
1294 | #D- |
---|
1295 | function IGCM_sys_ncflint { |
---|
1296 | IGCM_debug_PushStack "IGCM_sys_ncflint" $@ |
---|
1297 | if ( $DEBUG_sys ) ; then |
---|
1298 | echo "IGCM_sys_ncflint :" $@ |
---|
1299 | fi |
---|
1300 | |
---|
1301 | typeset NB_ESSAI DELAI status i |
---|
1302 | # number of tentative |
---|
1303 | NB_ESSAI=3 |
---|
1304 | # time delay between tentative |
---|
1305 | DELAI=2 |
---|
1306 | |
---|
1307 | i=0 |
---|
1308 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1309 | ncflint -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1310 | status=$? |
---|
1311 | if [ ${status} -gt 0 ] ; then |
---|
1312 | IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" |
---|
1313 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1314 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1315 | IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1316 | sleep $DELAI |
---|
1317 | else |
---|
1318 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1319 | break |
---|
1320 | fi |
---|
1321 | (( i = i + 1 )) |
---|
1322 | done |
---|
1323 | |
---|
1324 | if [ ${status} -gt 0 ] ; then |
---|
1325 | echo "IGCM_sys_ncflint : ncflint error" |
---|
1326 | IGCM_debug_Exit "ncflint" |
---|
1327 | fi |
---|
1328 | |
---|
1329 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
1330 | } |
---|
1331 | |
---|
1332 | #D-#================================================== |
---|
1333 | #D-function IGCM_sys_ncks |
---|
1334 | #D-* Purpose: encapsulate ncks call so as to manage error code and retry |
---|
1335 | #D-* Examples: |
---|
1336 | #D- |
---|
1337 | function IGCM_sys_ncks { |
---|
1338 | IGCM_debug_PushStack "IGCM_sys_ncks" $@ |
---|
1339 | if ( $DEBUG_sys ) ; then |
---|
1340 | echo "IGCM_sys_ncks :" $@ |
---|
1341 | fi |
---|
1342 | |
---|
1343 | typeset NB_ESSAI DELAI status i |
---|
1344 | # number of tentative |
---|
1345 | NB_ESSAI=3 |
---|
1346 | # time delay between tentative |
---|
1347 | DELAI=2 |
---|
1348 | |
---|
1349 | i=0 |
---|
1350 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1351 | ncks -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1352 | status=$? |
---|
1353 | if [ ${status} -gt 0 ] ; then |
---|
1354 | IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" |
---|
1355 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1356 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1357 | IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1358 | sleep $DELAI |
---|
1359 | else |
---|
1360 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1361 | break |
---|
1362 | fi |
---|
1363 | (( i = i + 1 )) |
---|
1364 | done |
---|
1365 | |
---|
1366 | if [ ${status} -gt 0 ] ; then |
---|
1367 | echo "IGCM_sys_ncks : ncks error" |
---|
1368 | IGCM_debug_Exit "ncks" |
---|
1369 | fi |
---|
1370 | |
---|
1371 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
1372 | } |
---|
1373 | |
---|
1374 | #D-#================================================== |
---|
1375 | #D-function IGCM_sys_ncpdq |
---|
1376 | #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry |
---|
1377 | #D-* Examples: |
---|
1378 | #D- |
---|
1379 | function IGCM_sys_ncpdq { |
---|
1380 | IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ |
---|
1381 | if ( $DEBUG_sys ) ; then |
---|
1382 | echo "IGCM_sys_ncpdq :" $@ |
---|
1383 | fi |
---|
1384 | |
---|
1385 | typeset NB_ESSAI DELAI status i |
---|
1386 | # number of tentative |
---|
1387 | NB_ESSAI=3 |
---|
1388 | # time delay between tentative |
---|
1389 | DELAI=2 |
---|
1390 | |
---|
1391 | i=0 |
---|
1392 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1393 | ncpdq -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1394 | status=$? |
---|
1395 | if [ ${status} -gt 0 ] ; then |
---|
1396 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" |
---|
1397 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1398 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1399 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1400 | sleep $DELAI |
---|
1401 | else |
---|
1402 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1403 | break |
---|
1404 | fi |
---|
1405 | (( i = i + 1 )) |
---|
1406 | done |
---|
1407 | |
---|
1408 | if [ ${status} -gt 0 ] ; then |
---|
1409 | echo "IGCM_sys_ncpdq : ncpdq error" |
---|
1410 | IGCM_debug_Exit "ncpdq" |
---|
1411 | fi |
---|
1412 | |
---|
1413 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
1414 | } |
---|
1415 | |
---|
1416 | #D-#================================================== |
---|
1417 | #D-function IGCM_sys_ncra |
---|
1418 | #D-* Purpose: encapsulate ncra call so as to manage error code and retry |
---|
1419 | #D-* Examples: |
---|
1420 | #D- |
---|
1421 | function IGCM_sys_ncra { |
---|
1422 | IGCM_debug_PushStack "IGCM_sys_ncra" $@ |
---|
1423 | if ( $DEBUG_sys ) ; then |
---|
1424 | echo "IGCM_sys_ncra :" $@ |
---|
1425 | fi |
---|
1426 | |
---|
1427 | typeset NB_ESSAI DELAI status i |
---|
1428 | # number of tentative |
---|
1429 | NB_ESSAI=3 |
---|
1430 | # time delay between tentative |
---|
1431 | DELAI=2 |
---|
1432 | |
---|
1433 | i=0 |
---|
1434 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1435 | ncra -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1436 | status=$? |
---|
1437 | if [ ${status} -gt 0 ] ; then |
---|
1438 | IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" |
---|
1439 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1440 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1441 | IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1442 | sleep $DELAI |
---|
1443 | else |
---|
1444 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1445 | break |
---|
1446 | fi |
---|
1447 | (( i = i + 1 )) |
---|
1448 | done |
---|
1449 | |
---|
1450 | if [ ${status} -gt 0 ] ; then |
---|
1451 | echo "IGCM_sys_ncra : ncra error" |
---|
1452 | IGCM_debug_Exit "ncra" |
---|
1453 | fi |
---|
1454 | |
---|
1455 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
1456 | } |
---|
1457 | |
---|
1458 | #D-#================================================== |
---|
1459 | #D-function IGCM_sys_ncrcat |
---|
1460 | #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry |
---|
1461 | #D-* Examples: |
---|
1462 | #D- |
---|
1463 | function IGCM_sys_ncrcat { |
---|
1464 | IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ |
---|
1465 | if ( $DEBUG_sys ) ; then |
---|
1466 | echo "IGCM_sys_ncrcat :" $@ |
---|
1467 | fi |
---|
1468 | |
---|
1469 | typeset NB_ESSAI DELAI status i lastArg |
---|
1470 | # number of tentative |
---|
1471 | NB_ESSAI=3 |
---|
1472 | # time delay between tentative |
---|
1473 | DELAI=2 |
---|
1474 | |
---|
1475 | i=0 |
---|
1476 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1477 | ncrcat -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1478 | status=$? |
---|
1479 | if [ ${status} -gt 0 ] ; then |
---|
1480 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" |
---|
1481 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1482 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1483 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1484 | sleep $DELAI |
---|
1485 | elif ( [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] && [ X${config_Post_IgnoreNonMonotonic} = XFALSE ] ) ; then |
---|
1486 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" |
---|
1487 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1488 | # remove files having corrupted time axis |
---|
1489 | eval lastArg=\${$#} |
---|
1490 | IGCM_debug_Print 2 "Remove files having corrupted time axis" |
---|
1491 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" |
---|
1492 | \rm ${lastArg} |
---|
1493 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1494 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1495 | sleep $DELAI |
---|
1496 | else |
---|
1497 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1498 | break |
---|
1499 | fi |
---|
1500 | (( i = i + 1 )) |
---|
1501 | done |
---|
1502 | |
---|
1503 | # Special case for spinup with cyclic time axis: change attribute calendar to none |
---|
1504 | if [ X${config_Post_IgnoreNonMonotonic} = XTRUE ] ; then |
---|
1505 | eval lastArg=\${$#} |
---|
1506 | echo "IGCM_sys_ncrcat : change attribute calendar to none in file:" ${lastArg} |
---|
1507 | IGCM_sys_ncatted -a calendar,time_counter,m,c,none ${lastArg} |
---|
1508 | fi |
---|
1509 | |
---|
1510 | if [ ${status} -gt 0 ] ; then |
---|
1511 | echo "IGCM_sys_ncrcat : ncrcat error" |
---|
1512 | #IGCM_debug_Exit "ncrcat" |
---|
1513 | fi |
---|
1514 | |
---|
1515 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
1516 | } |
---|
1517 | |
---|
1518 | #D-#================================================== |
---|
1519 | #D-function IGCM_sys_ncrename |
---|
1520 | #D-* Purpose: encapsulate ncrename call so as to manage error code and retry |
---|
1521 | #D-* Examples: |
---|
1522 | #D- |
---|
1523 | function IGCM_sys_ncrename { |
---|
1524 | IGCM_debug_PushStack "IGCM_sys_ncrename" $@ |
---|
1525 | if ( $DEBUG_sys ) ; then |
---|
1526 | echo "IGCM_sys_ncrename :" $@ |
---|
1527 | fi |
---|
1528 | |
---|
1529 | typeset NB_ESSAI DELAI status i |
---|
1530 | # number of tentative |
---|
1531 | NB_ESSAI=3 |
---|
1532 | # time delay between tentative |
---|
1533 | DELAI=2 |
---|
1534 | |
---|
1535 | i=0 |
---|
1536 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1537 | ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1538 | status=$? |
---|
1539 | if [ ${status} -gt 0 ] ; then |
---|
1540 | IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" |
---|
1541 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1542 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1543 | IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1544 | sleep $DELAI |
---|
1545 | else |
---|
1546 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1547 | break |
---|
1548 | fi |
---|
1549 | (( i = i + 1 )) |
---|
1550 | done |
---|
1551 | |
---|
1552 | if [ ${status} -gt 0 ] ; then |
---|
1553 | echo "IGCM_sys_ncrename : ncrename error" |
---|
1554 | IGCM_debug_Exit "ncrename" |
---|
1555 | fi |
---|
1556 | |
---|
1557 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
1558 | } |
---|
1559 | |
---|
1560 | #D-#================================================== |
---|
1561 | #D-function IGCM_sys_ncwa |
---|
1562 | #D-* Purpose: encapsulate ncwa call so as to manage error code and retry |
---|
1563 | #D-* Examples: |
---|
1564 | #D- |
---|
1565 | function IGCM_sys_ncwa { |
---|
1566 | IGCM_debug_PushStack "IGCM_sys_ncwa" $@ |
---|
1567 | if ( $DEBUG_sys ) ; then |
---|
1568 | echo "IGCM_sys_ncwa :" $@ |
---|
1569 | fi |
---|
1570 | |
---|
1571 | typeset NB_ESSAI DELAI status i |
---|
1572 | # number of tentative |
---|
1573 | NB_ESSAI=3 |
---|
1574 | # time delay between tentative |
---|
1575 | DELAI=2 |
---|
1576 | |
---|
1577 | i=0 |
---|
1578 | while [ $i -lt $NB_ESSAI ] ; do |
---|
1579 | ncwa -C --buffer_size 838860800 $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1580 | status=$? |
---|
1581 | if [ ${status} -gt 0 ] ; then |
---|
1582 | IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" |
---|
1583 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1584 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1585 | IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
1586 | sleep $DELAI |
---|
1587 | else |
---|
1588 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1589 | break |
---|
1590 | fi |
---|
1591 | (( i = i + 1 )) |
---|
1592 | done |
---|
1593 | |
---|
1594 | if [ ${status} -gt 0 ] ; then |
---|
1595 | echo "IGCM_sys_ncwa : ncwa error" |
---|
1596 | IGCM_debug_Exit "ncwa" |
---|
1597 | fi |
---|
1598 | |
---|
1599 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
1600 | } |
---|
1601 | |
---|
1602 | ############################################################## |
---|
1603 | # CDO OPERATOR |
---|
1604 | |
---|
1605 | #D-#================================================== |
---|
1606 | #D-function IGCM_sys_cdo |
---|
1607 | #D-* Purpose: encapsulate cdo call so as to manage error code and retry |
---|
1608 | #D-* Examples: |
---|
1609 | #D- |
---|
1610 | function IGCM_sys_cdo { |
---|
1611 | IGCM_debug_PushStack "IGCM_sys_cdo" $@ |
---|
1612 | if ( $DEBUG_sys ) ; then |
---|
1613 | echo "IGCM_sys_cdo :" $@ |
---|
1614 | fi |
---|
1615 | |
---|
1616 | typeset status |
---|
1617 | |
---|
1618 | \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
1619 | status=$? |
---|
1620 | if [ ${status} -gt 0 ] ; then |
---|
1621 | echo "IGCM_sys_cdo : error code ${status}" |
---|
1622 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1623 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
1624 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
1625 | return 1 |
---|
1626 | else |
---|
1627 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
1628 | return 0 |
---|
1629 | fi |
---|
1630 | |
---|
1631 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
1632 | } |
---|
1633 | |
---|
1634 | # |
---|