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