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
Line 
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
17
18#======================================================================#
19
20#D- Task type (computing, post-processing or checking)
21TaskType=checking
22typeset -i Verbosity=0
23
24CurrentUsr=$( whoami )
25
26if ( [ $# -eq 0 ] ) ; then
27  $0 -h
28  exit
29fi
30
31# Arguments
32# =========
33# Default argument values
34# -----------------------
35TargetUsr=${CurrentUsr}
36HostName=$( hostname | sed -e "s/[0-9].*//" )
37
38fg_color=true
39fg_search=false
40fg_quiet=false
41fg_running=false
42fg_path=false
43NbHisto=20
44
45# Get arguments from command line
46# -------------------------------
47while getopts :hj:p:qsu:r Opt ; do
48  case $Opt in
49    h)
50      echo "usage: $0 [-u user] [-q] [-j n] [-s] job_name"
51      echo "       $0 [-u user] [-q] [-j n] -p config.card_path"
52      echo "       $0 [-u user] [-q] [-j n] -r"
53      echo ""
54      echo "options :"
55      echo "  -h : print this help and exit"
56      echo "  -u : owner of the job"
57      echo "  -q : quiet"
58      echo "  -j : print n post-processing jobs (default is 20)"
59      echo "  -s : search for a new job in \$WORKDIR and fill in "
60      echo "       the catalog before printing information"
61      echo "  -p : give the directory (absolute path) containing "
62      echo "       the config.card instead of the job name."
63      echo "  -r : check all running simulations."
64      exit 0 ;;
65    j)
66      NbHisto=${OPTARG}
67      ;;
68    p)
69      fg_path=true
70      ConfigPath=${OPTARG}
71      ;;
72    q)
73      fg_quiet=true
74      ;;
75    s)
76      fg_search=true
77      ;;
78    u)
79      TargetUsr=${OPTARG}
80      ;;
81    r)
82      fg_running=true
83      ;;
84    :)
85      echo "$0: -"${OPTARG}" option: missing value"
86      exit 1
87      ;;
88    \?)
89      echo "$0: -"${OPTARG}" option: not supported"
90      exit 1
91      ;;
92  esac
93done
94shift $(($OPTIND-1))
95
96# If no config.card path is given, and we're not looking for running simulations,
97# at least one JobName must be given.
98if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then
99  $0 -h
100  exit
101fi
102
103if ( ( ${fg_path} ) && ( ${fg_search} ) ) ; then
104  echo "You cannot use -s and -p at the same time"
105  exit
106fi
107
108
109# Load libIGCM library
110# ====================
111libIGCM=${libIGCM:=::modipsl::/libIGCM}
112
113DEBUG_debug=false
114DEBUG_sys=false
115
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
121. ${libIGCM}/libIGCM_check/libIGCM_check.ksh
122. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
123#-------
124( ${DEBUG_debug} ) && IGCM_debug_Check
125( ${DEBUG_debug} ) && IGCM_card_Check
126( ${DEBUG_debug} ) && IGCM_date_Check
127
128
129if ( ${fg_running} ) ; then
130  # Look for running simu
131  IGCM_sys_ListJobInQueue ${TargetUsr} JobNameList
132fi
133
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
144if ( ${fg_quiet} ) ; then
145  NbHisto=1
146fi
147
148# Define the catalog in which the known simulations are stored
149# ============================================================
150SimuCatalog="${HOME}/.simucatalog.dat"
151if [ ! -s ${SimuCatalog} ] ; then
152  touch ${SimuCatalog}
153fi
154
155
156for JobName in ${JobNameList[*]} ; do
157
158  # Find SUBMIT_DIR in catalog
159  # ==========================
160  IGCM_check_SearchCatalog
161  Status=$?
162
163  if [ $Status -eq 0 ] ; then
164
165    IGCM_sys_Cd $SUBMIT_DIR
166
167
168    # Extract usefull information from run.card and config.card
169    # =========================================================
170
171    RunFile="${SUBMIT_DIR}/run.card"
172    ConfFile="${SUBMIT_DIR}/config.card"
173
174    IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
175    IGCM_check_CommonDef
176
177
178    if [ -s ${RunFile} ] ; then
179      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
180      PeriodState=${run_Configuration_PeriodState}
181    else
182      PeriodState="Waiting"
183    fi
184
185    if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
186      #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
187      IGCM_sys_CountJobInQueue ${JobName} NbRun
188
189      if [ ${NbRun} -eq 0 ] ; then
190        PeriodState="Fatal"
191      fi
192    fi
193
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}
199
200
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
213
214    DATA_DIR=${R_SAVE}
215    POST_DIR=${R_BUFR}/Out
216    CWORK_DIR=${R_FIGR}
217
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
224
225    if [ $PeriodState != "Waiting" ] ; then
226      # Check pending REBUILDS
227      # ======================
228      IGCM_check_CheckPendingRebuild
229
230      # Check last REBUILD and PACK* jobs
231      # =================================
232      IGCM_check_CheckRebPackJobs
233
234      # Check last MONITORING jobs
235      # ==========================
236      IGCM_check_CheckMonitoring
237
238      # Check last ATLAS jobs
239      # =====================
240      IGCM_check_CheckAtlas
241
242      # Time of last write on run.card
243      # ==============================
244      IGCM_sys_GetDate_FichWork ${SUBMIT_DIR}/run.card LastWrite "SplitFields" "${DateFormat}"
245
246    else
247
248      NbRebuild="."
249      FirstRebuild="."
250      LastRebuild="."
251
252      NbLines=0
253
254    fi
255
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.