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