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