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