Changeset 754


Ignore:
Timestamp:
11/30/12 18:38:00 (12 years ago)
Author:
labetoulle
Message:

Print the last 10 (default value, can be changed with -j option) rebuild, pack_* and atlas jobs instead of only the last one of each.
And use real boolean variables when needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_RunChecker

    r753 r754  
    1313 
    1414#======================================================================# 
    15  
    1615# Display a report on how a simulation is faring. 
     16 
    1717 
    1818function ChangeUsr { 
     
    3535 
    3636  if [ ${NbOcc} -eq 0 ] ; then 
    37     if [ X${fg_new} == X.true. ] ; then 
    38       echo "${JobName} not in Catalog, we'll try to find it in ${WORK_DIR}" 
     37    if ( ${fg_new} ) ; then 
     38      echo "${JobName} not in Catalog, we'll try to find it in ${WORKDIR}" 
    3939       
    4040      set -A FileList 
    41       FileList=$( find ${WORK_DIR}/ -name "Job_${JobName}" ) 
     41      FileList=$( find ${WORKDIR}/ -name "Job_${JobName}" ) 
    4242      echo $FileList 
    4343      (( NbOcc = ${#FileList[@]} )) 
    4444    else 
    4545      echo "${JobName} not in Catalog." 
    46       echo "Use option -n / --new to look for it and add it to the catalog." 
     46      echo "Add job_name, user_name, host_name and submit_dir in ${SimuCatalog}" 
    4747      exit 
    4848    fi 
     
    7373function AffichResult { 
    7474 
    75   fg_first=".false." 
    76   fg_last=".false." 
     75  fg_first=false 
     76  fg_last=false 
     77  fg_job=false 
    7778 
    7879  while [ $# -ne 0 ] ; do 
    7980    case ${1} in 
    8081      -f|--first) 
    81         fg_first=".true." 
     82        fg_first=true 
    8283        shift 1 ;; 
    8384      -l|--last) 
    84         fg_last=".true." 
     85        fg_last=true 
     86        shift 1 ;; 
     87      -j|--job) 
     88        fg_job=true 
    8589        shift 1 ;; 
    8690      -*) 
     
    9599 
    96100  # Define colors 
     101  # ============= 
    97102  ColEsc="\033[" 
    98103  ColNon="${ColEsc}0m"       # Return to normal 
     
    106111 
    107112   
    108   if [ X${fg_first} == X.true. ] ; then 
     113  # Print header 
     114  # ============ 
     115  if ( ${fg_first} ) ; then 
    109116    Dum="" 
    110117    (( len = 67 - ${#JobName} )) 
     
    117124    echo "| Date Begin - DateEnd    | PeriodState | Current Period          | CumulPeriod | Nb  : from     : to       |" 
    118125    echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|" 
     126 
     127    printf "| %-10s - %-10s | " \ 
     128           $DateBegin $DateEnd  
     129 
     130    case $PeriodState in 
     131      Fatal) 
     132        Color=${ColFat} 
     133        break ;; 
     134      Completed) 
     135        Color=${ColCpl} 
     136        break ;; 
     137      Waiting|OnQueue) 
     138        Color=${ColAtt} 
     139        break ;; 
     140      *) 
     141        Color=${ColDef} 
     142        break ;; 
     143    esac 
     144    printf "${Color}%-11s${ColNon} | " $PeriodState 
     145 
     146    printf "%-10s - %-10s | %11s | " \ 
     147           $PeriodDateBegin $PeriodDateEnd $CumulPeriod 
     148 
     149    if ( [ X${NbRebuild} != X. ] && [ X${NbRebuild} != X0 ] ) ; then 
     150      printf "${ColRbl}%3s : %-8s : %-8s${ColNon} |\n" \ 
     151             $NbRebuild $FirstRebuild $LastRebuild 
     152    else 
     153      printf "%3s : %-8s : %-8s |\n" \ 
     154             $NbRebuild $FirstRebuild $LastRebuild 
     155    fi 
     156 
     157    printf "|-----------------------------------------------------------------------------------------------------------|\n" 
     158    printf "|                                                      Last                                                 |\n" 
     159    printf "|     Rebuild      |   Pack_Output    |   Pack_Restart   |    Pack_Debug    |  Monitoring  |     Atlas      |\n" 
     160    printf "|------------------|------------------|------------------|------------------|--------------|----------------|\n" 
     161 
    119162    return 
    120163  fi 
    121164 
    122   if [ X${fg_last} == X.true. ] ; then 
     165  # Print Post-processing job status 
     166  # ================================ 
     167  if ( ${fg_job} ) ; then 
     168    printf "|" 
     169 
     170    # Print rebuild and pack jobs 
     171    # --------------------------- 
     172    for JobType in ${JobType_list[*]} ; do  
     173      eval Date=\${${JobType}_Date[${ind}]} 
     174      eval Status=\${${JobType}_Status[${ind}]} 
     175 
     176      if [ X${Status} == XOK  ] ; then 
     177        Color=${ColCpl} 
     178      else 
     179        Color=${ColFat} 
     180      fi 
     181      printf "     ${Color}%-8s${ColNon}     |" ${Date} 
     182    done 
     183 
     184    Color=${ColExp} 
     185 
     186    # Print monitoring jobs 
     187    # --------------------- 
     188    JobType=monitoring 
     189    if [ $ind -eq 0 ] ; then 
     190      eval Date=\${${JobType}_Date} 
     191    else 
     192      Date="" 
     193    fi 
     194    printf "     ${Color}%-4s${ColNon}     |" ${Date} 
     195 
     196    # Print atlas jobs 
     197    # ---------------- 
     198    JobType=atlas 
     199    eval Date=\${${JobType}_Date[${ind}]} 
     200    printf "  ${Color}%-12s${ColNon}  |" ${Date} 
     201 
     202    printf "\n" 
     203 
     204    return 
     205  fi 
     206 
     207  # Print footer 
     208  # ============ 
     209  if ( ${fg_last} ) ; then 
    123210    printf "|===========================================================================================================|\n" 
    124211    date +"${DateFormat}" 
     
    126213  fi 
    127214 
    128   printf "| %-10s - %-10s | " \ 
    129          $DateBegin $DateEnd  
    130  
    131   case $PeriodState in 
    132     Fatal) 
    133       Color=${ColFat} 
    134       break ;; 
    135     Completed) 
    136       Color=${ColCpl} 
    137       break ;; 
    138     Waiting|OnQueue) 
    139       Color=${ColAtt} 
    140       break ;; 
    141     *) 
    142       Color=${ColDef} 
    143       break ;; 
    144   esac 
    145   printf "${Color}%-11s${ColNon} | " $PeriodState 
    146  
    147   printf "%-10s - %-10s | %11s | " \ 
    148          $PeriodDateBegin $PeriodDateEnd $CumulPeriod 
    149  
    150   if ( [ X${NbRebuild} != X. ] && [ X${NbRebuild} != X0 ] ) ; then 
    151     printf "${ColRbl}%3s : %-8s : %-8s${ColNon} |\n" \ 
    152            $NbRebuild $FirstRebuild $LastRebuild 
    153   else 
    154     printf "%3s : %-8s : %-8s |\n" \ 
    155            $NbRebuild $FirstRebuild $LastRebuild 
    156   fi 
    157  
    158   printf "|-----------------------------------------------------------------------------------------------------------|\n" 
    159   printf "|                                                      Last                                                 |\n" 
    160   printf "|     Rebuild      |   Pack_Output    |   Pack_Restart   |    Pack_Debug    |  Monitoring  |     Atlas      |\n" 
    161   printf "|------------------|------------------|------------------|------------------|--------------|----------------|\n" 
    162  
    163   if [ X${Result[1]} == XOK  ] ; then 
    164     Color=${ColCpl} 
    165   else 
    166     Color=${ColFat} 
    167   fi 
    168   printf "|     ${Color}%-8s${ColNon}     |" ${LastDate[1]} 
    169  
    170   if [ X${Result[2]} == XOK  ] ; then 
    171     Color=${ColCpl} 
    172   else 
    173     Color=${ColFat} 
    174   fi 
    175   printf "     ${Color}%-8s${ColNon}     |" ${LastDate[2]} 
    176  
    177   if [ X${Result[3]} == XOK  ] ; then 
    178     Color=${ColCpl} 
    179   else 
    180     Color=${ColFat} 
    181   fi 
    182   printf "     ${Color}%-8s${ColNon}     |" ${LastDate[3]} 
    183  
    184   if [ X${Result[4]} == XOK  ] ; then 
    185     Color=${ColCpl} 
    186   else 
    187     Color=${ColFat} 
    188   fi 
    189   printf "     ${Color}%-8s${ColNon}     |" ${LastDate[4]} 
    190  
    191   Color=${ColExp} 
    192   printf "     ${Color}%-4s${ColNon}     |  ${Color}%-12s${ColNon}  |\n" \ 
    193          ${LastDate[5]} ${LastDate[6]} 
    194215} 
    195216 
     
    203224CurrentGrp=$( groups $CurrentUsr | awk '{print $3}' ) 
    204225 
     226if ( [ $# -eq 0 ] ) ; then 
     227  $0 -h 
     228  exit 
     229fi 
     230 
     231# Arguments 
     232# ========= 
     233# Default argument values 
     234# ----------------------- 
     235TargetUsr=${CurrentUsr} 
     236HostName=$( hostname | sed -e "s/[0-9].*//" ) 
     237 
     238fg_color=true 
     239fg_new=false 
     240fg_quiet=false 
     241NbHisto=10 
     242 
     243# Get arguments from command line 
     244# ------------------------------- 
     245while [ $# -ne 0 ] ; do 
     246  case $1 in 
     247    -h|--help|-help) 
     248      echo "usage: $0 [-u TargetUsr] JobName" 
     249      exit ;; 
     250    -b|-nocolor) 
     251      fg_color=false 
     252      shift 1 ;; 
     253    -n|-new) 
     254      fg_new=true 
     255      shift 1 ;; 
     256    -q|-quiet) 
     257      fg_quiet=true 
     258      shift 1 ;; 
     259    -p|-config-path) 
     260      ConfigPath="$2" 
     261      shift 2 ;; 
     262    -j|-job-number) 
     263      NbHisto="$2" 
     264      shift 2 ;; 
     265    -u|-user) 
     266      TargetUsr="$2" 
     267      shift 2 ;; 
     268    -*) 
     269      $0 -h 
     270      exit ;; 
     271    *) 
     272      break ;; 
     273  esac 
     274done 
     275 
     276if [ $# -lt 1 ] ; then 
     277  $0 -h 
     278  exit 
     279fi 
     280 
     281 
     282# Load libIGCM library 
     283# ==================== 
    205284libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    206285 
     
    215294. ${libIGCM}/libIGCM_config/libIGCM_config.ksh 
    216295 
    217 if ( [ $# -eq 0 ] ) ; then 
    218   $0 -h 
    219   exit 
     296 
     297JobName=$1 
     298 
     299if ( ${fg_quiet} ) ; then 
     300  NbHisto=1 
    220301fi 
    221  
    222 # Default argument values 
    223 TargetUsr=${CurrentUsr} 
    224 HostName=$( hostname | sed -e "s/[0-9].*//" ) 
    225  
    226 fg_color=".true." 
    227 fg_new=".false." 
    228 fg_quiet=".false." 
    229 (( NbHisto = 1 )) 
    230  
    231 # Get arguments from command line 
    232 while [ $# -ne 0 ] ; do 
    233   case $1 in 
    234     -h|--help|-help) 
    235       echo "usage: $0 [-u TargetUsr] JobName" 
    236       exit ;; 
    237     -b|--nocolor) 
    238       fg_color=".false." 
    239       shift 1 ;; 
    240     -n|--new) 
    241       fg_new=".true." 
    242       shift 1 ;; 
    243     -q|--quiet) 
    244       fg_quiet=".true." 
    245       shift 1 ;; 
    246     -p|--config-path) 
    247       ConfigPath="$2" 
    248       shift 2 ;; 
    249     -u|--user) 
    250       TargetUsr="$2" 
    251       shift 2 ;; 
    252     -*) 
    253       $0 -h 
    254       exit ;; 
    255     *) 
    256       break ;; 
    257   esac 
    258 done 
    259  
    260 JobName=$1 
    261302 
    262303echo "TargetUsr = ${TargetUsr}" 
     
    274315DateFormat="%d/%m/%y %R:%S" 
    275316 
    276 # Find SUBMIT_DIR from catalog 
    277  
     317# Find SUBMIT_DIR in catalog 
     318# ========================== 
    278319SearchCatalog 
    279320 
    280 # Go to SUBMIT_DIR  
    281321if [ ! X${SUBMIT_DIR} == X ] ; then 
    282322 
     
    286326 
    287327  # Extract usefull information from run.card and config.card 
     328  # ========================================================= 
    288329 
    289330  RunFile="${SUBMIT_DIR}/run.card" 
     
    332373  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then 
    333374    REBUILD_DIR=${R_SAVE}/TMP 
     375    RebuildJob="rebuild_fromArchive" 
    334376  else 
    335377    REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     378    RebuildJob="rebuild_fromWorkdir" 
    336379  fi 
    337380 
     
    350393  if [ $PeriodState != "Waiting" ] ; then 
    351394 
    352     # Check missing rebuilds 
     395    # Check pending rebuilds 
     396    # ====================== 
    353397 
    354398    set -A RebuildList $( find ${REBUILD_DIR}/ -name "REBUILD_*" | sort ) 
     
    371415  fi 
    372416 
    373   typeset -A LastDate Result 
    374  
    375   # Check last REBUILD 
    376   FileType=rebuild_* 
    377   (( ind = 1 )) 
    378  
    379   LastDate[$ind]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n ${NbHisto} | awk -F"." '{ print $2 }' ) 
    380  
    381   dum=$( basename $( grep ^IGCM_sys_PutBuffer_Out ${POST_DIR}/${FileType}.${LastDate[$ind]}.out | tail -1 | awk '{ print $4 }' ) | awk -F"_" '{ print $3 }' ) 
    382  
    383   if [[ ${dum} == ${LastDate[$ind]} ]] ; then 
    384     Result[$ind]=OK 
    385   else 
    386     Result[$ind]=KO 
    387   fi 
    388  
    389   # Check last PACK jobs 
    390   for FileType in pack_output pack_restart pack_debug ; do 
     417 
     418  # Check last REBUILD and PACK* jobs 
     419  # ================================= 
     420  # Define input parameters 
     421  # ----------------------- 
     422  set -A JobType_list "${RebuildJob}" "pack_output" "pack_restart" "pack_debug" 
     423 
     424  for JobType in ${JobType_list[*]} ; do  
     425    typeset    name1="${JobType}_String" 
     426    typeset    name2="${JobType}_Field" 
     427    if [ X${JobType} == X${RebuildJob} ] ; then 
     428      eval ${name1}=IGCM_sys_PutBuffer_Out 
     429      eval ${name2}=4 
     430    else 
     431      eval ${name1}=IGCM_sys_Put_Out 
     432      eval ${name2}=3 
     433    fi 
     434  done 
     435 
     436  # Check jobs 
     437  # ---------- 
     438  for JobType in ${JobType_list[*]} ; do  
     439    eval String=\${${JobType}_String} 
     440    eval Field=\${${JobType}_Field} 
     441 
     442    FileList=$( ls ${POST_DIR}/${JobType}.*.out | tail -n ${NbHisto} ) 
     443 
     444    (( ind = 0 )) 
     445    for FileName in ${FileList} ; do 
     446      LastDate=$( basename ${FileName} | awk -F"." '{ print $(NF-1) }' ) 
     447 
     448      dum=$( basename $( grep ^${String} ${POST_DIR}/${JobType}.${LastDate}.out | \ 
     449               tail -1 | awk -v Field=${Field} '{ print $( Field ) }' ) | \ 
     450               awk -F"_" '{ print $3 }' ) 
     451 
     452      if [[ X${dum} == X${LastDate} ]] ; then 
     453        Status=OK 
     454      else 
     455        Status=KO 
     456      fi 
     457 
     458      eval ${JobType}_Date[$ind]=${LastDate} 
     459      eval ${JobType}_Status[$ind]=${Status} 
     460       
     461      (( ind = ind + 1 )) 
     462    done 
     463  done 
     464 
     465  # Check last MONITORING jobs 
     466  # ========================== 
     467  JobType=monitoring 
     468  LastDate=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | \ 
     469                  awk '{ print $NF }' ) 
     470  eval ${JobType}_Date=${LastDate} 
     471 
     472  # Check last ATLAS jobs 
     473  # ===================== 
     474  JobType=atlas 
     475  FileList=$( ls ${CWORK_DIR}/ATLAS | tail -n ${NbHisto} ) 
     476 
     477  (( ind = 0 )) 
     478  for FileName in ${FileList} ; do 
     479    eval ${JobType}_Date[$ind]=${FileName} 
    391480    (( ind = ind + 1 )) 
    392  
    393     LastDate[$ind]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n ${NbHisto} | awk -F"." '{ print $2 }' ) 
    394  
    395     dum=$( basename $( grep ^IGCM_sys_Put_Out ${POST_DIR}/${FileType}.${LastDate[$ind]}.out | tail -1 | awk '{ print $3 }' ) | awk -F"_" '{ print $3 }' ) 
    396  
    397     if [[ ${dum} == ${LastDate[$ind]} ]] ; then 
    398       Result[$ind]=OK 
    399     else 
    400       Result[$ind]=KO 
    401     fi 
    402481  done 
    403482 
    404483 
    405   # Check last MONITORING jobs 
    406  
    407   #set -vx 
    408  
    409   FileType=monitoring 
    410   (( ind = ind + 1 )) 
    411  
    412   LastDate[$ind]=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | awk '{ print $NF }' ) 
    413  
    414   # Check last ATLAS jobs 
    415  
    416   FileType=atlas 
    417   (( ind = ind + 1 )) 
    418  
    419   LastDate[$ind]=$( ls ${CWORK_DIR}/ATLAS | tail -n ${NbHisto} ) 
    420  
    421  
    422484  # Time of last write on run.card 
     485  # ============================== 
    423486  LastWrite=$( ls -l --time-style=+"${DateFormat}" ${SUBMIT_DIR}/run.card | awk '{print $6 " " $7}' ) 
    424487     
    425488 
    426489  # Print results 
     490  # ============= 
    427491  AffichResult -f 
    428   AffichResult 
     492  ind=0 
     493  while [ $ind -lt $NbHisto ] ; do 
     494    AffichResult -j 
     495    (( ind = ind + 1 )) 
     496  done 
    429497  AffichResult -l 
    430498 
Note: See TracChangeset for help on using the changeset viewer.