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