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