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