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