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