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