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