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