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