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