[619] | 1 | #!/bin/ksh |
---|
[55] | 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sebastien Denvil |
---|
[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 |
---|
[55] | 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 |
---|
[619] | 16 | # if you use the prefix #D- for comments to be extracted. |
---|
[55] | 17 | # Extract with command: cat lib* | grep "^#D-" | cut -c "4-" |
---|
| 18 | #========================================================= |
---|
| 19 | |
---|
| 20 | #D-#================================================== |
---|
[56] | 21 | #D-LibIGCM_sys for Ulam |
---|
[55] | 22 | #D-#================================================== |
---|
| 23 | #D- |
---|
[619] | 24 | #D- This ksh library if a layer under some usefull |
---|
[55] | 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 | #===================================================== |
---|
[619] | 64 | # Host and user names |
---|
[217] | 65 | # $hostname ou hostname |
---|
[228] | 66 | typeset HOST=${HOST:=$( hostname )} |
---|
[55] | 67 | # $username ou whoami |
---|
[228] | 68 | typeset LOGIN=${LOGIN:=$( whoami )} |
---|
[55] | 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="-Lt -v" |
---|
| 79 | # RSYNC_opt args to "remote rsync" |
---|
| 80 | # ie storage filesystem |
---|
| 81 | typeset -r RHOST=gaya.idris.fr |
---|
| 82 | typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync |
---|
| 83 | |
---|
| 84 | #==================================================== |
---|
[305] | 85 | # Set environment tools (ferret, nco, cdo) |
---|
[56] | 86 | #==================================================== |
---|
[305] | 87 | . /home/rech/psl/rpsl035/.atlas_env_ulam_bash |
---|
[55] | 88 | |
---|
| 89 | #==================================================== |
---|
| 90 | # Host specific DIRECTORIES |
---|
| 91 | #==================================================== |
---|
| 92 | |
---|
| 93 | #==================================================== |
---|
| 94 | #- R_EXE (==> BIN_DIR = ${MODIPSL}/bin ) |
---|
| 95 | typeset -r R_EXE="${MODIPSL}/bin" |
---|
| 96 | |
---|
| 97 | #==================================================== |
---|
| 98 | #- SUBMIT_DIR : submission dir |
---|
[58] | 99 | typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}} |
---|
[55] | 100 | |
---|
| 101 | #==================================================== |
---|
| 102 | #- ARCHIVE |
---|
[619] | 103 | # modified 17/10/2011 /u to be used for file stored on gaya |
---|
| 104 | if (tty -s ) then |
---|
| 105 | typeset -r ARCHIVE=${HOMEGAYA} |
---|
| 106 | else |
---|
| 107 | typeset -r ARCHIVE=$(echo ${HOMEGAYA}|sed 's,/homegaya/,/u/',) |
---|
[506] | 108 | fi |
---|
[55] | 109 | |
---|
| 110 | #==================================================== |
---|
| 111 | #- IN |
---|
| 112 | typeset -r R_IN=${R_IN:=/u/rech/psl/rpsl035/IGCM} |
---|
[438] | 113 | typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/u/rech/psl/rpsl376} |
---|
[55] | 114 | |
---|
| 115 | #==================================================== |
---|
| 116 | #- OUT |
---|
| 117 | typeset -r R_OUT=${ARCHIVE}/IGCM_OUT |
---|
| 118 | |
---|
| 119 | #==================================================== |
---|
[633] | 120 | #- R_FIG (hosting figures : monitoring and atlas, and/or small files) |
---|
| 121 | typeset -r R_FIG=${ARCHIVE}/IGCM_OUT |
---|
| 122 | |
---|
| 123 | #==================================================== |
---|
[619] | 124 | #- R_BUF Buffer to pack files stored on Master |
---|
| 125 | typeset -r R_BUF=${WORKDIR}/IGCM_OUT |
---|
| 126 | |
---|
| 127 | #==================================================== |
---|
[55] | 128 | #- OUT_POST |
---|
| 129 | typeset -r R_OUT_POST=${WORKDIR}/IGCM_OUT |
---|
| 130 | |
---|
| 131 | #==================================================== |
---|
| 132 | #- RUN_DIR_PATH : Temporary working directory (=> TMP) |
---|
| 133 | typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}} |
---|
| 134 | |
---|
[61] | 135 | #==================================================== |
---|
| 136 | #- Max number of arguments passed to nco operator or demigration command |
---|
[502] | 137 | UNIX_MAX_LIMIT=120 |
---|
[61] | 138 | |
---|
[55] | 139 | #D-#================================================== |
---|
| 140 | #D-function IGCM_sys_RshMaster |
---|
| 141 | #D-* Purpose: Master rsh command |
---|
| 142 | #D-* Examples: |
---|
| 143 | #D- |
---|
| 144 | function IGCM_sys_RshMaster { |
---|
| 145 | #set -vx |
---|
[619] | 146 | IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ |
---|
| 147 | rsh ${MASTER} exec /bin/ksh <<-EOF |
---|
[55] | 148 | export libIGCM=${libIGCM_SX} |
---|
[98] | 149 | export DEBUG_debug=${DEBUG_debug} |
---|
[55] | 150 | . ${libIGCM_SX}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 151 | . ${libIGCM_SX}/libIGCM_card/libIGCM_card.ksh |
---|
| 152 | ${@} |
---|
| 153 | EOF |
---|
[619] | 154 | if [ $? -gt 0 ] ; then |
---|
| 155 | echo "IGCM_sys_RshMaster : erreur." |
---|
| 156 | IGCM_debug_Exit "IGCM_sys_RshMaster" |
---|
| 157 | fi |
---|
| 158 | IGCM_debug_PopStack "IGCM_sys_RshMaster" |
---|
[55] | 159 | } |
---|
| 160 | |
---|
| 161 | #D-#================================================== |
---|
| 162 | #D-function IGCM_sys_RshArchive |
---|
| 163 | #D-* Purpose: Archive rsh command |
---|
| 164 | #D-* Examples: |
---|
| 165 | #D- |
---|
| 166 | function IGCM_sys_RshArchive { |
---|
[619] | 167 | IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ |
---|
| 168 | /bin/ksh <<-EOF |
---|
[55] | 169 | ${@} |
---|
| 170 | EOF |
---|
[619] | 171 | if [ $? -gt 0 ] ; then |
---|
| 172 | echo "IGCM_sys_RshArchive : erreur." |
---|
| 173 | IGCM_debug_Exit "IGCM_sys_RshArchive" |
---|
| 174 | fi |
---|
| 175 | IGCM_debug_PopStack "IGCM_sys_RshArchive" |
---|
[55] | 176 | } |
---|
| 177 | |
---|
| 178 | #D-#================================================== |
---|
| 179 | #D-function IGCM_sys_RshPost |
---|
| 180 | #D-* Purpose: Master rsh command |
---|
| 181 | #D-* Examples: |
---|
| 182 | #D- |
---|
| 183 | function IGCM_sys_RshPost { |
---|
[619] | 184 | IGCM_debug_PushStack "IGCM_sys_RshPost" $@ |
---|
| 185 | if ( $DEBUG_sys ) ; then |
---|
| 186 | echo "IGCM_sys_RshPost :" $@ |
---|
| 187 | fi |
---|
| 188 | /bin/ksh ${@} |
---|
| 189 | if [ $? -gt 0 ] ; then |
---|
| 190 | echo "IGCM_sys_RshPost : erreur." |
---|
| 191 | IGCM_debug_Exit "IGCM_sys_RshPost" |
---|
| 192 | fi |
---|
| 193 | IGCM_debug_PopStack "IGCM_sys_RshPost" |
---|
[55] | 194 | } |
---|
| 195 | |
---|
| 196 | #D-#================================================== |
---|
[452] | 197 | #D-function IGCM_sys_SendMail |
---|
| 198 | #D-* Purpose: Send mail when simulation is over |
---|
| 199 | #D-* Examples: |
---|
| 200 | #D- |
---|
| 201 | function IGCM_sys_SendMail { |
---|
[619] | 202 | IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@ |
---|
| 203 | if ( $DEBUG_sys ) ; then |
---|
| 204 | echo "IGCM_sys_SendMail :" $@ |
---|
| 205 | fi |
---|
[452] | 206 | |
---|
[619] | 207 | if ( ${ExitFlag} ) ; then |
---|
| 208 | status=failed |
---|
| 209 | else |
---|
| 210 | status=completed |
---|
| 211 | fi |
---|
| 212 | cat << END_MAIL > job_end.mail |
---|
[452] | 213 | Dear ${LOGIN}, |
---|
| 214 | |
---|
| 215 | Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. |
---|
| 216 | Job started : ${DateBegin} |
---|
| 217 | Job ended : ${DateEnd} |
---|
| 218 | Output files are available in ${R_SAVE} |
---|
| 219 | Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR} |
---|
| 220 | END_MAIL |
---|
| 221 | |
---|
[619] | 222 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
| 223 | mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail |
---|
| 224 | elif [ -f ~/.forward ] ; then |
---|
| 225 | mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail |
---|
| 226 | fi |
---|
[452] | 227 | |
---|
[619] | 228 | if [ $? -gt 0 ] ; then |
---|
| 229 | echo "IGCM_sys_SendMail : erreur." |
---|
| 230 | IGCM_debug_Exit "IGCM_sys_SendMail" |
---|
| 231 | fi |
---|
| 232 | IGCM_debug_PopStack "IGCM_sys_SendMail" |
---|
[452] | 233 | } |
---|
| 234 | |
---|
| 235 | #D-#================================================== |
---|
[55] | 236 | #D-function IGCM_sys_Mkdir |
---|
| 237 | #D-* Purpose: Master locale mkdir command |
---|
| 238 | #D-* Examples: |
---|
| 239 | #D- |
---|
| 240 | function IGCM_sys_Mkdir { |
---|
[619] | 241 | IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ |
---|
| 242 | if ( $DEBUG_sys ) ; then |
---|
| 243 | echo "IGCM_sys_Mkdir :" $@ |
---|
| 244 | fi |
---|
| 245 | if [ ! -d ${1} ]; then |
---|
| 246 | \mkdir -p $1 |
---|
| 247 | if [ $? -gt 0 ] ; then |
---|
| 248 | echo "IGCM_sys_Mkdir : erreur." |
---|
| 249 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
[55] | 250 | fi |
---|
[619] | 251 | fi |
---|
[55] | 252 | # vérification : |
---|
[619] | 253 | if [ ! -d ${1} ] ; then |
---|
| 254 | echo "IGCM_sys_Mkdir : erreur." |
---|
| 255 | IGCM_debug_Exit "IGCM_sys_Mkdir" |
---|
| 256 | fi |
---|
| 257 | IGCM_debug_PopStack "IGCM_sys_Mkdir" |
---|
[55] | 258 | } |
---|
| 259 | |
---|
| 260 | #D-#================================================== |
---|
| 261 | #D-function IGCM_sys_MkdirArchive |
---|
| 262 | #D-* Purpose: Mkdir on Archive |
---|
| 263 | #D-* Examples: |
---|
| 264 | #D- |
---|
| 265 | function IGCM_sys_MkdirArchive { |
---|
[619] | 266 | IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ |
---|
| 267 | if ( $DEBUG_sys ) ; then |
---|
| 268 | echo "IGCM_sys_MkdirArchive :" $@ |
---|
| 269 | fi |
---|
[55] | 270 | #- creation de repertoire sur le serveur fichier |
---|
[619] | 271 | if [ ! -d ${1} ]; then |
---|
| 272 | \mkdir -p $1 |
---|
| 273 | if [ $? -gt 0 ] ; then |
---|
| 274 | echo "IGCM_sys_MkdirArchive : erreur." |
---|
| 275 | IGCM_debug_Exit "IGCM_sys_MkdirArchive" |
---|
[55] | 276 | fi |
---|
[619] | 277 | fi |
---|
| 278 | IGCM_debug_PopStack "IGCM_sys_MkdirArchive" |
---|
[55] | 279 | } |
---|
| 280 | |
---|
| 281 | #D-#================================================== |
---|
| 282 | #D-function IGCM_sys_MkdirWork |
---|
| 283 | #D-* Purpose: Mkdir on Work |
---|
| 284 | #D-* Examples: |
---|
| 285 | #D- |
---|
| 286 | function IGCM_sys_MkdirWork { |
---|
[619] | 287 | IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ |
---|
| 288 | if ( $DEBUG_sys ) ; then |
---|
| 289 | echo "IGCM_sys_MkdirWork :" $@ |
---|
| 290 | fi |
---|
[55] | 291 | #- creation de repertoire sur le serveur fichier |
---|
[619] | 292 | if [ ! -d ${1} ]; then |
---|
| 293 | \mkdir -p $1 |
---|
| 294 | if [ $? -gt 0 ] ; then |
---|
| 295 | echo "IGCM_sys_MkdirWork : erreur." |
---|
| 296 | IGCM_debug_Exit "IGCM_sys_MkdirWork" |
---|
[55] | 297 | fi |
---|
[619] | 298 | fi |
---|
| 299 | IGCM_debug_PopStack "IGCM_sys_MkdirWork" |
---|
[55] | 300 | } |
---|
| 301 | |
---|
| 302 | #D-#================================================== |
---|
| 303 | #D-function IGCM_sys_Cd |
---|
| 304 | #D-* Purpose: master cd command |
---|
| 305 | #D-* Examples: |
---|
| 306 | #D- |
---|
| 307 | function IGCM_sys_Cd { |
---|
[619] | 308 | IGCM_debug_PushStack "IGCM_sys_Cd" $@ |
---|
| 309 | if ( $DEBUG_sys ) ; then |
---|
| 310 | echo "IGCM_sys_Cd :" $@ |
---|
| 311 | fi |
---|
| 312 | \cd $1 |
---|
| 313 | if [ $? -gt 0 ] ; then |
---|
| 314 | echo "IGCM_sys_Cd : erreur." |
---|
| 315 | IGCM_debug_Exit "IGCM_sys_Cd" |
---|
| 316 | fi |
---|
| 317 | IGCM_debug_PopStack "IGCM_sys_Cd" |
---|
[55] | 318 | } |
---|
| 319 | |
---|
| 320 | #D-#================================================== |
---|
| 321 | #D-function IGCM_sys_Chmod |
---|
| 322 | #D-* Purpose: Chmod |
---|
| 323 | #D-* Examples: |
---|
| 324 | #D- |
---|
| 325 | function IGCM_sys_Chmod { |
---|
[619] | 326 | IGCM_debug_PushStack "IGCM_sys_Chmod" $@ |
---|
| 327 | if ( $DEBUG_sys ) ; then |
---|
| 328 | echo "IGCM_sys_Chmod :" $@ |
---|
| 329 | fi |
---|
| 330 | if [ $DRYRUN -le 1 ]; then |
---|
| 331 | \chmod $@ |
---|
| 332 | if [ $? -gt 0 ] ; then |
---|
| 333 | echo "IGCM_sys_Chmod : erreur." |
---|
| 334 | IGCM_debug_Exit "IGCM_sys_Chmod" |
---|
[55] | 335 | fi |
---|
[619] | 336 | else |
---|
| 337 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 338 | fi |
---|
| 339 | IGCM_debug_PopStack "IGCM_sys_Chmod" |
---|
[55] | 340 | } |
---|
| 341 | |
---|
| 342 | #D-#================================================== |
---|
| 343 | #D-function IGCM_sys_FileSize |
---|
| 344 | #D-* Purpose: Filesize |
---|
| 345 | #D-* Examples: |
---|
| 346 | #D- |
---|
| 347 | function IGCM_sys_FileSize { |
---|
[619] | 348 | IGCM_debug_PushStack "IGCM_sys_FileSize" $@ |
---|
[55] | 349 | |
---|
[619] | 350 | typeset sizeF |
---|
| 351 | set +A sizeF -- $( ls -la ${1} ) |
---|
| 352 | if [ $? -gt 0 ] ; then |
---|
| 353 | IGCM_debug_Exit "IGCM_sys_FileSize" |
---|
| 354 | fi |
---|
| 355 | eval ${2}=${sizeF[4]} |
---|
[55] | 356 | |
---|
[619] | 357 | IGCM_debug_PopStack "IGCM_sys_FileSize" |
---|
[55] | 358 | } |
---|
| 359 | |
---|
| 360 | #D-#================================================== |
---|
| 361 | #D-function IGCM_sys_TestDir |
---|
| 362 | #D-* Purpose: Test Directory that must exists |
---|
| 363 | #D-* Examples: |
---|
| 364 | #D- |
---|
| 365 | function IGCM_sys_TestDir { |
---|
[619] | 366 | IGCM_debug_PushStack "IGCM_sys_TestDir" $@ |
---|
| 367 | if ( $DEBUG_sys ) ; then |
---|
| 368 | echo "IGCM_sys_TestDir :" $@ |
---|
| 369 | fi |
---|
| 370 | typeset ExistFlag |
---|
| 371 | ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) |
---|
| 372 | IGCM_debug_PopStack "IGCM_sys_TestDir" |
---|
[67] | 373 | |
---|
[619] | 374 | return ${ExistFlag} |
---|
[55] | 375 | } |
---|
| 376 | |
---|
| 377 | #D-#================================================== |
---|
| 378 | #D-function IGCM_sys_TestDirArchive |
---|
| 379 | #D-* Purpose: Test Directory that must exists on Archive |
---|
| 380 | #D-* Examples: |
---|
| 381 | #D- |
---|
| 382 | function IGCM_sys_TestDirArchive { |
---|
[619] | 383 | IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ |
---|
| 384 | if ( $DEBUG_sys ) ; then |
---|
| 385 | echo "IGCM_sys_TestDirArchive :" $@ |
---|
| 386 | fi |
---|
| 387 | typeset ExistFlag DirNameToTest |
---|
| 388 | # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam |
---|
| 389 | DirNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,') |
---|
| 390 | ExistFlag=$( [ -d ${DirNameToTest} ] && echo 0 || echo 1 ) |
---|
| 391 | IGCM_debug_PopStack "IGCM_sys_TestDirArchive" |
---|
[67] | 392 | |
---|
[619] | 393 | return ${ExistFlag} |
---|
[55] | 394 | } |
---|
| 395 | |
---|
| 396 | #D-#================================================== |
---|
| 397 | #D-function IGCM_sys_TestFileArchive |
---|
| 398 | #D-* Purpose: Test file that must NOT EXISTS on Archive |
---|
| 399 | #D-* Examples: |
---|
| 400 | #D- |
---|
| 401 | function IGCM_sys_TestFileArchive { |
---|
[619] | 402 | IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ |
---|
| 403 | typeset ExistFlag FileNameToTest |
---|
[645] | 404 | # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam |
---|
[619] | 405 | FileNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,') |
---|
| 406 | ExistFlag=$( IGCM_sys_RshArchive "[ -f ${FileNameToTest} ] && echo 0 || echo 1" ) |
---|
| 407 | IGCM_debug_PopStack "IGCM_sys_TestFileArchive" |
---|
[55] | 408 | |
---|
[619] | 409 | return ${ExistFlag} |
---|
[67] | 410 | } |
---|
| 411 | |
---|
| 412 | #D-#================================================== |
---|
| 413 | #D-function IGCM_sys_CountFileArchive |
---|
| 414 | #D-* Purpose: Count files on Archive filesystem |
---|
| 415 | #D-* Examples: |
---|
| 416 | #D- |
---|
| 417 | function IGCM_sys_CountFileArchive { |
---|
[619] | 418 | IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ |
---|
| 419 | IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" |
---|
| 420 | if [ $? -gt 0 ] ; then |
---|
| 421 | echo "IGCM_sys_CountFileArchive : erreur." |
---|
| 422 | fi |
---|
| 423 | IGCM_debug_PopStack "IGCM_sys_CountFileArchive" |
---|
[55] | 424 | } |
---|
| 425 | |
---|
| 426 | #D-#================================================== |
---|
| 427 | #D-function IGCM_sys_Tree |
---|
| 428 | #D-* Purpose: Tree directories with files on ${ARCHIVE} |
---|
| 429 | #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} |
---|
| 430 | #D- |
---|
| 431 | function IGCM_sys_Tree { |
---|
[619] | 432 | IGCM_debug_PushStack "IGCM_sys_Tree" $@ |
---|
| 433 | if ( $DEBUG_sys ) ; then |
---|
| 434 | echo "IGCM_sys_Tree :" $@ |
---|
| 435 | fi |
---|
[55] | 436 | |
---|
[619] | 437 | \mfls -r $@ |
---|
[55] | 438 | |
---|
[619] | 439 | IGCM_debug_PopStack "IGCM_sys_Tree" |
---|
[55] | 440 | } |
---|
| 441 | |
---|
| 442 | #D-#================================================== |
---|
| 443 | #D-function IGCM_sys_Tar |
---|
| 444 | #D-* Purpose: master un-tar command |
---|
| 445 | #D-* Examples: |
---|
| 446 | #D- |
---|
| 447 | function IGCM_sys_Tar { |
---|
[619] | 448 | IGCM_debug_PushStack "IGCM_sys_Tar" $@ |
---|
| 449 | if ( $DEBUG_sys ) ; then |
---|
| 450 | echo "IGCM_sys_Tar :" $@ |
---|
| 451 | fi |
---|
| 452 | \tar cvf $@ |
---|
| 453 | if [ $? -gt 0 ] ; then |
---|
| 454 | echo "IGCM_sys_Tar : erreur." |
---|
| 455 | IGCM_debug_Exit "IGCM_sys_Tar" |
---|
| 456 | fi |
---|
| 457 | \tar tvf $1 |
---|
[55] | 458 | |
---|
[619] | 459 | IGCM_debug_PopStack "IGCM_sys_Tar" |
---|
[55] | 460 | } |
---|
| 461 | |
---|
| 462 | #D-#================================================== |
---|
| 463 | #D-function IGCM_sys_UnTar |
---|
| 464 | #D-* Purpose: master un-tar command |
---|
| 465 | #D-* Examples: |
---|
| 466 | #D- |
---|
| 467 | function IGCM_sys_UnTar { |
---|
[619] | 468 | IGCM_debug_PushStack "IGCM_sys_UnTar" $@ |
---|
| 469 | if ( $DEBUG_sys ) ; then |
---|
| 470 | echo "IGCM_sys_UnTar :" $@ |
---|
| 471 | fi |
---|
| 472 | \tar xvf $1 |
---|
| 473 | if [ $? -gt 0 ] ; then |
---|
| 474 | echo "IGCM_sys_UnTar : erreur." |
---|
| 475 | IGCM_debug_Exit "IGCM_sys_UnTar" |
---|
| 476 | fi |
---|
| 477 | IGCM_debug_PopStack "IGCM_sys_UnTar" |
---|
[55] | 478 | } |
---|
| 479 | |
---|
| 480 | #D-#================================================== |
---|
| 481 | #D-function IGCM_sys_QsubPost |
---|
| 482 | #D-* Purpose: Qsub new job on scalaire |
---|
| 483 | #D-* Examples: |
---|
| 484 | #D- |
---|
| 485 | function IGCM_sys_QsubPost { |
---|
[619] | 486 | IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ |
---|
| 487 | if ( $DEBUG_sys ) ; then |
---|
| 488 | echo "IGCM_sys_QsubPost :" $@ |
---|
| 489 | fi |
---|
| 490 | cd ${POST_DIR} |
---|
| 491 | /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM}/$1.job |
---|
| 492 | cd - |
---|
| 493 | if [ $? -gt 0 ] ; then |
---|
| 494 | echo "IGCM_sys_QsubPost : erreur " $@ |
---|
| 495 | IGCM_debug_Exit "IGCM_sys_QsubPost" |
---|
| 496 | fi |
---|
| 497 | IGCM_debug_PopStack "IGCM_sys_QsubPost" |
---|
[55] | 498 | } |
---|
| 499 | |
---|
| 500 | #D-************************* |
---|
[619] | 501 | #D- File transfer functions |
---|
[55] | 502 | #D-************************* |
---|
| 503 | #D- |
---|
| 504 | |
---|
| 505 | #D-#================================================== |
---|
| 506 | #D-function IGCM_sys_Rsync_out |
---|
| 507 | #D-* Purpose: treat return val of rsync |
---|
| 508 | #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync |
---|
| 509 | #D- Error values and explanations can depend on your system version. |
---|
| 510 | function IGCM_sys_Rsync_out { |
---|
[619] | 511 | RET=$1 |
---|
| 512 | if [ ! $RET ] ; then |
---|
| 513 | echo "rsync error !" |
---|
| 514 | fi |
---|
[55] | 515 | |
---|
[619] | 516 | if [ $MYLANG = "fr" ]; then |
---|
| 517 | case $RET in |
---|
| 518 | 0) return ;; |
---|
| 519 | 1) echo "Erreur de rsync ; RERR_SYNTAX : " |
---|
| 520 | echo "Erreur de syntaxe ou d'utilisation." |
---|
| 521 | return;; |
---|
| 522 | 2) echo "Erreur de rsync ; RERR_PROTOCOL : " |
---|
| 523 | echo "Incompatibilité de protocole." |
---|
| 524 | return;; |
---|
| 525 | 3) echo "Erreur de rsync ; RERR_FILESELECT 3" |
---|
| 526 | echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" |
---|
| 527 | echo "répertoires" |
---|
| 528 | return;; |
---|
| 529 | 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" |
---|
[622] | 530 | echo "Action demandée non supportée : une tentative de manipulation de" |
---|
| 531 | echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" |
---|
| 532 | echo "été faite ; ou une option qui est supportée par le client mais" |
---|
| 533 | echo "pas par le serveur a été spécifiée." |
---|
| 534 | return;; |
---|
| 535 | 10) echo "Erreur de rsync ; RERR_SOCKETIO" |
---|
| 536 | echo "Erreur dans le socket d'entrée sortie" |
---|
| 537 | return;; |
---|
| 538 | 11) echo "Erreur de rsync ; RERR_FILEIO" |
---|
| 539 | echo "Erreur d'entrée sortie fichier" |
---|
| 540 | return;; |
---|
| 541 | 12) echo "Erreur de rsync ; RERR_STREAMIO" |
---|
| 542 | echo "Erreur dans flux de donnée du protocole rsync" |
---|
| 543 | return;; |
---|
| 544 | 13) echo "Erreur de rsync ; RERR_MESSAGEIO" |
---|
| 545 | echo "Erreur avec les diagnostics du programme" |
---|
| 546 | return;; |
---|
| 547 | 14) echo "Erreur de rsync ; RERR_IPC" |
---|
| 548 | echo "Erreur dans le code IPC" |
---|
| 549 | return;; |
---|
| 550 | 20) echo "Erreur de rsync ; RERR_SIGNAL" |
---|
| 551 | echo "SIGUSR1 ou SIGINT reçu" |
---|
| 552 | return;; |
---|
| 553 | 21) echo "Erreur de rsync ; RERR_WAITCHILD" |
---|
| 554 | echo "Une erreur retournée par waitpid()" |
---|
| 555 | return;; |
---|
| 556 | 22) echo "Erreur de rsync ; RERR_MALLOC" |
---|
| 557 | echo "Erreur lors de l'allocation des tampons de mémoire de coeur" |
---|
| 558 | return;; |
---|
| 559 | 23) echo "" |
---|
| 560 | echo "Erreur fichier inexistant" |
---|
| 561 | return;; |
---|
| 562 | 30) echo "Erreur de rsync ; RERR_TIMEOUT" |
---|
| 563 | echo "Temps d'attente écoulé dans l'envoi/réception de données" |
---|
| 564 | return;; |
---|
| 565 | *) echo "Erreur de rsync : code de retour de rsync inconnu :" $RET |
---|
| 566 | return;; |
---|
| 567 | esac |
---|
| 568 | elif [ $MYLANG = "en" ] ; then |
---|
| 569 | case $RET in |
---|
| 570 | 0) return;; |
---|
| 571 | 1) echo "rsync error : Syntax or usage error " |
---|
| 572 | return;; |
---|
| 573 | 2) echo "rsync error : Protocol incompatibility " |
---|
| 574 | return;; |
---|
| 575 | 3) echo "rsync error : Errors selecting input/output files, dirs" |
---|
| 576 | return;; |
---|
| 577 | 4) echo "rsync error : Requested action not supported: an attempt" |
---|
| 578 | echo "was made to manipulate 64-bit files on a platform that cannot support" |
---|
| 579 | echo "them; or an option was specified that is supported by the client and" |
---|
| 580 | echo "not by the server." |
---|
| 581 | return;; |
---|
| 582 | 5) echo "rsync error : Error starting client-server protocol" |
---|
| 583 | return;; |
---|
| 584 | 10) echo "rsync error : Error in socket I/O " |
---|
| 585 | return;; |
---|
| 586 | 11) echo "rsync error : Error in file I/O " |
---|
| 587 | return;; |
---|
| 588 | 12) echo "rsync error : Error in rsync protocol data stream " |
---|
| 589 | return;; |
---|
| 590 | 13) echo "rsync error : Errors with program diagnostics " |
---|
| 591 | return;; |
---|
| 592 | 14) echo "rsync error : Error in IPC code " |
---|
| 593 | return;; |
---|
| 594 | 20) echo "rsync error : Received SIGUSR1 or SIGINT " |
---|
| 595 | return;; |
---|
| 596 | 21) echo "rsync error : Some error returned by waitpid() " |
---|
| 597 | return;; |
---|
| 598 | 22) echo "rsync error : Error allocating core memory buffers " |
---|
| 599 | return;; |
---|
| 600 | 23) echo "rsync error : Partial transfer due to error" |
---|
| 601 | return;; |
---|
| 602 | 24) echo "rsync error : Partial transfer due to vanished source files" |
---|
| 603 | return;; |
---|
| 604 | 30) echo "rsync error : Timeout in data send/receive " |
---|
| 605 | return;; |
---|
| 606 | *) echo "rsync error : return code of rsync unknown :" $RET |
---|
| 607 | return;; |
---|
| 608 | esac |
---|
| 609 | else |
---|
| 610 | echo "unknown language $MYLANG." |
---|
| 611 | return |
---|
| 612 | fi |
---|
[55] | 613 | } |
---|
[619] | 614 | |
---|
[55] | 615 | #D-#================================================== |
---|
| 616 | #D-function IGCM_sys_Cp |
---|
| 617 | #D-* Purpose: generic cp |
---|
| 618 | #D-* Examples: |
---|
| 619 | #D- |
---|
| 620 | function IGCM_sys_Cp { |
---|
[619] | 621 | IGCM_debug_PushStack "IGCM_sys_Cp" $@ |
---|
| 622 | if ( $DEBUG_sys ) ; then |
---|
| 623 | echo "IGCM_sys_Cp :" $@ |
---|
| 624 | fi |
---|
[55] | 625 | |
---|
[619] | 626 | typeset RET |
---|
[55] | 627 | |
---|
[619] | 628 | echo cp $@ > out_rsync 2>&1 |
---|
| 629 | \cp $@ >> out_rsync 2>&1 |
---|
| 630 | RET=$? |
---|
[55] | 631 | |
---|
[619] | 632 | if [ ${RET} -gt 0 ] ; then |
---|
| 633 | echo "IGCM_sys_Cp : error." |
---|
| 634 | cat out_rsync |
---|
| 635 | IGCM_debug_Exit "IGCM_sys_Cp" |
---|
| 636 | fi |
---|
| 637 | IGCM_debug_PopStack "IGCM_sys_Cp" |
---|
[55] | 638 | } |
---|
| 639 | |
---|
| 640 | #D-#================================================== |
---|
| 641 | #D-function IGCM_sys_Rm |
---|
| 642 | #D-* Purpose: generic rm |
---|
| 643 | #D-* Examples: |
---|
| 644 | #D- |
---|
| 645 | function IGCM_sys_Rm { |
---|
[619] | 646 | IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ |
---|
| 647 | if ( $DEBUG_sys ) ; then |
---|
| 648 | echo "IGCM_sys_Rm :" $@ |
---|
| 649 | fi |
---|
[55] | 650 | |
---|
[619] | 651 | typeset RET |
---|
[55] | 652 | |
---|
[619] | 653 | echo rm $@ > out_rsync 2>&1 |
---|
| 654 | \rm $@ >> out_rsync 2>&1 |
---|
| 655 | RET=$? |
---|
[55] | 656 | |
---|
[619] | 657 | if [ ${RET} -gt 0 ] ; then |
---|
| 658 | echo "IGCM_sys_Rm : error." |
---|
| 659 | cat out_rsync |
---|
| 660 | IGCM_debug_Exit "IGCM_sys_Rm" |
---|
| 661 | fi |
---|
| 662 | IGCM_debug_PopStack "IGCM_sys_Rm" |
---|
[55] | 663 | } |
---|
| 664 | |
---|
| 665 | #D-#================================================== |
---|
[203] | 666 | #D-function IGCM_sys_RmRunDir |
---|
| 667 | #D-* Purpose: rm tmpdir (dummy function most of the time batch |
---|
| 668 | #D- scheduler will do the job) |
---|
| 669 | #D-* Examples: |
---|
| 670 | #D- |
---|
| 671 | function IGCM_sys_RmRunDir { |
---|
[619] | 672 | IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ |
---|
| 673 | if ( $DEBUG_sys ) ; then |
---|
| 674 | echo "IGCM_sys_RmRunDir :" $@ |
---|
| 675 | echo "Dummy call, let the scheduler do that." |
---|
| 676 | fi |
---|
| 677 | IGCM_debug_PopStack "IGCM_sys_RmRunDir" |
---|
[203] | 678 | } |
---|
| 679 | |
---|
| 680 | #D-#================================================== |
---|
[55] | 681 | #D-function IGCM_sys_Mv |
---|
| 682 | #D-* Purpose: generic move |
---|
| 683 | #D-* Examples: |
---|
| 684 | #D- |
---|
| 685 | function IGCM_sys_Mv { |
---|
[619] | 686 | IGCM_debug_PushStack "IGCM_sys_Mv" $@ |
---|
| 687 | if ( $DEBUG_sys ) ; then |
---|
| 688 | echo "IGCM_sys_Mv :" $@ |
---|
| 689 | fi |
---|
[192] | 690 | |
---|
[619] | 691 | if [ $DRYRUN = 0 ]; then |
---|
[55] | 692 | |
---|
[619] | 693 | typeset RET |
---|
| 694 | |
---|
| 695 | echo mv $@ > out_rsync 2>&1 |
---|
| 696 | \mv $@ >> out_rsync 2>&1 |
---|
| 697 | RET=$? |
---|
| 698 | |
---|
| 699 | if [ ${RET} -gt 0 ] ; then |
---|
| 700 | echo "IGCM_sys_Mv : error in mv." |
---|
| 701 | cat out_rsync |
---|
| 702 | IGCM_debug_Exit "IGCM_sys_Mv" |
---|
[55] | 703 | fi |
---|
[619] | 704 | else |
---|
| 705 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 706 | fi |
---|
[55] | 707 | |
---|
[619] | 708 | IGCM_debug_PopStack "IGCM_sys_Mv" |
---|
[55] | 709 | } |
---|
| 710 | |
---|
| 711 | #D-#================================================== |
---|
| 712 | #D-function IGCM_sys_Put_Dir |
---|
| 713 | #D-* Purpose: Copy a complete directory on $(ARCHIVE) |
---|
| 714 | #D-* Examples: |
---|
| 715 | #D- |
---|
| 716 | function IGCM_sys_Put_Dir { |
---|
[619] | 717 | IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ |
---|
| 718 | if ( $DEBUG_sys ) ; then |
---|
| 719 | echo "IGCM_sys_Put_Dir :" $@ |
---|
| 720 | fi |
---|
| 721 | if [ $DRYRUN = 0 ]; then |
---|
| 722 | if [ ! -d ${1} ] ; then |
---|
| 723 | echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." |
---|
| 724 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
| 725 | return |
---|
[55] | 726 | fi |
---|
| 727 | |
---|
[619] | 728 | typeset RET |
---|
[55] | 729 | |
---|
[622] | 730 | # Only if we use rsync |
---|
| 731 | #IGCM_sys_TestDirArchive $( dirname $2 ) |
---|
| 732 | # |
---|
| 733 | #USUAL WAY |
---|
[619] | 734 | rcp -r $1 gaya:$2 > out_rsync 2>&1 |
---|
| 735 | RET=$? |
---|
[55] | 736 | |
---|
[619] | 737 | if [ ${RET} -gt 0 ] ; then |
---|
| 738 | echo "IGCM_sys_Put_Dir : error." |
---|
| 739 | cat out_rsync |
---|
| 740 | IGCM_debug_Exit "IGCM_sys_Put_Dir" |
---|
| 741 | fi |
---|
[134] | 742 | |
---|
[622] | 743 | # due to rcommand latency |
---|
[619] | 744 | sleep 10 |
---|
[134] | 745 | |
---|
[619] | 746 | else |
---|
| 747 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 748 | fi |
---|
| 749 | IGCM_debug_PopStack "IGCM_sys_Put_Dir" |
---|
[55] | 750 | } |
---|
| 751 | |
---|
| 752 | #D-#================================================== |
---|
| 753 | #D-function IGCM_sys_Get_Dir |
---|
| 754 | #D-* Purpose: Copy a complete directory from $(ARCHIVE) |
---|
| 755 | #D-* Examples: |
---|
| 756 | #D- |
---|
| 757 | function IGCM_sys_Get_Dir { |
---|
[619] | 758 | IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ |
---|
| 759 | if ( $DEBUG_sys ) ; then |
---|
| 760 | echo "IGCM_sys_Get_Dir :" $@ |
---|
| 761 | fi |
---|
| 762 | if [ $DRYRUN = 0 ]; then |
---|
[622] | 763 | |
---|
[59] | 764 | # if [ ! -d ${1} ] ; then |
---|
[619] | 765 | # echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." |
---|
| 766 | # IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
| 767 | # return |
---|
[59] | 768 | # fi |
---|
[55] | 769 | |
---|
[619] | 770 | typeset RET |
---|
[55] | 771 | |
---|
[622] | 772 | #USUAL WAY |
---|
[619] | 773 | rcp -rp gaya:$1 $2 > out_rsync 2>&1 |
---|
| 774 | RET=$? |
---|
[55] | 775 | |
---|
[619] | 776 | if [ ${RET} -gt 0 ] ; then |
---|
| 777 | echo "IGCM_sys_Get_Dir : error." |
---|
| 778 | cat out_rsync |
---|
| 779 | IGCM_debug_Exit "IGCM_sys_Get_Dir" |
---|
[55] | 780 | fi |
---|
[619] | 781 | else |
---|
| 782 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 783 | fi |
---|
| 784 | IGCM_debug_PopStack "IGCM_sys_Get_Dir" |
---|
[55] | 785 | } |
---|
| 786 | |
---|
| 787 | #D-#================================================== |
---|
| 788 | #D-function IGCM_sys_Get_Master |
---|
| 789 | #D-* Purpose: Copy a complete directory from MASTER filesystem |
---|
| 790 | #D-* Examples: |
---|
| 791 | #D- |
---|
| 792 | function IGCM_sys_Get_Master { |
---|
[619] | 793 | IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ |
---|
| 794 | if ( $DEBUG_sys ) ; then |
---|
| 795 | echo "IGCM_sys_Get_Master :" $@ |
---|
| 796 | fi |
---|
| 797 | if [ $DRYRUN = 0 ]; then |
---|
[675] | 798 | TEST=$( IGCM_sys_RshMaster [ -d $1 ] || [ -f $1 ] && echo 1 || echo 0 ) |
---|
[619] | 799 | if [ ${TEST} -ne 1 ] ; then |
---|
| 800 | echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ON ${MASTER}." |
---|
| 801 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
| 802 | return |
---|
[55] | 803 | fi |
---|
| 804 | |
---|
[619] | 805 | typeset RET |
---|
[55] | 806 | |
---|
[622] | 807 | #USUAL WAY |
---|
[619] | 808 | rcp -r ${MASTER}:$1 $2 > out_rsync 2>&1 |
---|
| 809 | RET=$? |
---|
[55] | 810 | |
---|
[619] | 811 | if [ ${RET} -gt 0 ] ; then |
---|
| 812 | echo "IGCM_sys_Get_Master : error." |
---|
| 813 | cat out_rsync |
---|
| 814 | IGCM_debug_Exit "IGCM_sys_Get_Master" |
---|
[55] | 815 | fi |
---|
[619] | 816 | else |
---|
| 817 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 818 | fi |
---|
| 819 | IGCM_debug_PopStack "IGCM_sys_Get_Master" |
---|
[55] | 820 | } |
---|
| 821 | |
---|
| 822 | #D-#================================================== |
---|
| 823 | #D-function IGCM_sys_Put_Out |
---|
| 824 | #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly |
---|
| 825 | #D-* Examples: |
---|
| 826 | #D- |
---|
| 827 | function IGCM_sys_Put_Out { |
---|
[619] | 828 | IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ |
---|
| 829 | if ( $DEBUG_sys ) ; then |
---|
| 830 | echo "IGCM_sys_Put_Out :" $@ |
---|
| 831 | fi |
---|
| 832 | if [ $DRYRUN = 0 ]; then |
---|
| 833 | if [ ! -f ${1} ] ; then |
---|
| 834 | echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." |
---|
| 835 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 836 | return 1 |
---|
[55] | 837 | fi |
---|
| 838 | |
---|
[619] | 839 | typeset RET |
---|
| 840 | # |
---|
| 841 | if [ X${JobType} = XRUN ] ; then |
---|
| 842 | if [ X${3} = X ] ; then |
---|
| 843 | IGCM_sys_Chmod 444 ${1} |
---|
| 844 | fi |
---|
| 845 | fi |
---|
[622] | 846 | # |
---|
| 847 | # |
---|
| 848 | # USUAL WAY |
---|
[619] | 849 | mfput $1 $2 > out_rsync 2>&1 |
---|
| 850 | RET=$? |
---|
[55] | 851 | |
---|
[619] | 852 | # #RSYNC WITH NETWORK RSH CALL |
---|
| 853 | # echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 |
---|
| 854 | # ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 |
---|
[55] | 855 | |
---|
[619] | 856 | # #RSYNC WITH NFS USE |
---|
| 857 | # echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 |
---|
| 858 | # ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 |
---|
[55] | 859 | |
---|
[619] | 860 | # RET=$? |
---|
| 861 | # IGCM_sys_Rsync_out $RET |
---|
[55] | 862 | |
---|
[619] | 863 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
| 864 | # (( RET=RET+$? )) |
---|
[55] | 865 | |
---|
[619] | 866 | if [ ${RET} -gt 0 ] ; then |
---|
| 867 | echo "IGCM_sys_Put_Out : error." |
---|
| 868 | cat out_rsync |
---|
| 869 | IGCM_debug_Print 1 "mfput failed. Make a second try :" |
---|
| 870 | # |
---|
| 871 | mfput $1 $2 > out_rsync 2>&1 |
---|
| 872 | RET=$? |
---|
| 873 | # |
---|
| 874 | if [ ${RET} -gt 0 ] ; then |
---|
| 875 | echo "IGCM_sys_Put_Out : error." |
---|
| 876 | IGCM_debug_Print 1 "mfput failed twice. You have a problem" |
---|
| 877 | cat out_rsync |
---|
| 878 | IGCM_debug_Exit "IGCM_sys_Put_Out" |
---|
| 879 | fi |
---|
[55] | 880 | fi |
---|
[619] | 881 | else |
---|
| 882 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 883 | fi |
---|
| 884 | IGCM_debug_PopStack "IGCM_sys_Put_Out" |
---|
| 885 | return 0 |
---|
[55] | 886 | } |
---|
| 887 | |
---|
| 888 | #D-#================================================== |
---|
| 889 | #D-function IGCM_sys_Get |
---|
| 890 | #D-* Purpose: Get a file from ${ARCHIVE} |
---|
| 891 | #D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX |
---|
| 892 | #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ |
---|
| 893 | function IGCM_sys_Get { |
---|
[619] | 894 | IGCM_debug_PushStack "IGCM_sys_Get" $@ |
---|
[55] | 895 | |
---|
[619] | 896 | typeset DEST RET dm_liste ifile target |
---|
[55] | 897 | |
---|
[619] | 898 | if ( $DEBUG_sys ) ; then |
---|
| 899 | echo "IGCM_sys_Get :" $@ |
---|
| 900 | fi |
---|
| 901 | if [ $DRYRUN -le 2 ]; then |
---|
| 902 | if [ X${1} = X'/l' ] ; then |
---|
[622] | 903 | # test if the first file is present in the old computation : |
---|
[619] | 904 | eval set +A dm_liste \${${2}} |
---|
| 905 | else |
---|
| 906 | dm_liste=${1} |
---|
[55] | 907 | fi |
---|
[619] | 908 | eval DEST=\${${#}} |
---|
[55] | 909 | |
---|
[622] | 910 | # test if the (first) file is present in the old computation : |
---|
| 911 | IGCM_sys_TestFileArchive ${dm_liste[0]} |
---|
| 912 | RET=$? |
---|
| 913 | if [ ${RET} -gt 0 ] ; then |
---|
| 914 | echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." |
---|
| 915 | IGCM_debug_Exit "IGCM_sys_Get" |
---|
| 916 | #IGCM_debug_PopStack "IGCM_sys_Get" |
---|
| 917 | #return |
---|
| 918 | fi |
---|
[55] | 919 | |
---|
[622] | 920 | # SD : dm_liste is not suited for computing job |
---|
| 921 | # because we change filename during transfert |
---|
| 922 | # dm_liste is better suited for post-treatment |
---|
| 923 | # SD : dm_liste necessary only with RSYNC |
---|
[55] | 924 | |
---|
[622] | 925 | #dm_liste=" " |
---|
| 926 | #(( ifile=1 )) |
---|
| 927 | #while [ $ifile -lt $# ] ; do |
---|
| 928 | # dm_liste=$( eval echo ${dm_liste[*]} " "\${${ifile}} ) |
---|
| 929 | # (( ifile = ifile + 1 )) |
---|
| 930 | #done |
---|
| 931 | #DEST=$( eval echo \${${#}} ) |
---|
[55] | 932 | |
---|
[622] | 933 | #USUAL WAY |
---|
| 934 | mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1 |
---|
[55] | 935 | |
---|
[622] | 936 | # #RSYNC WITH NETWORK RSH CALL |
---|
| 937 | # echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 |
---|
| 938 | # ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 |
---|
[55] | 939 | |
---|
[622] | 940 | # #RSYNC WITH NFS USE |
---|
| 941 | # echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1 |
---|
| 942 | # ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1 |
---|
[55] | 943 | |
---|
[622] | 944 | # RET=$? |
---|
| 945 | # IGCM_sys_Rsync_out $RET |
---|
[55] | 946 | |
---|
[622] | 947 | # ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync |
---|
| 948 | # (( RET=RET+$? )) |
---|
[55] | 949 | |
---|
[619] | 950 | else |
---|
| 951 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 952 | fi |
---|
| 953 | IGCM_debug_PopStack "IGCM_sys_Get" |
---|
[622] | 954 | } |
---|
[55] | 955 | |
---|
| 956 | #D-#================================================== |
---|
| 957 | #D-function IGCM_sys_Put_Dods |
---|
| 958 | #D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole. |
---|
| 959 | #D-* Examples: |
---|
| 960 | #D- |
---|
[622] | 961 | function IGCM_sys_Put_Dods { |
---|
| 962 | IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ |
---|
| 963 | if ( $DEBUG_sys ) ; then |
---|
| 964 | echo "IGCM_sys_Put_Dods :" $@ |
---|
| 965 | fi |
---|
| 966 | if [ $DRYRUN = 0 ]; then |
---|
| 967 | # We take our time on that |
---|
| 968 | sleep 10 |
---|
| 969 | IGCM_sys_TestDirArchive ${R_SAVE}/${1} |
---|
| 970 | if [ $? != 0 ] ; then |
---|
| 971 | echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." |
---|
| 972 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
| 973 | return |
---|
| 974 | fi |
---|
[55] | 975 | |
---|
[622] | 976 | typeset RET |
---|
| 977 | # |
---|
| 978 | rsh gaya exec /bin/ksh <<EOF |
---|
[619] | 979 | cd ${R_SAVE} |
---|
| 980 | /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1 |
---|
| 981 | /bin/chmod -R u+w ${R_SAVE}/${1} |
---|
| 982 | /usr/local/bin/dods_cp ${1} DODS/pub/${LOGIN}/${R_DODS} > /dev/null 2>&1 |
---|
| 983 | /bin/chmod -R +rX ${R_SAVE}/${1} |
---|
| 984 | /bin/chmod -R u+w ${R_SAVE}/${1} |
---|
[622] | 985 | EOF |
---|
| 986 | RET=$? |
---|
[55] | 987 | |
---|
[622] | 988 | if [ ${RET} -gt 0 ] ; then |
---|
| 989 | echo "IGCM_sys_Put_Dods : error." |
---|
| 990 | IGCM_debug_Exit "IGCM_sys_Put_Dods" |
---|
| 991 | fi |
---|
| 992 | else |
---|
| 993 | ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack |
---|
| 994 | fi |
---|
| 995 | IGCM_debug_PopStack "IGCM_sys_Put_Dods" |
---|
| 996 | } |
---|
[55] | 997 | |
---|
| 998 | ############################################################## A FINIR !! |
---|
| 999 | |
---|
| 1000 | #D-#================================================== |
---|
| 1001 | #D-function IGCM_sys_GetDate_FichWork |
---|
| 1002 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK |
---|
| 1003 | #D-* Examples: |
---|
| 1004 | #D- |
---|
[622] | 1005 | function IGCM_sys_GetDate_FichWork { |
---|
| 1006 | IGCM_debug_PushStack "IGCM_sys_FichWork" $@ |
---|
| 1007 | if ( $DEBUG_sys ) ; then |
---|
| 1008 | echo "IGCM_sys_GetDate_FichWork :" $@ |
---|
| 1009 | fi |
---|
[55] | 1010 | # donne la date filesys d'un fichier sur la machine work |
---|
[622] | 1011 | IGCM_debug_PopStack "IGCM_sys_FichWork" |
---|
| 1012 | } |
---|
[55] | 1013 | |
---|
| 1014 | #D-#================================================== |
---|
| 1015 | #D-function IGCM_sys_GetDate_FichArchive |
---|
[619] | 1016 | #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE |
---|
[55] | 1017 | #D-* Examples: |
---|
| 1018 | #D- |
---|
[622] | 1019 | function IGCM_sys_GetDate_FichArchive { |
---|
| 1020 | IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ |
---|
| 1021 | if ( $DEBUG_sys ) ; then |
---|
| 1022 | echo "IGCM_sys_GetDate_FichArchive :" $@ |
---|
| 1023 | fi |
---|
| 1024 | IGCM_debug_PopStack "IGCM_sys_FichArchive" |
---|
| 1025 | } |
---|
[55] | 1026 | |
---|
| 1027 | ############################################################## |
---|
| 1028 | # REBUILD OPERATOR |
---|
| 1029 | |
---|
[622] | 1030 | function IGCM_sys_rebuild { |
---|
| 1031 | IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ |
---|
| 1032 | if ( $DEBUG_sys ) ; then |
---|
| 1033 | echo "IGCM_sys_rebuild :" $@ |
---|
| 1034 | fi |
---|
| 1035 | /home/rech/psl/rpsl035/bin/rebuild -f -o $@ |
---|
| 1036 | if [ $? -gt 0 ] ; then |
---|
| 1037 | echo "IGCM_sys_rebuild : erreur ${@}." |
---|
| 1038 | IGCM_debug_Exit "rebuild" |
---|
| 1039 | fi |
---|
[55] | 1040 | |
---|
[622] | 1041 | IGCM_debug_PopStack "IGCM_sys_rebuild" |
---|
| 1042 | } |
---|
[697] | 1043 | |
---|
| 1044 | function IGCM_sys_rebuild_station { |
---|
| 1045 | IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@ |
---|
| 1046 | typeset i list_opt file_in file_out prefix_invert list_invert |
---|
| 1047 | if ( $DEBUG_sys ) ; then |
---|
| 1048 | echo "IGCM_sys_rebuild_station :" $@ |
---|
| 1049 | fi |
---|
| 1050 | list_opt=$@ |
---|
| 1051 | |
---|
| 1052 | # Invert Axis : t,x -> x,t |
---|
| 1053 | # t,pres,x -> x,t,pres |
---|
| 1054 | # So that we can concatenate along x |
---|
| 1055 | i=0 |
---|
| 1056 | for file_in in ${list_opt} ; do |
---|
| 1057 | (( i = i + 1)) |
---|
| 1058 | [ ${i} = 1 ] && file_out=${file_in} && continue |
---|
| 1059 | prefix_invert=$( basename ${file_in} .nc ) |
---|
| 1060 | IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc |
---|
| 1061 | list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc |
---|
| 1062 | done |
---|
| 1063 | |
---|
| 1064 | # Concatenate |
---|
| 1065 | IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc |
---|
| 1066 | |
---|
| 1067 | # Re-ivert file |
---|
| 1068 | IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} |
---|
| 1069 | |
---|
| 1070 | # Station re-ordering is too expansive to be run within libICGM |
---|
| 1071 | # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. |
---|
| 1072 | # This re-ordering must be done "in memory" by the cmorization process |
---|
| 1073 | # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) |
---|
| 1074 | # BEGIN reordering |
---|
| 1075 | |
---|
| 1076 | # Only LMDZ text output contains the exact ordering of the station. |
---|
| 1077 | # We isolate this in the code below: |
---|
| 1078 | # 0 38 -157.5000000000000 70.98591549295774 |
---|
| 1079 | # 0 54 27.49999999999999 67.18309859154928 |
---|
| 1080 | # 0 56 -62.50000000000001 82.39436619718309 |
---|
| 1081 | # 0 79 12.49999999999999 78.59154929577466 |
---|
| 1082 | # 0 116 -165.0000000000000 76.05633802816901 |
---|
| 1083 | # 0 117 130.0000000000000 70.98591549295774 |
---|
| 1084 | # 0 118 110.0000000000000 87.46478873239437 |
---|
| 1085 | # 1 40 4.999999999999995 51.97183098591550 |
---|
| 1086 | # typeset iStation iProc list_opt file_in file_out prefix_invert |
---|
| 1087 | # typeset -Z4 j4 |
---|
| 1088 | # typeset -Z3 j3 |
---|
| 1089 | |
---|
| 1090 | # unset list_opt |
---|
| 1091 | # set +A list_opt $@ |
---|
| 1092 | |
---|
| 1093 | # Filename after rebuild |
---|
| 1094 | # file_out=${list_opt[0]} |
---|
| 1095 | # Prefix of output files |
---|
| 1096 | # prefix_invert=$( basename ${file_out} .nc ) |
---|
| 1097 | # Number of procs |
---|
| 1098 | # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) |
---|
| 1099 | |
---|
| 1100 | # iProc=0 |
---|
| 1101 | # while [ ${iProc} -lt ${num_proc} ] ; do |
---|
| 1102 | # Array containing Station as a number |
---|
| 1103 | # unset proc_stn |
---|
| 1104 | # 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}' ) |
---|
| 1105 | # Number of stations produced by processor proc |
---|
| 1106 | # stationLast=${#proc_stn[*]} |
---|
| 1107 | # Proc number on 4 digits |
---|
| 1108 | # j4=${iProc} |
---|
| 1109 | # Init |
---|
| 1110 | # iStation=0 |
---|
| 1111 | # while [ ${iStation} -lt ${stationLast} ] ; do |
---|
| 1112 | # Station number on 3 digits |
---|
| 1113 | # j3=${proc_stn[${iStation}]} |
---|
| 1114 | # Extract station |
---|
| 1115 | # Invert Axis : t,x -> x,t |
---|
| 1116 | # t,pres,x -> x,t,pres |
---|
| 1117 | # So that we can concatenate along x |
---|
| 1118 | # 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 |
---|
| 1119 | # (( iStation = iStation + 1 )) |
---|
| 1120 | # done |
---|
| 1121 | # (( iProc = iProc + 1 )) |
---|
| 1122 | # done |
---|
| 1123 | |
---|
| 1124 | # Concatenate all station along x |
---|
| 1125 | # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc |
---|
| 1126 | |
---|
| 1127 | # Re-invert file |
---|
| 1128 | # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} |
---|
| 1129 | |
---|
| 1130 | # END reordering |
---|
| 1131 | |
---|
| 1132 | IGCM_debug_PopStack "IGCM_sys_rebuild_station" |
---|
| 1133 | } |
---|
| 1134 | |
---|
[55] | 1135 | ############################################################## |
---|
| 1136 | # NCO OPERATOR |
---|
| 1137 | |
---|
[622] | 1138 | function IGCM_sys_ncap2 { |
---|
| 1139 | IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ |
---|
| 1140 | if ( $DEBUG_sys ) ; then |
---|
| 1141 | echo "IGCM_sys_ncap2 :" $@ |
---|
| 1142 | fi |
---|
[714] | 1143 | |
---|
| 1144 | typeset NB_ESSAI DELAI status i |
---|
| 1145 | # number of tentative |
---|
| 1146 | NB_ESSAI=3 |
---|
| 1147 | # time delay between tentative |
---|
| 1148 | DELAI=2 |
---|
| 1149 | |
---|
| 1150 | i=0 |
---|
| 1151 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1152 | ncap2 "$@" > out_rsync 2>&1 |
---|
| 1153 | status=$? |
---|
| 1154 | if [ ${status} -gt 0 ] ; then |
---|
| 1155 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" |
---|
| 1156 | cat out_rsync |
---|
| 1157 | \rm out_rsync |
---|
| 1158 | IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1159 | else |
---|
| 1160 | \rm out_rsync |
---|
| 1161 | break |
---|
| 1162 | fi |
---|
| 1163 | (( i = i + 1 )) |
---|
| 1164 | done |
---|
| 1165 | |
---|
| 1166 | if [ ${status} -gt 0 ] ; then |
---|
| 1167 | echo "IGCM_sys_ncap2 : ncap2 error" |
---|
| 1168 | IGCM_debug_Exit "ncap2" |
---|
[622] | 1169 | fi |
---|
[55] | 1170 | |
---|
[622] | 1171 | IGCM_debug_PopStack "IGCM_sys_ncap2" |
---|
| 1172 | } |
---|
[55] | 1173 | |
---|
[622] | 1174 | function IGCM_sys_ncatted { |
---|
| 1175 | IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ |
---|
| 1176 | if ( $DEBUG_sys ) ; then |
---|
| 1177 | echo "IGCM_sys_ncatted :" $@ |
---|
| 1178 | fi |
---|
[714] | 1179 | |
---|
| 1180 | typeset NB_ESSAI DELAI status i |
---|
| 1181 | # number of tentative |
---|
| 1182 | NB_ESSAI=3 |
---|
| 1183 | # time delay between tentative |
---|
| 1184 | DELAI=2 |
---|
| 1185 | |
---|
| 1186 | i=0 |
---|
| 1187 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1188 | ncatted "$@" > out_rsync 2>&1 |
---|
| 1189 | status=$? |
---|
| 1190 | if [ ${status} -gt 0 ] ; then |
---|
| 1191 | IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" |
---|
| 1192 | cat out_rsync |
---|
| 1193 | \rm out_rsync |
---|
| 1194 | IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1195 | else |
---|
| 1196 | \rm out_rsync |
---|
| 1197 | break |
---|
| 1198 | fi |
---|
| 1199 | (( i = i + 1 )) |
---|
| 1200 | done |
---|
| 1201 | |
---|
| 1202 | if [ ${status} -gt 0 ] ; then |
---|
| 1203 | echo "IGCM_sys_ncatted : ncatted error" |
---|
| 1204 | IGCM_debug_Exit "ncatted" |
---|
[622] | 1205 | fi |
---|
[55] | 1206 | |
---|
[622] | 1207 | IGCM_debug_PopStack "IGCM_sys_ncatted" |
---|
| 1208 | } |
---|
[55] | 1209 | |
---|
[622] | 1210 | function IGCM_sys_ncbo { |
---|
| 1211 | IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ |
---|
| 1212 | if ( $DEBUG_sys ) ; then |
---|
| 1213 | echo "IGCM_sys_ncbo :" $@ |
---|
| 1214 | fi |
---|
[714] | 1215 | |
---|
| 1216 | typeset NB_ESSAI DELAI status i |
---|
| 1217 | # number of tentative |
---|
| 1218 | NB_ESSAI=3 |
---|
| 1219 | # time delay between tentative |
---|
| 1220 | DELAI=2 |
---|
| 1221 | |
---|
| 1222 | i=0 |
---|
| 1223 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1224 | ncbo $@ > out_rsync 2>&1 |
---|
| 1225 | status=$? |
---|
| 1226 | if [ ${status} -gt 0 ] ; then |
---|
| 1227 | IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" |
---|
| 1228 | cat out_rsync |
---|
| 1229 | \rm out_rsync |
---|
| 1230 | IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1231 | else |
---|
| 1232 | \rm out_rsync |
---|
| 1233 | break |
---|
| 1234 | fi |
---|
| 1235 | (( i = i + 1 )) |
---|
| 1236 | done |
---|
| 1237 | |
---|
| 1238 | if [ ${status} -gt 0 ] ; then |
---|
| 1239 | echo "IGCM_sys_ncbo : ncbo error" |
---|
| 1240 | IGCM_debug_Exit "ncbo" |
---|
[622] | 1241 | fi |
---|
[55] | 1242 | |
---|
[622] | 1243 | IGCM_debug_PopStack "IGCM_sys_ncbo" |
---|
| 1244 | } |
---|
[55] | 1245 | |
---|
[622] | 1246 | function IGCM_sys_ncdiff { |
---|
| 1247 | IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ |
---|
| 1248 | if ( $DEBUG_sys ) ; then |
---|
| 1249 | echo "IGCM_sys_ncdiff :" $@ |
---|
| 1250 | fi |
---|
[714] | 1251 | |
---|
| 1252 | typeset NB_ESSAI DELAI status i |
---|
| 1253 | # number of tentative |
---|
| 1254 | NB_ESSAI=3 |
---|
| 1255 | # time delay between tentative |
---|
| 1256 | DELAI=2 |
---|
| 1257 | |
---|
| 1258 | i=0 |
---|
| 1259 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1260 | ncdiff $@ > out_rsync 2>&1 |
---|
| 1261 | status=$? |
---|
| 1262 | if [ ${status} -gt 0 ] ; then |
---|
| 1263 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" |
---|
| 1264 | cat out_rsync |
---|
| 1265 | \rm out_rsync |
---|
| 1266 | IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1267 | else |
---|
| 1268 | \rm out_rsync |
---|
| 1269 | break |
---|
| 1270 | fi |
---|
| 1271 | (( i = i + 1 )) |
---|
| 1272 | done |
---|
| 1273 | |
---|
| 1274 | if [ ${status} -gt 0 ] ; then |
---|
| 1275 | echo "IGCM_sys_ncdiff : ncdiff error" |
---|
| 1276 | IGCM_debug_Exit "ncdiff" |
---|
[622] | 1277 | fi |
---|
[55] | 1278 | |
---|
[622] | 1279 | IGCM_debug_PopStack "IGCM_sys_ncdiff" |
---|
| 1280 | } |
---|
[55] | 1281 | |
---|
[622] | 1282 | function IGCM_sys_ncea { |
---|
| 1283 | IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ |
---|
| 1284 | if ( $DEBUG_sys ) ; then |
---|
| 1285 | echo "IGCM_sys_ncea :" $@ |
---|
| 1286 | fi |
---|
[714] | 1287 | |
---|
| 1288 | typeset NB_ESSAI DELAI status i |
---|
| 1289 | # number of tentative |
---|
| 1290 | NB_ESSAI=3 |
---|
| 1291 | # time delay between tentative |
---|
| 1292 | DELAI=2 |
---|
| 1293 | |
---|
| 1294 | i=0 |
---|
| 1295 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1296 | ncea $@ > out_rsync 2>&1 |
---|
| 1297 | status=$? |
---|
| 1298 | if [ ${status} -gt 0 ] ; then |
---|
| 1299 | IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" |
---|
| 1300 | cat out_rsync |
---|
| 1301 | \rm out_rsync |
---|
| 1302 | IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1303 | else |
---|
| 1304 | \rm out_rsync |
---|
| 1305 | break |
---|
| 1306 | fi |
---|
| 1307 | (( i = i + 1 )) |
---|
| 1308 | done |
---|
| 1309 | |
---|
| 1310 | if [ ${status} -gt 0 ] ; then |
---|
| 1311 | echo "IGCM_sys_ncea : ncea error" |
---|
| 1312 | IGCM_debug_Exit "ncea" |
---|
[622] | 1313 | fi |
---|
[55] | 1314 | |
---|
[622] | 1315 | IGCM_debug_PopStack "IGCM_sys_ncea" |
---|
| 1316 | } |
---|
[55] | 1317 | |
---|
[622] | 1318 | function IGCM_sys_ncecat { |
---|
| 1319 | IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ |
---|
| 1320 | if ( $DEBUG_sys ) ; then |
---|
| 1321 | echo "IGCM_sys_ncecat :" $@ |
---|
| 1322 | fi |
---|
[714] | 1323 | |
---|
| 1324 | typeset NB_ESSAI DELAI status i |
---|
| 1325 | # number of tentative |
---|
| 1326 | NB_ESSAI=3 |
---|
| 1327 | # time delay between tentative |
---|
| 1328 | DELAI=2 |
---|
| 1329 | |
---|
| 1330 | i=0 |
---|
| 1331 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1332 | ncecat $@ > out_rsync 2>&1 |
---|
| 1333 | status=$? |
---|
| 1334 | if [ ${status} -gt 0 ] ; then |
---|
| 1335 | IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" |
---|
| 1336 | cat out_rsync |
---|
| 1337 | \rm out_rsync |
---|
| 1338 | IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1339 | else |
---|
| 1340 | \rm out_rsync |
---|
| 1341 | break |
---|
| 1342 | fi |
---|
| 1343 | (( i = i + 1 )) |
---|
| 1344 | done |
---|
| 1345 | |
---|
| 1346 | if [ ${status} -gt 0 ] ; then |
---|
| 1347 | echo "IGCM_sys_ncecat : ncecat error" |
---|
| 1348 | IGCM_debug_Exit "ncecat" |
---|
[622] | 1349 | fi |
---|
[55] | 1350 | |
---|
[622] | 1351 | IGCM_debug_PopStack "IGCM_sys_ncecat" |
---|
| 1352 | } |
---|
[55] | 1353 | |
---|
[622] | 1354 | function IGCM_sys_ncflint { |
---|
| 1355 | IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ |
---|
| 1356 | if ( $DEBUG_sys ) ; then |
---|
| 1357 | echo "IGCM_sys_ncflint :" $@ |
---|
| 1358 | fi |
---|
[714] | 1359 | |
---|
| 1360 | typeset NB_ESSAI DELAI status i |
---|
| 1361 | # number of tentative |
---|
| 1362 | NB_ESSAI=3 |
---|
| 1363 | # time delay between tentative |
---|
| 1364 | DELAI=2 |
---|
| 1365 | |
---|
| 1366 | i=0 |
---|
| 1367 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1368 | ncflint $@ > out_rsync 2>&1 |
---|
| 1369 | status=$? |
---|
| 1370 | if [ ${status} -gt 0 ] ; then |
---|
| 1371 | IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" |
---|
| 1372 | cat out_rsync |
---|
| 1373 | \rm out_rsync |
---|
| 1374 | IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1375 | else |
---|
| 1376 | \rm out_rsync |
---|
| 1377 | break |
---|
| 1378 | fi |
---|
| 1379 | (( i = i + 1 )) |
---|
| 1380 | done |
---|
| 1381 | |
---|
| 1382 | if [ ${status} -gt 0 ] ; then |
---|
| 1383 | echo "IGCM_sys_ncflint : ncflint error" |
---|
| 1384 | IGCM_debug_Exit "ncflint" |
---|
[622] | 1385 | fi |
---|
[55] | 1386 | |
---|
[622] | 1387 | IGCM_debug_PopStack "IGCM_sys_ncflint" |
---|
| 1388 | } |
---|
[55] | 1389 | |
---|
[622] | 1390 | function IGCM_sys_ncks { |
---|
| 1391 | IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ |
---|
| 1392 | if ( $DEBUG_sys ) ; then |
---|
| 1393 | echo "IGCM_sys_ncks :" $@ |
---|
| 1394 | fi |
---|
[714] | 1395 | |
---|
| 1396 | typeset NB_ESSAI DELAI status i |
---|
| 1397 | # number of tentative |
---|
| 1398 | NB_ESSAI=3 |
---|
| 1399 | # time delay between tentative |
---|
| 1400 | DELAI=2 |
---|
| 1401 | |
---|
| 1402 | i=0 |
---|
| 1403 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1404 | ncks $@ > out_rsync 2>&1 |
---|
| 1405 | status=$? |
---|
| 1406 | if [ ${status} -gt 0 ] ; then |
---|
| 1407 | IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" |
---|
| 1408 | cat out_rsync |
---|
| 1409 | \rm out_rsync |
---|
| 1410 | IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1411 | else |
---|
| 1412 | \rm out_rsync |
---|
| 1413 | break |
---|
| 1414 | fi |
---|
| 1415 | (( i = i + 1 )) |
---|
| 1416 | done |
---|
| 1417 | |
---|
| 1418 | if [ ${status} -gt 0 ] ; then |
---|
| 1419 | echo "IGCM_sys_ncks : ncks error" |
---|
| 1420 | IGCM_debug_Exit "ncks" |
---|
[622] | 1421 | fi |
---|
[55] | 1422 | |
---|
[622] | 1423 | IGCM_debug_PopStack "IGCM_sys_ncks" |
---|
| 1424 | } |
---|
[55] | 1425 | |
---|
[622] | 1426 | function IGCM_sys_ncpdq { |
---|
| 1427 | IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ |
---|
| 1428 | if ( $DEBUG_sys ) ; then |
---|
| 1429 | echo "IGCM_sys_ncpdq :" $@ |
---|
| 1430 | fi |
---|
[714] | 1431 | |
---|
| 1432 | typeset NB_ESSAI DELAI status i |
---|
| 1433 | # number of tentative |
---|
| 1434 | NB_ESSAI=3 |
---|
| 1435 | # time delay between tentative |
---|
| 1436 | DELAI=2 |
---|
| 1437 | |
---|
| 1438 | i=0 |
---|
| 1439 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1440 | ncpdq $@ > out_rsync 2>&1 |
---|
| 1441 | status=$? |
---|
| 1442 | if [ ${status} -gt 0 ] ; then |
---|
| 1443 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" |
---|
| 1444 | cat out_rsync |
---|
| 1445 | \rm out_rsync |
---|
| 1446 | IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1447 | else |
---|
| 1448 | \rm out_rsync |
---|
| 1449 | break |
---|
| 1450 | fi |
---|
| 1451 | (( i = i + 1 )) |
---|
| 1452 | done |
---|
| 1453 | |
---|
| 1454 | if [ ${status} -gt 0 ] ; then |
---|
| 1455 | echo "IGCM_sys_ncpdq : ncpdq error" |
---|
| 1456 | IGCM_debug_Exit "ncpdq" |
---|
[622] | 1457 | fi |
---|
[55] | 1458 | |
---|
[622] | 1459 | IGCM_debug_PopStack "IGCM_sys_ncpdq" |
---|
| 1460 | } |
---|
[55] | 1461 | |
---|
[622] | 1462 | function IGCM_sys_ncra { |
---|
| 1463 | IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ |
---|
| 1464 | if ( $DEBUG_sys ) ; then |
---|
| 1465 | echo "IGCM_sys_ncra :" $@ |
---|
| 1466 | fi |
---|
[714] | 1467 | |
---|
| 1468 | typeset NB_ESSAI DELAI status i |
---|
| 1469 | # number of tentative |
---|
| 1470 | NB_ESSAI=3 |
---|
| 1471 | # time delay between tentative |
---|
| 1472 | DELAI=2 |
---|
| 1473 | |
---|
| 1474 | i=0 |
---|
| 1475 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1476 | ncra $@ > out_rsync 2>&1 |
---|
| 1477 | status=$? |
---|
| 1478 | if [ ${status} -gt 0 ] ; then |
---|
| 1479 | IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" |
---|
| 1480 | cat out_rsync |
---|
| 1481 | \rm out_rsync |
---|
| 1482 | IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1483 | else |
---|
| 1484 | \rm out_rsync |
---|
| 1485 | break |
---|
| 1486 | fi |
---|
| 1487 | (( i = i + 1 )) |
---|
| 1488 | done |
---|
| 1489 | |
---|
| 1490 | if [ ${status} -gt 0 ] ; then |
---|
| 1491 | echo "IGCM_sys_ncra : ncra error" |
---|
| 1492 | IGCM_debug_Exit "ncra" |
---|
[622] | 1493 | fi |
---|
[55] | 1494 | |
---|
[622] | 1495 | IGCM_debug_PopStack "IGCM_sys_ncra" |
---|
| 1496 | } |
---|
[55] | 1497 | |
---|
[622] | 1498 | function IGCM_sys_ncrcat { |
---|
| 1499 | IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ |
---|
| 1500 | if ( $DEBUG_sys ) ; then |
---|
| 1501 | echo "IGCM_sys_ncrcat :" $@ |
---|
| 1502 | fi |
---|
[714] | 1503 | |
---|
| 1504 | typeset NB_ESSAI DELAI status i |
---|
| 1505 | # number of tentative |
---|
| 1506 | NB_ESSAI=3 |
---|
| 1507 | # time delay between tentative |
---|
| 1508 | DELAI=2 |
---|
| 1509 | |
---|
| 1510 | i=0 |
---|
| 1511 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1512 | ncrcat $@ > out_rsync 2>&1 |
---|
| 1513 | status=$? |
---|
| 1514 | if [ ${status} -gt 0 ] ; then |
---|
| 1515 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" |
---|
| 1516 | cat out_rsync |
---|
| 1517 | \rm out_rsync |
---|
| 1518 | IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1519 | else |
---|
| 1520 | \rm out_rsync |
---|
| 1521 | break |
---|
| 1522 | fi |
---|
| 1523 | (( i = i + 1 )) |
---|
| 1524 | done |
---|
| 1525 | |
---|
| 1526 | if [ ${status} -gt 0 ] ; then |
---|
| 1527 | echo "IGCM_sys_ncrcat : ncrcat error" |
---|
| 1528 | #IGCM_debug_Exit "ncrcat" |
---|
[622] | 1529 | fi |
---|
[55] | 1530 | |
---|
[622] | 1531 | IGCM_debug_PopStack "IGCM_sys_ncrcat" |
---|
| 1532 | } |
---|
[55] | 1533 | |
---|
[622] | 1534 | function IGCM_sys_ncrename { |
---|
| 1535 | IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ |
---|
| 1536 | if ( $DEBUG_sys ) ; then |
---|
| 1537 | echo "IGCM_sys_ncrename :" $@ |
---|
| 1538 | fi |
---|
[714] | 1539 | |
---|
| 1540 | typeset NB_ESSAI DELAI status i |
---|
| 1541 | # number of tentative |
---|
| 1542 | NB_ESSAI=3 |
---|
| 1543 | # time delay between tentative |
---|
| 1544 | DELAI=2 |
---|
| 1545 | |
---|
| 1546 | i=0 |
---|
| 1547 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1548 | ncrename $@ > out_rsync 2>&1 |
---|
| 1549 | status=$? |
---|
| 1550 | if [ ${status} -gt 0 ] ; then |
---|
| 1551 | IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" |
---|
| 1552 | cat out_rsync |
---|
| 1553 | \rm out_rsync |
---|
| 1554 | IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1555 | else |
---|
| 1556 | \rm out_rsync |
---|
| 1557 | break |
---|
| 1558 | fi |
---|
| 1559 | (( i = i + 1 )) |
---|
| 1560 | done |
---|
| 1561 | |
---|
| 1562 | if [ ${status} -gt 0 ] ; then |
---|
| 1563 | echo "IGCM_sys_ncrename : ncrename error" |
---|
| 1564 | IGCM_debug_Exit "ncrename" |
---|
[622] | 1565 | fi |
---|
[55] | 1566 | |
---|
[622] | 1567 | IGCM_debug_PopStack "IGCM_sys_ncrename" |
---|
| 1568 | } |
---|
[55] | 1569 | |
---|
[622] | 1570 | function IGCM_sys_ncwa { |
---|
| 1571 | IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ |
---|
| 1572 | if ( $DEBUG_sys ) ; then |
---|
| 1573 | echo "IGCM_sys_ncwa :" $@ |
---|
| 1574 | fi |
---|
[714] | 1575 | |
---|
| 1576 | typeset NB_ESSAI DELAI status i |
---|
| 1577 | # number of tentative |
---|
| 1578 | NB_ESSAI=3 |
---|
| 1579 | # time delay between tentative |
---|
| 1580 | DELAI=2 |
---|
| 1581 | |
---|
| 1582 | i=0 |
---|
| 1583 | while [ $i -lt $NB_ESSAI ] ; do |
---|
| 1584 | ncwa $@ > out_rsync 2>&1 |
---|
| 1585 | status=$? |
---|
| 1586 | if [ ${status} -gt 0 ] ; then |
---|
| 1587 | IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" |
---|
| 1588 | cat out_rsync |
---|
| 1589 | \rm out_rsync |
---|
| 1590 | IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." |
---|
| 1591 | else |
---|
| 1592 | \rm out_rsync |
---|
| 1593 | break |
---|
| 1594 | fi |
---|
| 1595 | (( i = i + 1 )) |
---|
| 1596 | done |
---|
| 1597 | |
---|
| 1598 | if [ ${status} -gt 0 ] ; then |
---|
| 1599 | echo "IGCM_sys_ncwa : ncwa error" |
---|
| 1600 | IGCM_debug_Exit "ncwa" |
---|
[622] | 1601 | fi |
---|
[55] | 1602 | |
---|
[622] | 1603 | IGCM_debug_PopStack "IGCM_sys_ncwa" |
---|
| 1604 | } |
---|
[55] | 1605 | |
---|
[285] | 1606 | ############################################################## |
---|
| 1607 | # CDO OPERATOR |
---|
| 1608 | |
---|
[622] | 1609 | function IGCM_sys_cdo { |
---|
| 1610 | IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ |
---|
[714] | 1611 | if ( $DEBUG_sys ) ; then |
---|
| 1612 | echo "IGCM_sys_cdo :" $@ |
---|
| 1613 | fi |
---|
[285] | 1614 | |
---|
[714] | 1615 | typeset status |
---|
| 1616 | |
---|
| 1617 | \cdo $@ > out_rsync 2>&1 |
---|
| 1618 | status=$? |
---|
| 1619 | if [ ${status} -gt 0 ] ; then |
---|
| 1620 | echo "IGCM_sys_cdo : error code ${status}" |
---|
| 1621 | cat out_rsync |
---|
| 1622 | \rm out_rsync |
---|
[622] | 1623 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 1624 | return 1 |
---|
| 1625 | else |
---|
| 1626 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 1627 | return 0 |
---|
| 1628 | fi |
---|
[285] | 1629 | |
---|
[622] | 1630 | IGCM_debug_PopStack "IGCM_sys_cdo" |
---|
| 1631 | } |
---|
[285] | 1632 | |
---|
[55] | 1633 | ############################################################ |
---|
| 1634 | # Activate Running Environnment Variables |
---|
| 1635 | |
---|
[622] | 1636 | function IGCM_sys_activ_variables { |
---|
| 1637 | IGCM_debug_PushStack "IGCM_sys_activ_variables" |
---|
| 1638 | if ( $DEBUG_sys ) ; then |
---|
| 1639 | echo "IGCM_sys_activ_variables" |
---|
| 1640 | fi |
---|
| 1641 | IGCM_debug_PopStack "IGCM_sys_activ_variables" |
---|
| 1642 | } |
---|
[55] | 1643 | |
---|
| 1644 | ############################################################ |
---|
| 1645 | # Desactivate Running Environnment Variables |
---|
| 1646 | |
---|
[622] | 1647 | function IGCM_sys_desactiv_variables { |
---|
| 1648 | IGCM_debug_PushStack "IGCM_sys_desactiv_variables" |
---|
| 1649 | if ( $DEBUG_sys ) ; then |
---|
| 1650 | echo "IGCM_sys_desactiv_variables" |
---|
| 1651 | fi |
---|
| 1652 | IGCM_debug_PopStack "IGCM_sys_desactiv_variables" |
---|
| 1653 | } |
---|
[55] | 1654 | |
---|
| 1655 | ############################################################ |
---|
| 1656 | # Build run file |
---|
| 1657 | |
---|
[622] | 1658 | function IGCM_sys_build_run_file { |
---|
| 1659 | IGCM_debug_PushStack "IGCM_sys_build_run_file" |
---|
| 1660 | if ( $DEBUG_sys ) ; then |
---|
| 1661 | echo "IGCM_sys_build_run_file" |
---|
| 1662 | fi |
---|
| 1663 | IGCM_debug_PopStack "IGCM_sys_build_run_file" |
---|
| 1664 | } |
---|
[651] | 1665 | |
---|
| 1666 | ############################################################ |
---|
| 1667 | # Check of space available on temporary filesytems |
---|
| 1668 | function IGCM_sys_check_quota { |
---|
| 1669 | IGCM_debug_PushStack "IGCM_sys_check_quota" |
---|
| 1670 | if ( $DEBUG_sys ) ; then |
---|
| 1671 | echo "IGCM_sys_check_quota" |
---|
| 1672 | fi |
---|
| 1673 | IGCM_debug_PopStack "IGCM_sys_check_quota" |
---|
| 1674 | } |
---|