[428] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sébastien Denvil |
---|
| 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
[1061] | 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[428] | 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 |
---|
[809] | 16 | # if you use the prefix #D- for comments to be extracted. |
---|
[428] | 17 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
| 18 | #========================================================= |
---|
| 19 | |
---|
| 20 | #D-#================================================== |
---|
| 21 | #D-LibIGCM_sys for IITM IBM machine |
---|
| 22 | #D-#================================================== |
---|
| 23 | #D- |
---|
[809] | 24 | #D- This ksh library if a layer under some usefull |
---|
[428] | 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 | |
---|
[809] | 45 | # | | Cp/Exe/param/files | | | | |
---|
| 46 | # | | Chmod Qsub | | | | |
---|
[428] | 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 | #===================================================== |
---|
[809] | 64 | # Host and user names |
---|
[428] | 65 | # $hostname ou hostname |
---|
[1180] | 66 | typeset HOST=${HOST:=$( hostname )} |
---|
[428] | 67 | # $username ou whoami |
---|
[1180] | 68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
[428] | 69 | # $hostname of the MASTER job |
---|
[1180] | 70 | typeset MASTER=iitm01 |
---|
[428] | 71 | |
---|
| 72 | #D- |
---|
| 73 | #D-#================================================== |
---|
| 74 | #D-Program used in libIGCM |
---|
| 75 | #D-#================================================== |
---|
| 76 | |
---|
[810] | 77 | # Submit command |
---|
| 78 | typeset SUBMIT=${SUBMIT:=/usr/lpp/LoadL/full/bin/llsubmit} |
---|
[428] | 79 | # rsync with path |
---|
| 80 | typeset -r RSYNC=/usr/bin/rsync |
---|
| 81 | # RSYNC_opt args to rsync |
---|
| 82 | typeset -r RSYNC_opt="-va" |
---|
[810] | 83 | # ie storage filesystem |
---|
| 84 | typeset -r STOREHOST=iitm01 |
---|
| 85 | typeset -r REMOTE_RSYNC=/usr/bin/rsync |
---|
[428] | 86 | |
---|
| 87 | #==================================================== |
---|
[1180] | 88 | # Set environment tools (ferret, nco, cdo, rebuild, ...) |
---|
[810] | 89 | #==================================================== |
---|
[1180] | 90 | # Not applicable here. Only rebuild path |
---|
| 91 | export export PATH=${PATH}:/gpfs1/home/sebastien/REBUILD/ |
---|
[810] | 92 | |
---|
| 93 | #==================================================== |
---|
[428] | 94 | # Host specific DIRECTORIES |
---|
| 95 | #==================================================== |
---|
| 96 | |
---|
| 97 | #==================================================== |
---|
[1180] | 98 | #- MirrorlibIGCM for frontend |
---|
[810] | 99 | typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
| 100 | |
---|
| 101 | #==================================================== |
---|
| 102 | #- libIGCM_POST for frontend |
---|
| 103 | typeset -r libIGCM_POST=${libIGCM} |
---|
| 104 | |
---|
| 105 | #==================================================== |
---|
[428] | 106 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
| 107 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
| 108 | |
---|
| 109 | #==================================================== |
---|
| 110 | #- SUBMIT_DIR : submission dir |
---|
| 111 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}} |
---|
| 112 | |
---|
| 113 | #==================================================== |
---|
[725] | 114 | #- IN |
---|
| 115 | typeset -r R_IN=${R_IN:=/gpfs1/home/sabin} |
---|
| 116 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/gpfs1/home/sabin} |
---|
| 117 | |
---|
| 118 | #==================================================== |
---|
[428] | 119 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
[1064] | 120 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" )/RUN/${LOADL_STEP_ID}} |
---|
[428] | 121 | |
---|
| 122 | #==================================================== |
---|
[1179] | 123 | #- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs |
---|
[1186] | 124 | typeset -r OUTCOMMAND_PATH=/tmp |
---|
[1179] | 125 | |
---|
| 126 | #==================================================== |
---|
[428] | 127 | #- HOST_MPIRUN_COMMAND |
---|
[810] | 128 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"} |
---|
[428] | 129 | |
---|
| 130 | #==================================================== |
---|
| 131 | #- Max number of arguments passed to nco operator or demigration command |
---|
| 132 | UNIX_MAX_LIMIT=360 |
---|
| 133 | |
---|
[810] | 134 | #==================================================== |
---|
[1180] | 135 | #- set PackDefault to false on iitm |
---|
[810] | 136 | PackDefault=false |
---|
| 137 | |
---|
| 138 | #==================================================== |
---|
| 139 | #- Number of core per node (max number of OpenMP task) |
---|
| 140 | NUM_COREPERNODE=2 |
---|
| 141 | |
---|
| 142 | #==================================================== |
---|
| 143 | #- Default number of MPI task for IPSL coupled model |
---|
| 144 | #- required for backward compatibility |
---|
| 145 | #- |
---|
| 146 | DEFAULT_NUM_PROC_OCE=5 |
---|
| 147 | DEFAULT_NUM_PROC_CPL=1 |
---|
| 148 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
| 149 | DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} |
---|
| 150 | |
---|
[428] | 151 | #D-#================================================== |
---|
[1057] | 152 | #D-function IGCM_sys_defineArchives |
---|
| 153 | #D-* Purpose: |
---|
| 154 | #D-* Define ARCHIVE : Dedicated to large files |
---|
| 155 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
| 156 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
| 157 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
| 158 | #D-* Define R_BUF : Output tree located on STORAGE hosting files waiting for rebuild or pack processes |
---|
| 159 | #D-* if SpaceName=TEST nothing special will hapen |
---|
[725] | 160 | #D-* Examples: |
---|
| 161 | #D- |
---|
[1057] | 162 | function IGCM_sys_defineArchives { |
---|
| 163 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
| 164 | |
---|
[1060] | 165 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
[1057] | 166 | #==================================================== |
---|
| 167 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 168 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
[1057] | 169 | else |
---|
| 170 | #==================================================== |
---|
| 171 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 172 | ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" ) |
---|
[1057] | 173 | fi |
---|
| 174 | |
---|
[1060] | 175 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
[1057] | 176 | #==================================================== |
---|
| 177 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 178 | STORAGE=${config_UserChoices_STORAGE} |
---|
[1057] | 179 | else |
---|
| 180 | #==================================================== |
---|
| 181 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 182 | STORAGE=${ARCHIVE} |
---|
[1057] | 183 | fi |
---|
| 184 | |
---|
| 185 | # ON OBELIX NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST |
---|
| 186 | |
---|
| 187 | #==================================================== |
---|
| 188 | #- R_OUT |
---|
[1063] | 189 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
[1057] | 190 | |
---|
| 191 | #==================================================== |
---|
| 192 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
[1063] | 193 | R_FIG=${WORKDIR}/IGCM_OUT |
---|
[1057] | 194 | |
---|
| 195 | #==================================================== |
---|
| 196 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
[1063] | 197 | R_BUF=${WORKDIR}/IGCM_OUT |
---|
[1057] | 198 | |
---|
| 199 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
| 200 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
| 201 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
| 202 | |
---|
| 203 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
[725] | 204 | } |
---|
| 205 | |
---|
| 206 | #D-#================================================== |
---|
[428] | 207 | #D-function IGCM_sys_RshArchive |
---|
| 208 | #D-* Purpose: Archive rsh command |
---|
| 209 | #D-* Examples: |
---|
| 210 | #D- |
---|
| 211 | function IGCM_sys_RshArchive { |
---|
[810] | 212 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
[811] | 213 | /bin/ksh <<-EOF |
---|
[428] | 214 | ${@} |
---|
| 215 | EOF |
---|
[811] | 216 | status=$? |
---|
[810] | 217 | if [ ${status} -gt 0 ] ; then |
---|
| 218 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
| 219 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
| 220 | fi |
---|
| 221 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
[428] | 222 | } |
---|
| 223 | |
---|
| 224 | #D-#================================================== |
---|
[1180] | 225 | #D-function IGCM_sys_RshArchive_NoError |
---|
| 226 | #D-* Purpose: Archive rsh command, without error |
---|
| 227 | #D-* used only in monitoring.job |
---|
| 228 | #D-* Examples: |
---|
| 229 | #D- |
---|
| 230 | function IGCM_sys_RshArchive_NoError { |
---|
| 231 | IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ |
---|
| 232 | /bin/ksh <<-EOF |
---|
| 233 | ${@} 2> /dev/null |
---|
| 234 | EOF |
---|
| 235 | IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | #D-#================================================== |
---|
[428] | 239 | #D-function IGCM_sys_MkdirArchive |
---|
| 240 | #D-* Purpose: Mkdir on Archive |
---|
| 241 | #D-* Examples: |
---|
| 242 | #D- |
---|
| 243 | function IGCM_sys_MkdirArchive { |
---|
[810] | 244 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
| 245 | if ( $DEBUG_sys ) ; then |
---|
| 246 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
| 247 | fi |
---|
| 248 | #- creation de repertoire sur le serveur fichier |
---|
[1180] | 249 | if [ ! -d ${1} ]; then |
---|
| 250 | \mkdir -p $1 |
---|
| 251 | status=$? |
---|
[428] | 252 | |
---|
[1180] | 253 | if [ ${status} -gt 0 ] ; then |
---|
| 254 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
| 255 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
| 256 | fi |
---|
[810] | 257 | fi |
---|
| 258 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
[428] | 259 | } |
---|
| 260 | |
---|
| 261 | #D-#================================================== |
---|
| 262 | #D-function IGCM_sys_TestDirArchive |
---|
| 263 | #D-* Purpose: Test Directory that must exists on Archive |
---|
| 264 | #D-* Examples: |
---|
| 265 | #D- |
---|
| 266 | function IGCM_sys_TestDirArchive { |
---|
[810] | 267 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
| 268 | if ( $DEBUG_sys ) ; then |
---|
| 269 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
| 270 | fi |
---|
| 271 | typeset ExistFlag |
---|
| 272 | ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" ) |
---|
| 273 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
| 274 | return ${ExistFlag} |
---|
| 275 | } |
---|
[428] | 276 | |
---|
[810] | 277 | #D-#================================================== |
---|
| 278 | #D-function IGCM_sys_IsFileArchived |
---|
[1180] | 279 | #D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only |
---|
[810] | 280 | #D-* Examples: |
---|
| 281 | #D- |
---|
| 282 | function IGCM_sys_IsFileArchived { |
---|
| 283 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
| 284 | if ( $DEBUG_sys ) ; then |
---|
| 285 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
| 286 | fi |
---|
| 287 | typeset IsArchivedFlag |
---|
[818] | 288 | IsArchivedFlag=$( [ "X$( echo $@ | grep \/gpfs3 )" != "X" ] && echo 0 || echo 1 ) |
---|
[810] | 289 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
| 290 | |
---|
| 291 | return ${IsArchivedFlag} |
---|
[428] | 292 | } |
---|
| 293 | |
---|
| 294 | #D-#================================================== |
---|
| 295 | #D-function IGCM_sys_TestFileArchive |
---|
| 296 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 297 | #D-* Examples: |
---|
| 298 | #D- |
---|
| 299 | function IGCM_sys_TestFileArchive { |
---|
[810] | 300 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
| 301 | typeset ExistFlag |
---|
| 302 | ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) |
---|
| 303 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
[428] | 304 | |
---|
[810] | 305 | return ${ExistFlag} |
---|
[428] | 306 | } |
---|
| 307 | |
---|
| 308 | #D-#================================================== |
---|
| 309 | #D-function IGCM_sys_CountFileArchive |
---|
| 310 | #D-* Purpose: Count files on Archive filesystem |
---|
| 311 | #D-* Examples: |
---|
| 312 | #D- |
---|
| 313 | function IGCM_sys_CountFileArchive { |
---|
[810] | 314 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
| 315 | #Command depends on targeted file system |
---|
| 316 | DEBUG_sys=false IGCM_sys_IsFileArchived $1 |
---|
| 317 | if [ $? = 0 ] ; then |
---|
[428] | 318 | IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" |
---|
[810] | 319 | status=$? |
---|
| 320 | else |
---|
| 321 | ls ${@} 2>/dev/null | wc -l |
---|
| 322 | status=$? |
---|
| 323 | fi |
---|
| 324 | if [ ${status} -gt 0 ] ; then |
---|
| 325 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
| 326 | fi |
---|
| 327 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
[428] | 328 | } |
---|
| 329 | |
---|
| 330 | #D-#================================================== |
---|
| 331 | #D-function IGCM_sys_Qsub |
---|
| 332 | #D-* Purpose: Qsub new job |
---|
| 333 | #D-* Examples: |
---|
| 334 | #D- |
---|
| 335 | function IGCM_sys_Qsub { |
---|
[810] | 336 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
| 337 | |
---|
[811] | 338 | typeset status |
---|
[810] | 339 | |
---|
| 340 | if ( $DEBUG_sys ) ; then |
---|
| 341 | echo "IGCM_sys_Qsub :" $@ |
---|
| 342 | fi |
---|
| 343 | # We have to change output/error file |
---|
| 344 | [ ${#@} = 1 ] && REP_FOR_JOB=${SUBMIT_DIR} |
---|
| 345 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 346 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \ |
---|
[811] | 347 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:" \ |
---|
| 348 | $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
[1179] | 349 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ; |
---|
[810] | 350 | |
---|
[1179] | 351 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[811] | 352 | if [ ${status} -gt 0 ] ; then |
---|
| 353 | IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}" |
---|
[810] | 354 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
| 355 | else |
---|
[1179] | 356 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g ) |
---|
[810] | 357 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 358 | fi |
---|
| 359 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
[428] | 360 | } |
---|
| 361 | |
---|
| 362 | #D-#================================================== |
---|
| 363 | #D-function IGCM_sys_QsubPost |
---|
| 364 | #D-* Purpose: Qsub new job on scalaire |
---|
| 365 | #D-* Examples: |
---|
| 366 | #D- |
---|
| 367 | function IGCM_sys_QsubPost { |
---|
[810] | 368 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
| 369 | |
---|
[811] | 370 | typeset status |
---|
[810] | 371 | |
---|
| 372 | if ( $DEBUG_sys ) ; then |
---|
| 373 | echo "IGCM_sys_QsubPost :" $@ |
---|
| 374 | fi |
---|
| 375 | # We have to change output/error file |
---|
| 376 | [ ${#@} = 1 ] && REP_FOR_JOB=${POST_DIR} |
---|
| 377 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 378 | |
---|
| 379 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \ |
---|
[811] | 380 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:" \ |
---|
| 381 | ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
[810] | 382 | |
---|
[1179] | 383 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ; |
---|
[948] | 384 | |
---|
[1179] | 385 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[811] | 386 | if [ ${status} -gt 0 ] ; then |
---|
| 387 | IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}" |
---|
[810] | 388 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
| 389 | else |
---|
[1179] | 390 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g ) |
---|
[810] | 391 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 392 | fi |
---|
| 393 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
[428] | 394 | } |
---|
| 395 | |
---|
| 396 | #D-************************* |
---|
[809] | 397 | #D- File transfer functions |
---|
[428] | 398 | #D-************************* |
---|
| 399 | #D- |
---|
| 400 | |
---|
| 401 | #D-#================================================== |
---|
| 402 | #D-function IGCM_sys_RmRunDir |
---|
| 403 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
| 404 | #D- scheduler will do the job) |
---|
| 405 | #D-* Examples: |
---|
| 406 | #D- |
---|
| 407 | function IGCM_sys_RmRunDir { |
---|
[1057] | 408 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
[810] | 409 | if ( $DEBUG_sys ) ; then |
---|
| 410 | echo "IGCM_sys_RmRunDir :" $@ |
---|
| 411 | fi |
---|
[428] | 412 | |
---|
[810] | 413 | typeset status |
---|
[428] | 414 | |
---|
[1179] | 415 | echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 416 | \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 417 | status=$? |
---|
[428] | 418 | |
---|
[810] | 419 | if [ ${status} -gt 0 ] ; then |
---|
[1183] | 420 | IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}." |
---|
[1179] | 421 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 422 | IGCM_debug_Exit "IGCM_sys_RmRunDir" |
---|
| 423 | else |
---|
[1179] | 424 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 425 | fi |
---|
| 426 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
[428] | 427 | } |
---|
| 428 | |
---|
| 429 | #D-#================================================== |
---|
| 430 | #D-function IGCM_sys_Put_Dir |
---|
| 431 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
| 432 | #D-* Examples: |
---|
| 433 | #D- |
---|
| 434 | function IGCM_sys_Put_Dir { |
---|
[810] | 435 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
| 436 | if ( $DEBUG_sys ) ; then |
---|
| 437 | echo "IGCM_sys_Put_Dir :" $@ |
---|
| 438 | fi |
---|
| 439 | if [ $DRYRUN = 0 ]; then |
---|
| 440 | if [ ! -d ${1} ] ; then |
---|
| 441 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
| 442 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
| 443 | return |
---|
[428] | 444 | fi |
---|
| 445 | |
---|
[810] | 446 | typeset status |
---|
[428] | 447 | |
---|
[810] | 448 | # Only if we use rsync |
---|
| 449 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
| 450 | # |
---|
| 451 | #USUAL WAY |
---|
[1179] | 452 | \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 453 | status=$? |
---|
[428] | 454 | |
---|
[810] | 455 | if [ ${status} -gt 0 ] ; then |
---|
| 456 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
[1179] | 457 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 458 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
[428] | 459 | else |
---|
[1179] | 460 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 461 | fi |
---|
[810] | 462 | fi |
---|
| 463 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
[428] | 464 | } |
---|
| 465 | |
---|
| 466 | #D-#================================================== |
---|
| 467 | #D-function IGCM_sys_Get_Dir |
---|
[810] | 468 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
[428] | 469 | #D-* Examples: |
---|
| 470 | #D- |
---|
| 471 | function IGCM_sys_Get_Dir { |
---|
[810] | 472 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
| 473 | if ( $DEBUG_sys ) ; then |
---|
| 474 | echo "IGCM_sys_Get_Dir :" $@ |
---|
| 475 | fi |
---|
| 476 | if [ $DRYRUN = 0 ]; then |
---|
| 477 | if [ ! -d ${1} ] ; then |
---|
| 478 | echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
| 479 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
| 480 | return |
---|
[428] | 481 | fi |
---|
| 482 | |
---|
[810] | 483 | typeset status |
---|
[428] | 484 | |
---|
[811] | 485 | #USUAL WAY |
---|
[1179] | 486 | \cp -ur $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 487 | status=$? |
---|
[428] | 488 | |
---|
[810] | 489 | if [ ${status} -gt 0 ] ; then |
---|
| 490 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
[1179] | 491 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 492 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
[428] | 493 | else |
---|
[1179] | 494 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 495 | fi |
---|
[810] | 496 | fi |
---|
| 497 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
[428] | 498 | } |
---|
| 499 | |
---|
| 500 | #D-#================================================== |
---|
| 501 | #D-function IGCM_sys_Put_Rest |
---|
[810] | 502 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
[428] | 503 | #D- File and target directory must exist. |
---|
| 504 | #D-* Examples: |
---|
| 505 | #D- |
---|
| 506 | function IGCM_sys_Put_Rest { |
---|
[810] | 507 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
| 508 | if ( $DEBUG_sys ) ; then |
---|
| 509 | echo "IGCM_sys_Put_Rest :" $@ |
---|
| 510 | fi |
---|
| 511 | if [ $DRYRUN = 0 ]; then |
---|
| 512 | if [ ! -f ${1} ] ; then |
---|
| 513 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
| 514 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 515 | fi |
---|
| 516 | |
---|
[810] | 517 | typeset status |
---|
| 518 | # |
---|
| 519 | if [ X${JobType} = XRUN ] ; then |
---|
| 520 | IGCM_sys_Chmod 444 ${1} |
---|
| 521 | fi |
---|
| 522 | # |
---|
| 523 | # Only if we use rsync |
---|
| 524 | #IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 525 | # |
---|
| 526 | #USUAL WAY |
---|
[1179] | 527 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 528 | status=$? |
---|
[428] | 529 | |
---|
[810] | 530 | if [ ${status} -gt 0 ] ; then |
---|
[1180] | 531 | IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
[1179] | 532 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 533 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 534 | else |
---|
[1179] | 535 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 536 | fi |
---|
[810] | 537 | fi |
---|
| 538 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
[428] | 539 | } |
---|
| 540 | |
---|
| 541 | #D-#================================================== |
---|
| 542 | #D-function IGCM_sys_Put_Out |
---|
[810] | 543 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
[428] | 544 | #D-* Examples: |
---|
| 545 | #D- |
---|
| 546 | function IGCM_sys_Put_Out { |
---|
[810] | 547 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
| 548 | if ( $DEBUG_sys ) ; then |
---|
| 549 | echo "IGCM_sys_Put_Out :" $@ |
---|
| 550 | fi |
---|
| 551 | |
---|
| 552 | typeset status |
---|
| 553 | |
---|
| 554 | if [ $DRYRUN = 0 ]; then |
---|
| 555 | if [ ! -f ${1} ] ; then |
---|
| 556 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
| 557 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 558 | return 1 |
---|
[428] | 559 | fi |
---|
[810] | 560 | # |
---|
| 561 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 562 | # |
---|
| 563 | if [ X${JobType} = XRUN ] ; then |
---|
| 564 | if [ X${3} = X ] ; then |
---|
| 565 | IGCM_sys_Chmod 444 ${1} |
---|
[786] | 566 | fi |
---|
[810] | 567 | fi |
---|
| 568 | # |
---|
| 569 | #USUAL WAY |
---|
[1179] | 570 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 571 | status=$? |
---|
| 572 | |
---|
| 573 | if [ ${status} -gt 0 ] ; then |
---|
| 574 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}" |
---|
[1179] | 575 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 576 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
| 577 | else |
---|
[1179] | 578 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 579 | fi |
---|
| 580 | fi |
---|
| 581 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 582 | return 0 |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | #D-#================================================== |
---|
[428] | 586 | #D-function IGCM_sys_Get |
---|
| 587 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
| 588 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
| 589 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
| 590 | function IGCM_sys_Get { |
---|
[810] | 591 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
[428] | 592 | |
---|
[810] | 593 | typeset DEST status dm_liste |
---|
[428] | 594 | |
---|
[810] | 595 | if ( $DEBUG_sys ) ; then |
---|
| 596 | echo "IGCM_sys_Get :" $@ |
---|
| 597 | fi |
---|
| 598 | if [ $DRYRUN -le 2 ]; then |
---|
| 599 | if [ X${1} = X'/l' ] ; then |
---|
| 600 | eval set +A dm_liste \${${2}} |
---|
| 601 | else |
---|
| 602 | dm_liste=${1} |
---|
[428] | 603 | fi |
---|
[810] | 604 | eval DEST=\${${#}} |
---|
[428] | 605 | |
---|
[810] | 606 | # test if the (first) file is present in the old computation : |
---|
| 607 | DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]} |
---|
| 608 | if [ $? = 0 ] ; then |
---|
[786] | 609 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
[810] | 610 | status=$? |
---|
| 611 | else |
---|
| 612 | IGCM_sys_TestFileBuffer ${dm_liste[0]} |
---|
| 613 | status=$? |
---|
| 614 | fi |
---|
[428] | 615 | |
---|
[810] | 616 | if [ ${status} -gt 0 ] ; then |
---|
| 617 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
| 618 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 619 | return |
---|
| 620 | fi |
---|
[428] | 621 | |
---|
[810] | 622 | #USUAL WAY |
---|
[1179] | 623 | \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 624 | status=$? |
---|
| 625 | |
---|
| 626 | if [ ${status} -gt 0 ] ; then |
---|
| 627 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
[1179] | 628 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 629 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 630 | else |
---|
[1179] | 631 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 632 | fi |
---|
| 633 | fi |
---|
| 634 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | #D-#================================================== |
---|
[811] | 638 | #D-function IGCM_sys_Dods_Rm |
---|
| 639 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
| 640 | #D-* Examples: |
---|
| 641 | #D- |
---|
| 642 | function IGCM_sys_Dods_Rm { |
---|
| 643 | if ( $DEBUG_sys ) ; then |
---|
| 644 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
| 645 | fi |
---|
| 646 | return 0 |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | #D-#================================================== |
---|
| 650 | #D-function IGCM_sys_Dods_Cp |
---|
| 651 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
| 652 | #D-* Examples: |
---|
| 653 | #D- |
---|
| 654 | function IGCM_sys_Dods_Cp { |
---|
| 655 | if ( $DEBUG_sys ) ; then |
---|
| 656 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
| 657 | fi |
---|
| 658 | return 0 |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | #D-#================================================== |
---|
[810] | 662 | #D-function IGCM_sys_Put_Dods |
---|
| 663 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
| 664 | #D-* Examples: |
---|
| 665 | #D- |
---|
| 666 | function IGCM_sys_Put_Dods { |
---|
| 667 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
| 668 | if ( $DEBUG_sys ) ; then |
---|
| 669 | echo "IGCM_sys_Put_Dods :" $@ |
---|
| 670 | fi |
---|
| 671 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
| 672 | } |
---|
| 673 | |
---|
[428] | 674 | ############################################################## |
---|
| 675 | # REBUILD OPERATOR |
---|
| 676 | |
---|
[810] | 677 | #D-#================================================== |
---|
[1163] | 678 | #D-function IGCM_sys_sync |
---|
| 679 | #D-* Purpose: flush buffer on disk (dummy function on Ada) |
---|
| 680 | #D-* Examples: |
---|
| 681 | #D- |
---|
| 682 | function IGCM_sys_sync { |
---|
| 683 | IGCM_debug_PushStack "IGCM_sys_sync" $@ |
---|
| 684 | if ( $DEBUG_sys ) ; then |
---|
| 685 | echo "IGCM_sys_sync :" $@ |
---|
| 686 | echo "Dummy call, let the system do that." |
---|
| 687 | fi |
---|
| 688 | IGCM_debug_PopStack "IGCM_sys_sync" |
---|
| 689 | } |
---|
| 690 | |
---|
[428] | 691 | ############################################################ |
---|
| 692 | # Activate Running Environnment Variables |
---|
| 693 | |
---|
[810] | 694 | #D-#================================================== |
---|
| 695 | #D-function IGCM_sys_desactiv_variables |
---|
| 696 | #D-* Purpose: set environement variables prior to execution |
---|
| 697 | #D-* Examples: |
---|
| 698 | #D- |
---|
[428] | 699 | function IGCM_sys_activ_variables { |
---|
[810] | 700 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
| 701 | if ( $DEBUG_sys ) ; then |
---|
[811] | 702 | echo "IGCM_sys_activ_variables" |
---|
[810] | 703 | fi |
---|
[428] | 704 | |
---|
| 705 | # -------------------------------------------------------------------- |
---|
| 706 | #D- MPI specifications |
---|
| 707 | # -------------------------------------------------------------------- |
---|
| 708 | |
---|
| 709 | # -------------------------------------------------------------------- |
---|
| 710 | #D- Other specifications |
---|
| 711 | # -------------------------------------------------------------------- |
---|
| 712 | |
---|
[810] | 713 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
[428] | 714 | } |
---|
| 715 | |
---|
| 716 | ############################################################ |
---|
| 717 | # Desactivate Running Environnment Variables |
---|
| 718 | |
---|
[810] | 719 | #D-#================================================== |
---|
| 720 | #D-function IGCM_sys_desactiv_variables |
---|
| 721 | #D-* Purpose: unset environement variables after execution |
---|
| 722 | #D-* Examples: |
---|
| 723 | #D- |
---|
[428] | 724 | function IGCM_sys_desactiv_variables { |
---|
[810] | 725 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
| 726 | if ( $DEBUG_sys ) ; then |
---|
[811] | 727 | echo "IGCM_sys_desactiv_variables" |
---|
[810] | 728 | fi |
---|
[428] | 729 | # -------------------------------------------------------------------- |
---|
| 730 | #D- MPI specifications |
---|
| 731 | # -------------------------------------------------------------------- |
---|
| 732 | |
---|
| 733 | # -------------------------------------------------------------------- |
---|
| 734 | #D- Other specifications |
---|
| 735 | # -------------------------------------------------------------------- |
---|
| 736 | |
---|
[810] | 737 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
| 738 | } |
---|
[809] | 739 | |
---|
[810] | 740 | ############################################################ |
---|
| 741 | # Build MPI/OMP scripts run file (dummy function) |
---|
| 742 | |
---|
| 743 | #D-#================================================== |
---|
| 744 | #D-function IGCM_sys_build_run_file |
---|
| 745 | #D-* Purpose: build run file (deprecated) |
---|
| 746 | #D-* Examples: |
---|
| 747 | #D- |
---|
| 748 | function IGCM_sys_build_run_file { |
---|
| 749 | |
---|
[811] | 750 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
[810] | 751 | |
---|
[428] | 752 | } |
---|
| 753 | |
---|
| 754 | ############################################################ |
---|
[810] | 755 | # Build MPI/OMP scripts |
---|
[428] | 756 | |
---|
[810] | 757 | #D-#================================================== |
---|
| 758 | #D-function IGCM_sys_build_execution_scripts |
---|
| 759 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
| 760 | #D-* Examples: |
---|
| 761 | #D- |
---|
| 762 | function IGCM_sys_build_execution_scripts |
---|
| 763 | { |
---|
| 764 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
| 765 | if ( $DEBUG_sys ) ; then |
---|
| 766 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
| 767 | fi |
---|
| 768 | |
---|
| 769 | typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count |
---|
| 770 | |
---|
| 771 | if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then |
---|
| 772 | IGCM_debug_Exit "IGCM_sys_iitm build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} " |
---|
| 773 | fi |
---|
| 774 | |
---|
| 775 | if ( ${OK_PARA_MPMD} ) ; then |
---|
| 776 | |
---|
| 777 | if [ -f run_file ] ; then |
---|
| 778 | IGCM_sys_Rm -f run_file |
---|
| 779 | fi |
---|
| 780 | touch run_file |
---|
| 781 | |
---|
| 782 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 783 | # NEW : 2 Noeuds |
---|
| 784 | # @ task_geometry={(0)(1,2,3)} |
---|
| 785 | # Nombre de processus demandes |
---|
| 786 | echo "Job_${config_UserChoices_JobName} includes task_geometry = \c" |
---|
| 787 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" |
---|
| 788 | echo "Job_${config_UserChoices_JobName} includes task_geometry with NbNodes = \c" |
---|
| 789 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c |
---|
| 790 | NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 )) |
---|
| 791 | |
---|
| 792 | if [ ${NbNodes_Job} -eq 0 ] ; then |
---|
| 793 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run." |
---|
| 794 | exit 1 |
---|
| 795 | fi |
---|
| 796 | else |
---|
| 797 | |
---|
| 798 | # OLD : |
---|
| 799 | # @ total_tasks = 3 |
---|
| 800 | # @ environment = "BATCH_NUM_PROC_TOT=3" |
---|
| 801 | # Pas d OpenMP |
---|
| 802 | # @ resources = ConsumableCpus(1) |
---|
| 803 | |
---|
| 804 | echo "Job_${config_UserChoices_JobName} includes total_tasks = \c" |
---|
| 805 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" |
---|
| 806 | NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" ) |
---|
| 807 | NbProc_Job=${NbProc_Job:=0} |
---|
| 808 | if [ ${NbProc_Job} -eq 0 ] ; then |
---|
| 809 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run." |
---|
| 810 | exit 1 |
---|
| 811 | fi |
---|
| 812 | if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then |
---|
| 813 | IGCM_debug_Print 2 "ressources = ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}" |
---|
| 814 | else |
---|
| 815 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) " |
---|
| 816 | exit 1 |
---|
| 817 | fi |
---|
| 818 | fi |
---|
| 819 | |
---|
| 820 | # run_file construction |
---|
| 821 | |
---|
| 822 | # Then first loop on the components for the coupler ie oasis |
---|
| 823 | |
---|
| 824 | ### the coupler ie oasis must be the first one |
---|
| 825 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 826 | |
---|
| 827 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 828 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 829 | |
---|
| 830 | # for CPL component only |
---|
| 831 | if [ "X${comp}" = "XCPL" ] ; then |
---|
| 832 | |
---|
| 833 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 834 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 835 | |
---|
| 836 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 837 | (( mpi_count = 1 )) |
---|
| 838 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 839 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 840 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 841 | else |
---|
| 842 | echo "./${ExeNameOut}" >> run_file |
---|
| 843 | fi |
---|
| 844 | (( mpi_count = mpi_count + 1 )) |
---|
| 845 | done |
---|
| 846 | else |
---|
| 847 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 848 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 849 | else |
---|
| 850 | echo "./${ExeNameOut} " >> run_file |
---|
| 851 | fi |
---|
| 852 | fi |
---|
| 853 | fi |
---|
| 854 | done |
---|
| 855 | |
---|
| 856 | # Then second loop on the components |
---|
| 857 | |
---|
| 858 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 859 | |
---|
| 860 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 861 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 862 | |
---|
| 863 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
| 864 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
| 865 | |
---|
| 866 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 867 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 868 | |
---|
| 869 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 870 | (( mpi_count = 1 )) |
---|
| 871 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 872 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 873 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 874 | else |
---|
| 875 | echo "./${ExeNameOut}" >> run_file |
---|
| 876 | fi |
---|
| 877 | (( mpi_count = mpi_count + 1 )) |
---|
| 878 | done |
---|
| 879 | else |
---|
| 880 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 881 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 882 | else |
---|
| 883 | # to be tested : no MPI only OpenMP into MPMD mode |
---|
| 884 | echo "./${ExeNameOut} " >> run_file |
---|
| 885 | fi |
---|
| 886 | fi |
---|
| 887 | fi |
---|
| 888 | done |
---|
| 889 | |
---|
| 890 | EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file" |
---|
| 891 | |
---|
| 892 | IGCM_sys_Chmod u+x run_file |
---|
[428] | 893 | if ( $DEBUG_sys ) ; then |
---|
[810] | 894 | echo "run_file contains : " |
---|
| 895 | cat run_file |
---|
[428] | 896 | fi |
---|
| 897 | |
---|
[1180] | 898 | # Only one executable (SPMD mode). |
---|
| 899 | else |
---|
[428] | 900 | |
---|
[810] | 901 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[428] | 902 | |
---|
[810] | 903 | # Only if we really have an executable for the component : |
---|
| 904 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 905 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
| 906 | EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}" |
---|
| 907 | fi |
---|
[786] | 908 | |
---|
[810] | 909 | done |
---|
[428] | 910 | |
---|
[810] | 911 | fi |
---|
[428] | 912 | |
---|
[811] | 913 | IGCM_debug_Print 1 "sys iitm : execution command is" |
---|
[810] | 914 | IGCM_debug_Print 1 "$EXECUTION" |
---|
[428] | 915 | |
---|
[810] | 916 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
[428] | 917 | } |
---|
[651] | 918 | |
---|
[933] | 919 | #D-#================================================== |
---|
| 920 | #D-function IGCM_sys_check_path |
---|
| 921 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
| 922 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
| 923 | #D-* Examples: |
---|
| 924 | #D- |
---|
| 925 | function IGCM_sys_check_path { |
---|
| 926 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
| 927 | if ( $DEBUG_sys ) ; then |
---|
| 928 | echo "IGCM_sys_check_path" |
---|
| 929 | fi |
---|
[810] | 930 | |
---|
[933] | 931 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then |
---|
| 932 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
| 933 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
[936] | 934 | IGCM_debug_Exit "This will stop the job" |
---|
[933] | 935 | fi |
---|
| 936 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
| 937 | } |
---|
| 938 | |
---|
[810] | 939 | #D-#================================================== |
---|
| 940 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
| 941 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
| 942 | #D-* Examples: |
---|
| 943 | #D- |
---|
[651] | 944 | function IGCM_sys_check_quota { |
---|
[810] | 945 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
| 946 | if ( $DEBUG_sys ) ; then |
---|
| 947 | echo "IGCM_sys_check_quota" |
---|
| 948 | fi |
---|
| 949 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | #D-#================================================== |
---|
| 953 | #D-function IGCM_sys_CountJobInQueue |
---|
| 954 | #D-* Purpose: Check if job_name is currently |
---|
| 955 | #D- running or in queue |
---|
| 956 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
| 957 | #D- |
---|
| 958 | function IGCM_sys_CountJobInQueue { |
---|
| 959 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
| 960 | if ( $DEBUG_sys ) ; then |
---|
| 961 | echo "IGCM_sys_CountJobInQueue" |
---|
| 962 | fi |
---|
| 963 | |
---|
| 964 | # Print only the full (-W) JobName (%jn) |
---|
| 965 | NbRun=$( llq -W -f %jn | grep -c "$1" ) |
---|
| 966 | |
---|
| 967 | eval ${2}=${NbRun} |
---|
| 968 | |
---|
| 969 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
| 970 | } |
---|