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