[428] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sébastien Denvil |
---|
| 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: 423 $ Revision of last commit |
---|
| 7 | # $Author:: sdipsl $ Author of last commit |
---|
| 8 | # $Date:: 2011-02-18 16:49:14 +0100 (ven. 18 févr. 20#$ Date of last commit |
---|
| 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | #========================================================= |
---|
| 15 | # The documentation of this file can be automatically generated |
---|
[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 |
---|
| 66 | typeset HOST=${HOST:=$( hostname )} |
---|
| 67 | # $username ou whoami |
---|
| 68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
| 69 | # $hostname of the MASTER job |
---|
[810] | 70 | ntypeset -r MASTER=iitm01 |
---|
[428] | 71 | |
---|
| 72 | #D- |
---|
| 73 | #D-#================================================== |
---|
| 74 | #D-Program used in libIGCM |
---|
| 75 | #D-#================================================== |
---|
| 76 | |
---|
[810] | 77 | # Submit command |
---|
| 78 | typeset SUBMIT=${SUBMIT:=/usr/lpp/LoadL/full/bin/llsubmit} |
---|
[428] | 79 | # rsync with path |
---|
| 80 | typeset -r RSYNC=/usr/bin/rsync |
---|
| 81 | # RSYNC_opt args to rsync |
---|
| 82 | typeset -r RSYNC_opt="-va" |
---|
[810] | 83 | # ie storage filesystem |
---|
| 84 | typeset -r STOREHOST=iitm01 |
---|
| 85 | typeset -r REMOTE_RSYNC=/usr/bin/rsync |
---|
[428] | 86 | |
---|
| 87 | #==================================================== |
---|
[810] | 88 | # Source default environment |
---|
| 89 | #==================================================== |
---|
| 90 | ##. /etc/profile |
---|
| 91 | |
---|
| 92 | #==================================================== |
---|
| 93 | # Set environment tools (ferret, nco, cdo) |
---|
| 94 | #==================================================== |
---|
| 95 | # Not applicable here |
---|
| 96 | |
---|
| 97 | #==================================================== |
---|
[428] | 98 | # Host specific DIRECTORIES |
---|
| 99 | #==================================================== |
---|
| 100 | |
---|
| 101 | #==================================================== |
---|
[810] | 102 | #- Mirror libIGCM from iitm to a post-processing machine |
---|
| 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 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/gpfs1/home/sabin} |
---|
| 121 | |
---|
| 122 | #==================================================== |
---|
[428] | 123 | #- ARCHIVE |
---|
[810] | 124 | typeset ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" ) |
---|
[428] | 125 | |
---|
| 126 | #==================================================== |
---|
[810] | 127 | #- STORAGE (dedicated to small/medium files) |
---|
| 128 | typeset STORAGE=${ARCHIVE} |
---|
[428] | 129 | |
---|
| 130 | #==================================================== |
---|
[810] | 131 | #- R_OUT |
---|
| 132 | typeset R_OUT=${ARCHIVE}/IGCM_OUT |
---|
[428] | 133 | |
---|
| 134 | #==================================================== |
---|
[810] | 135 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
| 136 | typeset R_FIG=${WORKDIR}/IGCM_OUT |
---|
[428] | 137 | |
---|
| 138 | #==================================================== |
---|
[810] | 139 | #- R_BUF (ONLY FOR double copy an scratch) |
---|
| 140 | typeset -r R_BUF=${WORKDIR}/IGCM_OUT |
---|
| 141 | |
---|
| 142 | #==================================================== |
---|
[428] | 143 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
| 144 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${ARCHIVE}/RUN/${LOADL_STEP_ID}} |
---|
| 145 | |
---|
| 146 | #==================================================== |
---|
| 147 | #- HOST_MPIRUN_COMMAND |
---|
[810] | 148 | typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"} |
---|
[428] | 149 | |
---|
| 150 | #==================================================== |
---|
| 151 | #- Max number of arguments passed to nco operator or demigration command |
---|
| 152 | UNIX_MAX_LIMIT=360 |
---|
| 153 | |
---|
[810] | 154 | #==================================================== |
---|
| 155 | #- set PackDefault true on curie |
---|
| 156 | PackDefault=false |
---|
| 157 | |
---|
| 158 | #==================================================== |
---|
| 159 | #- Number of core per node (max number of OpenMP task) |
---|
| 160 | NUM_COREPERNODE=2 |
---|
| 161 | |
---|
| 162 | #==================================================== |
---|
| 163 | #- Default number of MPI task for IPSL coupled model |
---|
| 164 | #- required for backward compatibility |
---|
| 165 | #- |
---|
| 166 | DEFAULT_NUM_PROC_OCE=5 |
---|
| 167 | DEFAULT_NUM_PROC_CPL=1 |
---|
| 168 | (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) |
---|
| 169 | DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} |
---|
| 170 | |
---|
[428] | 171 | #D-#================================================== |
---|
[725] | 172 | #D-function IGCM_sys_ChangeArchive |
---|
| 173 | #D-* Purpose: Just a dummy call on this machine |
---|
| 174 | #D-* Examples: |
---|
| 175 | #D- |
---|
| 176 | function IGCM_sys_ChangeArchive { |
---|
| 177 | IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive " |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | #D-#================================================== |
---|
[428] | 181 | #D-function IGCM_sys_RshMaster |
---|
| 182 | #D-* Purpose: Just a fake command to wrapp |
---|
| 183 | #D- IGCM_card call in post-treatment |
---|
| 184 | #D- Ulam do not see brodie filesystem |
---|
| 185 | #D- Cesium do not see all mercure filesystem |
---|
| 186 | #D- That's why we need this hack. |
---|
| 187 | #D-* Examples: |
---|
| 188 | #D- |
---|
| 189 | function IGCM_sys_RshMaster { |
---|
[810] | 190 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
| 191 | /bin/ksh <<-EOF |
---|
| 192 | export libIGCM=${libIGCM} |
---|
| 193 | export DEBUG_debug=${DEBUG_debug} |
---|
| 194 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 195 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
[428] | 196 | ${@} |
---|
| 197 | EOF |
---|
[810] | 198 | if [ $? -gt 0 ] ; then |
---|
| 199 | echo "IGCM_sys_RshMaster : erreur." |
---|
| 200 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
| 201 | fi |
---|
| 202 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
[428] | 203 | } |
---|
| 204 | |
---|
| 205 | #D-#================================================== |
---|
| 206 | #D-function IGCM_sys_RshArchive |
---|
| 207 | #D-* Purpose: Archive rsh command |
---|
| 208 | #D-* Examples: |
---|
| 209 | #D- |
---|
| 210 | function IGCM_sys_RshArchive { |
---|
[810] | 211 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
[811] | 212 | /bin/ksh <<-EOF |
---|
[428] | 213 | ${@} |
---|
| 214 | EOF |
---|
[811] | 215 | status=$? |
---|
[810] | 216 | if [ ${status} -gt 0 ] ; then |
---|
| 217 | IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" |
---|
| 218 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
| 219 | fi |
---|
| 220 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
[428] | 221 | } |
---|
| 222 | |
---|
| 223 | #D-#================================================== |
---|
| 224 | #D-function IGCM_sys_RshPost |
---|
| 225 | #D-* Purpose: Post-process rsh command |
---|
| 226 | #D-* Examples: |
---|
| 227 | #D- |
---|
| 228 | function IGCM_sys_RshPost { |
---|
[810] | 229 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
| 230 | if ( $DEBUG_sys ) ; then |
---|
| 231 | echo "IGCM_sys_RshPost :" $@ |
---|
| 232 | fi |
---|
| 233 | |
---|
| 234 | # keep standard input to keep it for postpone if ulam don't answer |
---|
| 235 | cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
| 236 | |
---|
| 237 | /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
| 238 | if [ $? -gt 0 ] ; then |
---|
| 239 | echo "IGCM_sys_RshPost : erreur." |
---|
| 240 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
| 241 | fi |
---|
| 242 | # delete temporary file |
---|
| 243 | \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} |
---|
| 244 | |
---|
| 245 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
[428] | 246 | } |
---|
| 247 | |
---|
| 248 | #D-#================================================== |
---|
| 249 | #D-function IGCM_sys_SendMail |
---|
| 250 | #D-* Purpose: Send mail when simulation is over |
---|
| 251 | #D-* Examples: |
---|
| 252 | #D- |
---|
| 253 | function IGCM_sys_SendMail { |
---|
[810] | 254 | IGCM_debug_PushStack "IGCM_sys_SendMail" $@ |
---|
| 255 | if ( $DEBUG_sys ) ; then |
---|
| 256 | echo "IGCM_sys_SendMail :" $@ |
---|
| 257 | fi |
---|
[437] | 258 | |
---|
[810] | 259 | if ( ${ExitFlag} ) ; then |
---|
| 260 | status=failed |
---|
| 261 | else |
---|
| 262 | status=completed |
---|
| 263 | fi |
---|
| 264 | |
---|
| 265 | cat << END_MAIL > job_end.mail |
---|
[437] | 266 | Dear ${LOGIN}, |
---|
| 267 | |
---|
[452] | 268 | Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. |
---|
[428] | 269 | Job started : ${DateBegin} |
---|
| 270 | Job ended : ${DateEnd} |
---|
[810] | 271 | Output files are available in ${R_SAVE} |
---|
| 272 | Files to be rebuild are temporarily available in ${REBUILD_DIR} |
---|
| 273 | Pre-packed files are temporarily available in ${R_BUFR} |
---|
[452] | 274 | Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR} |
---|
[428] | 275 | END_MAIL |
---|
| 276 | |
---|
[810] | 277 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
| 278 | mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail |
---|
| 279 | elif [ -f ~/.forward ] ; then |
---|
| 280 | mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail |
---|
| 281 | else |
---|
| 282 | mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail |
---|
| 283 | fi |
---|
[428] | 284 | |
---|
[810] | 285 | sleep 10 |
---|
| 286 | rm -f job_end.mail |
---|
| 287 | |
---|
| 288 | if [ $? -gt 0 ] ; then |
---|
| 289 | echo "IGCM_sys_SendMail : erreur." |
---|
| 290 | IGCM_debug_Exit "IGCM_sys_SendMail" |
---|
| 291 | fi |
---|
| 292 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
[428] | 293 | } |
---|
| 294 | |
---|
| 295 | #D-#================================================== |
---|
| 296 | #D-function IGCM_sys_Mkdir |
---|
| 297 | #D-* Purpose: Master locale mkdir command |
---|
| 298 | #D-* Examples: |
---|
| 299 | #D- |
---|
| 300 | function IGCM_sys_Mkdir { |
---|
[810] | 301 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
| 302 | if ( $DEBUG_sys ) ; then |
---|
| 303 | echo "IGCM_sys_Mkdir :" $@ |
---|
| 304 | fi |
---|
| 305 | if [ ! -d ${1} ]; then |
---|
| 306 | \mkdir -p $1 |
---|
| 307 | if [ $? -gt 0 ] ; then |
---|
[786] | 308 | echo "IGCM_sys_Mkdir : erreur." |
---|
| 309 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
[428] | 310 | fi |
---|
[810] | 311 | fi |
---|
| 312 | # vérification : |
---|
| 313 | if [ ! -d ${1} ] ; then |
---|
| 314 | echo "IGCM_sys_Mkdir : erreur." |
---|
| 315 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
| 316 | fi |
---|
| 317 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
[428] | 318 | } |
---|
| 319 | |
---|
| 320 | #D-#================================================== |
---|
| 321 | #D-function IGCM_sys_MkdirArchive |
---|
| 322 | #D-* Purpose: Mkdir on Archive |
---|
| 323 | #D-* Examples: |
---|
| 324 | #D- |
---|
| 325 | function IGCM_sys_MkdirArchive { |
---|
[810] | 326 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
| 327 | if ( $DEBUG_sys ) ; then |
---|
| 328 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
| 329 | fi |
---|
| 330 | #- creation de repertoire sur le serveur fichier |
---|
| 331 | mkdir -p $1 |
---|
| 332 | status=$? |
---|
[428] | 333 | |
---|
[810] | 334 | if [ ${status} -gt 0 ] ; then |
---|
| 335 | IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" |
---|
| 336 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
| 337 | fi |
---|
| 338 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
[428] | 339 | } |
---|
| 340 | |
---|
| 341 | #D-#================================================== |
---|
| 342 | #D-function IGCM_sys_MkdirWork |
---|
| 343 | #D-* Purpose: Mkdir on Work |
---|
| 344 | #D-* Examples: |
---|
| 345 | #D- |
---|
| 346 | function IGCM_sys_MkdirWork { |
---|
[810] | 347 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
| 348 | if ( $DEBUG_sys ) ; then |
---|
| 349 | echo "IGCM_sys_MkdirWork :" $@ |
---|
| 350 | fi |
---|
| 351 | #- creation de repertoire sur le serveur fichier |
---|
| 352 | if [ ! -d ${1} ]; then |
---|
| 353 | \mkdir -p $1 |
---|
| 354 | if [ $? -gt 0 ] ; then |
---|
| 355 | echo "IGCM_sys_MkdirWork : erreur." |
---|
| 356 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
[428] | 357 | fi |
---|
[810] | 358 | fi |
---|
| 359 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
[428] | 360 | } |
---|
| 361 | |
---|
| 362 | #D-#================================================== |
---|
| 363 | #D-function IGCM_sys_Cd |
---|
| 364 | #D-* Purpose: master cd command |
---|
| 365 | #D-* Examples: |
---|
| 366 | #D- |
---|
| 367 | function IGCM_sys_Cd { |
---|
[810] | 368 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
| 369 | if ( $DEBUG_sys ) ; then |
---|
| 370 | echo "IGCM_sys_Cd :" $@ |
---|
| 371 | fi |
---|
| 372 | \cd $1 |
---|
| 373 | if [ $? -gt 0 ] ; then |
---|
| 374 | echo "IGCM_sys_Cd : erreur." |
---|
| 375 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
| 376 | fi |
---|
| 377 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
[428] | 378 | } |
---|
| 379 | |
---|
| 380 | #D-#================================================== |
---|
| 381 | #D-function IGCM_sys_Chmod |
---|
| 382 | #D-* Purpose: Chmod |
---|
| 383 | #D-* Examples: |
---|
| 384 | #D- |
---|
| 385 | function IGCM_sys_Chmod { |
---|
[810] | 386 | IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ |
---|
| 387 | if ( $DEBUG_sys ) ; then |
---|
| 388 | echo "IGCM_sys_Chmod :" $@ |
---|
| 389 | fi |
---|
| 390 | \chmod $@ |
---|
| 391 | if [ $? -gt 0 ] ; then |
---|
| 392 | echo "IGCM_sys_Chmod : erreur." |
---|
| 393 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
| 394 | fi |
---|
| 395 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
[428] | 396 | } |
---|
| 397 | |
---|
| 398 | #D-#================================================== |
---|
| 399 | #D-function IGCM_sys_FileSize |
---|
| 400 | #D-* Purpose: Filesize |
---|
| 401 | #D-* Examples: |
---|
| 402 | #D- |
---|
| 403 | function IGCM_sys_FileSize { |
---|
[810] | 404 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
[428] | 405 | |
---|
[810] | 406 | typeset sizeF |
---|
| 407 | set +A sizeF -- $( ls -la ${1} ) |
---|
| 408 | if [ $? -gt 0 ] ; then |
---|
| 409 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
| 410 | fi |
---|
| 411 | eval ${2}=${sizeF[4]} |
---|
[428] | 412 | |
---|
[810] | 413 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
[428] | 414 | } |
---|
| 415 | |
---|
| 416 | #D-#================================================== |
---|
| 417 | #D-function IGCM_sys_TestDir |
---|
| 418 | #D-* Purpose: Test Directory that must exists |
---|
| 419 | #D-* Examples: |
---|
| 420 | #D- |
---|
| 421 | function IGCM_sys_TestDir { |
---|
[810] | 422 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
| 423 | if ( $DEBUG_sys ) ; then |
---|
| 424 | echo "IGCM_sys_TestDir :" $@ |
---|
| 425 | fi |
---|
| 426 | typeset ExistFlag |
---|
| 427 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
| 428 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
[428] | 429 | |
---|
[810] | 430 | return ${ExistFlag} |
---|
[428] | 431 | } |
---|
| 432 | |
---|
| 433 | #D-#================================================== |
---|
| 434 | #D-function IGCM_sys_TestDirArchive |
---|
| 435 | #D-* Purpose: Test Directory that must exists on Archive |
---|
| 436 | #D-* Examples: |
---|
| 437 | #D- |
---|
| 438 | function IGCM_sys_TestDirArchive { |
---|
[810] | 439 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
| 440 | if ( $DEBUG_sys ) ; then |
---|
| 441 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
| 442 | fi |
---|
| 443 | typeset ExistFlag |
---|
| 444 | ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" ) |
---|
| 445 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
| 446 | return ${ExistFlag} |
---|
| 447 | } |
---|
[428] | 448 | |
---|
[810] | 449 | #D-#================================================== |
---|
| 450 | #D-function IGCM_sys_IsFileArchived |
---|
| 451 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 452 | #D-* Examples: |
---|
| 453 | #D- |
---|
| 454 | function IGCM_sys_IsFileArchived { |
---|
| 455 | IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ |
---|
| 456 | if ( $DEBUG_sys ) ; then |
---|
| 457 | echo "IGCM_sys_IsFileArchived :" $@ |
---|
| 458 | fi |
---|
| 459 | typeset IsArchivedFlag |
---|
[818] | 460 | IsArchivedFlag=$( [ "X$( echo $@ | grep \/gpfs3 )" != "X" ] && echo 0 || echo 1 ) |
---|
[810] | 461 | IGCM_debug_PopStack "IGCM_sys_IsFileArchived" |
---|
| 462 | |
---|
| 463 | return ${IsArchivedFlag} |
---|
[428] | 464 | } |
---|
| 465 | |
---|
| 466 | #D-#================================================== |
---|
| 467 | #D-function IGCM_sys_TestFileArchive |
---|
| 468 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 469 | #D-* Examples: |
---|
| 470 | #D- |
---|
| 471 | function IGCM_sys_TestFileArchive { |
---|
[810] | 472 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
| 473 | typeset ExistFlag |
---|
| 474 | ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) |
---|
| 475 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
[428] | 476 | |
---|
[810] | 477 | return ${ExistFlag} |
---|
[428] | 478 | } |
---|
| 479 | |
---|
| 480 | #D-#================================================== |
---|
[810] | 481 | #D-function IGCM_sys_TestFileBuffer |
---|
| 482 | #D-* Purpose: Test file that must NOT EXISTS on Buffer |
---|
| 483 | #D-* Examples: |
---|
| 484 | #D- |
---|
| 485 | function IGCM_sys_TestFileBuffer { |
---|
| 486 | IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ |
---|
| 487 | typeset ExistFlag |
---|
| 488 | ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) |
---|
| 489 | IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" |
---|
| 490 | |
---|
| 491 | return ${ExistFlag} |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | #D-#================================================== |
---|
[428] | 495 | #D-function IGCM_sys_CountFileArchive |
---|
| 496 | #D-* Purpose: Count files on Archive filesystem |
---|
| 497 | #D-* Examples: |
---|
| 498 | #D- |
---|
| 499 | function IGCM_sys_CountFileArchive { |
---|
[810] | 500 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
| 501 | #Command depends on targeted file system |
---|
| 502 | DEBUG_sys=false IGCM_sys_IsFileArchived $1 |
---|
| 503 | if [ $? = 0 ] ; then |
---|
[428] | 504 | IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" |
---|
[810] | 505 | status=$? |
---|
| 506 | else |
---|
| 507 | ls ${@} 2>/dev/null | wc -l |
---|
| 508 | status=$? |
---|
| 509 | fi |
---|
| 510 | if [ ${status} -gt 0 ] ; then |
---|
| 511 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
| 512 | fi |
---|
| 513 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
[428] | 514 | } |
---|
| 515 | |
---|
| 516 | #D-#================================================== |
---|
[810] | 517 | #D-function IGCM_sys_CountFileBuffer |
---|
| 518 | #D-* Purpose: Count files on Scratch filesystem |
---|
| 519 | #D-* Examples: |
---|
| 520 | #D- |
---|
| 521 | function IGCM_sys_CountFileBuffer { |
---|
| 522 | IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ |
---|
| 523 | ls ${@} 2>/dev/null | wc -l |
---|
| 524 | if [ $? -gt 0 ] ; then |
---|
| 525 | echo "IGCM_sys_CountFileBuffer : erreur." |
---|
| 526 | fi |
---|
| 527 | IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | #D-#================================================== |
---|
[428] | 531 | #D-function IGCM_sys_Tree |
---|
| 532 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
| 533 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
| 534 | #D- |
---|
| 535 | function IGCM_sys_Tree { |
---|
[810] | 536 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
| 537 | if ( $DEBUG_sys ) ; then |
---|
| 538 | echo "IGCM_sys_Tree :" $@ |
---|
| 539 | fi |
---|
[428] | 540 | |
---|
[811] | 541 | \tree -f $@ |
---|
[428] | 542 | |
---|
[810] | 543 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
[428] | 544 | } |
---|
| 545 | |
---|
| 546 | #D-#================================================== |
---|
| 547 | #D-function IGCM_sys_Tar |
---|
[810] | 548 | #D-* Purpose: master tar command |
---|
[428] | 549 | #D-* Examples: |
---|
| 550 | #D- |
---|
| 551 | function IGCM_sys_Tar { |
---|
[810] | 552 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
| 553 | if ( $DEBUG_sys ) ; then |
---|
| 554 | echo "IGCM_sys_Tar :" $@ |
---|
| 555 | fi |
---|
| 556 | \tar cf $@ |
---|
| 557 | if [ $? -gt 0 ] ; then |
---|
| 558 | echo "IGCM_sys_Tar : erreur." |
---|
| 559 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
| 560 | fi |
---|
| 561 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
[428] | 562 | } |
---|
| 563 | |
---|
| 564 | #D-#================================================== |
---|
| 565 | #D-function IGCM_sys_UnTar |
---|
| 566 | #D-* Purpose: master un-tar command |
---|
| 567 | #D-* Examples: |
---|
| 568 | #D- |
---|
| 569 | function IGCM_sys_UnTar { |
---|
[810] | 570 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
| 571 | if ( $DEBUG_sys ) ; then |
---|
| 572 | echo "IGCM_sys_UnTar :" $@ |
---|
| 573 | fi |
---|
| 574 | \tar xvf $1 |
---|
| 575 | if [ $? -gt 0 ] ; then |
---|
| 576 | echo "IGCM_sys_UnTar : erreur." |
---|
| 577 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
| 578 | fi |
---|
| 579 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
[428] | 580 | } |
---|
| 581 | |
---|
| 582 | #D-#================================================== |
---|
| 583 | #D-function IGCM_sys_Qsub |
---|
| 584 | #D-* Purpose: Qsub new job |
---|
| 585 | #D-* Examples: |
---|
| 586 | #D- |
---|
| 587 | function IGCM_sys_Qsub { |
---|
[810] | 588 | IGCM_debug_PushStack "IGCM_sys_Qsub" $@ |
---|
| 589 | |
---|
[811] | 590 | typeset status |
---|
[810] | 591 | |
---|
| 592 | if ( $DEBUG_sys ) ; then |
---|
| 593 | echo "IGCM_sys_Qsub :" $@ |
---|
| 594 | fi |
---|
| 595 | # We have to change output/error file |
---|
| 596 | [ ${#@} = 1 ] && REP_FOR_JOB=${SUBMIT_DIR} |
---|
| 597 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 598 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \ |
---|
[811] | 599 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:" \ |
---|
| 600 | $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 601 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM ; status=$? ; cd - ; |
---|
[810] | 602 | |
---|
[811] | 603 | if [ ${status} -gt 0 ] ; then |
---|
| 604 | IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}" |
---|
[810] | 605 | IGCM_debug_Exit "IGCM_sys_Qsub" |
---|
| 606 | else |
---|
| 607 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 608 | fi |
---|
| 609 | IGCM_debug_PopStack "IGCM_sys_Qsub" |
---|
[428] | 610 | } |
---|
| 611 | |
---|
| 612 | #D-#================================================== |
---|
| 613 | #D-function IGCM_sys_QsubPost |
---|
| 614 | #D-* Purpose: Qsub new job on scalaire |
---|
| 615 | #D-* Examples: |
---|
| 616 | #D- |
---|
| 617 | function IGCM_sys_QsubPost { |
---|
[810] | 618 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
| 619 | |
---|
[811] | 620 | typeset status |
---|
[810] | 621 | |
---|
| 622 | if ( $DEBUG_sys ) ; then |
---|
| 623 | echo "IGCM_sys_QsubPost :" $@ |
---|
| 624 | fi |
---|
| 625 | # We have to change output/error file |
---|
| 626 | [ ${#@} = 1 ] && REP_FOR_JOB=${POST_DIR} |
---|
| 627 | [ ${#@} = 2 ] && REP_FOR_JOB=${2} |
---|
| 628 | |
---|
| 629 | sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \ |
---|
[811] | 630 | -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:" \ |
---|
| 631 | ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
[810] | 632 | |
---|
[811] | 633 | cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM ; status=$? ; cd - ; |
---|
| 634 | if [ ${status} -gt 0 ] ; then |
---|
| 635 | IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}" |
---|
[810] | 636 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
| 637 | else |
---|
| 638 | IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM |
---|
| 639 | fi |
---|
| 640 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
[428] | 641 | } |
---|
| 642 | |
---|
| 643 | #D-************************* |
---|
[809] | 644 | #D- File transfer functions |
---|
[428] | 645 | #D-************************* |
---|
| 646 | #D- |
---|
| 647 | |
---|
| 648 | #D-#================================================== |
---|
| 649 | #D-function IGCM_sys_Rsync_out |
---|
| 650 | #D-* Purpose: treat return val of rsync |
---|
| 651 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
| 652 | #D- Error values and explanations can depend on your system version. |
---|
| 653 | function IGCM_sys_Rsync_out { |
---|
[810] | 654 | status=$1 |
---|
| 655 | if [ ! $status ] ; then |
---|
| 656 | echo "rsync error !" |
---|
| 657 | fi |
---|
[428] | 658 | |
---|
[810] | 659 | if [ $MYLANG = "fr" ]; then |
---|
| 660 | case $status in |
---|
| 661 | 0) return ;; |
---|
| 662 | 1) echo "Erreur de rsync ; RERR_SYNTAX : " |
---|
| 663 | echo "Erreur de syntaxe ou d'utilisation." |
---|
| 664 | return;; |
---|
| 665 | 2) echo "Erreur de rsync ; RERR_PROTOCOL : " |
---|
| 666 | echo "Incompatibilité de protocole." |
---|
| 667 | return;; |
---|
| 668 | 3) echo "Erreur de rsync ; RERR_FILESELECT 3" |
---|
| 669 | echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" |
---|
| 670 | echo "répertoires" |
---|
| 671 | return;; |
---|
| 672 | 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" |
---|
| 673 | echo "Action demandée non supportée : une tentative de manipulation de" |
---|
| 674 | echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" |
---|
| 675 | echo "été faite ; ou une option qui est supportée par le client mais" |
---|
| 676 | echo "pas par le serveur a été spécifiée." |
---|
| 677 | return;; |
---|
| 678 | 10) echo "Erreur de rsync ; RERR_SOCKETIO" |
---|
| 679 | echo "Erreur dans le socket d'entrée sortie" |
---|
| 680 | return;; |
---|
| 681 | 11) echo "Erreur de rsync ; RERR_FILEIO" |
---|
| 682 | echo "Erreur d'entrée sortie fichier" |
---|
| 683 | return;; |
---|
| 684 | 12) echo "Erreur de rsync ; RERR_STREAMIO" |
---|
| 685 | echo "Erreur dans flux de donnée du protocole rsync" |
---|
| 686 | return;; |
---|
| 687 | 13) echo "Erreur de rsync ; RERR_MESSAGEIO" |
---|
| 688 | echo "Erreur avec les diagnostics du programme" |
---|
| 689 | return;; |
---|
| 690 | 14) echo "Erreur de rsync ; RERR_IPC" |
---|
| 691 | echo "Erreur dans le code IPC" |
---|
| 692 | return;; |
---|
| 693 | 20) echo "Erreur de rsync ; RERR_SIGNAL" |
---|
| 694 | echo "SIGUSR1 ou SIGINT reçu" |
---|
| 695 | return;; |
---|
| 696 | 21) echo "Erreur de rsync ; RERR_WAITCHILD" |
---|
| 697 | echo "Une erreur retournée par waitpid()" |
---|
| 698 | return;; |
---|
| 699 | 22) echo "Erreur de rsync ; RERR_MALLOC" |
---|
| 700 | echo "Erreur lors de l'allocation des tampons de mémoire de coeur" |
---|
| 701 | return;; |
---|
| 702 | 23) echo "" |
---|
| 703 | echo "Erreur fichier inexistant" |
---|
| 704 | return;; |
---|
| 705 | 30) echo "Erreur de rsync ; RERR_TIMEOUT" |
---|
| 706 | echo "Temps d'attente écoulé dans l'envoi/réception de données" |
---|
| 707 | return;; |
---|
| 708 | *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status |
---|
| 709 | return;; |
---|
| 710 | esac |
---|
| 711 | elif [ $MYLANG = "en" ] ; then |
---|
| 712 | case $status in |
---|
| 713 | 0) return;; |
---|
| 714 | 1) echo "rsync error : Syntax or usage error " |
---|
| 715 | return;; |
---|
| 716 | 2) echo "rsync error : Protocol incompatibility " |
---|
| 717 | return;; |
---|
| 718 | 3) echo "rsync error : Errors selecting input/output files, dirs" |
---|
| 719 | return;; |
---|
| 720 | 4) echo "rsync error : Requested action not supported: an attempt" |
---|
| 721 | echo "was made to manipulate 64-bit files on a platform that cannot support" |
---|
| 722 | echo "them; or an option was specified that is supported by the client and" |
---|
| 723 | echo "not by the server." |
---|
| 724 | return;; |
---|
| 725 | 5) echo "rsync error : Error starting client-server protocol" |
---|
| 726 | return;; |
---|
| 727 | 10) echo "rsync error : Error in socket I/O " |
---|
| 728 | return;; |
---|
| 729 | 11) echo "rsync error : Error in file I/O " |
---|
| 730 | return;; |
---|
| 731 | 12) echo "rsync error : Error in rsync protocol data stream " |
---|
| 732 | return;; |
---|
| 733 | 13) echo "rsync error : Errors with program diagnostics " |
---|
| 734 | return;; |
---|
| 735 | 14) echo "rsync error : Error in IPC code " |
---|
| 736 | return;; |
---|
| 737 | 20) echo "rsync error : Received SIGUSR1 or SIGINT " |
---|
| 738 | return;; |
---|
| 739 | 21) echo "rsync error : Some error returned by waitpid() " |
---|
| 740 | return;; |
---|
| 741 | 22) echo "rsync error : Error allocating core memory buffers " |
---|
| 742 | return;; |
---|
| 743 | 23) echo "rsync error : Partial transfer due to error" |
---|
| 744 | return;; |
---|
| 745 | 24) echo "rsync error : Partial transfer due to vanished source files" |
---|
| 746 | return;; |
---|
| 747 | 30) echo "rsync error : Timeout in data send/receive " |
---|
| 748 | return;; |
---|
| 749 | *) echo "rsync error : return code of rsync unknown :" $status |
---|
| 750 | return;; |
---|
| 751 | esac |
---|
| 752 | else |
---|
| 753 | echo "unknown language $MYLANG." |
---|
| 754 | return |
---|
| 755 | fi |
---|
[428] | 756 | } |
---|
| 757 | |
---|
| 758 | #D-#================================================== |
---|
[810] | 759 | #D-function IGCM_sys_Miror_libIGCM |
---|
| 760 | #D-* Purpose: Mirror libIGCM PATH and lib to frontend |
---|
| 761 | #D-* Examples: |
---|
| 762 | #D- |
---|
| 763 | function IGCM_sys_Mirror_libIGCM { |
---|
| 764 | IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" |
---|
| 765 | if ( $DEBUG_sys ) ; then |
---|
| 766 | echo "IGCM_sys_Mirror_libIGCM" |
---|
| 767 | fi |
---|
| 768 | |
---|
| 769 | typeset status |
---|
| 770 | |
---|
| 771 | mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} |
---|
| 772 | |
---|
| 773 | echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 |
---|
| 774 | ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 |
---|
| 775 | status=$? |
---|
| 776 | |
---|
| 777 | if [ ${status} -gt 0 ] ; then |
---|
| 778 | echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." |
---|
| 779 | cat out_rsync |
---|
| 780 | fi |
---|
| 781 | IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | #D-#================================================== |
---|
[428] | 785 | #D-function IGCM_sys_Cp |
---|
| 786 | #D-* Purpose: generic cp |
---|
| 787 | #D-* Examples: |
---|
| 788 | #D- |
---|
| 789 | function IGCM_sys_Cp { |
---|
[810] | 790 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
| 791 | if ( $DEBUG_sys ) ; then |
---|
| 792 | echo "IGCM_sys_Cp :" $@ |
---|
| 793 | fi |
---|
[428] | 794 | |
---|
[810] | 795 | typeset status |
---|
[428] | 796 | |
---|
[810] | 797 | echo cp $@ > out_rsync 2>&1 |
---|
| 798 | \cp $@ >> out_rsync 2>&1 |
---|
| 799 | status=$? |
---|
[428] | 800 | |
---|
[810] | 801 | if [ ${status} -gt 0 ] ; then |
---|
| 802 | echo "IGCM_sys_Cp : error code ${status}" |
---|
| 803 | cat out_rsync |
---|
| 804 | IGCM_debug_Exit "IGCM_sys_Cp" |
---|
| 805 | else |
---|
| 806 | \rm out_rsync |
---|
| 807 | fi |
---|
| 808 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
[428] | 809 | } |
---|
| 810 | |
---|
| 811 | #D-#================================================== |
---|
| 812 | #D-function IGCM_sys_Rm |
---|
| 813 | #D-* Purpose: generic rm |
---|
| 814 | #D-* Examples: |
---|
| 815 | #D- |
---|
| 816 | function IGCM_sys_Rm { |
---|
[810] | 817 | IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ |
---|
| 818 | if ( $DEBUG_sys ) ; then |
---|
| 819 | echo "IGCM_sys_Rm :" $@ |
---|
| 820 | fi |
---|
[428] | 821 | |
---|
[810] | 822 | typeset status |
---|
[428] | 823 | |
---|
[810] | 824 | echo rm $@ > out_rsync 2>&1 |
---|
| 825 | \rm $@ >> out_rsync 2>&1 |
---|
| 826 | status=$? |
---|
[428] | 827 | |
---|
[810] | 828 | if [ ${status} -gt 0 ] ; then |
---|
| 829 | echo "IGCM_sys_Rm : error code ${status}" |
---|
| 830 | cat out_rsync |
---|
| 831 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
| 832 | else |
---|
| 833 | \rm out_rsync |
---|
| 834 | fi |
---|
| 835 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
[428] | 836 | } |
---|
| 837 | |
---|
| 838 | #D-#================================================== |
---|
| 839 | #D-function IGCM_sys_RmRunDir |
---|
| 840 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
| 841 | #D- scheduler will do the job) |
---|
| 842 | #D-* Examples: |
---|
| 843 | #D- |
---|
| 844 | function IGCM_sys_RmRunDir { |
---|
[810] | 845 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ |
---|
| 846 | if ( $DEBUG_sys ) ; then |
---|
| 847 | echo "IGCM_sys_RmRunDir :" $@ |
---|
| 848 | fi |
---|
[428] | 849 | |
---|
[810] | 850 | typeset status |
---|
[428] | 851 | |
---|
[810] | 852 | echo rm $@ > out_rsync 2>&1 |
---|
| 853 | \rm $@ >> out_rsync 2>&1 |
---|
| 854 | status=$? |
---|
[428] | 855 | |
---|
[810] | 856 | if [ ${status} -gt 0 ] ; then |
---|
| 857 | echo "IGCM_sys_RmRunDir : rm error code is ${status}." |
---|
| 858 | cat out_rsync |
---|
| 859 | IGCM_debug_Exit "IGCM_sys_RmRunDir" |
---|
| 860 | else |
---|
| 861 | \rm out_rsync |
---|
| 862 | fi |
---|
| 863 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
[428] | 864 | } |
---|
| 865 | |
---|
| 866 | #D-#================================================== |
---|
| 867 | #D-function IGCM_sys_Mv |
---|
| 868 | #D-* Purpose: generic move |
---|
| 869 | #D-* Examples: |
---|
| 870 | #D- |
---|
| 871 | function IGCM_sys_Mv { |
---|
[810] | 872 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
| 873 | if ( $DEBUG_sys ) ; then |
---|
| 874 | echo "IGCM_sys_Mv :" $@ |
---|
| 875 | fi |
---|
[428] | 876 | |
---|
[810] | 877 | if [ $DRYRUN = 0 ]; then |
---|
[428] | 878 | |
---|
[810] | 879 | typeset status |
---|
[786] | 880 | |
---|
[810] | 881 | echo mv $@ > out_rsync 2>&1 |
---|
| 882 | \mv $@ >> out_rsync 2>&1 |
---|
| 883 | status=$? |
---|
[786] | 884 | |
---|
[810] | 885 | if [ ${status} -gt 0 ] ; then |
---|
| 886 | echo "IGCM_sys_Mv : error code ${status}" |
---|
| 887 | cat out_rsync |
---|
| 888 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
[428] | 889 | else |
---|
[810] | 890 | \rm out_rsync |
---|
[428] | 891 | fi |
---|
[810] | 892 | fi |
---|
[428] | 893 | |
---|
[810] | 894 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
[428] | 895 | } |
---|
| 896 | |
---|
| 897 | #D-#================================================== |
---|
| 898 | #D-function IGCM_sys_Put_Dir |
---|
| 899 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
| 900 | #D-* Examples: |
---|
| 901 | #D- |
---|
| 902 | function IGCM_sys_Put_Dir { |
---|
[810] | 903 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
| 904 | if ( $DEBUG_sys ) ; then |
---|
| 905 | echo "IGCM_sys_Put_Dir :" $@ |
---|
| 906 | fi |
---|
| 907 | if [ $DRYRUN = 0 ]; then |
---|
| 908 | if [ ! -d ${1} ] ; then |
---|
| 909 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
| 910 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
| 911 | return |
---|
[428] | 912 | fi |
---|
| 913 | |
---|
[810] | 914 | typeset status |
---|
[428] | 915 | |
---|
[810] | 916 | # Only if we use rsync |
---|
| 917 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
| 918 | # |
---|
| 919 | #USUAL WAY |
---|
| 920 | \cp -r $1 $2 > out_rsync 2>&1 |
---|
| 921 | status=$? |
---|
[428] | 922 | |
---|
[810] | 923 | if [ ${status} -gt 0 ] ; then |
---|
| 924 | IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" |
---|
| 925 | cat out_rsync |
---|
| 926 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
[428] | 927 | else |
---|
[810] | 928 | \rm out_rsync |
---|
[428] | 929 | fi |
---|
[810] | 930 | fi |
---|
| 931 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
[428] | 932 | } |
---|
| 933 | |
---|
| 934 | #D-#================================================== |
---|
| 935 | #D-function IGCM_sys_Get_Dir |
---|
[810] | 936 | #D-* Purpose: Copy a complete directory from ${ARCHIVE} |
---|
[428] | 937 | #D-* Examples: |
---|
| 938 | #D- |
---|
| 939 | function IGCM_sys_Get_Dir { |
---|
[810] | 940 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
| 941 | if ( $DEBUG_sys ) ; then |
---|
| 942 | echo "IGCM_sys_Get_Dir :" $@ |
---|
| 943 | fi |
---|
| 944 | if [ $DRYRUN = 0 ]; then |
---|
| 945 | if [ ! -d ${1} ] ; then |
---|
| 946 | echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
| 947 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
| 948 | return |
---|
[428] | 949 | fi |
---|
| 950 | |
---|
[810] | 951 | typeset status |
---|
[428] | 952 | |
---|
[811] | 953 | #USUAL WAY |
---|
| 954 | \cp -ur $1 $2 > out_rsync 2>&1 |
---|
[810] | 955 | status=$? |
---|
[428] | 956 | |
---|
[810] | 957 | if [ ${status} -gt 0 ] ; then |
---|
| 958 | IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" |
---|
| 959 | cat out_rsync |
---|
| 960 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
[428] | 961 | else |
---|
[810] | 962 | \rm out_rsync |
---|
[428] | 963 | fi |
---|
[810] | 964 | fi |
---|
| 965 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
[428] | 966 | } |
---|
| 967 | |
---|
| 968 | #D-#================================================== |
---|
| 969 | #D-function IGCM_sys_Get_Master |
---|
| 970 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
| 971 | #D-* Examples: |
---|
| 972 | #D- |
---|
| 973 | function IGCM_sys_Get_Master { |
---|
[810] | 974 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
| 975 | if ( $DEBUG_sys ) ; then |
---|
| 976 | echo "IGCM_sys_Get_Master :" $@ |
---|
| 977 | fi |
---|
| 978 | if [ $DRYRUN = 0 ]; then |
---|
| 979 | if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then |
---|
| 980 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." |
---|
| 981 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
| 982 | return |
---|
[428] | 983 | fi |
---|
| 984 | |
---|
[810] | 985 | typeset NB_ESSAI DELAI status i |
---|
| 986 | # number of tentative |
---|
| 987 | NB_ESSAI=3 |
---|
| 988 | # time delay between tentative |
---|
| 989 | DELAI=2 |
---|
[428] | 990 | |
---|
[810] | 991 | i=0 |
---|
| 992 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 993 | \cp -urL $1 $2 > out_rsync 2>&1 |
---|
| 994 | status=$? |
---|
| 995 | if [ ${status} -gt 0 ]; then |
---|
| 996 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
| 997 | IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." |
---|
| 998 | sleep $DELAI |
---|
| 999 | else |
---|
| 1000 | break |
---|
| 1001 | fi |
---|
| 1002 | (( i = i + 1 )) |
---|
| 1003 | done |
---|
[428] | 1004 | |
---|
[810] | 1005 | if [ ${status} -gt 0 ] ; then |
---|
| 1006 | echo "IGCM_sys_Get_Master : error." |
---|
| 1007 | cat out_rsync |
---|
| 1008 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
[428] | 1009 | else |
---|
[810] | 1010 | \rm out_rsync |
---|
[428] | 1011 | fi |
---|
[810] | 1012 | fi |
---|
| 1013 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
[428] | 1014 | } |
---|
| 1015 | |
---|
[810] | 1016 | #==================================================== |
---|
| 1017 | #- Call IGCM_sys_Mirror_libIGCM now ! |
---|
| 1018 | if ( $MirrorlibIGCM ) ; then |
---|
| 1019 | IGCM_sys_Mirror_libIGCM |
---|
| 1020 | fi |
---|
| 1021 | |
---|
[428] | 1022 | #D-#================================================== |
---|
| 1023 | #D-function IGCM_sys_Put_Rest |
---|
[810] | 1024 | #D-* Purpose: Put computied restarts on ${ARCHIVE}. |
---|
[428] | 1025 | #D- File and target directory must exist. |
---|
| 1026 | #D-* Examples: |
---|
| 1027 | #D- |
---|
| 1028 | function IGCM_sys_Put_Rest { |
---|
[810] | 1029 | IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ |
---|
| 1030 | if ( $DEBUG_sys ) ; then |
---|
| 1031 | echo "IGCM_sys_Put_Rest :" $@ |
---|
| 1032 | fi |
---|
| 1033 | if [ $DRYRUN = 0 ]; then |
---|
| 1034 | if [ ! -f ${1} ] ; then |
---|
| 1035 | echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." |
---|
| 1036 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 1037 | fi |
---|
| 1038 | |
---|
[810] | 1039 | typeset status |
---|
| 1040 | # |
---|
| 1041 | if [ X${JobType} = XRUN ] ; then |
---|
| 1042 | IGCM_sys_Chmod 444 ${1} |
---|
| 1043 | fi |
---|
| 1044 | # |
---|
| 1045 | # Only if we use rsync |
---|
| 1046 | #IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 1047 | # |
---|
| 1048 | #USUAL WAY |
---|
| 1049 | \cp $1 $2 > out_rsync 2>&1 |
---|
| 1050 | status=$? |
---|
[428] | 1051 | |
---|
[810] | 1052 | if [ ${status} -gt 0 ] ; then |
---|
| 1053 | echo "IGCM_sys_Put_Rest : cp failed error code ${status}" |
---|
| 1054 | cat out_rsync |
---|
| 1055 | IGCM_debug_Exit "IGCM_sys_Put_Rest" |
---|
[428] | 1056 | else |
---|
[810] | 1057 | \rm out_rsync |
---|
[428] | 1058 | fi |
---|
[810] | 1059 | fi |
---|
| 1060 | IGCM_debug_PopStack "IGCM_sys_Put_Rest" |
---|
[428] | 1061 | } |
---|
| 1062 | |
---|
| 1063 | #D-#================================================== |
---|
[810] | 1064 | #D-function IGCM_sys_PutBuffer_Rest |
---|
| 1065 | #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. |
---|
| 1066 | #D- File and target directory must exist. |
---|
| 1067 | #D-* Examples: |
---|
| 1068 | #D- |
---|
| 1069 | function IGCM_sys_PutBuffer_Rest { |
---|
| 1070 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ |
---|
| 1071 | if ( $DEBUG_sys ) ; then |
---|
| 1072 | echo "IGCM_sys_PutBuffer_Rest :" $@ |
---|
| 1073 | fi |
---|
| 1074 | if [ $DRYRUN = 0 ]; then |
---|
| 1075 | if [ ! -f ${1} ] ; then |
---|
| 1076 | echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." |
---|
| 1077 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
| 1078 | fi |
---|
| 1079 | |
---|
| 1080 | typeset status |
---|
| 1081 | # |
---|
| 1082 | if [ X${JobType} = XRUN ] ; then |
---|
| 1083 | IGCM_sys_Chmod 444 ${1} |
---|
| 1084 | fi |
---|
| 1085 | |
---|
| 1086 | # |
---|
| 1087 | # USUAL WAY |
---|
| 1088 | \cp $1 $2 > out_rsync 2>&1 |
---|
| 1089 | status=$? |
---|
| 1090 | |
---|
| 1091 | if [ ${status} -gt 0 ] ; then |
---|
| 1092 | echo "IGCM_sys_PutBuffer_Rest : error code ${status}" |
---|
| 1093 | [ -f ${2} ] && ls -l ${2} |
---|
| 1094 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
| 1095 | cat out_rsync |
---|
| 1096 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" |
---|
| 1097 | else |
---|
| 1098 | \rm out_rsync |
---|
| 1099 | fi |
---|
| 1100 | fi |
---|
| 1101 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" |
---|
| 1102 | } |
---|
| 1103 | |
---|
| 1104 | #D-#================================================== |
---|
[801] | 1105 | #D-function IGCM_sys_PrepareTaredRestart |
---|
| 1106 | #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. |
---|
| 1107 | #D-* Examples: |
---|
| 1108 | #D- |
---|
| 1109 | function IGCM_sys_PrepareTaredRestart { |
---|
| 1110 | IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ |
---|
| 1111 | echo $1 |
---|
| 1112 | IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" |
---|
| 1113 | } |
---|
| 1114 | |
---|
| 1115 | #D-#================================================== |
---|
[428] | 1116 | #D-function IGCM_sys_Put_Out |
---|
[810] | 1117 | #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly |
---|
[428] | 1118 | #D-* Examples: |
---|
| 1119 | #D- |
---|
| 1120 | function IGCM_sys_Put_Out { |
---|
[810] | 1121 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
| 1122 | if ( $DEBUG_sys ) ; then |
---|
| 1123 | echo "IGCM_sys_Put_Out :" $@ |
---|
| 1124 | fi |
---|
| 1125 | |
---|
| 1126 | typeset status |
---|
| 1127 | |
---|
| 1128 | if [ $DRYRUN = 0 ]; then |
---|
| 1129 | if [ ! -f ${1} ] ; then |
---|
| 1130 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
| 1131 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 1132 | return 1 |
---|
[428] | 1133 | fi |
---|
[810] | 1134 | # |
---|
| 1135 | IGCM_sys_MkdirArchive $( dirname $2 ) |
---|
| 1136 | # |
---|
| 1137 | if [ X${JobType} = XRUN ] ; then |
---|
| 1138 | if [ X${3} = X ] ; then |
---|
| 1139 | IGCM_sys_Chmod 444 ${1} |
---|
[786] | 1140 | fi |
---|
[810] | 1141 | fi |
---|
| 1142 | # |
---|
| 1143 | #USUAL WAY |
---|
| 1144 | \cp $1 $2 > out_rsync 2>&1 |
---|
| 1145 | status=$? |
---|
| 1146 | |
---|
| 1147 | if [ ${status} -gt 0 ] ; then |
---|
| 1148 | IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}" |
---|
| 1149 | cat out_rsync |
---|
| 1150 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
| 1151 | else |
---|
| 1152 | \rm out_rsync |
---|
| 1153 | fi |
---|
| 1154 | fi |
---|
| 1155 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 1156 | return 0 |
---|
| 1157 | } |
---|
| 1158 | |
---|
| 1159 | #D-#================================================== |
---|
| 1160 | #D-function IGCM_sys_PutBuffer_Out |
---|
| 1161 | #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly |
---|
| 1162 | #D-* Examples: |
---|
| 1163 | #D- |
---|
| 1164 | function IGCM_sys_PutBuffer_Out { |
---|
| 1165 | IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ |
---|
| 1166 | if ( $DEBUG_sys ) ; then |
---|
| 1167 | echo "IGCM_sys_PutBuffer_Out :" $@ |
---|
| 1168 | fi |
---|
| 1169 | |
---|
| 1170 | typeset NB_ESSAI DELAI status i exist skip |
---|
| 1171 | |
---|
| 1172 | # number of tentative |
---|
| 1173 | NB_ESSAI=3 |
---|
| 1174 | # time delay between tentative |
---|
| 1175 | DELAI=2 |
---|
| 1176 | |
---|
| 1177 | if [ $DRYRUN = 0 ]; then |
---|
| 1178 | if [ ! -f ${1} ] ; then |
---|
| 1179 | echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." |
---|
| 1180 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
| 1181 | return 1 |
---|
| 1182 | fi |
---|
| 1183 | # |
---|
| 1184 | IGCM_sys_Mkdir $( dirname $2 ) |
---|
| 1185 | # |
---|
| 1186 | |
---|
| 1187 | exist=false |
---|
| 1188 | skip=false |
---|
| 1189 | if [ -f $2 ] ; then |
---|
| 1190 | IGCM_debug_Print 1 "$2 already exist" |
---|
| 1191 | exist=true |
---|
| 1192 | if [ "X$( diff $1 $2 )" = X ] ; then |
---|
| 1193 | IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" |
---|
| 1194 | status=0 |
---|
| 1195 | skip=true |
---|
| 1196 | else |
---|
| 1197 | IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" |
---|
| 1198 | skip=false |
---|
| 1199 | fi |
---|
| 1200 | fi |
---|
| 1201 | # |
---|
| 1202 | if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then |
---|
| 1203 | IGCM_sys_Chmod u+w $2 |
---|
| 1204 | fi |
---|
| 1205 | |
---|
| 1206 | if [ X${skip} = Xfalse ] ; then |
---|
| 1207 | i=0 |
---|
| 1208 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1209 | # USUAL WAY |
---|
| 1210 | \cp $1 $2 > out_rsync 2>&1 |
---|
| 1211 | status=$? |
---|
| 1212 | if [ ${status} -gt 0 ]; then |
---|
| 1213 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
| 1214 | IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." |
---|
| 1215 | [ -f ${2} ] && ls -l ${2} |
---|
| 1216 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
| 1217 | sleep $DELAI |
---|
| 1218 | else |
---|
| 1219 | break |
---|
| 1220 | fi |
---|
| 1221 | (( i = i + 1 )) |
---|
| 1222 | done |
---|
| 1223 | fi |
---|
| 1224 | |
---|
| 1225 | if [ ${status} -gt 0 ] ; then |
---|
| 1226 | echo "IGCM_sys_PutBuffer_Out : error." |
---|
| 1227 | [ -f ${2} ] && ls -l ${2} |
---|
| 1228 | [ -f ${2}/${1} ] && ls -l ${2}/${1} |
---|
| 1229 | cat out_rsync |
---|
| 1230 | IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" |
---|
| 1231 | else |
---|
| 1232 | |
---|
[786] | 1233 | if [ X${JobType} = XRUN ] ; then |
---|
[810] | 1234 | if [ X${3} = X ] ; then |
---|
| 1235 | [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} |
---|
| 1236 | [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} |
---|
| 1237 | fi |
---|
[786] | 1238 | fi |
---|
[428] | 1239 | |
---|
[810] | 1240 | \rm out_rsync |
---|
[428] | 1241 | fi |
---|
[810] | 1242 | fi |
---|
| 1243 | IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" |
---|
| 1244 | return 0 |
---|
[428] | 1245 | } |
---|
| 1246 | |
---|
| 1247 | #D-#================================================== |
---|
| 1248 | #D-function IGCM_sys_Get |
---|
| 1249 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
| 1250 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
| 1251 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
| 1252 | function IGCM_sys_Get { |
---|
[810] | 1253 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
[428] | 1254 | |
---|
[810] | 1255 | typeset DEST status dm_liste |
---|
[428] | 1256 | |
---|
[810] | 1257 | if ( $DEBUG_sys ) ; then |
---|
| 1258 | echo "IGCM_sys_Get :" $@ |
---|
| 1259 | fi |
---|
| 1260 | if [ $DRYRUN -le 2 ]; then |
---|
| 1261 | if [ X${1} = X'/l' ] ; then |
---|
| 1262 | # test if the first file is present in the old computation : |
---|
| 1263 | eval set +A dm_liste \${${2}} |
---|
| 1264 | else |
---|
| 1265 | dm_liste=${1} |
---|
[428] | 1266 | fi |
---|
[810] | 1267 | eval DEST=\${${#}} |
---|
[428] | 1268 | |
---|
[810] | 1269 | # test if the (first) file is present in the old computation : |
---|
| 1270 | DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]} |
---|
| 1271 | if [ $? = 0 ] ; then |
---|
[786] | 1272 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
[810] | 1273 | status=$? |
---|
| 1274 | else |
---|
| 1275 | IGCM_sys_TestFileBuffer ${dm_liste[0]} |
---|
| 1276 | status=$? |
---|
| 1277 | fi |
---|
[428] | 1278 | |
---|
[810] | 1279 | if [ ${status} -gt 0 ] ; then |
---|
| 1280 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
| 1281 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 1282 | return |
---|
| 1283 | fi |
---|
[428] | 1284 | |
---|
[810] | 1285 | #USUAL WAY |
---|
| 1286 | \cp ${dm_liste[*]} ${DEST} > out_rsync 2>&1 |
---|
| 1287 | status=$? |
---|
| 1288 | |
---|
| 1289 | if [ ${status} -gt 0 ] ; then |
---|
| 1290 | IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" |
---|
| 1291 | cat out_rsync |
---|
| 1292 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 1293 | else |
---|
| 1294 | \rm out_rsync |
---|
| 1295 | fi |
---|
| 1296 | fi |
---|
| 1297 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
| 1298 | } |
---|
| 1299 | |
---|
| 1300 | #D-#================================================== |
---|
| 1301 | #D-function IGCM_sys_GetBuffer |
---|
| 1302 | #D-* Purpose: Get a file from ${SCRATCHDIR} |
---|
| 1303 | #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX |
---|
| 1304 | #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ |
---|
| 1305 | function IGCM_sys_GetBuffer { |
---|
| 1306 | IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ |
---|
| 1307 | |
---|
| 1308 | typeset DEST buf_liste target file_work |
---|
| 1309 | typeset NB_ESSAI DELAI status i |
---|
| 1310 | |
---|
| 1311 | if ( $DEBUG_sys ) ; then |
---|
| 1312 | echo "IGCM_sys_GetBuffer :" $@ |
---|
| 1313 | fi |
---|
| 1314 | |
---|
| 1315 | # number of tentative |
---|
| 1316 | NB_ESSAI=3 |
---|
| 1317 | # time delay between tentative |
---|
| 1318 | DELAI=2 |
---|
| 1319 | |
---|
| 1320 | if [ $DRYRUN -le 2 ]; then |
---|
| 1321 | if [ X${1} = X'/l' ] ; then |
---|
| 1322 | # test if the first file is present in the old computation : |
---|
| 1323 | eval set +A buf_liste \${${2}} |
---|
| 1324 | else |
---|
| 1325 | eval set +A buf_liste ${1} |
---|
| 1326 | fi |
---|
| 1327 | eval DEST=\${${#}} |
---|
| 1328 | |
---|
| 1329 | #USUAL WAY |
---|
| 1330 | if [ X${1} = X'/l' ] ; then |
---|
| 1331 | for target in ${buf_liste[*]} ; do |
---|
| 1332 | local_file=$( basename ${target} ) |
---|
| 1333 | i=0 |
---|
| 1334 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1335 | \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 |
---|
| 1336 | status=$? |
---|
| 1337 | if [ ${status} -gt 0 ]; then |
---|
| 1338 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
| 1339 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
| 1340 | sleep $DELAI |
---|
| 1341 | else |
---|
| 1342 | break |
---|
| 1343 | fi |
---|
| 1344 | (( i = i + 1 )) |
---|
| 1345 | done |
---|
| 1346 | if [ ${status} -gt 0 ] ; then |
---|
| 1347 | echo "IGCM_sys_Get : error" |
---|
[786] | 1348 | cat out_rsync |
---|
[810] | 1349 | \rm out_rsync |
---|
| 1350 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
| 1351 | else |
---|
| 1352 | \rm out_rsync |
---|
| 1353 | fi |
---|
| 1354 | done |
---|
| 1355 | else |
---|
| 1356 | i=0 |
---|
| 1357 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1358 | \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 |
---|
| 1359 | status=$? |
---|
| 1360 | if [ ${status} -gt 0 ]; then |
---|
| 1361 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" |
---|
| 1362 | IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." |
---|
| 1363 | sleep $DELAI |
---|
| 1364 | else |
---|
| 1365 | break |
---|
| 1366 | fi |
---|
| 1367 | (( i = i + 1 )) |
---|
| 1368 | done |
---|
| 1369 | if [ ${status} -gt 0 ] ; then |
---|
| 1370 | echo "IGCM_sys_Get : error" |
---|
| 1371 | cat out_rsync |
---|
| 1372 | \rm out_rsync |
---|
| 1373 | IGCM_debug_Exit "IGCM_sys_GetBuffer" |
---|
| 1374 | else |
---|
| 1375 | \rm out_rsync |
---|
[786] | 1376 | fi |
---|
[428] | 1377 | fi |
---|
[810] | 1378 | fi |
---|
| 1379 | IGCM_debug_PopStack "IGCM_sys_GetBuffer" |
---|
[428] | 1380 | } |
---|
| 1381 | |
---|
| 1382 | #D-#================================================== |
---|
| 1383 | #D-function IGCM_sys_GetDate_FichWork |
---|
| 1384 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
| 1385 | #D-* Examples: |
---|
| 1386 | #D- |
---|
| 1387 | function IGCM_sys_GetDate_FichWork { |
---|
[810] | 1388 | IGCM_debug_PushStack "IGCM_sys_FichWork" $@ |
---|
| 1389 | if ( $DEBUG_sys ) ; then |
---|
| 1390 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
| 1391 | fi |
---|
| 1392 | # donne la date filesys d'un fichier sur la machine work |
---|
| 1393 | IGCM_debug_PopStack "IGCM_sys_FichWork" |
---|
[428] | 1394 | } |
---|
| 1395 | |
---|
| 1396 | #D-#================================================== |
---|
| 1397 | #D-function IGCM_sys_GetDate_FichArchive |
---|
[809] | 1398 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE |
---|
[428] | 1399 | #D-* Examples: |
---|
| 1400 | #D- |
---|
| 1401 | function IGCM_sys_GetDate_FichArchive { |
---|
[810] | 1402 | IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ |
---|
| 1403 | if ( $DEBUG_sys ) ; then |
---|
| 1404 | echo "IGCM_sys_GetDate_FichArchive :" $@ |
---|
| 1405 | fi |
---|
| 1406 | IGCM_debug_PopStack "IGCM_sys_FichArchive" |
---|
[428] | 1407 | } |
---|
| 1408 | |
---|
[810] | 1409 | #D-#================================================== |
---|
[811] | 1410 | #D-function IGCM_sys_Dods_Rm |
---|
| 1411 | #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. |
---|
| 1412 | #D-* Examples: |
---|
| 1413 | #D- |
---|
| 1414 | function IGCM_sys_Dods_Rm { |
---|
| 1415 | if ( $DEBUG_sys ) ; then |
---|
| 1416 | echo "IGCM_sys_Dods_Rm :" $@ |
---|
| 1417 | fi |
---|
| 1418 | return 0 |
---|
| 1419 | } |
---|
| 1420 | |
---|
| 1421 | #D-#================================================== |
---|
| 1422 | #D-function IGCM_sys_Dods_Cp |
---|
| 1423 | #D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. |
---|
| 1424 | #D-* Examples: |
---|
| 1425 | #D- |
---|
| 1426 | function IGCM_sys_Dods_Cp { |
---|
| 1427 | if ( $DEBUG_sys ) ; then |
---|
| 1428 | echo "IGCM_sys_Dods_Cp :" $@ |
---|
| 1429 | fi |
---|
| 1430 | return 0 |
---|
| 1431 | } |
---|
| 1432 | |
---|
| 1433 | #D-#================================================== |
---|
[810] | 1434 | #D-function IGCM_sys_Put_Dods |
---|
| 1435 | #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here |
---|
| 1436 | #D-* Examples: |
---|
| 1437 | #D- |
---|
| 1438 | function IGCM_sys_Put_Dods { |
---|
| 1439 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
| 1440 | if ( $DEBUG_sys ) ; then |
---|
| 1441 | echo "IGCM_sys_Put_Dods :" $@ |
---|
| 1442 | fi |
---|
| 1443 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
| 1444 | } |
---|
| 1445 | |
---|
[428] | 1446 | ############################################################## |
---|
| 1447 | # REBUILD OPERATOR |
---|
| 1448 | |
---|
[810] | 1449 | #D-#================================================== |
---|
| 1450 | #D-function IGCM_sys_rebuild |
---|
| 1451 | #D-* Purpose: rebuild parallel files |
---|
| 1452 | #D-* Examples: |
---|
| 1453 | #D- |
---|
[428] | 1454 | function IGCM_sys_rebuild { |
---|
[810] | 1455 | IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ |
---|
| 1456 | if ( $DEBUG_sys ) ; then |
---|
| 1457 | echo "IGCM_sys_rebuild :" $@ |
---|
| 1458 | fi |
---|
| 1459 | |
---|
| 1460 | typeset NB_ESSAI DELAI status i firstArg |
---|
| 1461 | # number of tentative |
---|
| 1462 | NB_ESSAI=3 |
---|
| 1463 | # time delay between tentative |
---|
| 1464 | DELAI=2 |
---|
| 1465 | |
---|
| 1466 | i=0 |
---|
| 1467 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1468 | /gpfs1/home/sebastien/REBUILD/rebuild -f -o $@ > out_rsync 2>&1 |
---|
| 1469 | status=$? |
---|
| 1470 | if [ ${status} -gt 0 ] ; then |
---|
| 1471 | IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" |
---|
| 1472 | cat out_rsync |
---|
| 1473 | \rm out_rsync |
---|
| 1474 | IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1475 | firstArg=${1} |
---|
| 1476 | \rm ${firstArg} |
---|
| 1477 | sleep $DELAI |
---|
| 1478 | else |
---|
| 1479 | \rm out_rsync |
---|
| 1480 | break |
---|
[428] | 1481 | fi |
---|
[810] | 1482 | (( i = i + 1 )) |
---|
| 1483 | done |
---|
[428] | 1484 | |
---|
[810] | 1485 | if [ ${status} -gt 0 ] ; then |
---|
| 1486 | echo "IGCM_sys_rebuild : rebuild error code is ${status}" |
---|
| 1487 | IGCM_debug_Exit "rebuild" |
---|
| 1488 | fi |
---|
| 1489 | |
---|
| 1490 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
[428] | 1491 | } |
---|
| 1492 | |
---|
[810] | 1493 | #D-#================================================== |
---|
| 1494 | #D-function IGCM_sys_rebuild_station |
---|
| 1495 | #D-* Purpose: rebuild parallel files describing station |
---|
| 1496 | #D-* Examples: |
---|
| 1497 | #D- |
---|
| 1498 | function IGCM_sys_rebuild_station { |
---|
| 1499 | IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@ |
---|
| 1500 | typeset i list_opt file_in file_out prefix_invert list_invert |
---|
| 1501 | if ( $DEBUG_sys ) ; then |
---|
| 1502 | echo "IGCM_sys_rebuild_station :" $@ |
---|
| 1503 | fi |
---|
| 1504 | list_opt=$@ |
---|
| 1505 | |
---|
| 1506 | # Invert Axis : t,x -> x,t |
---|
| 1507 | # t,pres,x -> x,t,pres |
---|
| 1508 | # So that we can concatenate along x |
---|
| 1509 | i=0 |
---|
| 1510 | for file_in in ${list_opt} ; do |
---|
| 1511 | (( i = i + 1)) |
---|
| 1512 | [ ${i} = 1 ] && file_out=${file_in} && continue |
---|
| 1513 | prefix_invert=$( basename ${file_in} .nc ) |
---|
| 1514 | IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc |
---|
| 1515 | list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc |
---|
| 1516 | done |
---|
| 1517 | |
---|
| 1518 | # Concatenate |
---|
| 1519 | IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc |
---|
| 1520 | |
---|
| 1521 | # Re-ivert file |
---|
| 1522 | IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} |
---|
| 1523 | |
---|
| 1524 | # Station re-ordering is too expansive to be run within libICGM |
---|
| 1525 | # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. |
---|
| 1526 | # This re-ordering must be done "in memory" by the cmorization process |
---|
| 1527 | # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) |
---|
| 1528 | # BEGIN reordering |
---|
| 1529 | |
---|
| 1530 | # Only LMDZ text output contains the exact ordering of the station. |
---|
| 1531 | # We isolate this in the code below: |
---|
| 1532 | # 0 38 -157.5000000000000 70.98591549295774 |
---|
| 1533 | # 0 54 27.49999999999999 67.18309859154928 |
---|
| 1534 | # 0 56 -62.50000000000001 82.39436619718309 |
---|
| 1535 | # 0 79 12.49999999999999 78.59154929577466 |
---|
| 1536 | # 0 116 -165.0000000000000 76.05633802816901 |
---|
| 1537 | # 0 117 130.0000000000000 70.98591549295774 |
---|
| 1538 | # 0 118 110.0000000000000 87.46478873239437 |
---|
| 1539 | # 1 40 4.999999999999995 51.97183098591550 |
---|
| 1540 | # typeset iStation iProc list_opt file_in file_out prefix_invert |
---|
| 1541 | # typeset -Z4 j4 |
---|
| 1542 | # typeset -Z3 j3 |
---|
| 1543 | |
---|
| 1544 | # unset list_opt |
---|
| 1545 | # set +A list_opt $@ |
---|
| 1546 | |
---|
| 1547 | # Filename after rebuild |
---|
| 1548 | # file_out=${list_opt[0]} |
---|
| 1549 | # Prefix of output files |
---|
| 1550 | # prefix_invert=$( basename ${file_out} .nc ) |
---|
| 1551 | # Number of procs |
---|
| 1552 | # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) |
---|
| 1553 | |
---|
| 1554 | # iProc=0 |
---|
| 1555 | # while [ ${iProc} -lt ${num_proc} ] ; do |
---|
| 1556 | # Array containing Station as a number |
---|
| 1557 | # unset proc_stn |
---|
| 1558 | # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | awk ' {print $2}' ) |
---|
| 1559 | # Number of stations produced by processor proc |
---|
| 1560 | # stationLast=${#proc_stn[*]} |
---|
| 1561 | # Proc number on 4 digits |
---|
| 1562 | # j4=${iProc} |
---|
| 1563 | # Init |
---|
| 1564 | # iStation=0 |
---|
| 1565 | # while [ ${iStation} -lt ${stationLast} ] ; do |
---|
| 1566 | # Station number on 3 digits |
---|
| 1567 | # j3=${proc_stn[${iStation}]} |
---|
| 1568 | # Extract station |
---|
| 1569 | # Invert Axis : t,x -> x,t |
---|
| 1570 | # t,pres,x -> x,t,pres |
---|
| 1571 | # So that we can concatenate along x |
---|
| 1572 | # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc |
---|
| 1573 | # (( iStation = iStation + 1 )) |
---|
| 1574 | # done |
---|
| 1575 | # (( iProc = iProc + 1 )) |
---|
| 1576 | # done |
---|
| 1577 | |
---|
| 1578 | # Concatenate all station along x |
---|
| 1579 | # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc |
---|
| 1580 | |
---|
| 1581 | # Re-invert file |
---|
| 1582 | # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} |
---|
| 1583 | |
---|
| 1584 | # END reordering |
---|
| 1585 | |
---|
| 1586 | IGCM_debug_PopStack "IGCM_sys_rebuild_station" |
---|
| 1587 | } |
---|
| 1588 | |
---|
[428] | 1589 | ############################################################ |
---|
| 1590 | # Activate Running Environnment Variables |
---|
| 1591 | |
---|
[810] | 1592 | #D-#================================================== |
---|
| 1593 | #D-function IGCM_sys_desactiv_variables |
---|
| 1594 | #D-* Purpose: set environement variables prior to execution |
---|
| 1595 | #D-* Examples: |
---|
| 1596 | #D- |
---|
[428] | 1597 | function IGCM_sys_activ_variables { |
---|
[810] | 1598 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
| 1599 | if ( $DEBUG_sys ) ; then |
---|
[811] | 1600 | echo "IGCM_sys_activ_variables" |
---|
[810] | 1601 | fi |
---|
[428] | 1602 | |
---|
| 1603 | # -------------------------------------------------------------------- |
---|
| 1604 | #D- MPI specifications |
---|
| 1605 | # -------------------------------------------------------------------- |
---|
| 1606 | |
---|
| 1607 | # -------------------------------------------------------------------- |
---|
| 1608 | #D- Other specifications |
---|
| 1609 | # -------------------------------------------------------------------- |
---|
| 1610 | |
---|
[810] | 1611 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
[428] | 1612 | } |
---|
| 1613 | |
---|
| 1614 | ############################################################ |
---|
| 1615 | # Desactivate Running Environnment Variables |
---|
| 1616 | |
---|
[810] | 1617 | #D-#================================================== |
---|
| 1618 | #D-function IGCM_sys_desactiv_variables |
---|
| 1619 | #D-* Purpose: unset environement variables after execution |
---|
| 1620 | #D-* Examples: |
---|
| 1621 | #D- |
---|
[428] | 1622 | function IGCM_sys_desactiv_variables { |
---|
[810] | 1623 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
| 1624 | if ( $DEBUG_sys ) ; then |
---|
[811] | 1625 | echo "IGCM_sys_desactiv_variables" |
---|
[810] | 1626 | fi |
---|
[428] | 1627 | # -------------------------------------------------------------------- |
---|
| 1628 | #D- MPI specifications |
---|
| 1629 | # -------------------------------------------------------------------- |
---|
| 1630 | |
---|
| 1631 | # -------------------------------------------------------------------- |
---|
| 1632 | #D- Other specifications |
---|
| 1633 | # -------------------------------------------------------------------- |
---|
| 1634 | |
---|
[810] | 1635 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
| 1636 | } |
---|
[809] | 1637 | |
---|
[810] | 1638 | ############################################################ |
---|
| 1639 | # Build MPI/OMP scripts run file (dummy function) |
---|
| 1640 | |
---|
| 1641 | #D-#================================================== |
---|
| 1642 | #D-function IGCM_sys_build_run_file |
---|
| 1643 | #D-* Purpose: build run file (deprecated) |
---|
| 1644 | #D-* Examples: |
---|
| 1645 | #D- |
---|
| 1646 | function IGCM_sys_build_run_file { |
---|
| 1647 | |
---|
[811] | 1648 | IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " |
---|
[810] | 1649 | |
---|
[428] | 1650 | } |
---|
| 1651 | |
---|
| 1652 | ############################################################ |
---|
[810] | 1653 | # Build MPI/OMP scripts |
---|
[428] | 1654 | |
---|
[810] | 1655 | #D-#================================================== |
---|
| 1656 | #D-function IGCM_sys_build_execution_scripts |
---|
| 1657 | #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} |
---|
| 1658 | #D-* Examples: |
---|
| 1659 | #D- |
---|
| 1660 | function IGCM_sys_build_execution_scripts |
---|
| 1661 | { |
---|
| 1662 | IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ |
---|
| 1663 | if ( $DEBUG_sys ) ; then |
---|
| 1664 | echo "IGCM_sys_build_execution_scripts " $@ |
---|
| 1665 | fi |
---|
| 1666 | |
---|
| 1667 | typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count |
---|
| 1668 | |
---|
| 1669 | if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then |
---|
| 1670 | IGCM_debug_Exit "IGCM_sys_iitm build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} " |
---|
| 1671 | fi |
---|
| 1672 | |
---|
| 1673 | if ( ${OK_PARA_MPMD} ) ; then |
---|
| 1674 | |
---|
| 1675 | if [ -f run_file ] ; then |
---|
| 1676 | IGCM_sys_Rm -f run_file |
---|
| 1677 | fi |
---|
| 1678 | touch run_file |
---|
| 1679 | |
---|
| 1680 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1681 | # NEW : 2 Noeuds |
---|
| 1682 | # @ task_geometry={(0)(1,2,3)} |
---|
| 1683 | # Nombre de processus demandes |
---|
| 1684 | echo "Job_${config_UserChoices_JobName} includes task_geometry = \c" |
---|
| 1685 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" |
---|
| 1686 | echo "Job_${config_UserChoices_JobName} includes task_geometry with NbNodes = \c" |
---|
| 1687 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c |
---|
| 1688 | NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 )) |
---|
| 1689 | |
---|
| 1690 | if [ ${NbNodes_Job} -eq 0 ] ; then |
---|
| 1691 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run." |
---|
| 1692 | exit 1 |
---|
| 1693 | fi |
---|
| 1694 | else |
---|
| 1695 | |
---|
| 1696 | # OLD : |
---|
| 1697 | # @ total_tasks = 3 |
---|
| 1698 | # @ environment = "BATCH_NUM_PROC_TOT=3" |
---|
| 1699 | # Pas d OpenMP |
---|
| 1700 | # @ resources = ConsumableCpus(1) |
---|
| 1701 | |
---|
| 1702 | echo "Job_${config_UserChoices_JobName} includes total_tasks = \c" |
---|
| 1703 | cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" |
---|
| 1704 | NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" ) |
---|
| 1705 | NbProc_Job=${NbProc_Job:=0} |
---|
| 1706 | if [ ${NbProc_Job} -eq 0 ] ; then |
---|
| 1707 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run." |
---|
| 1708 | exit 1 |
---|
| 1709 | fi |
---|
| 1710 | if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then |
---|
| 1711 | IGCM_debug_Print 2 "ressources = ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}" |
---|
| 1712 | else |
---|
| 1713 | IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) " |
---|
| 1714 | exit 1 |
---|
| 1715 | fi |
---|
| 1716 | fi |
---|
| 1717 | |
---|
| 1718 | # run_file construction |
---|
| 1719 | |
---|
| 1720 | # Then first loop on the components for the coupler ie oasis |
---|
| 1721 | |
---|
| 1722 | ### the coupler ie oasis must be the first one |
---|
| 1723 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 1724 | |
---|
| 1725 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 1726 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 1727 | |
---|
| 1728 | # for CPL component only |
---|
| 1729 | if [ "X${comp}" = "XCPL" ] ; then |
---|
| 1730 | |
---|
| 1731 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 1732 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 1733 | |
---|
| 1734 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 1735 | |
---|
| 1736 | (( mpi_count = 1 )) |
---|
| 1737 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 1738 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1739 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 1740 | else |
---|
| 1741 | echo "./${ExeNameOut}" >> run_file |
---|
| 1742 | fi |
---|
| 1743 | (( mpi_count = mpi_count + 1 )) |
---|
| 1744 | done |
---|
| 1745 | else |
---|
| 1746 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1747 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 1748 | else |
---|
| 1749 | echo "./${ExeNameOut} " >> run_file |
---|
| 1750 | fi |
---|
| 1751 | fi |
---|
| 1752 | fi |
---|
| 1753 | done |
---|
| 1754 | |
---|
| 1755 | # Then second loop on the components |
---|
| 1756 | |
---|
| 1757 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 1758 | |
---|
| 1759 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 1760 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 1761 | |
---|
| 1762 | # Only if we really have an executable for the component and not the coupler ie oasis: |
---|
| 1763 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then |
---|
| 1764 | |
---|
| 1765 | eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} |
---|
| 1766 | eval comp_proc_omp_loc=\${${comp}_PROC_OMP} |
---|
| 1767 | |
---|
| 1768 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 1769 | |
---|
| 1770 | (( mpi_count = 1 )) |
---|
| 1771 | until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do |
---|
| 1772 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1773 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 1774 | else |
---|
| 1775 | echo "./${ExeNameOut}" >> run_file |
---|
| 1776 | fi |
---|
| 1777 | (( mpi_count = mpi_count + 1 )) |
---|
| 1778 | done |
---|
| 1779 | else |
---|
| 1780 | if ( ${OK_PARA_OMP} ) ; then |
---|
| 1781 | echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file |
---|
| 1782 | else |
---|
| 1783 | # to be tested : no MPI only OpenMP into MPMD mode |
---|
| 1784 | echo "./${ExeNameOut} " >> run_file |
---|
| 1785 | fi |
---|
| 1786 | fi |
---|
| 1787 | fi |
---|
| 1788 | done |
---|
| 1789 | |
---|
| 1790 | EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file" |
---|
| 1791 | |
---|
| 1792 | IGCM_sys_Chmod u+x run_file |
---|
[428] | 1793 | if ( $DEBUG_sys ) ; then |
---|
[810] | 1794 | echo "run_file contains : " |
---|
| 1795 | cat run_file |
---|
[428] | 1796 | fi |
---|
| 1797 | |
---|
[810] | 1798 | else # Only one executable. launch it. |
---|
[428] | 1799 | |
---|
[810] | 1800 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[428] | 1801 | |
---|
[810] | 1802 | # Only if we really have an executable for the component : |
---|
| 1803 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 1804 | if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then |
---|
| 1805 | EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}" |
---|
| 1806 | fi |
---|
[786] | 1807 | |
---|
[810] | 1808 | done |
---|
[428] | 1809 | |
---|
[810] | 1810 | fi |
---|
[428] | 1811 | |
---|
[811] | 1812 | IGCM_debug_Print 1 "sys iitm : execution command is" |
---|
[810] | 1813 | IGCM_debug_Print 1 "$EXECUTION" |
---|
[428] | 1814 | |
---|
[810] | 1815 | IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" |
---|
[428] | 1816 | } |
---|
[651] | 1817 | |
---|
| 1818 | ############################################################ |
---|
[810] | 1819 | # Check of space available on temporary filesytems. Dummy function here |
---|
| 1820 | |
---|
| 1821 | #D-#================================================== |
---|
| 1822 | #D-function IGCM_sys_check_quota. Dummy call here |
---|
| 1823 | #D-* Purpose: check user quota. Stop the simulation if quota above 90% |
---|
| 1824 | #D-* Examples: |
---|
| 1825 | #D- |
---|
[651] | 1826 | function IGCM_sys_check_quota { |
---|
[810] | 1827 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
| 1828 | if ( $DEBUG_sys ) ; then |
---|
| 1829 | echo "IGCM_sys_check_quota" |
---|
| 1830 | fi |
---|
| 1831 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
| 1832 | } |
---|
| 1833 | |
---|
| 1834 | #D-#================================================== |
---|
| 1835 | #D-function IGCM_sys_CountJobInQueue |
---|
| 1836 | #D-* Purpose: Check if job_name is currently |
---|
| 1837 | #D- running or in queue |
---|
| 1838 | #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun |
---|
| 1839 | #D- |
---|
| 1840 | function IGCM_sys_CountJobInQueue { |
---|
| 1841 | IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" |
---|
| 1842 | if ( $DEBUG_sys ) ; then |
---|
| 1843 | echo "IGCM_sys_CountJobInQueue" |
---|
| 1844 | fi |
---|
| 1845 | |
---|
| 1846 | # Print only the full (-W) JobName (%jn) |
---|
| 1847 | NbRun=$( llq -W -f %jn | grep -c "$1" ) |
---|
| 1848 | |
---|
| 1849 | eval ${2}=${NbRun} |
---|
| 1850 | |
---|
| 1851 | IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" |
---|
| 1852 | } |
---|
| 1853 | |
---|
| 1854 | ############################################################## |
---|
| 1855 | # NCO OPERATOR |
---|
| 1856 | |
---|
| 1857 | #D-#================================================== |
---|
| 1858 | #D-function IGCM_sys_ncap2 |
---|
| 1859 | #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry |
---|
| 1860 | #D-* Examples: |
---|
| 1861 | #D- |
---|
| 1862 | function IGCM_sys_ncap2 { |
---|
| 1863 | IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ |
---|
| 1864 | if ( $DEBUG_sys ) ; then |
---|
| 1865 | echo "IGCM_sys_ncap2 :" $@ |
---|
| 1866 | fi |
---|
| 1867 | |
---|
| 1868 | typeset NB_ESSAI DELAI status i |
---|
| 1869 | # number of tentative |
---|
| 1870 | NB_ESSAI=3 |
---|
| 1871 | # time delay between tentative |
---|
| 1872 | DELAI=2 |
---|
| 1873 | |
---|
| 1874 | i=0 |
---|
| 1875 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1876 | ncap2 "$@" > out_rsync 2>&1 |
---|
| 1877 | status=$? |
---|
| 1878 | if [ ${status} -gt 0 ] ; then |
---|
| 1879 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" |
---|
| 1880 | cat out_rsync |
---|
| 1881 | \rm out_rsync |
---|
| 1882 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1883 | sleep $DELAI |
---|
| 1884 | else |
---|
| 1885 | \rm out_rsync |
---|
| 1886 | break |
---|
[651] | 1887 | fi |
---|
[810] | 1888 | (( i = i + 1 )) |
---|
| 1889 | done |
---|
| 1890 | |
---|
| 1891 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 1892 | echo "IGCM_sys_ncap2 : ncap2 error" |
---|
| 1893 | IGCM_debug_Exit "ncap2" |
---|
[810] | 1894 | fi |
---|
| 1895 | |
---|
| 1896 | IGCM_debug_PopStack "IGCM_sys_ncap2" |
---|
[651] | 1897 | } |
---|
[810] | 1898 | |
---|
| 1899 | #D-#================================================== |
---|
| 1900 | #D-function IGCM_sys_ncatted |
---|
| 1901 | #D-* Purpose: encapsulate ncatted call so as to manage error code and retry |
---|
| 1902 | #D-* Examples: |
---|
| 1903 | #D- |
---|
| 1904 | function IGCM_sys_ncatted { |
---|
| 1905 | IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ |
---|
| 1906 | if ( $DEBUG_sys ) ; then |
---|
| 1907 | echo "IGCM_sys_ncatted :" $@ |
---|
| 1908 | fi |
---|
| 1909 | |
---|
| 1910 | typeset NB_ESSAI DELAI status i |
---|
| 1911 | # number of tentative |
---|
| 1912 | NB_ESSAI=3 |
---|
| 1913 | # time delay between tentative |
---|
| 1914 | DELAI=2 |
---|
| 1915 | |
---|
| 1916 | i=0 |
---|
| 1917 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1918 | ncatted "$@" > out_rsync 2>&1 |
---|
| 1919 | status=$? |
---|
| 1920 | if [ ${status} -gt 0 ] ; then |
---|
| 1921 | IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" |
---|
| 1922 | cat out_rsync |
---|
| 1923 | \rm out_rsync |
---|
| 1924 | IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1925 | sleep $DELAI |
---|
| 1926 | else |
---|
| 1927 | \rm out_rsync |
---|
| 1928 | break |
---|
| 1929 | fi |
---|
| 1930 | (( i = i + 1 )) |
---|
| 1931 | done |
---|
| 1932 | |
---|
| 1933 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 1934 | echo "IGCM_sys_ncatted : ncatted error" |
---|
| 1935 | IGCM_debug_Exit "ncatted" |
---|
[810] | 1936 | fi |
---|
| 1937 | |
---|
| 1938 | IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
| 1939 | } |
---|
| 1940 | |
---|
| 1941 | #D-#================================================== |
---|
| 1942 | #D-function IGCM_sys_ncbo |
---|
| 1943 | #D-* Purpose: encapsulate ncbo call so as to manage error code and retry |
---|
| 1944 | #D-* Examples: |
---|
| 1945 | #D- |
---|
| 1946 | function IGCM_sys_ncbo { |
---|
| 1947 | IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ |
---|
| 1948 | if ( $DEBUG_sys ) ; then |
---|
| 1949 | echo "IGCM_sys_ncbo :" $@ |
---|
| 1950 | fi |
---|
| 1951 | |
---|
| 1952 | typeset NB_ESSAI DELAI status i |
---|
| 1953 | # number of tentative |
---|
| 1954 | NB_ESSAI=3 |
---|
| 1955 | # time delay between tentative |
---|
| 1956 | DELAI=2 |
---|
| 1957 | |
---|
| 1958 | i=0 |
---|
| 1959 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1960 | ncbo $@ > out_rsync 2>&1 |
---|
| 1961 | status=$? |
---|
| 1962 | if [ ${status} -gt 0 ] ; then |
---|
| 1963 | IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" |
---|
| 1964 | cat out_rsync |
---|
| 1965 | \rm out_rsync |
---|
| 1966 | IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1967 | sleep $DELAI |
---|
| 1968 | else |
---|
| 1969 | \rm out_rsync |
---|
| 1970 | break |
---|
| 1971 | fi |
---|
| 1972 | (( i = i + 1 )) |
---|
| 1973 | done |
---|
| 1974 | |
---|
| 1975 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 1976 | echo "IGCM_sys_ncbo : ncbo error" |
---|
| 1977 | IGCM_debug_Exit "ncbo" |
---|
[810] | 1978 | fi |
---|
| 1979 | |
---|
| 1980 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
| 1981 | } |
---|
| 1982 | |
---|
| 1983 | #D-#================================================== |
---|
| 1984 | #D-function IGCM_sys_ncdif |
---|
| 1985 | #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry |
---|
| 1986 | #D-* Examples: |
---|
| 1987 | #D- |
---|
| 1988 | function IGCM_sys_ncdiff { |
---|
| 1989 | IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ |
---|
| 1990 | if ( $DEBUG_sys ) ; then |
---|
| 1991 | echo "IGCM_sys_ncdiff :" $@ |
---|
| 1992 | fi |
---|
| 1993 | |
---|
| 1994 | typeset NB_ESSAI DELAI status i |
---|
| 1995 | # number of tentative |
---|
| 1996 | NB_ESSAI=3 |
---|
| 1997 | # time delay between tentative |
---|
| 1998 | DELAI=2 |
---|
| 1999 | |
---|
| 2000 | i=0 |
---|
| 2001 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2002 | ncdiff $@ > out_rsync 2>&1 |
---|
| 2003 | status=$? |
---|
| 2004 | if [ ${status} -gt 0 ] ; then |
---|
| 2005 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" |
---|
| 2006 | cat out_rsync |
---|
| 2007 | \rm out_rsync |
---|
| 2008 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2009 | sleep $DELAI |
---|
| 2010 | else |
---|
| 2011 | \rm out_rsync |
---|
| 2012 | break |
---|
| 2013 | fi |
---|
| 2014 | (( i = i + 1 )) |
---|
| 2015 | done |
---|
| 2016 | |
---|
| 2017 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2018 | echo "IGCM_sys_ncdiff : ncdiff error" |
---|
| 2019 | IGCM_debug_Exit "ncdiff" |
---|
[810] | 2020 | fi |
---|
| 2021 | |
---|
| 2022 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
| 2023 | } |
---|
| 2024 | |
---|
| 2025 | #D-#================================================== |
---|
| 2026 | #D-function IGCM_sys_ncea |
---|
| 2027 | #D-* Purpose: encapsulate ncea call so as to manage error code and retry |
---|
| 2028 | #D-* Examples: |
---|
| 2029 | #D- |
---|
| 2030 | function IGCM_sys_ncea { |
---|
| 2031 | IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ |
---|
| 2032 | if ( $DEBUG_sys ) ; then |
---|
| 2033 | echo "IGCM_sys_ncea :" $@ |
---|
| 2034 | fi |
---|
| 2035 | |
---|
| 2036 | typeset NB_ESSAI DELAI status i |
---|
| 2037 | # number of tentative |
---|
| 2038 | NB_ESSAI=3 |
---|
| 2039 | # time delay between tentative |
---|
| 2040 | DELAI=2 |
---|
| 2041 | |
---|
| 2042 | i=0 |
---|
| 2043 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2044 | ncea $@ > out_rsync 2>&1 |
---|
| 2045 | status=$? |
---|
| 2046 | if [ ${status} -gt 0 ] ; then |
---|
| 2047 | IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" |
---|
| 2048 | cat out_rsync |
---|
| 2049 | \rm out_rsync |
---|
| 2050 | IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2051 | sleep $DELAI |
---|
| 2052 | else |
---|
| 2053 | \rm out_rsync |
---|
| 2054 | break |
---|
| 2055 | fi |
---|
| 2056 | (( i = i + 1 )) |
---|
| 2057 | done |
---|
| 2058 | |
---|
| 2059 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2060 | echo "IGCM_sys_ncea : ncea error" |
---|
| 2061 | IGCM_debug_Exit "ncea" |
---|
[810] | 2062 | fi |
---|
| 2063 | |
---|
| 2064 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
| 2065 | } |
---|
| 2066 | |
---|
| 2067 | #D-#================================================== |
---|
| 2068 | #D-function IGCM_sys_ncecat |
---|
| 2069 | #D-* Purpose: encapsulate ncecat call so as to manage error code and retry |
---|
| 2070 | #D-* Examples: |
---|
| 2071 | #D- |
---|
| 2072 | function IGCM_sys_ncecat { |
---|
| 2073 | IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ |
---|
| 2074 | if ( $DEBUG_sys ) ; then |
---|
| 2075 | echo "IGCM_sys_ncecat :" $@ |
---|
| 2076 | fi |
---|
| 2077 | |
---|
| 2078 | typeset NB_ESSAI DELAI status i |
---|
| 2079 | # number of tentative |
---|
| 2080 | NB_ESSAI=3 |
---|
| 2081 | # time delay between tentative |
---|
| 2082 | DELAI=2 |
---|
| 2083 | |
---|
| 2084 | i=0 |
---|
| 2085 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2086 | ncecat $@ > out_rsync 2>&1 |
---|
| 2087 | status=$? |
---|
| 2088 | if [ ${status} -gt 0 ] ; then |
---|
| 2089 | IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" |
---|
| 2090 | cat out_rsync |
---|
| 2091 | \rm out_rsync |
---|
| 2092 | IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2093 | sleep $DELAI |
---|
| 2094 | else |
---|
| 2095 | \rm out_rsync |
---|
| 2096 | break |
---|
| 2097 | fi |
---|
| 2098 | (( i = i + 1 )) |
---|
| 2099 | done |
---|
| 2100 | |
---|
| 2101 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2102 | echo "IGCM_sys_ncecat : ncecat error" |
---|
| 2103 | IGCM_debug_Exit "ncecat" |
---|
[810] | 2104 | fi |
---|
| 2105 | |
---|
| 2106 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
| 2107 | } |
---|
| 2108 | |
---|
| 2109 | #D-#================================================== |
---|
| 2110 | #D-function IGCM_sys_ncflint |
---|
| 2111 | #D-* Purpose: encapsulate ncflint call so as to manage error code and retry |
---|
| 2112 | #D-* Examples: |
---|
| 2113 | #D- |
---|
| 2114 | function IGCM_sys_ncflint { |
---|
| 2115 | IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ |
---|
| 2116 | if ( $DEBUG_sys ) ; then |
---|
| 2117 | echo "IGCM_sys_ncflint :" $@ |
---|
| 2118 | fi |
---|
| 2119 | |
---|
| 2120 | typeset NB_ESSAI DELAI status i |
---|
| 2121 | # number of tentative |
---|
| 2122 | NB_ESSAI=3 |
---|
| 2123 | # time delay between tentative |
---|
| 2124 | DELAI=2 |
---|
| 2125 | |
---|
| 2126 | i=0 |
---|
| 2127 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2128 | ncflint $@ > out_rsync 2>&1 |
---|
| 2129 | status=$? |
---|
| 2130 | if [ ${status} -gt 0 ] ; then |
---|
| 2131 | IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" |
---|
| 2132 | cat out_rsync |
---|
| 2133 | \rm out_rsync |
---|
| 2134 | IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2135 | sleep $DELAI |
---|
| 2136 | else |
---|
| 2137 | \rm out_rsync |
---|
| 2138 | break |
---|
| 2139 | fi |
---|
| 2140 | (( i = i + 1 )) |
---|
| 2141 | done |
---|
| 2142 | |
---|
| 2143 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2144 | echo "IGCM_sys_ncflint : ncflint error" |
---|
| 2145 | IGCM_debug_Exit "ncflint" |
---|
[810] | 2146 | fi |
---|
| 2147 | |
---|
| 2148 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
| 2149 | } |
---|
| 2150 | |
---|
| 2151 | #D-#================================================== |
---|
| 2152 | #D-function IGCM_sys_ncks |
---|
| 2153 | #D-* Purpose: encapsulate ncks call so as to manage error code and retry |
---|
| 2154 | #D-* Examples: |
---|
| 2155 | #D- |
---|
| 2156 | function IGCM_sys_ncks { |
---|
| 2157 | IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ |
---|
| 2158 | if ( $DEBUG_sys ) ; then |
---|
| 2159 | echo "IGCM_sys_ncks :" $@ |
---|
| 2160 | fi |
---|
| 2161 | |
---|
| 2162 | typeset NB_ESSAI DELAI status i |
---|
| 2163 | # number of tentative |
---|
| 2164 | NB_ESSAI=3 |
---|
| 2165 | # time delay between tentative |
---|
| 2166 | DELAI=2 |
---|
| 2167 | |
---|
| 2168 | i=0 |
---|
| 2169 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2170 | ncks $@ > out_rsync 2>&1 |
---|
| 2171 | status=$? |
---|
| 2172 | if [ ${status} -gt 0 ] ; then |
---|
| 2173 | IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" |
---|
| 2174 | cat out_rsync |
---|
| 2175 | \rm out_rsync |
---|
| 2176 | IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2177 | sleep $DELAI |
---|
| 2178 | else |
---|
| 2179 | \rm out_rsync |
---|
| 2180 | break |
---|
| 2181 | fi |
---|
| 2182 | (( i = i + 1 )) |
---|
| 2183 | done |
---|
| 2184 | |
---|
| 2185 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2186 | echo "IGCM_sys_ncks : ncks error" |
---|
| 2187 | IGCM_debug_Exit "ncks" |
---|
[810] | 2188 | fi |
---|
| 2189 | |
---|
| 2190 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
| 2191 | } |
---|
| 2192 | |
---|
| 2193 | #D-#================================================== |
---|
| 2194 | #D-function IGCM_sys_ncpdq |
---|
| 2195 | #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry |
---|
| 2196 | #D-* Examples: |
---|
| 2197 | #D- |
---|
| 2198 | function IGCM_sys_ncpdq { |
---|
| 2199 | IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ |
---|
| 2200 | if ( $DEBUG_sys ) ; then |
---|
| 2201 | echo "IGCM_sys_ncpdq :" $@ |
---|
| 2202 | fi |
---|
| 2203 | |
---|
| 2204 | typeset NB_ESSAI DELAI status i |
---|
| 2205 | # number of tentative |
---|
| 2206 | NB_ESSAI=3 |
---|
| 2207 | # time delay between tentative |
---|
| 2208 | DELAI=2 |
---|
| 2209 | |
---|
| 2210 | i=0 |
---|
| 2211 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2212 | ncpdq $@ > out_rsync 2>&1 |
---|
| 2213 | status=$? |
---|
| 2214 | if [ ${status} -gt 0 ] ; then |
---|
| 2215 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" |
---|
| 2216 | cat out_rsync |
---|
| 2217 | \rm out_rsync |
---|
| 2218 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2219 | sleep $DELAI |
---|
| 2220 | else |
---|
| 2221 | \rm out_rsync |
---|
| 2222 | break |
---|
| 2223 | fi |
---|
| 2224 | (( i = i + 1 )) |
---|
| 2225 | done |
---|
| 2226 | |
---|
| 2227 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2228 | echo "IGCM_sys_ncpdq : ncpdq error" |
---|
| 2229 | IGCM_debug_Exit "ncpdq" |
---|
[810] | 2230 | fi |
---|
| 2231 | |
---|
| 2232 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
| 2233 | } |
---|
| 2234 | |
---|
| 2235 | #D-#================================================== |
---|
| 2236 | #D-function IGCM_sys_ncra |
---|
| 2237 | #D-* Purpose: encapsulate ncra call so as to manage error code and retry |
---|
| 2238 | #D-* Examples: |
---|
| 2239 | #D- |
---|
| 2240 | function IGCM_sys_ncra { |
---|
| 2241 | IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ |
---|
| 2242 | if ( $DEBUG_sys ) ; then |
---|
| 2243 | echo "IGCM_sys_ncra :" $@ |
---|
| 2244 | fi |
---|
| 2245 | |
---|
| 2246 | typeset NB_ESSAI DELAI status i |
---|
| 2247 | # number of tentative |
---|
| 2248 | NB_ESSAI=3 |
---|
| 2249 | # time delay between tentative |
---|
| 2250 | DELAI=2 |
---|
| 2251 | |
---|
| 2252 | i=0 |
---|
| 2253 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2254 | ncra $@ > out_rsync 2>&1 |
---|
| 2255 | status=$? |
---|
| 2256 | if [ ${status} -gt 0 ] ; then |
---|
| 2257 | IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" |
---|
| 2258 | cat out_rsync |
---|
| 2259 | \rm out_rsync |
---|
| 2260 | IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2261 | sleep $DELAI |
---|
| 2262 | else |
---|
| 2263 | \rm out_rsync |
---|
| 2264 | break |
---|
| 2265 | fi |
---|
| 2266 | (( i = i + 1 )) |
---|
| 2267 | done |
---|
| 2268 | |
---|
| 2269 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2270 | echo "IGCM_sys_ncra : ncra error" |
---|
| 2271 | IGCM_debug_Exit "ncra" |
---|
[810] | 2272 | fi |
---|
| 2273 | |
---|
| 2274 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
| 2275 | } |
---|
| 2276 | |
---|
| 2277 | #D-#================================================== |
---|
| 2278 | #D-function IGCM_sys_ncrcat |
---|
| 2279 | #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry |
---|
| 2280 | #D-* Examples: |
---|
| 2281 | #D- |
---|
| 2282 | function IGCM_sys_ncrcat { |
---|
| 2283 | IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ |
---|
| 2284 | if ( $DEBUG_sys ) ; then |
---|
| 2285 | echo "IGCM_sys_ncrcat :" $@ |
---|
| 2286 | fi |
---|
| 2287 | |
---|
| 2288 | typeset NB_ESSAI DELAI status i lastArg |
---|
| 2289 | # number of tentative |
---|
| 2290 | NB_ESSAI=3 |
---|
| 2291 | # time delay between tentative |
---|
| 2292 | DELAI=2 |
---|
| 2293 | |
---|
| 2294 | i=0 |
---|
| 2295 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2296 | ncrcat $@ > out_rsync 2>&1 |
---|
| 2297 | status=$? |
---|
| 2298 | if [ ${status} -gt 0 ] ; then |
---|
| 2299 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" |
---|
| 2300 | cat out_rsync |
---|
| 2301 | \rm out_rsync |
---|
| 2302 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2303 | sleep $DELAI |
---|
| 2304 | elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" out_rsync )" = "X" ] ; then |
---|
| 2305 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" |
---|
| 2306 | cat out_rsync |
---|
| 2307 | # remove files having corrupted time axis |
---|
| 2308 | eval lastArg=\${$#} |
---|
| 2309 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" |
---|
| 2310 | \rm ${lastArg} |
---|
| 2311 | \rm out_rsync |
---|
| 2312 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2313 | sleep $DELAI |
---|
| 2314 | else |
---|
| 2315 | \rm out_rsync |
---|
| 2316 | break |
---|
| 2317 | fi |
---|
| 2318 | (( i = i + 1 )) |
---|
| 2319 | done |
---|
| 2320 | |
---|
| 2321 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2322 | echo "IGCM_sys_ncrcat : ncrcat error" |
---|
[810] | 2323 | #IGCM_debug_Exit "ncrcat" |
---|
| 2324 | fi |
---|
| 2325 | |
---|
| 2326 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
| 2327 | } |
---|
| 2328 | |
---|
| 2329 | #D-#================================================== |
---|
| 2330 | #D-function IGCM_sys_ncrename |
---|
| 2331 | #D-* Purpose: encapsulate ncrename call so as to manage error code and retry |
---|
| 2332 | #D-* Examples: |
---|
| 2333 | #D- |
---|
| 2334 | function IGCM_sys_ncrename { |
---|
| 2335 | IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ |
---|
| 2336 | if ( $DEBUG_sys ) ; then |
---|
| 2337 | echo "IGCM_sys_ncrename :" $@ |
---|
| 2338 | fi |
---|
| 2339 | |
---|
| 2340 | typeset NB_ESSAI DELAI status i |
---|
| 2341 | # number of tentative |
---|
| 2342 | NB_ESSAI=3 |
---|
| 2343 | # time delay between tentative |
---|
| 2344 | DELAI=2 |
---|
| 2345 | |
---|
| 2346 | i=0 |
---|
| 2347 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2348 | ncrename $@ > out_rsync 2>&1 |
---|
| 2349 | status=$? |
---|
| 2350 | if [ ${status} -gt 0 ] ; then |
---|
| 2351 | IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" |
---|
| 2352 | cat out_rsync |
---|
| 2353 | \rm out_rsync |
---|
| 2354 | IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2355 | sleep $DELAI |
---|
| 2356 | else |
---|
| 2357 | \rm out_rsync |
---|
| 2358 | break |
---|
| 2359 | fi |
---|
| 2360 | (( i = i + 1 )) |
---|
| 2361 | done |
---|
| 2362 | |
---|
| 2363 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2364 | echo "IGCM_sys_ncrename : ncrename error" |
---|
| 2365 | IGCM_debug_Exit "ncrename" |
---|
[810] | 2366 | fi |
---|
| 2367 | |
---|
| 2368 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
| 2369 | } |
---|
| 2370 | |
---|
| 2371 | #D-#================================================== |
---|
| 2372 | #D-function IGCM_sys_ncwa |
---|
| 2373 | #D-* Purpose: encapsulate ncwa call so as to manage error code and retry |
---|
| 2374 | #D-* Examples: |
---|
| 2375 | #D- |
---|
| 2376 | function IGCM_sys_ncwa { |
---|
| 2377 | IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ |
---|
| 2378 | if ( $DEBUG_sys ) ; then |
---|
| 2379 | echo "IGCM_sys_ncwa :" $@ |
---|
| 2380 | fi |
---|
| 2381 | |
---|
| 2382 | typeset NB_ESSAI DELAI status i |
---|
| 2383 | # number of tentative |
---|
| 2384 | NB_ESSAI=3 |
---|
| 2385 | # time delay between tentative |
---|
| 2386 | DELAI=2 |
---|
| 2387 | |
---|
| 2388 | i=0 |
---|
| 2389 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 2390 | ncwa $@ > out_rsync 2>&1 |
---|
| 2391 | status=$? |
---|
| 2392 | if [ ${status} -gt 0 ] ; then |
---|
| 2393 | IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" |
---|
| 2394 | cat out_rsync |
---|
| 2395 | \rm out_rsync |
---|
| 2396 | IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 2397 | sleep $DELAI |
---|
| 2398 | else |
---|
| 2399 | \rm out_rsync |
---|
| 2400 | break |
---|
| 2401 | fi |
---|
| 2402 | (( i = i + 1 )) |
---|
| 2403 | done |
---|
| 2404 | |
---|
| 2405 | if [ ${status} -gt 0 ] ; then |
---|
[811] | 2406 | echo "IGCM_sys_ncwa : ncwa error" |
---|
| 2407 | IGCM_debug_Exit "ncwa" |
---|
[810] | 2408 | fi |
---|
| 2409 | |
---|
| 2410 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
| 2411 | } |
---|
| 2412 | |
---|
| 2413 | ############################################################## |
---|
| 2414 | # CDO OPERATOR |
---|
| 2415 | |
---|
| 2416 | #D-#================================================== |
---|
| 2417 | #D-function IGCM_sys_cdo |
---|
| 2418 | #D-* Purpose: encapsulate cdo call so as to manage error code and retry |
---|
| 2419 | #D-* Examples: |
---|
| 2420 | #D- |
---|
| 2421 | function IGCM_sys_cdo { |
---|
| 2422 | IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ |
---|
| 2423 | if ( $DEBUG_sys ) ; then |
---|
| 2424 | echo "IGCM_sys_cdo :" $@ |
---|
| 2425 | fi |
---|
| 2426 | |
---|
| 2427 | typeset status |
---|
| 2428 | |
---|
| 2429 | \cdo $@ > out_rsync 2>&1 |
---|
| 2430 | status=$? |
---|
| 2431 | if [ ${status} -gt 0 ] ; then |
---|
| 2432 | echo "IGCM_sys_cdo : error code ${status}" |
---|
| 2433 | cat out_rsync |
---|
| 2434 | \rm out_rsync |
---|
| 2435 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 2436 | return 1 |
---|
| 2437 | else |
---|
| 2438 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 2439 | return 0 |
---|
| 2440 | fi |
---|
| 2441 | |
---|
| 2442 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 2443 | } |
---|