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