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