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