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