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