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