[428] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sébastien Denvil |
---|
| 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
[1061] | 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[428] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | #========================================================= |
---|
| 15 | # The documentation of this file can be automatically generated |
---|
[809] | 16 | # if you use the prefix #D- for comments to be extracted. |
---|
[428] | 17 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
| 18 | #========================================================= |
---|
| 19 | |
---|
| 20 | #D-#================================================== |
---|
| 21 | #D-LibIGCM_sys for IITM IBM machine |
---|
| 22 | #D-#================================================== |
---|
| 23 | #D- |
---|
[809] | 24 | #D- This ksh library if a layer under some usefull |
---|
[428] | 25 | #D-environment variables and shell commands. |
---|
| 26 | #D-All those definitions depend on host particularities. |
---|
| 27 | #D-It manages a stack mechanism and test validity of operations. |
---|
| 28 | #D-All function described bellow must be prefixed by IGCM_sys. |
---|
| 29 | |
---|
| 30 | #==================================================== |
---|
| 31 | # libIGCM_sys PARAMETERS |
---|
| 32 | #==================================================== |
---|
| 33 | |
---|
| 34 | #==================================================== |
---|
| 35 | # set DEBUG_sys to true to output calls of function |
---|
| 36 | typeset -r DEBUG_sys=${DEBUG_sys:=true} |
---|
| 37 | |
---|
| 38 | #==================================================== |
---|
| 39 | # Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get) |
---|
| 40 | typeset -r DRYRUN=${DRYRUN:=0} |
---|
| 41 | |
---|
| 42 | # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! |
---|
| 43 | # ------------------------------------------------------------------------------------- |
---|
| 44 | # | DRYRUN= | Date computations, | sys_Get | Exe | sys_Put_Out; sys_Put_Rest | |
---|
[809] | 45 | # | | Cp/Exe/param/files | | | | |
---|
| 46 | # | | Chmod Qsub | | | | |
---|
[428] | 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 | #===================================================== |
---|
[809] | 64 | # Host and user names |
---|
[428] | 65 | # $hostname ou hostname |
---|
[1180] | 66 | typeset HOST=${HOST:=$( hostname )} |
---|
[428] | 67 | # $username ou whoami |
---|
[1180] | 68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
[428] | 69 | # $hostname of the MASTER job |
---|
[1180] | 70 | typeset MASTER=iitm01 |
---|
[1201] | 71 | # project name |
---|
| 72 | typeset PROJECT=NONE |
---|
| 73 | # jobWarningDelay in seconds |
---|
| 74 | typeset jobWarningDelay=NONE |
---|
[428] | 75 | |
---|
| 76 | #D- |
---|
| 77 | #D-#================================================== |
---|
| 78 | #D-Program used in libIGCM |
---|
| 79 | #D-#================================================== |
---|
| 80 | |
---|
[810] | 81 | # Submit command |
---|
| 82 | typeset SUBMIT=${SUBMIT:=/usr/lpp/LoadL/full/bin/llsubmit} |
---|
[428] | 83 | # rsync with path |
---|
| 84 | typeset -r RSYNC=/usr/bin/rsync |
---|
| 85 | # RSYNC_opt args to rsync |
---|
| 86 | typeset -r RSYNC_opt="-va" |
---|
[810] | 87 | # ie storage filesystem |
---|
| 88 | typeset -r STOREHOST=iitm01 |
---|
| 89 | typeset -r REMOTE_RSYNC=/usr/bin/rsync |
---|
[428] | 90 | |
---|
| 91 | #==================================================== |
---|
[1180] | 92 | # Set environment tools (ferret, nco, cdo, rebuild, ...) |
---|
[810] | 93 | #==================================================== |
---|
[1180] | 94 | # Not applicable here. Only rebuild path |
---|
| 95 | export export PATH=${PATH}:/gpfs1/home/sebastien/REBUILD/ |
---|
[810] | 96 | |
---|
| 97 | #==================================================== |
---|
[428] | 98 | # Host specific DIRECTORIES |
---|
| 99 | #==================================================== |
---|
| 100 | |
---|
| 101 | #==================================================== |
---|
[1180] | 102 | #- MirrorlibIGCM for frontend |
---|
[810] | 103 | typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} |
---|
| 104 | |
---|
| 105 | #==================================================== |
---|
| 106 | #- libIGCM_POST for frontend |
---|
| 107 | typeset -r libIGCM_POST=${libIGCM} |
---|
| 108 | |
---|
| 109 | #==================================================== |
---|
[428] | 110 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
| 111 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
| 112 | |
---|
| 113 | #==================================================== |
---|
| 114 | #- SUBMIT_DIR : submission dir |
---|
| 115 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}} |
---|
| 116 | |
---|
| 117 | #==================================================== |
---|
[725] | 118 | #- IN |
---|
| 119 | typeset -r R_IN=${R_IN:=/gpfs1/home/sabin} |
---|
| 120 | |
---|
| 121 | #==================================================== |
---|
[428] | 122 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
[1064] | 123 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" )/RUN/${LOADL_STEP_ID}} |
---|
[428] | 124 | |
---|
| 125 | #==================================================== |
---|
[1179] | 126 | #- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs |
---|
[1186] | 127 | typeset -r OUTCOMMAND_PATH=/tmp |
---|
[1179] | 128 | |
---|
| 129 | #==================================================== |
---|
[428] | 130 | #- HOST_MPIRUN_COMMAND |
---|
[810] | 131 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"} |
---|
[428] | 132 | |
---|
| 133 | #==================================================== |
---|
| 134 | #- Max number of arguments passed to nco operator or demigration command |
---|
| 135 | UNIX_MAX_LIMIT=360 |
---|
| 136 | |
---|
[810] | 137 | #==================================================== |
---|
[1180] | 138 | #- set PackDefault to false on iitm |
---|
[810] | 139 | PackDefault=false |
---|
| 140 | |
---|
| 141 | #==================================================== |
---|
| 142 | #- Number of core per node (max number of OpenMP task) |
---|
| 143 | NUM_COREPERNODE=2 |
---|
| 144 | |
---|
| 145 | #==================================================== |
---|
| 146 | #- Default number of MPI task for IPSL coupled model |
---|
| 147 | #- required for backward compatibility |
---|
| 148 | #- |
---|
| 149 | DEFAULT_NUM_PROC_OCE=5 |
---|
| 150 | DEFAULT_NUM_PROC_CPL=1 |
---|
| 151 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
| 152 | |
---|
[428] | 153 | #D-#================================================== |
---|
[1057] | 154 | #D-function IGCM_sys_defineArchives |
---|
| 155 | #D-* Purpose: |
---|
| 156 | #D-* Define ARCHIVE : Dedicated to large files |
---|
| 157 | #D-* Define STORAGE : Dedicated to small/medium files |
---|
| 158 | #D-* Define R_OUT : Output tree located on ARCHIVE |
---|
| 159 | #D-* Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
| 160 | #D-* Define R_BUF : Output tree located on STORAGE hosting files waiting for rebuild or pack processes |
---|
| 161 | #D-* if SpaceName=TEST nothing special will hapen |
---|
[725] | 162 | #D-* Examples: |
---|
| 163 | #D- |
---|
[1057] | 164 | function IGCM_sys_defineArchives { |
---|
| 165 | IGCM_debug_PushStack "IGCM_sys_defineArchives" |
---|
| 166 | |
---|
[1060] | 167 | if [ ! X${config_UserChoices_ARCHIVE} = X ]; then |
---|
[1057] | 168 | #==================================================== |
---|
| 169 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 170 | ARCHIVE=${config_UserChoices_ARCHIVE} |
---|
[1057] | 171 | else |
---|
| 172 | #==================================================== |
---|
| 173 | #- ARCHIVE (dedicated to large files) |
---|
[1063] | 174 | ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" ) |
---|
[1057] | 175 | fi |
---|
| 176 | |
---|
[1060] | 177 | if [ ! X${config_UserChoices_STORAGE} = X ]; then |
---|
[1057] | 178 | #==================================================== |
---|
| 179 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 180 | STORAGE=${config_UserChoices_STORAGE} |
---|
[1057] | 181 | else |
---|
| 182 | #==================================================== |
---|
| 183 | #- STORAGE (dedicated to small/medium files) |
---|
[1063] | 184 | STORAGE=${ARCHIVE} |
---|
[1057] | 185 | fi |
---|
| 186 | |
---|
| 187 | # ON OBELIX NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST |
---|
| 188 | |
---|
| 189 | #==================================================== |
---|
| 190 | #- R_OUT |
---|
[1063] | 191 | R_OUT=${ARCHIVE}/IGCM_OUT |
---|
[1057] | 192 | |
---|
| 193 | #==================================================== |
---|
| 194 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
[1063] | 195 | R_FIG=${WORKDIR}/IGCM_OUT |
---|
[1057] | 196 | |
---|
| 197 | #==================================================== |
---|
[1431] | 198 | #- CMIP6 (hosting CMIP6 files produced by XIOS2 and configured by dr2xml) |
---|
| 199 | CMIP6_BUF=${STORAGE}/IGCM_OUT |
---|
| 200 | |
---|
| 201 | #==================================================== |
---|
[1057] | 202 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
[1063] | 203 | R_BUF=${WORKDIR}/IGCM_OUT |
---|
[1057] | 204 | |
---|
| 205 | IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}" |
---|
| 206 | IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}" |
---|
| 207 | IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}" |
---|
| 208 | |
---|
| 209 | IGCM_debug_PopStack "IGCM_sys_defineArchives" |
---|
[725] | 210 | } |
---|
| 211 | |
---|
| 212 | #D-#================================================== |
---|
[428] | 213 | #D-function IGCM_sys_RshArchive |
---|
| 214 | #D-* Purpose: Archive rsh command |
---|
| 215 | #D-* Examples: |
---|
| 216 | #D- |
---|
| 217 | function IGCM_sys_RshArchive { |
---|
[810] | 218 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
[811] | 219 | /bin/ksh <<-EOF |
---|
[428] | 220 | ${@} |
---|
| 221 | EOF |
---|
[811] | 222 | status=$? |
---|
[810] | 223 | if [ ${status} -gt 0 ] ; then |
---|
| 224 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
| 225 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
| 226 | fi |
---|
| 227 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
[428] | 228 | } |
---|
| 229 | |
---|
| 230 | #D-#================================================== |
---|
[1180] | 231 | #D-function IGCM_sys_RshArchive_NoError |
---|
| 232 | #D-* Purpose: Archive rsh command, without error |
---|
| 233 | #D-* used only in monitoring.job |
---|
| 234 | #D-* Examples: |
---|
| 235 | #D- |
---|
| 236 | function IGCM_sys_RshArchive_NoError { |
---|
| 237 | IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ |
---|
| 238 | /bin/ksh <<-EOF |
---|
| 239 | ${@} 2> /dev/null |
---|
| 240 | EOF |
---|
| 241 | IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | #D-#================================================== |
---|
[428] | 245 | #D-function IGCM_sys_MkdirArchive |
---|
| 246 | #D-* Purpose: Mkdir on Archive |
---|
| 247 | #D-* Examples: |
---|
| 248 | #D- |
---|
| 249 | function IGCM_sys_MkdirArchive { |
---|
[810] | 250 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
| 251 | if ( $DEBUG_sys ) ; then |
---|
| 252 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
| 253 | fi |
---|
| 254 | #- creation de repertoire sur le serveur fichier |
---|
[1180] | 255 | if [ ! -d ${1} ]; then |
---|
| 256 | \mkdir -p $1 |
---|
| 257 | status=$? |
---|
[428] | 258 | |
---|
[1180] | 259 | if [ ${status} -gt 0 ] ; then |
---|
| 260 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
| 261 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
| 262 | fi |
---|
[810] | 263 | fi |
---|
| 264 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
[428] | 265 | } |
---|
| 266 | |
---|
| 267 | #D-#================================================== |
---|
| 268 | #D-function IGCM_sys_TestDirArchive |
---|
| 269 | #D-* Purpose: Test Directory that must exists on Archive |
---|
| 270 | #D-* Examples: |
---|
| 271 | #D- |
---|
| 272 | function IGCM_sys_TestDirArchive { |
---|
[810] | 273 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
| 274 | if ( $DEBUG_sys ) ; then |
---|
| 275 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
| 276 | fi |
---|
| 277 | typeset ExistFlag |
---|
| 278 | ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" ) |
---|
| 279 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
| 280 | return ${ExistFlag} |
---|
| 281 | } |
---|
[428] | 282 | |
---|
[810] | 283 | #D-#================================================== |
---|
| 284 | #D-function IGCM_sys_IsFileArchived |
---|
[1180] | 285 | #D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only |
---|
[810] | 286 | #D-* Examples: |
---|
| 287 | #D- |
---|
| 288 | function IGCM_sys_IsFileArchived { |
---|
| 289 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
| 290 | if ( $DEBUG_sys ) ; then |
---|
| 291 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
| 292 | fi |
---|
| 293 | typeset IsArchivedFlag |
---|
[818] | 294 | IsArchivedFlag=$( [ "X$( echo $@ | grep \/gpfs3 )" != "X" ] && echo 0 || echo 1 ) |
---|
[810] | 295 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
| 296 | |
---|
| 297 | return ${IsArchivedFlag} |
---|
[428] | 298 | } |
---|
| 299 | |
---|
| 300 | #D-#================================================== |
---|
| 301 | #D-function IGCM_sys_TestFileArchive |
---|
| 302 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 303 | #D-* Examples: |
---|
| 304 | #D- |
---|
| 305 | function IGCM_sys_TestFileArchive { |
---|
[810] | 306 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
| 307 | typeset ExistFlag |
---|
| 308 | ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) |
---|
| 309 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
[428] | 310 | |
---|
[810] | 311 | return ${ExistFlag} |
---|
[428] | 312 | } |
---|
| 313 | |
---|
| 314 | #D-#================================================== |
---|
| 315 | #D-function IGCM_sys_CountFileArchive |
---|
| 316 | #D-* Purpose: Count files on Archive filesystem |
---|
| 317 | #D-* Examples: |
---|
| 318 | #D- |
---|
| 319 | function IGCM_sys_CountFileArchive { |
---|
[810] | 320 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
| 321 | #Command depends on targeted file system |
---|
| 322 | DEBUG_sys=false IGCM_sys_IsFileArchived $1 |
---|
| 323 | if [ $? = 0 ] ; then |
---|
[428] | 324 | IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" |
---|
[810] | 325 | status=$? |
---|
| 326 | else |
---|
| 327 | ls ${@} 2>/dev/null | wc -l |
---|
| 328 | status=$? |
---|
| 329 | fi |
---|
| 330 | if [ ${status} -gt 0 ] ; then |
---|
| 331 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
| 332 | fi |
---|
| 333 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
[428] | 334 | } |
---|
| 335 | |
---|
| 336 | #D-#================================================== |
---|
| 337 | #D-function IGCM_sys_Qsub |
---|
| 338 | #D-* Purpose: Qsub new job |
---|
| 339 | #D-* Examples: |
---|
| 340 | #D- |
---|
| 341 | function IGCM_sys_Qsub { |
---|
[810] | 342 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
| 343 | |
---|
[811] | 344 | typeset status |
---|
[810] | 345 | |
---|
| 346 | if ( $DEBUG_sys ) ; then |
---|
| 347 | echo "IGCM_sys_Qsub :" $@ |
---|
| 348 | fi |
---|
| 349 | # We have to change output/error file |
---|
| 350 | [ ${#@} = 1 ] && REP_FOR_JOB=${SUBMIT_DIR} |
---|
| 351 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 352 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \ |
---|
[811] | 353 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:" \ |
---|
| 354 | $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
[1179] | 355 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ; |
---|
[810] | 356 | |
---|
[1179] | 357 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[811] | 358 | if [ ${status} -gt 0 ] ; then |
---|
| 359 | IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}" |
---|
[810] | 360 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
| 361 | else |
---|
[1179] | 362 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g ) |
---|
[810] | 363 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 364 | fi |
---|
| 365 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
[428] | 366 | } |
---|
| 367 | |
---|
| 368 | #D-#================================================== |
---|
| 369 | #D-function IGCM_sys_QsubPost |
---|
| 370 | #D-* Purpose: Qsub new job on scalaire |
---|
| 371 | #D-* Examples: |
---|
| 372 | #D- |
---|
| 373 | function IGCM_sys_QsubPost { |
---|
[810] | 374 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
| 375 | |
---|
[811] | 376 | typeset status |
---|
[810] | 377 | |
---|
| 378 | if ( $DEBUG_sys ) ; then |
---|
| 379 | echo "IGCM_sys_QsubPost :" $@ |
---|
| 380 | fi |
---|
| 381 | # We have to change output/error file |
---|
| 382 | [ ${#@} = 1 ] && REP_FOR_JOB=${POST_DIR} |
---|
| 383 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 384 | |
---|
| 385 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \ |
---|
[811] | 386 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:" \ |
---|
| 387 | ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
[810] | 388 | |
---|
[1179] | 389 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ; |
---|
[948] | 390 | |
---|
[1179] | 391 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[811] | 392 | if [ ${status} -gt 0 ] ; then |
---|
| 393 | IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}" |
---|
[810] | 394 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
| 395 | else |
---|
[1179] | 396 | JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g ) |
---|
[810] | 397 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 398 | fi |
---|
| 399 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
[428] | 400 | } |
---|
| 401 | |
---|
| 402 | #D-************************* |
---|
[809] | 403 | #D- File transfer functions |
---|
[428] | 404 | #D-************************* |
---|
| 405 | #D- |
---|
| 406 | |
---|
| 407 | #D-#================================================== |
---|
| 408 | #D-function IGCM_sys_RmRunDir |
---|
| 409 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
| 410 | #D- scheduler will do the job) |
---|
| 411 | #D-* Examples: |
---|
| 412 | #D- |
---|
| 413 | function IGCM_sys_RmRunDir { |
---|
[1057] | 414 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@ |
---|
[810] | 415 | if ( $DEBUG_sys ) ; then |
---|
| 416 | echo "IGCM_sys_RmRunDir :" $@ |
---|
| 417 | fi |
---|
[428] | 418 | |
---|
[810] | 419 | typeset status |
---|
[428] | 420 | |
---|
[1179] | 421 | echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
| 422 | \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 423 | status=$? |
---|
[428] | 424 | |
---|
[810] | 425 | if [ ${status} -gt 0 ] ; then |
---|
[1183] | 426 | IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}." |
---|
[1179] | 427 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 428 | IGCM_debug_Exit "IGCM_sys_RmRunDir" |
---|
| 429 | else |
---|
[1179] | 430 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 431 | fi |
---|
| 432 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
[428] | 433 | } |
---|
| 434 | |
---|
| 435 | #D-#================================================== |
---|
| 436 | #D-function IGCM_sys_Put_Dir |
---|
| 437 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
| 438 | #D-* Examples: |
---|
| 439 | #D- |
---|
| 440 | function IGCM_sys_Put_Dir { |
---|
[810] | 441 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
| 442 | if ( $DEBUG_sys ) ; then |
---|
| 443 | echo "IGCM_sys_Put_Dir :" $@ |
---|
| 444 | fi |
---|
| 445 | if [ $DRYRUN = 0 ]; then |
---|
| 446 | if [ ! -d ${1} ] ; then |
---|
| 447 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
| 448 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
| 449 | return |
---|
[428] | 450 | fi |
---|
| 451 | |
---|
[810] | 452 | typeset status |
---|
[428] | 453 | |
---|
[810] | 454 | # Only if we use rsync |
---|
| 455 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
| 456 | # |
---|
| 457 | #USUAL WAY |
---|
[1179] | 458 | \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 459 | status=$? |
---|
[428] | 460 | |
---|
[810] | 461 | if [ ${status} -gt 0 ] ; then |
---|
| 462 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
[1179] | 463 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 464 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
[428] | 465 | else |
---|
[1179] | 466 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 467 | fi |
---|
[810] | 468 | fi |
---|
| 469 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
[428] | 470 | } |
---|
| 471 | |
---|
| 472 | #D-#================================================== |
---|
| 473 | #D-function IGCM_sys_Get_Dir |
---|
[810] | 474 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
[428] | 475 | #D-* Examples: |
---|
| 476 | #D- |
---|
| 477 | function IGCM_sys_Get_Dir { |
---|
[810] | 478 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
| 479 | if ( $DEBUG_sys ) ; then |
---|
| 480 | echo "IGCM_sys_Get_Dir :" $@ |
---|
| 481 | fi |
---|
| 482 | if [ $DRYRUN = 0 ]; then |
---|
| 483 | if [ ! -d ${1} ] ; then |
---|
| 484 | echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
| 485 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
| 486 | return |
---|
[428] | 487 | fi |
---|
| 488 | |
---|
[810] | 489 | typeset status |
---|
[428] | 490 | |
---|
[811] | 491 | #USUAL WAY |
---|
[1179] | 492 | \cp -ur $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 493 | status=$? |
---|
[428] | 494 | |
---|
[810] | 495 | if [ ${status} -gt 0 ] ; then |
---|
| 496 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
[1179] | 497 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 498 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
[428] | 499 | else |
---|
[1179] | 500 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 501 | fi |
---|
[810] | 502 | fi |
---|
| 503 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
[428] | 504 | } |
---|
| 505 | |
---|
| 506 | #D-#================================================== |
---|
| 507 | #D-function IGCM_sys_Put_Rest |
---|
[810] | 508 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
[428] | 509 | #D- File and target directory must exist. |
---|
| 510 | #D-* Examples: |
---|
| 511 | #D- |
---|
| 512 | function IGCM_sys_Put_Rest { |
---|
[810] | 513 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
| 514 | if ( $DEBUG_sys ) ; then |
---|
| 515 | echo "IGCM_sys_Put_Rest :" $@ |
---|
| 516 | fi |
---|
| 517 | if [ $DRYRUN = 0 ]; then |
---|
| 518 | if [ ! -f ${1} ] ; then |
---|
| 519 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
| 520 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 521 | fi |
---|
| 522 | |
---|
[810] | 523 | typeset status |
---|
| 524 | # |
---|
| 525 | if [ X${JobType} = XRUN ] ; then |
---|
| 526 | IGCM_sys_Chmod 444 ${1} |
---|
| 527 | fi |
---|
| 528 | # |
---|
| 529 | # Only if we use rsync |
---|
| 530 | #IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 531 | # |
---|
| 532 | #USUAL WAY |
---|
[1179] | 533 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 534 | status=$? |
---|
[428] | 535 | |
---|
[810] | 536 | if [ ${status} -gt 0 ] ; then |
---|
[1180] | 537 | IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
[1179] | 538 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 539 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 540 | else |
---|
[1179] | 541 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[428] | 542 | fi |
---|
[810] | 543 | fi |
---|
| 544 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
[428] | 545 | } |
---|
| 546 | |
---|
| 547 | #D-#================================================== |
---|
| 548 | #D-function IGCM_sys_Put_Out |
---|
[810] | 549 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
[428] | 550 | #D-* Examples: |
---|
| 551 | #D- |
---|
| 552 | function IGCM_sys_Put_Out { |
---|
[810] | 553 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
| 554 | if ( $DEBUG_sys ) ; then |
---|
| 555 | echo "IGCM_sys_Put_Out :" $@ |
---|
| 556 | fi |
---|
| 557 | |
---|
| 558 | typeset status |
---|
| 559 | |
---|
| 560 | if [ $DRYRUN = 0 ]; then |
---|
| 561 | if [ ! -f ${1} ] ; then |
---|
| 562 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
| 563 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 564 | return 1 |
---|
[428] | 565 | fi |
---|
[810] | 566 | # |
---|
| 567 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 568 | # |
---|
| 569 | if [ X${JobType} = XRUN ] ; then |
---|
| 570 | if [ X${3} = X ] ; then |
---|
| 571 | IGCM_sys_Chmod 444 ${1} |
---|
[786] | 572 | fi |
---|
[810] | 573 | fi |
---|
| 574 | # |
---|
| 575 | #USUAL WAY |
---|
[1179] | 576 | \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 577 | status=$? |
---|
| 578 | |
---|
| 579 | if [ ${status} -gt 0 ] ; then |
---|
| 580 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}" |
---|
[1179] | 581 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 582 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
| 583 | else |
---|
[1179] | 584 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 585 | fi |
---|
| 586 | fi |
---|
| 587 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 588 | return 0 |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | #D-#================================================== |
---|
[428] | 592 | #D-function IGCM_sys_Get |
---|
| 593 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
| 594 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
| 595 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
| 596 | function IGCM_sys_Get { |
---|
[810] | 597 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
[428] | 598 | |
---|
[810] | 599 | typeset DEST status dm_liste |
---|
[428] | 600 | |
---|
[810] | 601 | if ( $DEBUG_sys ) ; then |
---|
| 602 | echo "IGCM_sys_Get :" $@ |
---|
| 603 | fi |
---|
| 604 | if [ $DRYRUN -le 2 ]; then |
---|
| 605 | if [ X${1} = X'/l' ] ; then |
---|
| 606 | eval set +A dm_liste \${${2}} |
---|
| 607 | else |
---|
| 608 | dm_liste=${1} |
---|
[428] | 609 | fi |
---|
[810] | 610 | eval DEST=\${${#}} |
---|
[428] | 611 | |
---|
[810] | 612 | # test if the (first) file is present in the old computation : |
---|
| 613 | DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]} |
---|
| 614 | if [ $? = 0 ] ; then |
---|
[786] | 615 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
[810] | 616 | status=$? |
---|
| 617 | else |
---|
| 618 | IGCM_sys_TestFileBuffer ${dm_liste[0]} |
---|
| 619 | status=$? |
---|
| 620 | fi |
---|
[428] | 621 | |
---|
[810] | 622 | if [ ${status} -gt 0 ] ; then |
---|
| 623 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
| 624 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 625 | return |
---|
| 626 | fi |
---|
[428] | 627 | |
---|
[810] | 628 | #USUAL WAY |
---|
[1179] | 629 | \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 |
---|
[810] | 630 | status=$? |
---|
| 631 | |
---|
| 632 | if [ ${status} -gt 0 ] ; then |
---|
| 633 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
[1179] | 634 | cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 635 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 636 | else |
---|
[1179] | 637 | \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ |
---|
[810] | 638 | fi |
---|
| 639 | fi |
---|
| 640 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | #D-#================================================== |
---|
[811] | 644 | #D-function IGCM_sys_Dods_Rm |
---|
| 645 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
| 646 | #D-* Examples: |
---|
| 647 | #D- |
---|
| 648 | function IGCM_sys_Dods_Rm { |
---|
| 649 | if ( $DEBUG_sys ) ; then |
---|
| 650 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
| 651 | fi |
---|
| 652 | return 0 |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | #D-#================================================== |
---|
| 656 | #D-function IGCM_sys_Dods_Cp |
---|
| 657 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
| 658 | #D-* Examples: |
---|
| 659 | #D- |
---|
| 660 | function IGCM_sys_Dods_Cp { |
---|
| 661 | if ( $DEBUG_sys ) ; then |
---|
| 662 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
| 663 | fi |
---|
| 664 | return 0 |
---|
| 665 | } |
---|
| 666 | |
---|
| 667 | #D-#================================================== |
---|
[810] | 668 | #D-function IGCM_sys_Put_Dods |
---|
| 669 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
| 670 | #D-* Examples: |
---|
| 671 | #D- |
---|
| 672 | function IGCM_sys_Put_Dods { |
---|
| 673 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
| 674 | if ( $DEBUG_sys ) ; then |
---|
| 675 | echo "IGCM_sys_Put_Dods :" $@ |
---|
| 676 | fi |
---|
| 677 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
| 678 | } |
---|
| 679 | |
---|
[428] | 680 | ############################################################## |
---|
| 681 | # REBUILD OPERATOR |
---|
| 682 | |
---|
[810] | 683 | #D-#================================================== |
---|
[1163] | 684 | #D-function IGCM_sys_sync |
---|
| 685 | #D-* Purpose: flush buffer on disk (dummy function on Ada) |
---|
| 686 | #D-* Examples: |
---|
| 687 | #D- |
---|
| 688 | function IGCM_sys_sync { |
---|
| 689 | IGCM_debug_PushStack "IGCM_sys_sync" $@ |
---|
| 690 | if ( $DEBUG_sys ) ; then |
---|
| 691 | echo "IGCM_sys_sync :" $@ |
---|
| 692 | echo "Dummy call, let the system do that." |
---|
| 693 | fi |
---|
| 694 | IGCM_debug_PopStack "IGCM_sys_sync" |
---|
| 695 | } |
---|
| 696 | |
---|
[428] | 697 | ############################################################ |
---|
| 698 | # Activate Running Environnment Variables |
---|
| 699 | |
---|
[810] | 700 | #D-#================================================== |
---|
[1239] | 701 | #D-function IGCM_sys_activ_variables |
---|
[810] | 702 | #D-* Purpose: set environement variables prior to execution |
---|
| 703 | #D-* Examples: |
---|
| 704 | #D- |
---|
[428] | 705 | function IGCM_sys_activ_variables { |
---|
[810] | 706 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
| 707 | if ( $DEBUG_sys ) ; then |
---|
[811] | 708 | echo "IGCM_sys_activ_variables" |
---|
[810] | 709 | fi |
---|
[428] | 710 | |
---|
| 711 | # -------------------------------------------------------------------- |
---|
| 712 | #D- MPI specifications |
---|
| 713 | # -------------------------------------------------------------------- |
---|
| 714 | |
---|
| 715 | # -------------------------------------------------------------------- |
---|
| 716 | #D- Other specifications |
---|
| 717 | # -------------------------------------------------------------------- |
---|
| 718 | |
---|
[810] | 719 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
[428] | 720 | } |
---|
| 721 | |
---|
| 722 | ############################################################ |
---|
| 723 | # Desactivate Running Environnment Variables |
---|
| 724 | |
---|
[810] | 725 | #D-#================================================== |
---|
| 726 | #D-function IGCM_sys_desactiv_variables |
---|
| 727 | #D-* Purpose: unset environement variables after execution |
---|
| 728 | #D-* Examples: |
---|
| 729 | #D- |
---|
[428] | 730 | function IGCM_sys_desactiv_variables { |
---|
[810] | 731 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
| 732 | if ( $DEBUG_sys ) ; then |
---|
[811] | 733 | echo "IGCM_sys_desactiv_variables" |
---|
[810] | 734 | fi |
---|
[428] | 735 | # -------------------------------------------------------------------- |
---|
| 736 | #D- MPI specifications |
---|
| 737 | # -------------------------------------------------------------------- |
---|
| 738 | |
---|
| 739 | # -------------------------------------------------------------------- |
---|
| 740 | #D- Other specifications |
---|
| 741 | # -------------------------------------------------------------------- |
---|
| 742 | |
---|
[810] | 743 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
| 744 | } |
---|
[809] | 745 | |
---|
[810] | 746 | ############################################################ |
---|
[1239] | 747 | # Update job headers to be used by the scheduler |
---|
| 748 | |
---|
| 749 | #D-#================================================== |
---|
| 750 | #D-function IGCM_sys_updateHeaders |
---|
| 751 | #D-* Purpose: Update job headers to be used by the scheduler |
---|
| 752 | #D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP |
---|
| 753 | #D- |
---|
| 754 | function IGCM_sys_updateHeaders { |
---|
| 755 | IGCM_debug_PushStack "IGCM_sys_updateHeaders" |
---|
| 756 | if ( $DEBUG_sys ) ; then |
---|
| 757 | echo "IGCM_sys_updateHeaders" |
---|
| 758 | fi |
---|
| 759 | typeset file |
---|
| 760 | file=$1 |
---|
| 761 | |
---|
| 762 | if [ ${executionType} -eq 1 ] ; then |
---|
| 763 | # MPMD + MPI |
---|
| 764 | sed -e "/::openMPthreads::/d" \ |
---|
| 765 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
| 766 | ${file} > ${file}.tmp |
---|
| 767 | |
---|
| 768 | elif [ ${executionType} -eq 2 ] ; then |
---|
| 769 | # MPMD + MPI + OMP |
---|
| 770 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 771 | -e "s/::JobNumProcTot::/${coreNumber}/" \ |
---|
| 772 | ${file} > ${file}.tmp |
---|
| 773 | |
---|
| 774 | elif [ ${executionType} -eq 3 ] ; then |
---|
| 775 | # SPMD + MPI/OMP |
---|
| 776 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 777 | -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
| 778 | ${file} > ${file}.tmp |
---|
| 779 | |
---|
| 780 | elif [ ${executionType} -eq 4 ] ; then |
---|
| 781 | # SPMD + MPI only |
---|
| 782 | sed -e "s/::JobNumProcTot::/${mpiTasks}/" \ |
---|
| 783 | -e "/::openMPthreads::/d" \ |
---|
| 784 | ${file} > ${file}.tmp |
---|
| 785 | |
---|
| 786 | elif [ ${executionType} -eq 5 ] ; then |
---|
| 787 | # SPMD + OMP only |
---|
| 788 | sed -e "s/::openMPthreads::/${openMPthreads}/" \ |
---|
| 789 | -e "/::JobNumProcTot::/d" \ |
---|
| 790 | ${file} > ${file}.tmp |
---|
| 791 | |
---|
| 792 | elif [ ${executionType} -eq 6 ] ; then |
---|
| 793 | # SEQUENTIAL THEN |
---|
| 794 | sed -e "s/::JobNumProcTot::/1/" \ |
---|
| 795 | -e "/::openMPthreads::/d" \ |
---|
| 796 | ${file} > ${file}.tmp |
---|
| 797 | |
---|
| 798 | fi |
---|
| 799 | |
---|
| 800 | IGCM_sys_Mv ${file}.tmp ${file} |
---|
| 801 | |
---|
| 802 | IGCM_debug_PopStack "IGCM_sys_updateHeaders" |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | ############################################################ |
---|
[810] | 806 | # Build MPI/OMP scripts run file (dummy function) |
---|
| 807 | |
---|
| 808 | #D-#================================================== |
---|
| 809 | #D-function IGCM_sys_build_run_file |
---|
| 810 | #D-* Purpose: build run file (deprecated) |
---|
| 811 | #D-* Examples: |
---|
| 812 | #D- |
---|
| 813 | function IGCM_sys_build_run_file { |
---|
| 814 | |
---|
[811] | 815 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
[810] | 816 | |
---|
[428] | 817 | } |
---|
| 818 | |
---|
| 819 | ############################################################ |
---|
[810] | 820 | # Build MPI/OMP scripts |
---|
[428] | 821 | |
---|
[810] | 822 | #D-#================================================== |
---|
| 823 | #D-function IGCM_sys_build_execution_scripts |
---|
| 824 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
| 825 | #D-* Examples: |
---|
| 826 | #D- |
---|
| 827 | function IGCM_sys_build_execution_scripts |
---|
| 828 | { |
---|
| 829 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
| 830 | if ( $DEBUG_sys ) ; then |
---|
| 831 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
| 832 | fi |
---|
| 833 | |
---|
| 834 | typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count |
---|
| 835 | |
---|
| 836 | if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then |
---|
| 837 | IGCM_debug_Exit "IGCM_sys_iitm build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} " |
---|
| 838 | fi |
---|
| 839 | |
---|
| 840 | if ( ${OK_PARA_MPMD} ) ; then |
---|
| 841 | |
---|
| 842 | if [ -f run_file ] ; then |
---|
| 843 | IGCM_sys_Rm -f run_file |
---|
| 844 | fi |
---|
| 845 | touch run_file |
---|
| 846 | |
---|
| 847 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 848 | # NEW : 2 Noeuds |
---|
| 849 | # @ task_geometry={(0)(1,2,3)} |
---|
| 850 | # Nombre de processus demandes |
---|
| 851 | echo "Job_${config_UserChoices_JobName} includes task_geometry = \c" |
---|
| 852 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" |
---|
| 853 | echo "Job_${config_UserChoices_JobName} includes task_geometry with NbNodes = \c" |
---|
| 854 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c |
---|
| 855 | NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 )) |
---|
| 856 | |
---|
| 857 | if [ ${NbNodes_Job} -eq 0 ] ; then |
---|
| 858 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run." |
---|
| 859 | exit 1 |
---|
| 860 | fi |
---|
| 861 | else |
---|
| 862 | |
---|
| 863 | # OLD : |
---|
| 864 | # @ total_tasks = 3 |
---|
| 865 | # @ environment = "BATCH_NUM_PROC_TOT=3" |
---|
| 866 | # Pas d OpenMP |
---|
| 867 | # @ resources = ConsumableCpus(1) |
---|
| 868 | |
---|
| 869 | echo "Job_${config_UserChoices_JobName} includes total_tasks = \c" |
---|
| 870 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" |
---|
| 871 | NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" ) |
---|
| 872 | NbProc_Job=${NbProc_Job:=0} |
---|
| 873 | if [ ${NbProc_Job} -eq 0 ] ; then |
---|
| 874 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run." |
---|
| 875 | exit 1 |
---|
| 876 | fi |
---|
| 877 | if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then |
---|
| 878 | IGCM_debug_Print 2 "ressources = ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}" |
---|
| 879 | else |
---|
| 880 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) " |
---|
| 881 | exit 1 |
---|
| 882 | fi |
---|
| 883 | fi |
---|
| 884 | |
---|
| 885 | # run_file construction |
---|
| 886 | |
---|
| 887 | # Then first loop on the components for the coupler ie oasis |
---|
| 888 | |
---|
| 889 | ### the coupler ie oasis must be the first one |
---|
| 890 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 891 | |
---|
| 892 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 893 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 894 | |
---|
| 895 | # for CPL component only |
---|
| 896 | if [ "X${comp}" = "XCPL" ] ; then |
---|
| 897 | |
---|
| 898 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 899 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 900 | |
---|
| 901 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 902 | (( mpi_count = 1 )) |
---|
| 903 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 904 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 905 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 906 | else |
---|
| 907 | echo "./${ExeNameOut}" >> run_file |
---|
| 908 | fi |
---|
| 909 | (( mpi_count = mpi_count + 1 )) |
---|
| 910 | done |
---|
| 911 | else |
---|
| 912 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 913 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 914 | else |
---|
| 915 | echo "./${ExeNameOut} " >> run_file |
---|
| 916 | fi |
---|
| 917 | fi |
---|
| 918 | fi |
---|
| 919 | done |
---|
| 920 | |
---|
| 921 | # Then second loop on the components |
---|
| 922 | |
---|
| 923 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 924 | |
---|
| 925 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 926 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 927 | |
---|
| 928 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
| 929 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
| 930 | |
---|
| 931 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 932 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 933 | |
---|
| 934 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 935 | (( mpi_count = 1 )) |
---|
| 936 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 937 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 938 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 939 | else |
---|
| 940 | echo "./${ExeNameOut}" >> run_file |
---|
| 941 | fi |
---|
| 942 | (( mpi_count = mpi_count + 1 )) |
---|
| 943 | done |
---|
| 944 | else |
---|
| 945 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 946 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 947 | else |
---|
| 948 | # to be tested : no MPI only OpenMP into MPMD mode |
---|
| 949 | echo "./${ExeNameOut} " >> run_file |
---|
| 950 | fi |
---|
| 951 | fi |
---|
| 952 | fi |
---|
| 953 | done |
---|
| 954 | |
---|
| 955 | EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file" |
---|
| 956 | |
---|
| 957 | IGCM_sys_Chmod u+x run_file |
---|
[428] | 958 | if ( $DEBUG_sys ) ; then |
---|
[810] | 959 | echo "run_file contains : " |
---|
| 960 | cat run_file |
---|
[428] | 961 | fi |
---|
| 962 | |
---|
[1180] | 963 | # Only one executable (SPMD mode). |
---|
| 964 | else |
---|
[428] | 965 | |
---|
[810] | 966 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[428] | 967 | |
---|
[810] | 968 | # Only if we really have an executable for the component : |
---|
| 969 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 970 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
| 971 | EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}" |
---|
| 972 | fi |
---|
[786] | 973 | |
---|
[810] | 974 | done |
---|
[428] | 975 | |
---|
[810] | 976 | fi |
---|
[428] | 977 | |
---|
[811] | 978 | IGCM_debug_Print 1 "sys iitm : execution command is" |
---|
[810] | 979 | IGCM_debug_Print 1 "$EXECUTION" |
---|
[428] | 980 | |
---|
[810] | 981 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
[428] | 982 | } |
---|
[651] | 983 | |
---|
[933] | 984 | #D-#================================================== |
---|
| 985 | #D-function IGCM_sys_check_path |
---|
| 986 | #D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine |
---|
| 987 | #D-* do not point to an important use directory. Stop immediately in that case. |
---|
| 988 | #D-* Examples: |
---|
| 989 | #D- |
---|
| 990 | function IGCM_sys_check_path { |
---|
| 991 | IGCM_debug_PushStack "IGCM_sys_check_path" |
---|
| 992 | if ( $DEBUG_sys ) ; then |
---|
| 993 | echo "IGCM_sys_check_path" |
---|
| 994 | fi |
---|
[810] | 995 | |
---|
[933] | 996 | if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then |
---|
| 997 | IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}" |
---|
| 998 | IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}" |
---|
[936] | 999 | IGCM_debug_Exit "This will stop the job" |
---|
[933] | 1000 | fi |
---|
| 1001 | IGCM_debug_PopStack "IGCM_sys_check_path" |
---|
| 1002 | } |
---|
| 1003 | |
---|
[810] | 1004 | #D-#================================================== |
---|
| 1005 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
| 1006 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
| 1007 | #D-* Examples: |
---|
| 1008 | #D- |
---|
[651] | 1009 | function IGCM_sys_check_quota { |
---|
[810] | 1010 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
| 1011 | if ( $DEBUG_sys ) ; then |
---|
| 1012 | echo "IGCM_sys_check_quota" |
---|
| 1013 | fi |
---|
| 1014 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
| 1015 | } |
---|
| 1016 | |
---|
| 1017 | #D-#================================================== |
---|
| 1018 | #D-function IGCM_sys_CountJobInQueue |
---|
[1244] | 1019 | #D-* Purpose: Count number of users job |
---|
[810] | 1020 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
| 1021 | #D- |
---|
| 1022 | function IGCM_sys_CountJobInQueue { |
---|
| 1023 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
| 1024 | if ( $DEBUG_sys ) ; then |
---|
| 1025 | echo "IGCM_sys_CountJobInQueue" |
---|
| 1026 | fi |
---|
| 1027 | |
---|
| 1028 | # Print only the full (-W) JobName (%jn) |
---|
| 1029 | NbRun=$( llq -W -f %jn | grep -c "$1" ) |
---|
| 1030 | |
---|
| 1031 | eval ${2}=${NbRun} |
---|
| 1032 | |
---|
| 1033 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
| 1034 | } |
---|
[1380] | 1035 | |
---|
| 1036 | #D-#================================================== |
---|
| 1037 | #D-function IGCM_sys_rebuild_nemo |
---|
| 1038 | #D-* Purpose: rebuild nemo parallel files with general rebuild |
---|
| 1039 | #D-* Examples: |
---|
| 1040 | #D- |
---|
| 1041 | |
---|
| 1042 | function IGCM_sys_rebuild_nemo { |
---|
| 1043 | IGCM_debug_PushStack "IGCM_sys_rebuild_nemo" $@ |
---|
| 1044 | if ( $DEBUG_sys ) ; then |
---|
| 1045 | echo "IGCM_sys_rebuild_nemo :" $@ |
---|
| 1046 | fi |
---|
| 1047 | |
---|
| 1048 | nemo_generic_restart_file_name_out=${1} |
---|
| 1049 | nemo_extension_out=${3} |
---|
| 1050 | shift ; shift ; shift |
---|
| 1051 | |
---|
| 1052 | IGCM_sys_rebuild -o ${nemo_generic_restart_file_name_out}.${nemo_extension_out} $@ |
---|
| 1053 | |
---|
| 1054 | IGCM_debug_PopStack "IGCM_sys_rebuild_nemo" |
---|
| 1055 | } |
---|
| 1056 | |
---|
| 1057 | |
---|