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