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