1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel |
---|
5 | # Contact: Arnaud.Caubel__at__lsce.ipsl.fr |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | |
---|
14 | #========================================================= |
---|
15 | # The documentation of this file can be automatically generated |
---|
16 | # if you use the prefix #D- for comments to be extracted. |
---|
17 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
18 | #========================================================= |
---|
19 | |
---|
20 | #D-#================================================== |
---|
21 | #D-LibIGCM_sys for Curie |
---|
22 | #D-#================================================== |
---|
23 | #D- |
---|
24 | #D- This ksh library if a layer under some usefull |
---|
25 | #D-environment variables and shell commands. |
---|
26 | #D-All those definitions depend on host particularities. |
---|
27 | #D-It manages a stack mechanism and test validity of operations. |
---|
28 | #D-All function described bellow must be prefixed by IGCM_sys. |
---|
29 | |
---|
30 | #==================================================== |
---|
31 | # libIGCM_sys PARAMETERS |
---|
32 | #==================================================== |
---|
33 | |
---|
34 | #==================================================== |
---|
35 | # set DEBUG_sys to true to output calls of function |
---|
36 | typeset -r DEBUG_sys=${DEBUG_sys:=true} |
---|
37 | |
---|
38 | #==================================================== |
---|
39 | # Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get) |
---|
40 | typeset -r DRYRUN=${DRYRUN:=0} |
---|
41 | |
---|
42 | # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! |
---|
43 | # ------------------------------------------------------------------------------------- |
---|
44 | # | DRYRUN= | Date computations, | sys_Get | Exe | sys_Put_Out; sys_Put_Rest | |
---|
45 | # | | Cp/Exe/param/files | | | | |
---|
46 | # | | Chmod Qsub | | | | |
---|
47 | # ------------------------------------------------------------------------------------- |
---|
48 | # | 0 | yes | yes | yes | yes | |
---|
49 | # ------------------------------------------------------------------------------------- |
---|
50 | # | 1 | yes | yes | yes | no | |
---|
51 | # ------------------------------------------------------------------------------------- |
---|
52 | # | 2 | yes | yes | no | no | |
---|
53 | # ------------------------------------------------------------------------------------- |
---|
54 | # | 3 | yes | no | no | no | |
---|
55 | # ------------------------------------------------------------------------------------- |
---|
56 | |
---|
57 | #===================================================== |
---|
58 | # Global Variables : |
---|
59 | #===================================================== |
---|
60 | # Language : "fr" or "en" |
---|
61 | typeset -r MYLANG="fr" |
---|
62 | |
---|
63 | #===================================================== |
---|
64 | # Host and user names |
---|
65 | # $hostname ou hostname |
---|
66 | typeset HOST=${HOST:=$( hostname )} |
---|
67 | # $username ou whoami |
---|
68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
69 | # $hostname of the MASTER job |
---|
70 | typeset MASTER=curie |
---|
71 | # add default project on curie |
---|
72 | typeset DEFAULT_PROJECT=gen0826 |
---|
73 | |
---|
74 | #D- |
---|
75 | #D-#================================================== |
---|
76 | #D-Program used in libIGCM |
---|
77 | #D-#================================================== |
---|
78 | |
---|
79 | # Submit command |
---|
80 | typeset SUBMIT=${SUBMIT:=ccc_msub} |
---|
81 | # rsync with path |
---|
82 | typeset -r RSYNC=/usr/bin/rsync |
---|
83 | # RSYNC_opt args to rsync |
---|
84 | typeset -r RSYNC_opt="-va" |
---|
85 | # ie storage filesystem |
---|
86 | typeset -r STOREHOST=${MASTER} |
---|
87 | typeset -r REMOTE_RSYNC=/usr/bin/rsync |
---|
88 | |
---|
89 | #==================================================== |
---|
90 | # Set environment tools (ferret, nco, cdo, rebuild, ...) |
---|
91 | #==================================================== |
---|
92 | if [ X${TaskType} = Xcomputing ] ; then |
---|
93 | . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4_curie_ksh > /dev/null 2>&1 |
---|
94 | # to run with netcdf 3.6.3 ie compilation done before 17/2/2014 |
---|
95 | # uncomment 2 lines : |
---|
96 | # module unload netcdf |
---|
97 | # module load netcdf/3.6.3 |
---|
98 | else |
---|
99 | . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4_curie_ksh > /dev/null 2>&1 |
---|
100 | PCMDI_MP=/ccc/work/cont003/dsm/p86ipsl/PCMDI-MP |
---|
101 | fi |
---|
102 | export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddNoise/src_X64_CURIE/bin |
---|
103 | export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddPerturbation/src_X64_CURIE/bin |
---|
104 | export PATH=${PATH}:$( ccc_home -u p86ipsl )/rebuild/src_X64_CURIE/modipsl_v2_2_2_netcdf4.2/bin/ |
---|
105 | |
---|
106 | #==================================================== |
---|
107 | # Specific for ocean additionnal diagnostic |
---|
108 | export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO" |
---|
109 | export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET" |
---|
110 | |
---|
111 | #==================================================== |
---|
112 | # Host specific DIRECTORIES |
---|
113 | #==================================================== |
---|
114 | |
---|
115 | # ============ CESIUM START ============ # |
---|
116 | |
---|
117 | #==================================================== |
---|
118 | #- Mirror libIGCM from titane to cesium if needed |
---|
119 | #ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' ) |
---|
120 | #if [ ! ${ROOTSYS} = "home" ] ; then |
---|
121 | # typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} |
---|
122 | #else |
---|
123 | # typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
124 | #fi |
---|
125 | |
---|
126 | #==================================================== |
---|
127 | #- libIGCM_POST |
---|
128 | #if ( ${MirrorlibIGCM} ) ; then |
---|
129 | # PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) |
---|
130 | # typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM |
---|
131 | #else |
---|
132 | # typeset -r libIGCM_POST=${libIGCM} |
---|
133 | #fi |
---|
134 | |
---|
135 | # ============ CESIUM END ============ # |
---|
136 | |
---|
137 | #==================================================== |
---|
138 | #- MirrorlibIGCM for frontend |
---|
139 | typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
140 | |
---|
141 | #==================================================== |
---|
142 | #- libIGCM_POST for frontend |
---|
143 | typeset -r libIGCM_POST=${libIGCM} |
---|
144 | |
---|
145 | #==================================================== |
---|
146 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
147 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
148 | |
---|
149 | #==================================================== |
---|
150 | #- SUBMIT_DIR : submission dir |
---|
151 | typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}} |
---|
152 | |
---|
153 | #==================================================== |
---|
154 | #- IN |
---|
155 | typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} |
---|
156 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data} |
---|
157 | |
---|
158 | #==================================================== |
---|
159 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
160 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}_${$}} |
---|
161 | |
---|
162 | #==================================================== |
---|
163 | #- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs |
---|
164 | typeset -r OUTCOMMAND_PATH=/tmp |
---|
165 | |
---|
166 | #==================================================== |
---|
167 | #- HOST_MPIRUN_COMMAND |
---|
168 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time ccc_mprun -E-K1"} |
---|
169 | |
---|
170 | #==================================================== |
---|
171 | #- Max number of arguments passed to nco operator or demigration command |
---|
172 | UNIX_MAX_LIMIT=360 |
---|
173 | |
---|
174 | #==================================================== |
---|
175 | #- set PackDefault to true on curie |
---|
176 | PackDefault=true |
---|
177 | |
---|
178 | #==================================================== |
---|
179 | #- Number of core per node (max number of OpenMP task) |
---|
180 | NUM_COREPERNODE=8 |
---|
181 | |
---|
182 | #==================================================== |
---|
183 | #- Default number of MPI task for IPSL coupled model |
---|
184 | #- required for backward compatibility |
---|
185 | #- |
---|
186 | DEFAULT_NUM_PROC_OCE=5 |
---|
187 | DEFAULT_NUM_PROC_CPL=1 |
---|
188 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
189 | DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} |
---|
190 | |
---|
191 | #D-#================================================== |
---|
192 | #D-function IGCM_sys_defineArchives |
---|
193 | #D-* Purpose: |
---|
194 | #D-* Define ARCHIVE : Dedicated to large files |
---|
195 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
196 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
197 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
198 | #D-* Define R_BUF : Output tree located on SCRATCHDIR hosting files waiting for rebuild or pack processes |
---|
199 | #D-* if SpaceName=TEST everything is stored on SCRATCHDIR |
---|
200 | #D-* Examples: |
---|
201 | #D- |
---|
202 | function IGCM_sys_defineArchives { |
---|
203 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
204 | |
---|
205 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
206 | #==================================================== |
---|
207 | #- ARCHIVE (dedicated to large files) |
---|
208 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
209 | else |
---|
210 | #==================================================== |
---|
211 | #- ARCHIVE (dedicated to large files) |
---|
212 | ARCHIVE=${CCCSTOREDIR} |
---|
213 | fi |
---|
214 | |
---|
215 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
216 | #==================================================== |
---|
217 | #- STORAGE (dedicated to small/medium files) |
---|
218 | STORAGE=${config_UserChoices_STORAGE} |
---|
219 | else |
---|
220 | #==================================================== |
---|
221 | #- STORAGE (dedicated to small/medium files) |
---|
222 | STORAGE=${CCCWORKDIR} |
---|
223 | fi |
---|
224 | |
---|
225 | if [ X${config_UserChoices_SpaceName} = XTEST ]; then |
---|
226 | #==================================================== |
---|
227 | #- R_OUT |
---|
228 | R_OUT=${SCRATCHDIR}/IGCM_OUT |
---|
229 | |
---|
230 | #==================================================== |
---|
231 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
232 | R_FIG=${SCRATCHDIR}/IGCM_OUT |
---|
233 | |
---|
234 | IGCM_debug_Print 1 "SpaceName=TEST ==> OVERRULE destination path directories" |
---|
235 | |
---|
236 | else |
---|
237 | #==================================================== |
---|
238 | #- R_OUT |
---|
239 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
240 | |
---|
241 | #==================================================== |
---|
242 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
243 | R_FIG=${STORAGE}/IGCM_OUT |
---|
244 | fi |
---|
245 | |
---|
246 | #==================================================== |
---|
247 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
248 | R_BUF=${SCRATCHDIR}/IGCM_OUT |
---|
249 | |
---|
250 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
251 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
252 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
253 | |
---|
254 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
255 | } |
---|
256 | |
---|
257 | #D-#================================================== |
---|
258 | #D-function IGCM_sys_RshArchive |
---|
259 | #D-* Purpose: Archive rsh command |
---|
260 | #D-* Examples: |
---|
261 | #D- |
---|
262 | function IGCM_sys_RshArchive { |
---|
263 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
264 | /bin/ksh <<-EOF |
---|
265 | ${@} |
---|
266 | EOF |
---|
267 | status=$? |
---|
268 | if [ ${status} -gt 0 ] ; then |
---|
269 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
270 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
271 | fi |
---|
272 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
273 | } |
---|
274 | |
---|
275 | #D-#================================================== |
---|
276 | #D-function IGCM_sys_RshArchive_NoError |
---|
277 | #D-* Purpose: Archive rsh command, without error |
---|
278 | #D-* used only in monitoring.job |
---|
279 | #D-* Examples: |
---|
280 | #D- |
---|
281 | function IGCM_sys_RshArchive_NoError { |
---|
282 | IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ |
---|
283 | /bin/ksh <<-EOF |
---|
284 | ${@} 2> /dev/null |
---|
285 | EOF |
---|
286 | IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" |
---|
287 | } |
---|
288 | |
---|
289 | #D-#================================================== |
---|
290 | #D-function IGCM_sys_MkdirArchive |
---|
291 | #D-* Purpose: Mkdir on Archive |
---|
292 | #D-* Examples: |
---|
293 | #D- |
---|
294 | function IGCM_sys_MkdirArchive { |
---|
295 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
296 | if ( $DEBUG_sys ) ; then |
---|
297 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
298 | fi |
---|
299 | #- creation de repertoire sur le serveur fichier |
---|
300 | if [ ! -d ${1} ]; then |
---|
301 | \mkdir -p $1 |
---|
302 | status=$? |
---|
303 | |
---|
304 | if [ ${status} -gt 0 ] ; then |
---|
305 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
306 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
307 | fi |
---|
308 | fi |
---|
309 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
310 | } |
---|
311 | |
---|
312 | #D-#================================================== |
---|
313 | #D-function IGCM_sys_TestDirArchive |
---|
314 | #D-* Purpose: Test Directory that must exists on Archive |
---|
315 | #D-* Examples: |
---|
316 | #D- |
---|
317 | function IGCM_sys_TestDirArchive { |
---|
318 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
319 | if ( $DEBUG_sys ) ; then |
---|
320 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
321 | fi |
---|
322 | typeset ExistFlag |
---|
323 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
324 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
325 | return ${ExistFlag} |
---|
326 | } |
---|
327 | |
---|
328 | #D-#================================================== |
---|
329 | #D-function IGCM_sys_IsFileArchived |
---|
330 | #D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only |
---|
331 | #D-* Examples: |
---|
332 | #D- |
---|
333 | function IGCM_sys_IsFileArchived { |
---|
334 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
335 | if ( $DEBUG_sys ) ; then |
---|
336 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
337 | fi |
---|
338 | typeset IsArchivedFlag |
---|
339 | IsArchivedFlag=$( [ X$( echo $@ | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 ) |
---|
340 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
341 | |
---|
342 | return ${IsArchivedFlag} |
---|
343 | } |
---|
344 | |
---|
345 | #D-#================================================== |
---|
346 | #D-function IGCM_sys_TestFileArchive |
---|
347 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
348 | #D-* Examples: |
---|
349 | #D- |
---|
350 | function IGCM_sys_TestFileArchive { |
---|
351 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
352 | typeset ExistFlag |
---|
353 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
354 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
355 | |
---|
356 | return ${ExistFlag} |
---|
357 | } |
---|
358 | |
---|
359 | #D-#================================================== |
---|
360 | #D-function IGCM_sys_CountFileArchive |
---|
361 | #D-* Purpose: Count files on Archive filesystem |
---|
362 | #D-* Examples: |
---|
363 | #D- |
---|
364 | function IGCM_sys_CountFileArchive { |
---|
365 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
366 | ls ${@} 2>/dev/null | wc -l |
---|
367 | if [ $? -gt 0 ] ; then |
---|
368 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
369 | fi |
---|
370 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
371 | } |
---|
372 | |
---|
373 | #D-#================================================== |
---|
374 | #D-function IGCM_sys_Tree |
---|
375 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
376 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
377 | #D- |
---|
378 | function IGCM_sys_Tree { |
---|
379 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
380 | if ( $DEBUG_sys ) ; then |
---|
381 | echo "IGCM_sys_Tree :" $@ |
---|
382 | fi |
---|
383 | |
---|
384 | \ls -lR ${@} |
---|
385 | |
---|
386 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
387 | } |
---|
388 | |
---|
389 | #D-#================================================== |
---|
390 | #D-function IGCM_sys_Qsub |
---|
391 | #D-* Purpose: Qsub new job |
---|
392 | #D-* Examples: |
---|
393 | #D- |
---|
394 | function IGCM_sys_Qsub { |
---|
395 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
396 | if ( $DEBUG_sys ) ; then |
---|
397 | echo "IGCM_sys_Qsub :" $@ |
---|
398 | fi |
---|
399 | typeset options status |
---|
400 | options="-o ${SUBMIT_DIR}/${Script_Output} -e ${SUBMIT_DIR}/${Script_Output}" |
---|
401 | |
---|
402 | /usr/bin/ccc_msub ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
403 | status=$? |
---|
404 | |
---|
405 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
406 | if [ ${status} -gt 0 ] ; then |
---|
407 | IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}" |
---|
408 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
409 | else |
---|
410 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ ) |
---|
411 | fi |
---|
412 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
413 | } |
---|
414 | |
---|
415 | #D-#================================================== |
---|
416 | #D-function IGCM_sys_QsubPost |
---|
417 | #D-* Purpose: Qsub new job on scalaire |
---|
418 | #D-* Examples: |
---|
419 | #D- |
---|
420 | function IGCM_sys_QsubPost { |
---|
421 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
422 | if ( $DEBUG_sys ) ; then |
---|
423 | echo "IGCM_sys_QsubPost :" $@ |
---|
424 | fi |
---|
425 | typeset options status |
---|
426 | MY_PROJECT=$(echo ${BRIDGE_MSUB_PROJECT:=${DEFAULT_PROJECT}} | cut -d@ -f1 ) |
---|
427 | |
---|
428 | # EASIER TO DO THIS INSTEAD OF DUPLICATING libIGCM_sys_curie.ksh |
---|
429 | case $( hostname -s ) in |
---|
430 | curie*) |
---|
431 | options="-Q normal -A ${MY_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out";; |
---|
432 | airain*) |
---|
433 | options="-q ivybridge -A dsm -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out" |
---|
434 | esac |
---|
435 | |
---|
436 | /usr/bin/ccc_msub ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
437 | status=$? |
---|
438 | |
---|
439 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
440 | if [ ${status} -gt 0 ] ; then |
---|
441 | IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}" |
---|
442 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
443 | else |
---|
444 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ ) |
---|
445 | fi |
---|
446 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
447 | } |
---|
448 | |
---|
449 | #D-************************* |
---|
450 | #D- File transfer functions |
---|
451 | #D-************************* |
---|
452 | #D- |
---|
453 | |
---|
454 | #D-#================================================== |
---|
455 | #D-function IGCM_sys_RmRunDir |
---|
456 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
457 | #D- scheduler will do the job) |
---|
458 | #D-* Examples: |
---|
459 | #D- |
---|
460 | function IGCM_sys_RmRunDir { |
---|
461 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
462 | if ( $DEBUG_sys ) ; then |
---|
463 | echo "IGCM_sys_RmRunDir :" $@ |
---|
464 | fi |
---|
465 | |
---|
466 | typeset status |
---|
467 | |
---|
468 | echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
469 | \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
470 | status=$? |
---|
471 | |
---|
472 | if [ ${status} -gt 0 ] ; then |
---|
473 | IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}." |
---|
474 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
475 | IGCM_debug_Exit "IGCM_sys_RmRunDir" |
---|
476 | else |
---|
477 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
478 | fi |
---|
479 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
480 | } |
---|
481 | |
---|
482 | #D-#================================================== |
---|
483 | #D-function IGCM_sys_Put_Dir |
---|
484 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
485 | #D-* Examples: |
---|
486 | #D- |
---|
487 | function IGCM_sys_Put_Dir { |
---|
488 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
489 | if ( $DEBUG_sys ) ; then |
---|
490 | echo "IGCM_sys_Put_Dir :" $@ |
---|
491 | fi |
---|
492 | if [ $DRYRUN = 0 ]; then |
---|
493 | if [ ! -d ${1} ] ; then |
---|
494 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
495 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
496 | return |
---|
497 | fi |
---|
498 | |
---|
499 | typeset status |
---|
500 | |
---|
501 | # Only if we use rsync |
---|
502 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
503 | # |
---|
504 | #USUAL WAY |
---|
505 | \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
506 | status=$? |
---|
507 | |
---|
508 | if [ ${status} -gt 0 ] ; then |
---|
509 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
510 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
511 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
512 | else |
---|
513 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
514 | fi |
---|
515 | fi |
---|
516 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
517 | } |
---|
518 | |
---|
519 | #D-#================================================== |
---|
520 | #D-function IGCM_sys_Get_Dir |
---|
521 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
522 | #D-* Examples: |
---|
523 | #D- |
---|
524 | function IGCM_sys_Get_Dir { |
---|
525 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
526 | if ( $DEBUG_sys ) ; then |
---|
527 | echo "IGCM_sys_Get_Dir :" $@ |
---|
528 | fi |
---|
529 | if [ $DRYRUN = 0 ]; then |
---|
530 | typeset NB_ESSAI DELAI status i |
---|
531 | # number of tentative |
---|
532 | NB_ESSAI=3 |
---|
533 | # time delay between tentative |
---|
534 | DELAI=2 |
---|
535 | |
---|
536 | # |
---|
537 | # USUAL WAY |
---|
538 | # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command : |
---|
539 | ccc_hsm get -r $1 |
---|
540 | |
---|
541 | i=0 |
---|
542 | while [ $i -lt $NB_ESSAI ] ; do |
---|
543 | \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
544 | status=$? |
---|
545 | if [ ${status} -gt 0 ] ; then |
---|
546 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
547 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again." |
---|
548 | sleep $DELAI |
---|
549 | else |
---|
550 | break |
---|
551 | fi |
---|
552 | (( i = i + 1 )) |
---|
553 | done |
---|
554 | |
---|
555 | if [ ${status} -gt 0 ] ; then |
---|
556 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
557 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
558 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
559 | else |
---|
560 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
561 | fi |
---|
562 | fi |
---|
563 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
564 | } |
---|
565 | |
---|
566 | #D-#================================================== |
---|
567 | #D-function IGCM_sys_Put_Rest |
---|
568 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
569 | #D- File and target directory must exist. |
---|
570 | #D-* Examples: |
---|
571 | #D- |
---|
572 | function IGCM_sys_Put_Rest { |
---|
573 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
574 | if ( $DEBUG_sys ) ; then |
---|
575 | echo "IGCM_sys_Put_Rest :" $@ |
---|
576 | fi |
---|
577 | if [ $DRYRUN = 0 ]; then |
---|
578 | if [ ! -f ${1} ] ; then |
---|
579 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
580 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
581 | fi |
---|
582 | |
---|
583 | typeset status |
---|
584 | # |
---|
585 | # USUAL WAY |
---|
586 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
587 | status=$? |
---|
588 | |
---|
589 | # #RSYNC WITH NETWORK SSH CALL |
---|
590 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
591 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
592 | |
---|
593 | # #RSYNC WITH NFS USE |
---|
594 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
595 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
596 | |
---|
597 | # status=$? |
---|
598 | # IGCM_sys_Rsync_out $status |
---|
599 | |
---|
600 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
601 | # (( status=status+$? )) |
---|
602 | |
---|
603 | if [ ${status} -gt 0 ] ; then |
---|
604 | IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
605 | [ -f ${1} ] && ls -l ${1} |
---|
606 | [ -f ${2} ] && ls -l ${2} |
---|
607 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
608 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
609 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
610 | else |
---|
611 | |
---|
612 | if [ X${JobType} = XRUN ] ; then |
---|
613 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
614 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
615 | fi |
---|
616 | |
---|
617 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
618 | fi |
---|
619 | fi |
---|
620 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
621 | } |
---|
622 | |
---|
623 | #D-#================================================== |
---|
624 | #D-function IGCM_sys_Put_Out |
---|
625 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
626 | #D-* Examples: |
---|
627 | #D- |
---|
628 | function IGCM_sys_Put_Out { |
---|
629 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
630 | if ( $DEBUG_sys ) ; then |
---|
631 | echo "IGCM_sys_Put_Out :" $@ |
---|
632 | fi |
---|
633 | |
---|
634 | typeset NB_ESSAI DELAI status i exist skip |
---|
635 | |
---|
636 | # number of tentative |
---|
637 | NB_ESSAI=3 |
---|
638 | # time delay between tentative |
---|
639 | DELAI=2 |
---|
640 | |
---|
641 | if [ $DRYRUN = 0 ]; then |
---|
642 | if [ ! -f ${1} ] ; then |
---|
643 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
644 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
645 | return 1 |
---|
646 | fi |
---|
647 | # |
---|
648 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
649 | # |
---|
650 | exist=false |
---|
651 | skip=false |
---|
652 | if [ -f $2 ] ; then |
---|
653 | IGCM_debug_Print 1 "$2 already exist" |
---|
654 | ccc_hsm get $2 |
---|
655 | exist=true |
---|
656 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
657 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
658 | skip=true |
---|
659 | else |
---|
660 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
661 | skip=false |
---|
662 | fi |
---|
663 | fi |
---|
664 | # |
---|
665 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
666 | IGCM_sys_Chmod u+w $2 |
---|
667 | fi |
---|
668 | |
---|
669 | if [ X${skip} = Xfalse ] ; then |
---|
670 | i=0 |
---|
671 | while [ $i -lt $NB_ESSAI ] ; do |
---|
672 | if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then |
---|
673 | # USUAL WAY |
---|
674 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
675 | status=$? |
---|
676 | else |
---|
677 | # NOT SO USUAL WAY |
---|
678 | \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
679 | status=$? |
---|
680 | fi |
---|
681 | if [ ${status} -gt 0 ]; then |
---|
682 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
683 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." |
---|
684 | [ -f ${1} ] && ls -l ${1} |
---|
685 | [ -f ${2} ] && ls -l ${2} |
---|
686 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
687 | sleep $DELAI |
---|
688 | else |
---|
689 | break |
---|
690 | fi |
---|
691 | (( i = i + 1 )) |
---|
692 | done |
---|
693 | fi |
---|
694 | |
---|
695 | # #RSYNC WITH NETWORK SSH CALL |
---|
696 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
697 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
698 | |
---|
699 | # #RSYNC WITH NFS USE |
---|
700 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
701 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
702 | |
---|
703 | # status=$? |
---|
704 | # IGCM_sys_Rsync_out $status |
---|
705 | |
---|
706 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
707 | # (( status=status+$? )) |
---|
708 | |
---|
709 | if [ ${status} -gt 0 ] ; then |
---|
710 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}" |
---|
711 | [ -f ${1} ] && ls -l ${1} |
---|
712 | [ -f ${2} ] && ls -l ${2} |
---|
713 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
714 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
715 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
716 | else |
---|
717 | |
---|
718 | if [ X${JobType} = XRUN ] ; then |
---|
719 | if [ X${3} = X ] ; then |
---|
720 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
721 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
722 | fi |
---|
723 | fi |
---|
724 | |
---|
725 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
726 | fi |
---|
727 | fi |
---|
728 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
729 | return 0 |
---|
730 | } |
---|
731 | |
---|
732 | #D-#================================================== |
---|
733 | #D-function IGCM_sys_Get |
---|
734 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
735 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
736 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
737 | function IGCM_sys_Get { |
---|
738 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
739 | |
---|
740 | typeset DEST dm_liste target file_work |
---|
741 | typeset NB_ESSAI DELAI status i |
---|
742 | |
---|
743 | if ( $DEBUG_sys ) ; then |
---|
744 | echo "IGCM_sys_Get :" $@ |
---|
745 | fi |
---|
746 | |
---|
747 | # number of tentative |
---|
748 | NB_ESSAI=3 |
---|
749 | # time delay between tentative |
---|
750 | DELAI=2 |
---|
751 | |
---|
752 | if [ $DRYRUN -le 2 ]; then |
---|
753 | if [ X${1} = X'/l' ] ; then |
---|
754 | eval set +A dm_liste \${${2}} |
---|
755 | else |
---|
756 | eval set +A dm_liste ${1} |
---|
757 | fi |
---|
758 | eval DEST=\${${#}} |
---|
759 | ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
760 | status=$? |
---|
761 | if [ ${status} -gt 0 ] ; then |
---|
762 | echo "WARNING IGCM_sys_Get : error code ${status}" |
---|
763 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
764 | echo "WARNING IGCM_sys_Get : will stop later if the cp fails." |
---|
765 | fi |
---|
766 | |
---|
767 | #if [ ${status} -gt 0 ] ; then |
---|
768 | # if [ ! "X$( grep "Lost dmusrcmd connection" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then |
---|
769 | # cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
770 | # echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " |
---|
771 | # sleep 30 |
---|
772 | # echo "We try another time" |
---|
773 | ## dmget ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
774 | # ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
775 | # status=$? |
---|
776 | # if [ ${status} -gt 0 ] ; then |
---|
777 | # echo "ERROR IGCM_sys_Get : again demigration error :" |
---|
778 | # cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
779 | # IGCM_debug_Exit "IGCM_sys_Get" |
---|
780 | # fi |
---|
781 | # else |
---|
782 | # echo "ERROR IGCM_sys_Get : demigration error :" |
---|
783 | # cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
784 | # IGCM_debug_Exit "IGCM_sys_Get" |
---|
785 | # fi |
---|
786 | #fi |
---|
787 | |
---|
788 | # #RSYNC WITH NETWORK SSH CALL |
---|
789 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
790 | # ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
791 | |
---|
792 | # #RSYNC WITH NFS USE |
---|
793 | # echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
794 | # ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
795 | |
---|
796 | # status=$? |
---|
797 | # IGCM_sys_Rsync_out $status |
---|
798 | |
---|
799 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
800 | # (( status=status+$? )) |
---|
801 | |
---|
802 | #USUAL WAY |
---|
803 | if [ X${1} = X'/l' ] ; then |
---|
804 | for target in ${dm_liste[*]} ; do |
---|
805 | local_file=$( basename ${target} ) |
---|
806 | # test if the target file is present before the loop |
---|
807 | IGCM_sys_TestFileArchive ${target} |
---|
808 | status=$? |
---|
809 | if [ ${status} -gt 0 ] ; then |
---|
810 | echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ." |
---|
811 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
812 | else |
---|
813 | i=0 |
---|
814 | while [ $i -lt $NB_ESSAI ] ; do |
---|
815 | #if [ X${DoLink} = Xtrue ] ; then |
---|
816 | # \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
817 | # status=$? |
---|
818 | # else |
---|
819 | # \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
820 | # status=$? |
---|
821 | #fi |
---|
822 | \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
823 | status=$? |
---|
824 | if [ ${status} -gt 0 ]; then |
---|
825 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
826 | IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again." |
---|
827 | sleep $DELAI |
---|
828 | else |
---|
829 | break |
---|
830 | fi |
---|
831 | (( i = i + 1 )) |
---|
832 | done |
---|
833 | if [ ${status} -gt 0 ] ; then |
---|
834 | echo "IGCM_sys_Get : error" |
---|
835 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
836 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
837 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
838 | else |
---|
839 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
840 | fi |
---|
841 | fi |
---|
842 | done |
---|
843 | else |
---|
844 | i=0 |
---|
845 | while [ $i -lt $NB_ESSAI ] ; do |
---|
846 | \cp ${dm_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
847 | status=$? |
---|
848 | if [ ${status} -gt 0 ]; then |
---|
849 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
850 | IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again." |
---|
851 | sleep $DELAI |
---|
852 | else |
---|
853 | break |
---|
854 | fi |
---|
855 | (( i = i + 1 )) |
---|
856 | done |
---|
857 | if [ ${status} -gt 0 ] ; then |
---|
858 | echo "IGCM_sys_Get : error" |
---|
859 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
860 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
861 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
862 | else |
---|
863 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
864 | fi |
---|
865 | fi |
---|
866 | fi |
---|
867 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
868 | } |
---|
869 | |
---|
870 | #D-#================================================== |
---|
871 | #D-function IGCM_sys_GetDate_Monitoring |
---|
872 | #D-* Purpose: get the last year for which the monitoring has been computed |
---|
873 | #D-* Examples: |
---|
874 | #D- |
---|
875 | function IGCM_sys_GetDate_Monitoring { |
---|
876 | IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@ |
---|
877 | if ( $DEBUG_sys ) ; then |
---|
878 | echo "IGCM_sys_GetDate_Monitoring :" $@ |
---|
879 | fi |
---|
880 | |
---|
881 | eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' ) |
---|
882 | |
---|
883 | IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring" |
---|
884 | } |
---|
885 | |
---|
886 | #D-#================================================== |
---|
887 | #D-function IGCM_sys_Dods_Rm |
---|
888 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
889 | #D-* Examples: |
---|
890 | #D- |
---|
891 | function IGCM_sys_Dods_Rm { |
---|
892 | if ( $DEBUG_sys ) ; then |
---|
893 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
894 | fi |
---|
895 | typeset status |
---|
896 | if [ $DRYRUN = 0 ]; then |
---|
897 | |
---|
898 | # if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then |
---|
899 | # echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." |
---|
900 | # echo "Nothing has been done." |
---|
901 | # return |
---|
902 | # fi |
---|
903 | |
---|
904 | /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 |
---|
905 | status=$? |
---|
906 | |
---|
907 | # if [ ${status} -gt 0 ] ; then |
---|
908 | # echo "IGCM_sys_Dods_Rm : error." |
---|
909 | # cat out_dods_rm |
---|
910 | # IGCM_debug_Exit "IGCM_sys_Dods_Rm" |
---|
911 | # else |
---|
912 | # rm out_dods_rm |
---|
913 | # fi |
---|
914 | |
---|
915 | fi |
---|
916 | return $status |
---|
917 | } |
---|
918 | |
---|
919 | #D-#================================================== |
---|
920 | #D-function IGCM_sys_Dods_Cp |
---|
921 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
922 | #D-* Examples: |
---|
923 | #D- |
---|
924 | function IGCM_sys_Dods_Cp { |
---|
925 | if ( $DEBUG_sys ) ; then |
---|
926 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
927 | fi |
---|
928 | typeset status |
---|
929 | if [ $DRYRUN = 0 ]; then |
---|
930 | |
---|
931 | # if [ ! -d ${R_SAVE}/${1} ] ; then |
---|
932 | # echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." |
---|
933 | # echo "Nothing has been done." |
---|
934 | # return |
---|
935 | # fi |
---|
936 | |
---|
937 | /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 |
---|
938 | status=$? |
---|
939 | |
---|
940 | # if [ ${status} -gt 0 ] ; then |
---|
941 | # echo "IGCM_sys_Dods_Cp : error." |
---|
942 | # cat out_dods_cp |
---|
943 | # IGCM_debug_Exit "IGCM_sys_Dods_Cp" |
---|
944 | # else |
---|
945 | # rm out_dods_cp |
---|
946 | # fi |
---|
947 | |
---|
948 | fi |
---|
949 | return $status |
---|
950 | } |
---|
951 | |
---|
952 | #D-#================================================== |
---|
953 | #D-function IGCM_sys_Put_Dods |
---|
954 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. |
---|
955 | #D-* Examples: |
---|
956 | #D- |
---|
957 | function IGCM_sys_Put_Dods { |
---|
958 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
959 | if ( $DEBUG_sys ) ; then |
---|
960 | echo "IGCM_sys_Put_Dods :" $@ |
---|
961 | fi |
---|
962 | typeset status |
---|
963 | if [ $DRYRUN = 0 ]; then |
---|
964 | if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then |
---|
965 | echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should." |
---|
966 | echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST." |
---|
967 | echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST." |
---|
968 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
969 | return |
---|
970 | fi |
---|
971 | |
---|
972 | if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then |
---|
973 | echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should." |
---|
974 | echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS." |
---|
975 | echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS." |
---|
976 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
977 | return |
---|
978 | fi |
---|
979 | # |
---|
980 | if [ -d ${R_SAVE}/${1} ] ; then |
---|
981 | cd ${R_SAVE} |
---|
982 | elif [ -d ${R_FIGR}/${1} ] ; then |
---|
983 | cd ${R_FIGR} |
---|
984 | fi |
---|
985 | |
---|
986 | IGCM_sys_Dods_Rm ${1} |
---|
987 | IGCM_sys_Dods_Cp ${1} |
---|
988 | status=0 |
---|
989 | |
---|
990 | if [ ${status} -gt 0 ] ; then |
---|
991 | echo "IGCM_sys_Put_Dods : error." |
---|
992 | IGCM_debug_Exit "IGCM_sys_Put_Dods" |
---|
993 | fi |
---|
994 | fi |
---|
995 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
996 | } |
---|
997 | |
---|
998 | ############################################################## |
---|
999 | # REBUILD OPERATOR |
---|
1000 | |
---|
1001 | #D-#================================================== |
---|
1002 | #D-function IGCM_sys_sync |
---|
1003 | #D-* Purpose: flush buffer on disk |
---|
1004 | #D-* Examples: |
---|
1005 | #D- |
---|
1006 | function IGCM_sys_sync { |
---|
1007 | IGCM_debug_PushStack "IGCM_sys_sync" $@ |
---|
1008 | if ( $DEBUG_sys ) ; then |
---|
1009 | echo "IGCM_sys_sync :" $@ |
---|
1010 | fi |
---|
1011 | |
---|
1012 | /bin/sync |
---|
1013 | |
---|
1014 | IGCM_debug_PopStack "IGCM_sys_sync" |
---|
1015 | } |
---|
1016 | |
---|
1017 | ############################################################ |
---|
1018 | # Activate Running Environnment Variables |
---|
1019 | |
---|
1020 | #D-#================================================== |
---|
1021 | #D-function IGCM_sys_desactiv_variables |
---|
1022 | #D-* Purpose: set environement variables prior to execution |
---|
1023 | #D-* Examples: |
---|
1024 | #D- |
---|
1025 | function IGCM_sys_activ_variables { |
---|
1026 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
1027 | if ( $DEBUG_sys ) ; then |
---|
1028 | echo "IGCM_sys_activ_variables" |
---|
1029 | fi |
---|
1030 | |
---|
1031 | # -------------------------------------------------------------------- |
---|
1032 | #D- MPI specifications |
---|
1033 | # -------------------------------------------------------------------- |
---|
1034 | export OMPI_MCA_paffinity_hwloc_priority=41 |
---|
1035 | # -------------------------------------------------------------------- |
---|
1036 | #D- Other specifications |
---|
1037 | # -------------------------------------------------------------------- |
---|
1038 | |
---|
1039 | ulimit -s unlimited |
---|
1040 | |
---|
1041 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
1042 | } |
---|
1043 | |
---|
1044 | ############################################################ |
---|
1045 | # Desactivate Running Environnment Variables |
---|
1046 | |
---|
1047 | #D-#================================================== |
---|
1048 | #D-function IGCM_sys_desactiv_variables |
---|
1049 | #D-* Purpose: unset environement variables after execution |
---|
1050 | #D-* Examples: |
---|
1051 | #D- |
---|
1052 | function IGCM_sys_desactiv_variables { |
---|
1053 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
1054 | if ( $DEBUG_sys ) ; then |
---|
1055 | echo "IGCM_sys_desactiv_variables" |
---|
1056 | fi |
---|
1057 | # -------------------------------------------------------------------- |
---|
1058 | #D- MPI specifications |
---|
1059 | # -------------------------------------------------------------------- |
---|
1060 | |
---|
1061 | # -------------------------------------------------------------------- |
---|
1062 | #D- Other specifications |
---|
1063 | # -------------------------------------------------------------------- |
---|
1064 | |
---|
1065 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
1066 | } |
---|
1067 | |
---|
1068 | ############################################################ |
---|
1069 | # Build MPI/OMP scripts run file (dummy function) |
---|
1070 | |
---|
1071 | #D-#================================================== |
---|
1072 | #D-function IGCM_sys_build_run_file |
---|
1073 | #D-* Purpose: build run file (deprecated) |
---|
1074 | #D-* Examples: |
---|
1075 | #D- |
---|
1076 | function IGCM_sys_build_run_file { |
---|
1077 | |
---|
1078 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
1079 | |
---|
1080 | } |
---|
1081 | |
---|
1082 | ############################################################ |
---|
1083 | # Build MPI/OMP scripts |
---|
1084 | |
---|
1085 | #D-#================================================== |
---|
1086 | #D-function IGCM_sys_build_execution_scripts |
---|
1087 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
1088 | #D-* Examples: |
---|
1089 | #D- |
---|
1090 | function IGCM_sys_build_execution_scripts |
---|
1091 | { |
---|
1092 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
1093 | if ( $DEBUG_sys ) ; then |
---|
1094 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
1095 | fi |
---|
1096 | |
---|
1097 | EXECUTION=${HOST_MPIRUN_COMMAND} |
---|
1098 | |
---|
1099 | # MPMD mode |
---|
1100 | if ( ${OK_PARA_MPMD} ) ; then |
---|
1101 | |
---|
1102 | # Only MPI (MPMD) |
---|
1103 | if ( ! ${OK_PARA_OMP} ) ; then |
---|
1104 | |
---|
1105 | if [ -f run_file ] ; then |
---|
1106 | IGCM_sys_Rm -f run_file |
---|
1107 | fi |
---|
1108 | touch run_file |
---|
1109 | |
---|
1110 | # Build run_file |
---|
1111 | |
---|
1112 | # First loop on the components for the coupler ie oasis (only if oasis3) |
---|
1113 | # the coupler ie oasis3 must be the first one |
---|
1114 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1115 | |
---|
1116 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1117 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1118 | |
---|
1119 | # for CPL component only |
---|
1120 | if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
1121 | |
---|
1122 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1123 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1124 | echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
1125 | fi |
---|
1126 | done |
---|
1127 | |
---|
1128 | # Then second loop on the components |
---|
1129 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1130 | |
---|
1131 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1132 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1133 | |
---|
1134 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
1135 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
1136 | |
---|
1137 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1138 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1139 | echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
1140 | fi |
---|
1141 | done |
---|
1142 | |
---|
1143 | EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file" |
---|
1144 | |
---|
1145 | IGCM_sys_Chmod u+x run_file |
---|
1146 | if ( $DEBUG_sys ) ; then |
---|
1147 | echo "run_file contains : " |
---|
1148 | cat run_file |
---|
1149 | fi |
---|
1150 | |
---|
1151 | # MPI-OpenMP (MPMD) |
---|
1152 | else |
---|
1153 | |
---|
1154 | # Use of mpirun instead of ccc_mprun |
---|
1155 | EXECUTION="time mpirun" |
---|
1156 | |
---|
1157 | # Hosts treatment |
---|
1158 | ${EXECUTION} hostname | sort | uniq > hosts.tmp |
---|
1159 | |
---|
1160 | i=0 |
---|
1161 | rm -f hosts rankfile |
---|
1162 | IGCM_debug_Print 1 "sys Curie, Hosts available :" |
---|
1163 | for nodes in `cat hosts.tmp` |
---|
1164 | do |
---|
1165 | host[$i]=$nodes |
---|
1166 | echo "${host[$i]}" >> hosts |
---|
1167 | IGCM_debug_Print 1 ${host[$i]} |
---|
1168 | i=$((i+1)) |
---|
1169 | done |
---|
1170 | rm -f hosts.tmp |
---|
1171 | |
---|
1172 | listnodes=${host[*]} |
---|
1173 | |
---|
1174 | EXECUTION="${EXECUTION} -hostfile hosts -rankfile rankfile" |
---|
1175 | |
---|
1176 | # Initialisation |
---|
1177 | rank=0 |
---|
1178 | current_core=0 |
---|
1179 | core_per_node=16 |
---|
1180 | init_exec=n |
---|
1181 | |
---|
1182 | # Loop on the components |
---|
1183 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1184 | |
---|
1185 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1186 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1187 | |
---|
1188 | # Not possible if oasis has an executable (i.e old version of oasis3) |
---|
1189 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" = "XCPL" ] ) ; then |
---|
1190 | IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version" |
---|
1191 | IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler" |
---|
1192 | IGCM_debug_Verif_Exit |
---|
1193 | fi |
---|
1194 | |
---|
1195 | # Only if we really have an executable for the component : |
---|
1196 | if [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
1197 | |
---|
1198 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1199 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1200 | |
---|
1201 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1202 | echo "" >> script_${ExeNameOut}.ksh |
---|
1203 | if [ ${comp_proc_omp_loc} -gt 1 ] ; then |
---|
1204 | |
---|
1205 | # Check if the number of threads is correct |
---|
1206 | case ${comp_proc_omp_loc} in |
---|
1207 | 2|4|8|16) |
---|
1208 | IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads" |
---|
1209 | ;; |
---|
1210 | *) |
---|
1211 | IGCM_debug_Exit "ERROR with OMP parameters !" |
---|
1212 | IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads" |
---|
1213 | IGCM_debug_Print 2 "Only 2,4,8,16 as number of OMP threads are possible " |
---|
1214 | IGCM_debug_Verif_Exit |
---|
1215 | ;; |
---|
1216 | esac |
---|
1217 | echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
1218 | echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
1219 | echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
1220 | echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
1221 | fi |
---|
1222 | #echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >> script_${ExeNameOut}.ksh |
---|
1223 | #echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh |
---|
1224 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1225 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1226 | |
---|
1227 | if [ ${init_exec} = y ] ; then |
---|
1228 | EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
1229 | else |
---|
1230 | EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
1231 | init_exec=y |
---|
1232 | fi |
---|
1233 | |
---|
1234 | # Build rankfile : method used to assign cores and nodes for the MPI process |
---|
1235 | # Ex : |
---|
1236 | #rank 0=curie5296 slot=0,2,4,6 |
---|
1237 | #rank 1=curie5296 slot=8,10,12,14 |
---|
1238 | # Example of final command : |
---|
1239 | # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh |
---|
1240 | # with script_lmdz.x.ksh : |
---|
1241 | # #!/bin/ksh |
---|
1242 | #export KMP_STACKSIZE=3g |
---|
1243 | #export KMP_LIBRARY=turnaround |
---|
1244 | #export MKL_SERIAL=YES |
---|
1245 | #OMP_NUM_THREADS=4 |
---|
1246 | #./lmdz.x |
---|
1247 | # |
---|
1248 | |
---|
1249 | for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do |
---|
1250 | (( index_host = current_core / core_per_node )) |
---|
1251 | host_value=${host[${index_host}]} |
---|
1252 | (( slot = current_core % core_per_node )) |
---|
1253 | virg="," |
---|
1254 | string_final="" |
---|
1255 | for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do |
---|
1256 | (( index_slot = index * 2 )) |
---|
1257 | string=$index_slot$virg |
---|
1258 | string_final=$string_final$string |
---|
1259 | done |
---|
1260 | string_final=$( echo $string_final | sed "s/.$//" ) |
---|
1261 | echo "rank $rank=$host_value slot=$string_final" >> rankfile |
---|
1262 | (( rank = rank + 1 )) |
---|
1263 | (( current_core = current_core + comp_proc_omp_loc )) |
---|
1264 | done |
---|
1265 | fi |
---|
1266 | |
---|
1267 | done |
---|
1268 | fi |
---|
1269 | |
---|
1270 | # Only one executable (SPMD mode). |
---|
1271 | else |
---|
1272 | |
---|
1273 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1274 | |
---|
1275 | # Only if we really have an executable for the component : |
---|
1276 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1277 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
1278 | |
---|
1279 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
1280 | echo "" >> script_${ExeNameOut}.ksh |
---|
1281 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
1282 | |
---|
1283 | if ( ${OK_PARA_OMP} ) ; then |
---|
1284 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
1285 | echo "" >> script_${ExeNameOut}.ksh |
---|
1286 | echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
1287 | echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
1288 | echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
1289 | echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
1290 | fi |
---|
1291 | |
---|
1292 | if ( ${OK_PARA_MPI} ) ; then |
---|
1293 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
1294 | # Default : ccc_mprun used if nb_proc gt 1 |
---|
1295 | # to have out/err per process on different files |
---|
1296 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}" >> script_${ExeNameOut}.ksh |
---|
1297 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1298 | EXECUTION="${HOST_MPIRUN_COMMAND} -n ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
1299 | else |
---|
1300 | # Default : ccc_mprun is NOT used if nb_proc eq 1 |
---|
1301 | # to have out/err per process on different files |
---|
1302 | # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
1303 | echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
1304 | EXECUTION="/usr/bin/time ./script_${ExeNameOut}.ksh" |
---|
1305 | fi |
---|
1306 | |
---|
1307 | IGCM_debug_Print 1 "sys Curie : script_${ExeNameOut}.ksh contains" |
---|
1308 | cat script_${ExeNameOut}.ksh |
---|
1309 | |
---|
1310 | fi |
---|
1311 | |
---|
1312 | done |
---|
1313 | |
---|
1314 | fi |
---|
1315 | |
---|
1316 | IGCM_debug_Print 1 "sys Curie : execution command is " |
---|
1317 | IGCM_debug_Print 1 "$EXECUTION" |
---|
1318 | |
---|
1319 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
1320 | } |
---|
1321 | |
---|
1322 | #D-#================================================== |
---|
1323 | #D-function IGCM_sys_check_path |
---|
1324 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
1325 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
1326 | #D-* Examples: |
---|
1327 | #D- |
---|
1328 | function IGCM_sys_check_path { |
---|
1329 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
1330 | if ( $DEBUG_sys ) ; then |
---|
1331 | echo "IGCM_sys_check_path" |
---|
1332 | fi |
---|
1333 | |
---|
1334 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${SCRATCHDIR} ] || [ X${RUN_DIR_PATH} = X${CCCWORKDIR} ] || [ X${RUN_DIR_PATH} = X${CCCSTOREDIR} ] ) ; then |
---|
1335 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
1336 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
1337 | IGCM_debug_Exit "This will stop the job" |
---|
1338 | fi |
---|
1339 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
1340 | } |
---|
1341 | |
---|
1342 | #D-#================================================== |
---|
1343 | #D-function IGCM_sys_check_quota |
---|
1344 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
1345 | #D-* Examples: |
---|
1346 | #D- |
---|
1347 | function IGCM_sys_check_quota { |
---|
1348 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
1349 | if ( $DEBUG_sys ) ; then |
---|
1350 | echo "IGCM_sys_check_quota" |
---|
1351 | fi |
---|
1352 | # Limit of quota (in %) |
---|
1353 | limit_quota=90 |
---|
1354 | |
---|
1355 | # Check of the volume |
---|
1356 | volume_quota=$(ccc_quota | grep ' scratch' | gawk '{print $2}') |
---|
1357 | volume_avail=$(ccc_quota | grep ' scratch' | gawk '{print $3}') |
---|
1358 | |
---|
1359 | if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then |
---|
1360 | |
---|
1361 | unit_avail=${volume_avail: -1} |
---|
1362 | unit_quota=${volume_quota: -1} |
---|
1363 | |
---|
1364 | if [ "${unit_quota}" = "*" ] ; then |
---|
1365 | IGCM_debug_Print 1 "Please, check your quota of volume on scratch" |
---|
1366 | IGCM_debug_Print 1 "More than 100% of your quota is used" |
---|
1367 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
1368 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
1369 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
1370 | IGCM_debug_Verif_Exit |
---|
1371 | fi |
---|
1372 | |
---|
1373 | temp_avail=${volume_avail%%${volume_avail: -1}*} |
---|
1374 | temp_quota=${volume_quota%%${volume_quota: -1}*} |
---|
1375 | |
---|
1376 | if [ ! ${unit_avail} = ${unit_quota} ] ; then |
---|
1377 | |
---|
1378 | # Convertion |
---|
1379 | if [ ${volume_avail: -1} = "T" ] ; then |
---|
1380 | (( temp_avail = temp_avail * 1000000000000 )) |
---|
1381 | elif [ ${volume_avail: -1} = "G" ] ; then |
---|
1382 | (( temp_avail = temp_avail * 1000000000 )) |
---|
1383 | elif [ ${volume_avail: -1} = "M" ] ; then |
---|
1384 | (( temp_avail = temp_avail * 1000000 )) |
---|
1385 | elif [ ${volume_avail: -1} = "k" ] ; then |
---|
1386 | (( temp_avail = temp_avail * 1000 )) |
---|
1387 | else |
---|
1388 | (( temp_avail = volume_avail )) |
---|
1389 | fi |
---|
1390 | if [ ${volume_quota: -1} = "T" ] ; then |
---|
1391 | (( temp_quota = temp_quota * 1000000000000 )) |
---|
1392 | elif [ ${volume_quota: -1} = "G" ] ; then |
---|
1393 | (( temp_quota = temp_quota * 1000000000 )) |
---|
1394 | elif [ ${volume_quota: -1} = "M" ] ; then |
---|
1395 | (( temp_quota = temp_quota * 1000000 )) |
---|
1396 | elif [ ${volume_quota: -1} = "k" ] ; then |
---|
1397 | (( temp_quota = temp_quota * 1000 )) |
---|
1398 | else |
---|
1399 | (( temp_quota = volume_quota )) |
---|
1400 | fi |
---|
1401 | fi |
---|
1402 | |
---|
1403 | quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc) |
---|
1404 | # echo "volume ratio is " $quota_volume |
---|
1405 | |
---|
1406 | if [ ${quota_volume} -ge ${limit_quota} ] ; then |
---|
1407 | IGCM_debug_Print 1 "Please, check your quota of volume on scratch" |
---|
1408 | IGCM_debug_Print 1 "${quota_volume}% of your quota is used" |
---|
1409 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
1410 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
1411 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
1412 | IGCM_debug_Verif_Exit |
---|
1413 | fi |
---|
1414 | |
---|
1415 | fi |
---|
1416 | |
---|
1417 | # Check of the number of inodes |
---|
1418 | |
---|
1419 | inode_quota=$(ccc_quota | grep ' scratch' | gawk '{print $6}') |
---|
1420 | inode_avail=$(ccc_quota | grep ' scratch' | gawk '{print $7}') |
---|
1421 | |
---|
1422 | if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then |
---|
1423 | |
---|
1424 | unit_avail=${inode_avail: -1} |
---|
1425 | unit_quota=${inode_quota: -1} |
---|
1426 | |
---|
1427 | if [ "${unit_quota}" = "*" ] ; then |
---|
1428 | IGCM_debug_Print 1 "Please, check your quota of inode on scratch" |
---|
1429 | IGCM_debug_Print 1 "More than 100% of your quota is used" |
---|
1430 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
1431 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
1432 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
1433 | IGCM_debug_Verif_Exit |
---|
1434 | fi |
---|
1435 | |
---|
1436 | temp_avail=${inode_avail%%${inode_avail: -1}*} |
---|
1437 | temp_quota=${inode_quota%%${inode_quota: -1}*} |
---|
1438 | |
---|
1439 | if [ ! ${unit_avail} = ${unit_quota} ] ; then |
---|
1440 | |
---|
1441 | # Convertion |
---|
1442 | if [ ${inode_avail: -1} = "T" ] ; then |
---|
1443 | (( temp_avail = temp_avail * 1000000000000 )) |
---|
1444 | elif [ ${inode_avail: -1} = "G" ] ; then |
---|
1445 | (( temp_avail = temp_avail * 1000000000 )) |
---|
1446 | elif [ ${inode_avail: -1} = "M" ] ; then |
---|
1447 | (( temp_avail = temp_avail * 1000000 )) |
---|
1448 | elif [ ${inode_avail: -1} = "k" ] ; then |
---|
1449 | (( temp_avail = temp_avail * 1000 )) |
---|
1450 | else |
---|
1451 | (( temp_avail = inode_avail )) |
---|
1452 | fi |
---|
1453 | |
---|
1454 | if [ ${inode_quota: -1} = "T" ] ; then |
---|
1455 | (( temp_quota = temp_quota * 1000000000000 )) |
---|
1456 | elif [ ${inode_quota: -1} = "G" ] ; then |
---|
1457 | (( temp_quota = temp_quota * 1000000000 )) |
---|
1458 | elif [ ${inode_quota: -1} = "M" ] ; then |
---|
1459 | (( temp_quota = temp_quota * 1000000 )) |
---|
1460 | elif [ ${inode_quota: -1} = "k" ] ; then |
---|
1461 | (( temp_quota = temp_quota * 1000 )) |
---|
1462 | else |
---|
1463 | (( temp_quota = inode_quota )) |
---|
1464 | fi |
---|
1465 | fi |
---|
1466 | quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc) |
---|
1467 | # echo "inode ratio is " $quota_inode |
---|
1468 | |
---|
1469 | if [ ${quota_inode} -ge ${limit_quota} ] ; then |
---|
1470 | IGCM_debug_Print 1 "Please, check your quota of inode on scratch" |
---|
1471 | IGCM_debug_Print 1 "${quota_inode}% of your quota is used" |
---|
1472 | IGCM_debug_Print 1 "Use the ccc_quota command to check" |
---|
1473 | IGCM_debug_Print 1 "You must have more than 10% available to run" |
---|
1474 | IGCM_debug_Exit "Not enough space to run ! STOP HERE" |
---|
1475 | IGCM_debug_Verif_Exit |
---|
1476 | fi |
---|
1477 | fi |
---|
1478 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
1479 | } |
---|
1480 | |
---|
1481 | #D-#================================================== |
---|
1482 | #D-function IGCM_sys_GetJobID |
---|
1483 | #D-* Purpose: Check if job_name is currently |
---|
1484 | #D- running or in queue |
---|
1485 | #D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID |
---|
1486 | #D- |
---|
1487 | function IGCM_sys_GetJobID { |
---|
1488 | IGCM_debug_PushStack "IGCM_sys_GetJobID" |
---|
1489 | if ( $DEBUG_sys ) ; then |
---|
1490 | echo "IGCM_sys_GetJobID" |
---|
1491 | fi |
---|
1492 | |
---|
1493 | # With -f option, the full job name is given in the last column |
---|
1494 | ID=$( ccc_mstat -f -u $2 | \ |
---|
1495 | gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' ) |
---|
1496 | |
---|
1497 | eval ${3}=${ID} |
---|
1498 | IGCM_debug_PopStack "IGCM_sys_GetJobID" |
---|
1499 | } |
---|
1500 | |
---|
1501 | #D-#================================================== |
---|
1502 | #D-function IGCM_sys_CountJobInQueue |
---|
1503 | #D-* Purpose: Check if job_name is currently |
---|
1504 | #D- running or in queue |
---|
1505 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
1506 | #D- |
---|
1507 | function IGCM_sys_CountJobInQueue { |
---|
1508 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
1509 | if ( $DEBUG_sys ) ; then |
---|
1510 | echo "IGCM_sys_CountJobInQueue" |
---|
1511 | fi |
---|
1512 | |
---|
1513 | # With -f option, the full job name is given in the last column |
---|
1514 | NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ( $NF ~ JobName ) { x=x+1 } END { print x }' ) |
---|
1515 | |
---|
1516 | eval ${2}=${NbRun} |
---|
1517 | |
---|
1518 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
1519 | } |
---|
1520 | |
---|
1521 | #D-#================================================== |
---|
1522 | #D-function IGCM_sys_ListJobInQueue |
---|
1523 | #D-* Purpose: Check if job_name is currently |
---|
1524 | #D- running or in queue |
---|
1525 | #D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList |
---|
1526 | #D- |
---|
1527 | function IGCM_sys_ListJobInQueue { |
---|
1528 | IGCM_debug_PushStack "IGCM_sys_ListJobInQueue" |
---|
1529 | if ( $DEBUG_sys ) ; then |
---|
1530 | echo "IGCM_sys_ListJobInQueue" |
---|
1531 | fi |
---|
1532 | |
---|
1533 | # With -f option, the full job name is given in the last column |
---|
1534 | set -A JobList $( ccc_mstat -f | gawk -v User=$1 \ |
---|
1535 | '( $2 == User && \ |
---|
1536 | $NF != /TS/ && \ |
---|
1537 | $NF !~ /PACK/ && \ |
---|
1538 | $NF !~ /REBUILD/ && \ |
---|
1539 | $NF !~ /pack/ ) \ |
---|
1540 | { print $NF }' | sed -e "s/\(.*\)\.[0-9]*/\1/" ) |
---|
1541 | |
---|
1542 | eval set -A ${2} ${JobList[*]} |
---|
1543 | |
---|
1544 | IGCM_debug_PopStack "IGCM_sys_ListJobInQueue" |
---|
1545 | } |
---|