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