source: trunk/libIGCM/AA_RunChecker @ 955

Last change on this file since 955 was 955, checked in by labetoulle, 11 years ago

RunChecker? :

  • Introduction of getopts to process command line options
  • new option -r to check running simulations

(#131)

  • Property svn:keywords set to Revision Author Date
File size: 6.7 KB
RevLine 
[751]1#!/bin/ksh
2
3#**************************************************************
4# Author: Sonia Labetoulle
5# Contact: sonia.labetoulle__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2012)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#======================================================================#
15# Display a report on how a simulation is faring.
16
[754]17
[751]18#======================================================================#
19
[835]20#D- Task type (computing, post-processing or checking)
[775]21TaskType=checking
[753]22typeset -i Verbosity=0
[751]23
[753]24CurrentUsr=$( whoami )
25
[751]26if ( [ $# -eq 0 ] ) ; then
27  $0 -h
28  exit
29fi
30
[754]31# Arguments
32# =========
[751]33# Default argument values
[754]34# -----------------------
[753]35TargetUsr=${CurrentUsr}
[751]36HostName=$( hostname | sed -e "s/[0-9].*//" )
37
[754]38fg_color=true
[756]39fg_search=false
[754]40fg_quiet=false
[955]41fg_running=false
[755]42fg_path=false
[827]43NbHisto=20
[751]44
45# Get arguments from command line
[754]46# -------------------------------
[955]47while getopts :hj:p:qsu:r Opt ; do
[953]48  case $Opt in
49    h)
[762]50      echo "usage: $0 [-u user] [-q] [-j n] [-s] job_name"
51      echo "       $0 [-u user] [-q] [-j n] -p config.card_path"
[953]52      echo "       $0 [-u user] [-q] [-j n] -r"
[755]53      echo ""
54      echo "options :"
55      echo "  -h : print this help and exit"
56      echo "  -u : owner of the job"
57      echo "  -q : quiet"
[827]58      echo "  -j : print n post-processing jobs (default is 20)"
[756]59      echo "  -s : search for a new job in \$WORKDIR and fill in "
[755]60      echo "       the catalog before printing information"
[762]61      echo "  -p : give the directory (absolute path) containing "
62      echo "       the config.card instead of the job name."
[955]63      echo "  -r : check all running simulations."
[843]64      exit 0 ;;
[953]65    j)
66      NbHisto=${OPTARG}
67      ;;
68    p)
[755]69      fg_path=true
[953]70      ConfigPath=${OPTARG}
71      ;;
72    q)
[762]73      fg_quiet=true
[953]74      ;;
75    s)
[762]76      fg_search=true
[953]77      ;;
78    u)
79      TargetUsr=${OPTARG}
80      ;;
[955]81    r)
82      fg_running=true
83      ;;
[953]84    :)
85      echo "$0: -"${OPTARG}" option: missing value"
86      exit 1
87      ;;
88    \?)
89      echo "$0: -"${OPTARG}" option: not supported"
90      exit 1
91      ;;
[751]92  esac
93done
[953]94shift $(($OPTIND-1))
[751]95
[955]96# If no config.card path is given, and we're not looking for running simulations,
97# at least one JobName must be given.
[953]98if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then
[754]99  $0 -h
100  exit
101fi
102
[756]103if ( ( ${fg_path} ) && ( ${fg_search} ) ) ; then
104  echo "You cannot use -s and -p at the same time"
105  exit
106fi
[754]107
[756]108
[754]109# Load libIGCM library
110# ====================
111libIGCM=${libIGCM:=::modipsl::/libIGCM}
112
[834]113DEBUG_debug=false
[835]114DEBUG_sys=false
[834]115
[754]116. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
117. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
118. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
119#-------
120. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
[952]121. ${libIGCM}/libIGCM_check/libIGCM_check.ksh
[754]122. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
[832]123#-------
124( ${DEBUG_debug} ) && IGCM_debug_Check
125( ${DEBUG_debug} ) && IGCM_card_Check
126( ${DEBUG_debug} ) && IGCM_date_Check
[754]127
[952]128
[955]129if ( ${fg_running} ) ; then
130  # Look for running simu
131  IGCM_sys_ListJobInQueue ${TargetUsr} JobNameList
132fi
[751]133
[955]134if [ $# -ge 1 ] ; then
135  set -A JobNameList ${JobNameList[*]} ${*}
136fi
137
138if [ ${#JobNameList[*]} -lt 1 ] ; then
139  echo "No running simulation found."
140  exit 0
141fi
142
143
[754]144if ( ${fg_quiet} ) ; then
145  NbHisto=1
146fi
147
[751]148# Define the catalog in which the known simulations are stored
[952]149# ============================================================
[768]150SimuCatalog="${HOME}/.simucatalog.dat"
[751]151if [ ! -s ${SimuCatalog} ] ; then
152  touch ${SimuCatalog}
153fi
154
155
[955]156for JobName in ${JobNameList[*]} ; do
[751]157
[955]158  # Find SUBMIT_DIR in catalog
159  # ==========================
160  IGCM_check_SearchCatalog
161  Status=$?
[751]162
[955]163  if [ $Status -eq 0 ] ; then
[751]164
[955]165    IGCM_sys_Cd $SUBMIT_DIR
[751]166
167
[955]168    # Extract usefull information from run.card and config.card
169    # =========================================================
[753]170
[955]171    RunFile="${SUBMIT_DIR}/run.card"
172    ConfFile="${SUBMIT_DIR}/config.card"
[753]173
[955]174    IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
175    IGCM_check_CommonDef
[751]176
177
[955]178    if [ -s ${RunFile} ] ; then
179      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
180      PeriodState=${run_Configuration_PeriodState}
181    else
182      PeriodState="Waiting"
[751]183    fi
184
[955]185    if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
186      #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
187      IGCM_sys_CountJobInQueue ${JobName} NbRun
[751]188
[955]189      if [ ${NbRun} -eq 0 ] ; then
190        PeriodState="Fatal"
191      fi
192    fi
[751]193
[955]194    DateBegin=${config_UserChoices_DateBegin}
195    DateEnd=${config_UserChoices_DateEnd}
196    TagName=${config_UserChoices_TagName}
197    ExperimentName=${config_UserChoices_ExperimentName}
198    SpaceName=${config_UserChoices_SpaceName}
[751]199
200
[955]201    if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
202      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
203      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
204      IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
205      PeriodDateBegin=${run_Configuration_PeriodDateBegin}
206      PeriodDateEnd=${run_Configuration_PeriodDateEnd}
207      CumulPeriod=${run_Configuration_CumulPeriod}
208    else
209      PeriodDateBegin="."
210      PeriodDateEnd="."
211      CumulPeriod="."
212    fi
[753]213
[955]214    DATA_DIR=${R_SAVE}
215    POST_DIR=${R_BUFR}/Out
216    CWORK_DIR=${R_FIGR}
[751]217
[955]218    if [ ${TargetUsr} != ${CurrentUsr} ] ; then
219      DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
220      POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
221      CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
222      REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
223    fi
[751]224
[955]225    if [ $PeriodState != "Waiting" ] ; then
226      # Check pending REBUILDS
227      # ======================
228      IGCM_check_CheckPendingRebuild
[751]229
[955]230      # Check last REBUILD and PACK* jobs
231      # =================================
232      IGCM_check_CheckRebPackJobs
[751]233
[955]234      # Check last MONITORING jobs
235      # ==========================
236      IGCM_check_CheckMonitoring
[756]237
[955]238      # Check last ATLAS jobs
239      # =====================
240      IGCM_check_CheckAtlas
[762]241
[955]242      # Time of last write on run.card
243      # ==============================
244      IGCM_sys_GetDate_FichWork ${SUBMIT_DIR}/run.card LastWrite "SplitFields" "${DateFormat}"
[952]245
[955]246    else
[762]247
[955]248      NbRebuild="."
249      FirstRebuild="."
250      LastRebuild="."
[751]251
[955]252      NbLines=0
[834]253
[955]254    fi
[751]255
[955]256
257    # Print results
258    # =============
259    IGCM_check_PrintHeader
260    ind=0
261    while [ $ind -lt $NbLines ] ; do
262      IGCM_check_PrintJob
263      (( ind = ind + 1 ))
264    done
265    IGCM_check_PrintFooter
266
267  fi
268
269done
Note: See TracBrowser for help on using the repository browser.