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