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