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