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