[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 | #===================================================== |
---|
[1300] | 64 | # Host user names project maxCpuTime |
---|
[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 | #==================================================== |
---|
[1300] | 138 | #- set PackDefault to false on the default machine |
---|
[1180] | 139 | PackDefault=false |
---|
| 140 | |
---|
| 141 | #==================================================== |
---|
[664] | 142 | #- Default number of MPI task for IPSL coupled model |
---|
| 143 | #- required for backward compatibility |
---|
| 144 | #- |
---|
[1300] | 145 | DEFAULT_NUM_PROC_OCE=5 |
---|
[664] | 146 | DEFAULT_NUM_PROC_CPL=1 |
---|
| 147 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
| 148 | |
---|
[2] | 149 | #D-#================================================== |
---|
[1057] | 150 | #D-function IGCM_sys_defineArchives |
---|
| 151 | #D-* Purpose: |
---|
| 152 | #D-* Define ARCHIVE : Dedicated to large files |
---|
| 153 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
| 154 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
| 155 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
| 156 | #D-* Define R_BUF : Output tree located on STORAGE hosting files waiting for rebuild or pack processes |
---|
| 157 | #D-* if SpaceName=TEST nothing special will hapen |
---|
[725] | 158 | #D-* Examples: |
---|
| 159 | #D- |
---|
[1057] | 160 | function IGCM_sys_defineArchives { |
---|
| 161 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
| 162 | |
---|
[1060] | 163 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
[1057] | 164 | #==================================================== |
---|
| 165 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 166 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
[1057] | 167 | else |
---|
| 168 | #==================================================== |
---|
| 169 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 170 | ARCHIVE=${ARCHIVE:=/home/${LOGIN}} |
---|
[1057] | 171 | fi |
---|
| 172 | |
---|
[1060] | 173 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
[1057] | 174 | #==================================================== |
---|
| 175 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 176 | STORAGE=${config_UserChoices_STORAGE} |
---|
[1057] | 177 | else |
---|
| 178 | #==================================================== |
---|
| 179 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 180 | STORAGE=${ARCHIVE} |
---|
[1057] | 181 | fi |
---|
| 182 | |
---|
[1178] | 183 | # ON DEFAULT MACHINE NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST |
---|
[1057] | 184 | |
---|
| 185 | #==================================================== |
---|
| 186 | #- R_OUT |
---|
[1063] | 187 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
[1057] | 188 | |
---|
| 189 | #==================================================== |
---|
| 190 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
[1063] | 191 | R_FIG=${STORAGE}/IGCM_OUT |
---|
[1057] | 192 | |
---|
| 193 | #==================================================== |
---|
| 194 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
[1063] | 195 | R_BUF=${STORAGE}/IGCM_OUT |
---|
[1057] | 196 | |
---|
| 197 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
| 198 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
| 199 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
| 200 | |
---|
| 201 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
[725] | 202 | } |
---|
| 203 | |
---|
| 204 | #D-#================================================== |
---|
[37] | 205 | #D-function IGCM_sys_RshArchive |
---|
| 206 | #D-* Purpose: Archive rsh command |
---|
| 207 | #D-* Examples: |
---|
| 208 | #D- |
---|
| 209 | function IGCM_sys_RshArchive { |
---|
[664] | 210 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
[800] | 211 | /bin/ksh <<-EOF |
---|
[40] | 212 | ${@} |
---|
| 213 | EOF |
---|
[811] | 214 | status=$? |
---|
| 215 | if [ ${status} -gt 0 ] ; then |
---|
| 216 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
[664] | 217 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
| 218 | fi |
---|
| 219 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
[37] | 220 | } |
---|
| 221 | |
---|
| 222 | #D-#================================================== |
---|
[1178] | 223 | #D-function IGCM_sys_RshArchive_NoError |
---|
| 224 | #D-* Purpose: Archive rsh command, without error |
---|
| 225 | #D-* used only in monitoring.job |
---|
| 226 | #D-* Examples: |
---|
| 227 | #D- |
---|
| 228 | function IGCM_sys_RshArchive_NoError { |
---|
| 229 | IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ |
---|
| 230 | /bin/ksh <<-EOF |
---|
[1181] | 231 | ${@} 2> /dev/null |
---|
[1178] | 232 | EOF |
---|
| 233 | IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | #D-#================================================== |
---|
[2] | 237 | #D-function IGCM_sys_MkdirArchive |
---|
| 238 | #D-* Purpose: Mkdir on Archive |
---|
| 239 | #D-* Examples: |
---|
| 240 | #D- |
---|
| 241 | function IGCM_sys_MkdirArchive { |
---|
[664] | 242 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
| 243 | if ( $DEBUG_sys ) ; then |
---|
| 244 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
| 245 | fi |
---|
[800] | 246 | #- creation de repertoire sur le serveur fichier |
---|
[1178] | 247 | if [ ! -d ${1} ]; then |
---|
| 248 | \mkdir -p $1 |
---|
| 249 | status=$? |
---|
[811] | 250 | |
---|
[1178] | 251 | if [ ${status} -gt 0 ] ; then |
---|
| 252 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
| 253 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
| 254 | fi |
---|
[664] | 255 | fi |
---|
| 256 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
[2] | 257 | } |
---|
| 258 | |
---|
| 259 | #D-#================================================== |
---|
| 260 | #D-function IGCM_sys_TestDirArchive |
---|
| 261 | #D-* Purpose: Test Directory that must exists on Archive |
---|
| 262 | #D-* Examples: |
---|
| 263 | #D- |
---|
| 264 | function IGCM_sys_TestDirArchive { |
---|
[664] | 265 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
| 266 | if ( $DEBUG_sys ) ; then |
---|
| 267 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
| 268 | fi |
---|
| 269 | typeset ExistFlag |
---|
| 270 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
| 271 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
| 272 | return ${ExistFlag} |
---|
[2] | 273 | } |
---|
| 274 | |
---|
| 275 | #D-#================================================== |
---|
[800] | 276 | #D-function IGCM_sys_IsFileArchived |
---|
[1180] | 277 | #D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only |
---|
[800] | 278 | #D-* Examples: |
---|
| 279 | #D- |
---|
| 280 | function IGCM_sys_IsFileArchived { |
---|
| 281 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
| 282 | if ( $DEBUG_sys ) ; then |
---|
| 283 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
| 284 | fi |
---|
| 285 | typeset IsArchivedFlag |
---|
| 286 | # Never archived for this system |
---|
| 287 | IsArchivedFlag=1 |
---|
| 288 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
| 289 | |
---|
| 290 | return ${IsArchivedFlag} |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | #D-#================================================== |
---|
[2] | 294 | #D-function IGCM_sys_TestFileArchive |
---|
| 295 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 296 | #D-* Examples: |
---|
| 297 | #D- |
---|
| 298 | function IGCM_sys_TestFileArchive { |
---|
[664] | 299 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
| 300 | typeset ExistFlag |
---|
| 301 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
| 302 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
[67] | 303 | |
---|
[664] | 304 | return ${ExistFlag} |
---|
[67] | 305 | } |
---|
| 306 | |
---|
| 307 | #D-#================================================== |
---|
| 308 | #D-function IGCM_sys_CountFileArchive |
---|
| 309 | #D-* Purpose: Count files on Archive filesystem |
---|
| 310 | #D-* Examples: |
---|
| 311 | #D- |
---|
| 312 | function IGCM_sys_CountFileArchive { |
---|
[664] | 313 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
| 314 | ls ${@} 2>/dev/null | wc -l |
---|
| 315 | if [ $? -gt 0 ] ; then |
---|
| 316 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
| 317 | fi |
---|
| 318 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
[2] | 319 | } |
---|
| 320 | |
---|
| 321 | #D-#================================================== |
---|
| 322 | #D-function IGCM_sys_Tree |
---|
| 323 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
| 324 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
| 325 | #D- |
---|
| 326 | function IGCM_sys_Tree { |
---|
[664] | 327 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
| 328 | if ( $DEBUG_sys ) ; then |
---|
| 329 | echo "IGCM_sys_Tree :" $@ |
---|
| 330 | fi |
---|
[2] | 331 | |
---|
[1300] | 332 | \ls -lR ${@} |
---|
[2] | 333 | |
---|
[664] | 334 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
[2] | 335 | } |
---|
| 336 | |
---|
| 337 | #D-#================================================== |
---|
| 338 | #D-function IGCM_sys_Qsub |
---|
| 339 | #D-* Purpose: Qsub new job |
---|
| 340 | #D-* Examples: |
---|
| 341 | #D- |
---|
| 342 | function IGCM_sys_Qsub { |
---|
[664] | 343 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
| 344 | if ( $DEBUG_sys ) ; then |
---|
| 345 | echo "IGCM_sys_Qsub :" $@ |
---|
| 346 | fi |
---|
[800] | 347 | echo "${@} > ${SUBMIT_DIR}/${Script_Output} 2>&1 &" |
---|
| 348 | ${@} > ${SUBMIT_DIR}/${Script_Output} 2>&1 & |
---|
[664] | 349 | if [ $? -gt 0 ] ; then |
---|
[800] | 350 | echo "IGCM_sys_Qsub : erreur ${options} $1" |
---|
[664] | 351 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
| 352 | fi |
---|
| 353 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
[2] | 354 | } |
---|
| 355 | |
---|
| 356 | #D-#================================================== |
---|
| 357 | #D-function IGCM_sys_QsubPost |
---|
| 358 | #D-* Purpose: Qsub new job on scalaire |
---|
| 359 | #D-* Examples: |
---|
| 360 | #D- |
---|
| 361 | function IGCM_sys_QsubPost { |
---|
[664] | 362 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
| 363 | if ( $DEBUG_sys ) ; then |
---|
| 364 | echo "IGCM_sys_QsubPost :" $@ |
---|
| 365 | fi |
---|
| 366 | echo "${libIGCM_POST}/$1.job > ${POST_DIR}/$1.${PeriodDateEnd}.out 2>&1 &" |
---|
| 367 | ${libIGCM_POST}/$1.job > ${POST_DIR}/${Script_Post_Output}.out 2>&1 & |
---|
| 368 | if [ $? -gt 0 ] ; then |
---|
| 369 | echo "IGCM_sys_QsubPost : erreur " $@ |
---|
| 370 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
| 371 | fi |
---|
| 372 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
[2] | 373 | } |
---|
| 374 | |
---|
| 375 | #D-************************* |
---|
[664] | 376 | #D- File transfer functions |
---|
[2] | 377 | #D-************************* |
---|
| 378 | #D- |
---|
| 379 | |
---|
| 380 | #D-#================================================== |
---|
[203] | 381 | #D-function IGCM_sys_RmRunDir |
---|
| 382 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
| 383 | #D- scheduler will do the job) |
---|
| 384 | #D-* Examples: |
---|
| 385 | #D- |
---|
| 386 | function IGCM_sys_RmRunDir { |
---|
[1057] | 387 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
[664] | 388 | if ( $DEBUG_sys ) ; then |
---|
| 389 | echo "IGCM_sys_RmRunDir :" $@ |
---|
[1183] | 390 | IGCM_debug_Print 1 "Dummy call, let the user do that." |
---|
[664] | 391 | fi |
---|
| 392 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
[203] | 393 | } |
---|
| 394 | |
---|
| 395 | #D-#================================================== |
---|
[2] | 396 | #D-function IGCM_sys_Put_Dir |
---|
| 397 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
| 398 | #D-* Examples: |
---|
| 399 | #D- |
---|
| 400 | function IGCM_sys_Put_Dir { |
---|
[664] | 401 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
| 402 | if ( $DEBUG_sys ) ; then |
---|
| 403 | echo "IGCM_sys_Put_Dir :" $@ |
---|
| 404 | fi |
---|
| 405 | if [ $DRYRUN = 0 ]; then |
---|
| 406 | if [ ! -d ${1} ] ; then |
---|
| 407 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
| 408 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
| 409 | return |
---|
[2] | 410 | fi |
---|
| 411 | |
---|
[717] | 412 | typeset status |
---|
[2] | 413 | |
---|
[717] | 414 | # Only if we use rsync |
---|
| 415 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
| 416 | # |
---|
| 417 | #USUAL WAY |
---|
[1179] | 418 | \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[717] | 419 | status=$? |
---|
[2] | 420 | |
---|
[717] | 421 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 422 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
[1179] | 423 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 424 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
[2] | 425 | else |
---|
[1179] | 426 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[2] | 427 | fi |
---|
[664] | 428 | fi |
---|
| 429 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
[2] | 430 | } |
---|
| 431 | |
---|
| 432 | #D-#================================================== |
---|
| 433 | #D-function IGCM_sys_Get_Dir |
---|
[717] | 434 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
[2] | 435 | #D-* Examples: |
---|
| 436 | #D- |
---|
| 437 | function IGCM_sys_Get_Dir { |
---|
[664] | 438 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
| 439 | if ( $DEBUG_sys ) ; then |
---|
| 440 | echo "IGCM_sys_Get_Dir :" $@ |
---|
| 441 | fi |
---|
| 442 | if [ $DRYRUN = 0 ]; then |
---|
[1180] | 443 | typeset NB_ESSAI DELAI status i |
---|
| 444 | # number of tentative |
---|
| 445 | NB_ESSAI=3 |
---|
| 446 | # time delay between tentative |
---|
| 447 | DELAI=2 |
---|
[2] | 448 | |
---|
[1180] | 449 | # |
---|
| 450 | # USUAL WAY |
---|
| 451 | i=0 |
---|
| 452 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 453 | \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 454 | status=$? |
---|
| 455 | if [ ${status} -gt 0 ] ; then |
---|
| 456 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
| 457 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again." |
---|
| 458 | sleep $DELAI |
---|
| 459 | else |
---|
| 460 | break |
---|
| 461 | fi |
---|
| 462 | (( i = i + 1 )) |
---|
| 463 | done |
---|
[2] | 464 | |
---|
[811] | 465 | if [ ${status} -gt 0 ] ; then |
---|
| 466 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
[1179] | 467 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 468 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
[2] | 469 | else |
---|
[1179] | 470 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[2] | 471 | fi |
---|
[664] | 472 | fi |
---|
| 473 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
[2] | 474 | } |
---|
| 475 | |
---|
| 476 | #D-#================================================== |
---|
| 477 | #D-function IGCM_sys_Put_Rest |
---|
[717] | 478 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
[117] | 479 | #D- File and target directory must exist. |
---|
[2] | 480 | #D-* Examples: |
---|
| 481 | #D- |
---|
| 482 | function IGCM_sys_Put_Rest { |
---|
[664] | 483 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
| 484 | if ( $DEBUG_sys ) ; then |
---|
| 485 | echo "IGCM_sys_Put_Rest :" $@ |
---|
| 486 | fi |
---|
| 487 | if [ $DRYRUN = 0 ]; then |
---|
| 488 | if [ ! -f ${1} ] ; then |
---|
| 489 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
| 490 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[2] | 491 | fi |
---|
[717] | 492 | |
---|
| 493 | typeset status |
---|
| 494 | # |
---|
[1178] | 495 | # USUAL WAY |
---|
[1179] | 496 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[717] | 497 | status=$? |
---|
[2] | 498 | |
---|
[717] | 499 | # #RSYNC WITH NETWORK SSH CALL |
---|
[1179] | 500 | # echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 501 | # ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[2] | 502 | |
---|
[717] | 503 | # #RSYNC WITH NFS USE |
---|
[1179] | 504 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 505 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[2] | 506 | |
---|
[717] | 507 | # status=$? |
---|
| 508 | # IGCM_sys_Rsync_out $status |
---|
| 509 | |
---|
[1179] | 510 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[717] | 511 | # (( status=status+$? )) |
---|
| 512 | |
---|
| 513 | if [ ${status} -gt 0 ] ; then |
---|
[1180] | 514 | IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
[1178] | 515 | [ -f ${1} ] && ls -l ${1} |
---|
| 516 | [ -f ${2} ] && ls -l ${2} |
---|
| 517 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
[1179] | 518 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 519 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
| 520 | else |
---|
[1178] | 521 | |
---|
| 522 | if [ X${JobType} = XRUN ] ; then |
---|
| 523 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
| 524 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
| 525 | fi |
---|
| 526 | |
---|
[1179] | 527 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 528 | fi |
---|
| 529 | fi |
---|
| 530 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
| 531 | } |
---|
[2] | 532 | |
---|
[664] | 533 | #D-#================================================== |
---|
[2] | 534 | #D-function IGCM_sys_Put_Out |
---|
[717] | 535 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
[2] | 536 | #D-* Examples: |
---|
| 537 | #D- |
---|
| 538 | function IGCM_sys_Put_Out { |
---|
[664] | 539 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
| 540 | if ( $DEBUG_sys ) ; then |
---|
| 541 | echo "IGCM_sys_Put_Out :" $@ |
---|
| 542 | fi |
---|
[811] | 543 | |
---|
| 544 | typeset status |
---|
| 545 | |
---|
[664] | 546 | if [ $DRYRUN = 0 ]; then |
---|
[811] | 547 | if [ ! -f ${1} ] ; then |
---|
[664] | 548 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
| 549 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 550 | return 1 |
---|
[2] | 551 | fi |
---|
[800] | 552 | # |
---|
[811] | 553 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 554 | # |
---|
[664] | 555 | if [ X${JobType} = XRUN ] ; then |
---|
| 556 | if [ X${3} = X ] ; then |
---|
| 557 | IGCM_sys_Chmod 444 ${1} |
---|
| 558 | fi |
---|
| 559 | fi |
---|
[800] | 560 | # |
---|
[2] | 561 | |
---|
[1179] | 562 | echo ${RSYNC} ${RSYNC_opt} $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 563 | ${RSYNC} ${RSYNC_opt} $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[811] | 564 | status=$? |
---|
| 565 | IGCM_sys_Rsync_out $status |
---|
[2] | 566 | |
---|
[1179] | 567 | ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[811] | 568 | (( status=status+$? )) |
---|
[2] | 569 | |
---|
[811] | 570 | if [ ${status} -gt 0 ] ; then |
---|
| 571 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}" |
---|
[1179] | 572 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 573 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
[2] | 574 | else |
---|
[1179] | 575 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[2] | 576 | fi |
---|
[664] | 577 | fi |
---|
| 578 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 579 | return 0 |
---|
[2] | 580 | } |
---|
| 581 | |
---|
| 582 | #D-#================================================== |
---|
| 583 | #D-function IGCM_sys_Get |
---|
| 584 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
| 585 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
| 586 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
| 587 | function IGCM_sys_Get { |
---|
[664] | 588 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
[2] | 589 | |
---|
[811] | 590 | typeset DEST status dm_liste |
---|
[2] | 591 | |
---|
[664] | 592 | if ( $DEBUG_sys ) ; then |
---|
| 593 | echo "IGCM_sys_Get :" $@ |
---|
| 594 | fi |
---|
| 595 | if [ $DRYRUN -le 2 ]; then |
---|
| 596 | if [ X${1} = X'/l' ] ; then |
---|
| 597 | eval set +A dm_liste \${${2}} |
---|
| 598 | else |
---|
| 599 | dm_liste=${1} |
---|
[2] | 600 | fi |
---|
[664] | 601 | eval DEST=\${${#}} |
---|
[2] | 602 | |
---|
[800] | 603 | # test if the (first) file is present in the old computation : |
---|
[664] | 604 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
[811] | 605 | status=$? |
---|
| 606 | if [ ${status} -gt 0 ] ; then |
---|
[664] | 607 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
| 608 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
[811] | 609 | return |
---|
[664] | 610 | fi |
---|
[2] | 611 | |
---|
[811] | 612 | #USUAL WAY |
---|
[1179] | 613 | \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[811] | 614 | status=$? |
---|
[2] | 615 | |
---|
[811] | 616 | if [ ${status} -gt 0 ] ; then |
---|
| 617 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
[1179] | 618 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[664] | 619 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
[2] | 620 | else |
---|
[1179] | 621 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[2] | 622 | fi |
---|
[664] | 623 | fi |
---|
| 624 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
[2] | 625 | } |
---|
| 626 | |
---|
| 627 | #D-#================================================== |
---|
[1178] | 628 | #D-function IGCM_sys_GetDate_Monitoring |
---|
| 629 | #D-* Purpose: get the last year for which the monitoring has been computed |
---|
| 630 | #D-* Examples: |
---|
| 631 | #D- |
---|
| 632 | function IGCM_sys_GetDate_Monitoring { |
---|
| 633 | IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@ |
---|
| 634 | if ( $DEBUG_sys ) ; then |
---|
| 635 | echo "IGCM_sys_GetDate_Monitoring :" $@ |
---|
| 636 | fi |
---|
| 637 | |
---|
| 638 | eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' ) |
---|
| 639 | |
---|
| 640 | IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring" |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | #D-#================================================== |
---|
[343] | 644 | #D-function IGCM_sys_Dods_Rm |
---|
[717] | 645 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
[343] | 646 | #D-* Examples: |
---|
| 647 | #D- |
---|
| 648 | function IGCM_sys_Dods_Rm { |
---|
[664] | 649 | if ( $DEBUG_sys ) ; then |
---|
| 650 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
| 651 | fi |
---|
| 652 | return 0 |
---|
[343] | 653 | } |
---|
| 654 | |
---|
| 655 | #D-#================================================== |
---|
| 656 | #D-function IGCM_sys_Dods_Cp |
---|
[811] | 657 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
[343] | 658 | #D-* Examples: |
---|
| 659 | #D- |
---|
| 660 | function IGCM_sys_Dods_Cp { |
---|
[664] | 661 | if ( $DEBUG_sys ) ; then |
---|
| 662 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
| 663 | fi |
---|
| 664 | return 0 |
---|
[343] | 665 | } |
---|
| 666 | |
---|
| 667 | #D-#================================================== |
---|
[2] | 668 | #D-function IGCM_sys_Put_Dods |
---|
[811] | 669 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
[2] | 670 | #D-* Examples: |
---|
| 671 | #D- |
---|
| 672 | function IGCM_sys_Put_Dods { |
---|
[664] | 673 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
| 674 | if ( $DEBUG_sys ) ; then |
---|
| 675 | echo "IGCM_sys_Put_Dods :" $@ |
---|
| 676 | fi |
---|
| 677 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
[2] | 678 | } |
---|
| 679 | |
---|
[664] | 680 | ############################################################## |
---|
| 681 | # REBUILD OPERATOR |
---|
[2] | 682 | |
---|
[811] | 683 | #D-#================================================== |
---|
[1163] | 684 | #D-function IGCM_sys_sync |
---|
[1300] | 685 | #D-* Purpose: flush buffer on disk (dummy function on Default machine) |
---|
[1163] | 686 | #D-* Examples: |
---|
| 687 | #D- |
---|
| 688 | function IGCM_sys_sync { |
---|
| 689 | IGCM_debug_PushStack "IGCM_sys_sync" $@ |
---|
| 690 | if ( $DEBUG_sys ) ; then |
---|
| 691 | echo "IGCM_sys_sync :" $@ |
---|
| 692 | echo "Dummy call, let the system do that." |
---|
| 693 | fi |
---|
| 694 | IGCM_debug_PopStack "IGCM_sys_sync" |
---|
| 695 | } |
---|
| 696 | |
---|
[664] | 697 | ############################################################ |
---|
| 698 | # Activate Running Environnment Variables |
---|
| 699 | |
---|
[811] | 700 | #D-#================================================== |
---|
[1239] | 701 | #D-function IGCM_sys_activ_variables |
---|
[811] | 702 | #D-* Purpose: set environement variables prior to execution |
---|
| 703 | #D-* Examples: |
---|
| 704 | #D- |
---|
[664] | 705 | function IGCM_sys_activ_variables { |
---|
| 706 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
| 707 | if ( $DEBUG_sys ) ; then |
---|
| 708 | echo "IGCM_sys_activ_variables" |
---|
| 709 | fi |
---|
[811] | 710 | |
---|
| 711 | # -------------------------------------------------------------------- |
---|
| 712 | #D- MPI specifications |
---|
| 713 | # -------------------------------------------------------------------- |
---|
| 714 | |
---|
| 715 | # -------------------------------------------------------------------- |
---|
| 716 | #D- Other specifications |
---|
| 717 | # -------------------------------------------------------------------- |
---|
| 718 | |
---|
[1300] | 719 | ulimit -s unlimited |
---|
| 720 | |
---|
[664] | 721 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
[2] | 722 | } |
---|
| 723 | |
---|
[664] | 724 | ############################################################ |
---|
| 725 | # Desactivate Running Environnment Variables |
---|
[2] | 726 | |
---|
[811] | 727 | #D-#================================================== |
---|
| 728 | #D-function IGCM_sys_desactiv_variables |
---|
| 729 | #D-* Purpose: unset environement variables after execution |
---|
| 730 | #D-* Examples: |
---|
| 731 | #D- |
---|
[664] | 732 | function IGCM_sys_desactiv_variables { |
---|
| 733 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
| 734 | if ( $DEBUG_sys ) ; then |
---|
| 735 | echo "IGCM_sys_desactiv_variables" |
---|
| 736 | fi |
---|
[811] | 737 | # -------------------------------------------------------------------- |
---|
| 738 | #D- MPI specifications |
---|
| 739 | # -------------------------------------------------------------------- |
---|
| 740 | |
---|
| 741 | # -------------------------------------------------------------------- |
---|
| 742 | #D- Other specifications |
---|
| 743 | # -------------------------------------------------------------------- |
---|
| 744 | |
---|
[664] | 745 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
| 746 | } |
---|
| 747 | |
---|
| 748 | ############################################################ |
---|
[1239] | 749 | # Update job headers to be used by the scheduler |
---|
| 750 | |
---|
| 751 | #D-#================================================== |
---|
| 752 | #D-function IGCM_sys_updateHeaders |
---|
| 753 | #D-* Purpose: Update job headers to be used by the scheduler |
---|
| 754 | #D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP |
---|
| 755 | #D- |
---|
| 756 | function IGCM_sys_updateHeaders { |
---|
| 757 | IGCM_debug_PushStack "IGCM_sys_updateHeaders" |
---|
| 758 | if ( $DEBUG_sys ) ; then |
---|
| 759 | echo "IGCM_sys_updateHeaders" |
---|
| 760 | fi |
---|
| 761 | typeset file |
---|
| 762 | file=$1 |
---|
| 763 | |
---|
| 764 | if [ ${executionType} -eq 1 ] ; then |
---|
| 765 | # MPMD + MPI |
---|
| 766 | sed -e "/::openMPthreads::/d" \ |
---|
| 767 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
| 768 | ${file} > ${file}.tmp |
---|
| 769 | |
---|
| 770 | elif [ ${executionType} -eq 2 ] ; then |
---|
| 771 | # MPMD + MPI + OMP |
---|
| 772 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 773 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
| 774 | ${file} > ${file}.tmp |
---|
| 775 | |
---|
| 776 | elif [ ${executionType} -eq 3 ] ; then |
---|
| 777 | # SPMD + MPI/OMP |
---|
| 778 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 779 | -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
| 780 | ${file} > ${file}.tmp |
---|
| 781 | |
---|
| 782 | elif [ ${executionType} -eq 4 ] ; then |
---|
| 783 | # SPMD + MPI only |
---|
| 784 | sed -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
| 785 | -e "/::openMPthreads::/d" \ |
---|
| 786 | ${file} > ${file}.tmp |
---|
| 787 | |
---|
| 788 | elif [ ${executionType} -eq 5 ] ; then |
---|
| 789 | # SPMD + OMP only |
---|
| 790 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 791 | -e "/::JobNumProcTot::/d" \ |
---|
| 792 | ${file} > ${file}.tmp |
---|
| 793 | |
---|
| 794 | elif [ ${executionType} -eq 6 ] ; then |
---|
| 795 | # SEQUENTIAL THEN |
---|
| 796 | sed -e "s/::JobNumProcTot::/1/" \ |
---|
| 797 | -e "/::openMPthreads::/d" \ |
---|
| 798 | ${file} > ${file}.tmp |
---|
| 799 | |
---|
| 800 | fi |
---|
| 801 | |
---|
| 802 | IGCM_sys_Mv ${file}.tmp ${file} |
---|
| 803 | |
---|
| 804 | IGCM_debug_PopStack "IGCM_sys_updateHeaders" |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | ############################################################ |
---|
[800] | 808 | # Build MPI/OMP scripts run file (dummy function) |
---|
[664] | 809 | |
---|
[811] | 810 | #D-#================================================== |
---|
| 811 | #D-function IGCM_sys_build_run_file |
---|
| 812 | #D-* Purpose: build run file (deprecated) |
---|
| 813 | #D-* Examples: |
---|
| 814 | #D- |
---|
[664] | 815 | function IGCM_sys_build_run_file { |
---|
| 816 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
| 817 | } |
---|
| 818 | |
---|
| 819 | ############################################################ |
---|
| 820 | # Build MPI/OMP scripts |
---|
[811] | 821 | |
---|
| 822 | #D-#================================================== |
---|
| 823 | #D-function IGCM_sys_build_execution_scripts |
---|
| 824 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
| 825 | #D-* Examples: |
---|
| 826 | #D- |
---|
[664] | 827 | function IGCM_sys_build_execution_scripts |
---|
| 828 | { |
---|
| 829 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
| 830 | if ( $DEBUG_sys ) ; then |
---|
| 831 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
| 832 | fi |
---|
[1180] | 833 | |
---|
[1300] | 834 | EXECUTION=${HOST_MPIRUN_COMMAND} |
---|
[664] | 835 | |
---|
[1300] | 836 | # MPMD mode |
---|
[664] | 837 | if ( ${OK_PARA_MPMD} ) ; then |
---|
| 838 | |
---|
[1300] | 839 | # Only MPI (MPMD) |
---|
| 840 | if ( ! ${OK_PARA_OMP} ) ; then |
---|
[664] | 841 | |
---|
[1300] | 842 | if [ -f run_file ] ; then |
---|
| 843 | IGCM_sys_Rm -f run_file |
---|
| 844 | fi |
---|
| 845 | touch run_file |
---|
[664] | 846 | |
---|
[1300] | 847 | # Build run_file |
---|
| 848 | |
---|
| 849 | # First loop on the components for the coupler ie oasis (only if oasis3) |
---|
| 850 | # the coupler ie oasis3 must be the first one |
---|
| 851 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 852 | |
---|
| 853 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 854 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 855 | |
---|
| 856 | # for CPL component only |
---|
| 857 | if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
| 858 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 859 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 860 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file |
---|
| 861 | fi |
---|
| 862 | done |
---|
| 863 | |
---|
| 864 | # Then second loop on the components |
---|
| 865 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 866 | |
---|
| 867 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 868 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 869 | |
---|
| 870 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
| 871 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
| 872 | |
---|
| 873 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 874 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 875 | echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file |
---|
| 876 | fi |
---|
| 877 | done |
---|
| 878 | |
---|
| 879 | EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file" |
---|
| 880 | |
---|
| 881 | IGCM_sys_Chmod u+x run_file |
---|
| 882 | if ( $DEBUG_sys ) ; then |
---|
| 883 | echo "run_file contains : " |
---|
| 884 | cat run_file |
---|
| 885 | fi |
---|
| 886 | |
---|
| 887 | # MPI-OpenMP (MPMD) |
---|
| 888 | else |
---|
| 889 | |
---|
[664] | 890 | # Hosts treatment |
---|
| 891 | ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp |
---|
| 892 | |
---|
| 893 | i=0 |
---|
| 894 | rm -f hosts |
---|
[1300] | 895 | IGCM_debug_Print 1 "sys $( hostname ), Hosts available :" |
---|
[664] | 896 | for nodes in `cat hosts.tmp` ; do |
---|
| 897 | host[$i]=$nodes |
---|
| 898 | echo "${host[$i]} slots=1 max_slots=1" >> hosts |
---|
| 899 | IGCM_debug_Print 1 ${host[$i]} |
---|
| 900 | i=$((i+1)) |
---|
| 901 | done |
---|
| 902 | rm -f hosts.tmp |
---|
| 903 | |
---|
| 904 | listnodes=${host[*]} |
---|
| 905 | |
---|
| 906 | EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts" |
---|
| 907 | |
---|
| 908 | # Initialisation |
---|
[1300] | 909 | rank=0 |
---|
| 910 | current_core=0 |
---|
| 911 | core_per_node=4 |
---|
[664] | 912 | init_exec=n |
---|
| 913 | |
---|
[1300] | 914 | # Loop on the components |
---|
[664] | 915 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 916 | |
---|
[1300] | 917 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 918 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
[664] | 919 | |
---|
[1300] | 920 | # Not possible if oasis has an executable (i.e old version of oasis3) |
---|
| 921 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" = "XCPL" ] ) ; then |
---|
| 922 | IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version" |
---|
| 923 | IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler" |
---|
| 924 | IGCM_debug_Verif_Exit |
---|
[664] | 925 | fi |
---|
| 926 | |
---|
| 927 | # Only if we really have an executable for the component : |
---|
[1300] | 928 | if [ "X${ExeNameOut}" != X\"\" ] ; then |
---|
[664] | 929 | |
---|
| 930 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 931 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 932 | |
---|
| 933 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
| 934 | echo "" >> script_${ExeNameOut}.ksh |
---|
[1300] | 935 | if [ ${comp_proc_omp_loc} -gt 1 ] ; then |
---|
| 936 | |
---|
| 937 | # Check if the number of threads is correct |
---|
| 938 | case ${comp_proc_omp_loc} in |
---|
| 939 | 2|4) |
---|
| 940 | IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads" |
---|
| 941 | ;; |
---|
| 942 | *) |
---|
| 943 | IGCM_debug_Exit "ERROR with OMP parameters !" |
---|
| 944 | IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads" |
---|
| 945 | IGCM_debug_Print 2 "Only 2,4 as number of OMP threads are possible " |
---|
| 946 | IGCM_debug_Verif_Exit |
---|
| 947 | ;; |
---|
| 948 | esac |
---|
| 949 | #echo "export KMP_STACKSIZE=3g" >> script_${ExeNameOut}.ksh |
---|
| 950 | #echo "export KMP_LIBRARY=turnaround" >> script_${ExeNameOut}.ksh |
---|
| 951 | #echo "export MKL_SERIAL=YES" >> script_${ExeNameOut}.ksh |
---|
| 952 | echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh |
---|
| 953 | echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
| 954 | fi |
---|
[1317] | 955 | echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >> script_${ExeNameOut}.ksh |
---|
| 956 | echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh |
---|
| 957 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
[664] | 958 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
| 959 | |
---|
[1300] | 960 | if [ ${init_exec} = y ] ; then |
---|
| 961 | EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
| 962 | else |
---|
| 963 | EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" |
---|
| 964 | init_exec=y |
---|
| 965 | fi |
---|
[664] | 966 | |
---|
[1300] | 967 | # Build rankfile : method used to assign cores and nodes for the MPI process |
---|
| 968 | # Ex : |
---|
| 969 | #rank 0=curie5296 slot=0,1,2,3 |
---|
| 970 | #rank 1=curie5296 slot=4,5,6,7 |
---|
| 971 | # Example of final command : |
---|
| 972 | # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh |
---|
| 973 | # with script_lmdz.x.ksh : |
---|
| 974 | # #!/bin/ksh |
---|
| 975 | #export OMP_STACKSIZE=200M |
---|
| 976 | #export OMP_NUM_THREADS=4 |
---|
| 977 | #./lmdz.x |
---|
[664] | 978 | |
---|
[1300] | 979 | for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do |
---|
| 980 | (( index_host = current_core / core_per_node )) |
---|
| 981 | host_value=${host[${index_host}]} |
---|
| 982 | (( slot = current_core % core_per_node )) |
---|
| 983 | virg="," |
---|
| 984 | string_final="" |
---|
| 985 | for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do |
---|
| 986 | string=$index$virg |
---|
| 987 | string_final=$string_final$string |
---|
| 988 | done |
---|
| 989 | string_final=$( echo $string_final | sed "s/.$//" ) |
---|
| 990 | echo "rank $rank=$host_value slot=$string_final" >> rankfile |
---|
| 991 | (( rank = rank + 1 )) |
---|
| 992 | (( current_core = current_core + comp_proc_omp_loc )) |
---|
[664] | 993 | done |
---|
| 994 | fi |
---|
| 995 | done |
---|
[2] | 996 | fi |
---|
| 997 | |
---|
[1300] | 998 | # Only one executable (SPMD mode). |
---|
| 999 | else |
---|
[664] | 1000 | |
---|
| 1001 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 1002 | |
---|
| 1003 | # Only if we really have an executable for the component : |
---|
| 1004 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 1005 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
| 1006 | |
---|
| 1007 | echo "#!/bin/ksh" > script_${ExeNameOut}.ksh |
---|
| 1008 | echo "" >> script_${ExeNameOut}.ksh |
---|
| 1009 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1010 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
[1300] | 1011 | echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh |
---|
| 1012 | echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh |
---|
[664] | 1013 | fi |
---|
| 1014 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 1015 | # Default : mpirun used if nb_proc gt 1 |
---|
| 1016 | # pour sortie out/err par process |
---|
[1317] | 1017 | echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}" >> script_${ExeNameOut}.ksh |
---|
| 1018 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
[664] | 1019 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
| 1020 | EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh" |
---|
| 1021 | else |
---|
| 1022 | # Default : mpirun is NOT used if nb_proc eq 1 |
---|
| 1023 | # pour sortie out/err par process |
---|
[1317] | 1024 | echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh |
---|
| 1025 | #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh |
---|
[664] | 1026 | IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh |
---|
| 1027 | EXECUTION="time ./script_${ExeNameOut}.ksh" |
---|
| 1028 | fi |
---|
[1178] | 1029 | |
---|
| 1030 | IGCM_debug_Print 1 "sys $( hostname ) : script_${ExeNameOut}.ksh contains" |
---|
| 1031 | cat script_${ExeNameOut}.ksh |
---|
| 1032 | |
---|
[664] | 1033 | fi |
---|
[1180] | 1034 | |
---|
[664] | 1035 | done |
---|
| 1036 | |
---|
| 1037 | fi |
---|
| 1038 | |
---|
[811] | 1039 | IGCM_debug_Print 1 "sys $( hostname ) : execution command is" |
---|
| 1040 | IGCM_debug_Print 1 "$EXECUTION" |
---|
[664] | 1041 | |
---|
| 1042 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
[2] | 1043 | } |
---|
| 1044 | |
---|
[933] | 1045 | #D-#================================================== |
---|
| 1046 | #D-function IGCM_sys_check_path |
---|
| 1047 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
| 1048 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
| 1049 | #D-* Examples: |
---|
| 1050 | #D- |
---|
| 1051 | function IGCM_sys_check_path { |
---|
| 1052 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
| 1053 | if ( $DEBUG_sys ) ; then |
---|
| 1054 | echo "IGCM_sys_check_path" |
---|
| 1055 | fi |
---|
[811] | 1056 | |
---|
[933] | 1057 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then |
---|
| 1058 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
| 1059 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
[936] | 1060 | IGCM_debug_Exit "This will stop the job" |
---|
[933] | 1061 | fi |
---|
| 1062 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
| 1063 | } |
---|
| 1064 | |
---|
[811] | 1065 | #D-#================================================== |
---|
| 1066 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
| 1067 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
| 1068 | #D-* Examples: |
---|
| 1069 | #D- |
---|
[664] | 1070 | function IGCM_sys_check_quota { |
---|
| 1071 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
| 1072 | if ( $DEBUG_sys ) ; then |
---|
| 1073 | echo "IGCM_sys_check_quota" |
---|
| 1074 | fi |
---|
[1300] | 1075 | |
---|
| 1076 | # TO BE IMPLEMENTED |
---|
| 1077 | |
---|
[664] | 1078 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
| 1079 | } |
---|
| 1080 | |
---|
[811] | 1081 | #D-#================================================== |
---|
[1286] | 1082 | #D-function IGCM_sys_projectAccounting |
---|
| 1083 | #D-* Purpose: store project accounting information in a file |
---|
| 1084 | #D-* Examples: |
---|
| 1085 | #D- |
---|
| 1086 | function IGCM_sys_projectAccounting { |
---|
| 1087 | IGCM_debug_PushStack "IGCM_sys_projectAccounting" |
---|
| 1088 | if ( $DEBUG_sys ) ; then |
---|
| 1089 | echo "IGCM_sys_check_quota" |
---|
| 1090 | fi |
---|
| 1091 | |
---|
| 1092 | touch $1 |
---|
| 1093 | |
---|
| 1094 | IGCM_debug_PopStack "IGCM_sys_projectAccounting" |
---|
| 1095 | } |
---|
| 1096 | |
---|
| 1097 | #D-#================================================== |
---|
[1244] | 1098 | #D-function IGCM_sys_getJobSchedulerID |
---|
| 1099 | #D-* Purpose: Get the job ID during execution |
---|
| 1100 | #D-* Examples: IGCM_sys_getJobSchedulerID jobSchedulerID |
---|
| 1101 | #D- |
---|
| 1102 | function IGCM_sys_getJobSchedulerID { |
---|
| 1103 | IGCM_debug_PushStack "IGCM_sys_getJobSchedulerID" |
---|
| 1104 | if ( $DEBUG_sys ) ; then |
---|
| 1105 | echo "IGCM_sys_getJobSchedulerID" |
---|
| 1106 | fi |
---|
| 1107 | |
---|
[1300] | 1108 | # N/A content |
---|
[1244] | 1109 | eval ${1}="N/A" |
---|
| 1110 | |
---|
| 1111 | IGCM_debug_PopStack "IGCM_sys_getJobSchedulerID" |
---|
| 1112 | } |
---|
| 1113 | |
---|
| 1114 | #D-#================================================== |
---|
[1300] | 1115 | #D-function IGCM_sys_GetJobID |
---|
| 1116 | #D-* Purpose: Get the job ID from the JobName |
---|
| 1117 | #D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID |
---|
| 1118 | #D- |
---|
| 1119 | function IGCM_sys_GetJobID { |
---|
| 1120 | IGCM_debug_PushStack "IGCM_sys_GetJobID" |
---|
| 1121 | if ( $DEBUG_sys ) ; then |
---|
| 1122 | echo "IGCM_sys_GetJobID" |
---|
| 1123 | fi |
---|
| 1124 | |
---|
| 1125 | # N/A content |
---|
| 1126 | eval ${3}="N/A" |
---|
| 1127 | IGCM_debug_PopStack "IGCM_sys_GetJobID" |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | #D-#================================================== |
---|
[811] | 1131 | #D-function IGCM_sys_CountJobInQueue |
---|
[1244] | 1132 | #D-* Purpose: Count number of users job |
---|
[811] | 1133 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
| 1134 | #D- |
---|
| 1135 | function IGCM_sys_CountJobInQueue { |
---|
| 1136 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
| 1137 | if ( $DEBUG_sys ) ; then |
---|
| 1138 | echo "IGCM_sys_CountJobInQueue" |
---|
| 1139 | fi |
---|
| 1140 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
| 1141 | } |
---|
[1272] | 1142 | |
---|
| 1143 | #D-#================================================== |
---|
| 1144 | #D-function IGCM_sys_atlas |
---|
| 1145 | #D-* Purpose: encapsulate atlas call so as to manage error code and curie specificity |
---|
| 1146 | #D-* Examples: |
---|
| 1147 | #D- |
---|
| 1148 | function IGCM_sys_atlas { |
---|
| 1149 | IGCM_debug_PushStack "IGCM_sys_atlas" $@ |
---|
| 1150 | if ( $DEBUG_sys ) ; then |
---|
| 1151 | echo "IGCM_sys_atlas :" $@ |
---|
| 1152 | fi |
---|
| 1153 | |
---|
| 1154 | typeset status |
---|
| 1155 | |
---|
| 1156 | \atlas $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 1157 | status=$? |
---|
| 1158 | if [ ${status} -gt 0 ] ; then |
---|
| 1159 | echo "IGCM_sys_atlas : error code ${status}" |
---|
| 1160 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
| 1161 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
| 1162 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
| 1163 | return 1 |
---|
| 1164 | else |
---|
| 1165 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
| 1166 | return 0 |
---|
| 1167 | fi |
---|
| 1168 | |
---|
| 1169 | IGCM_debug_PopStack "IGCM_sys_atlas" |
---|
| 1170 | } |
---|
| 1171 | |
---|