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