source: tags/libIGCM_v2.2/AA_RunChecker

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

Bugfix for RunChecker? : restore -p option (problem with the loop used by -r option, #131).

  • Property svn:keywords set to Revision Author Date
File size: 7.0 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 [job_name2 ...]"
51      echo "       $0 [-u user] [-q] [-j n] -p config.card_path"
52      echo "       $0 [-u user] [-q] [-j n] -r [job_name job_name2 ...]"
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
108if ( ( ${fg_path} ) && ( ${fg_running} ) ) ; then
109  echo "You cannot use -r and -p at the same time"
110  exit
111fi
112
113
114# Load libIGCM library
115# ====================
116libIGCM=${libIGCM:=::modipsl::/libIGCM}
117
118DEBUG_debug=false
119DEBUG_sys=false
120
121. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
122. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
123. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
124#-------
125. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
126. ${libIGCM}/libIGCM_check/libIGCM_check.ksh
127. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
128#-------
129( ${DEBUG_debug} ) && IGCM_debug_Check
130( ${DEBUG_debug} ) && IGCM_card_Check
131( ${DEBUG_debug} ) && IGCM_date_Check
132
133
134if ( ${fg_running} ) ; then
135  # Look for running simu
136  IGCM_sys_ListJobInQueue ${TargetUsr} JobNameList
137fi
138
139if [ $# -ge 1 ] ; then
140  set -A JobNameList ${JobNameList[*]} ${*}
141elif ( ${fg_path} ) ; then
142  set -A JobNameList "Unknown"
143fi
144
145if [ ${#JobNameList[*]} -lt 1 ] ; then
146  echo "No running simulation found."
147  exit 0
148fi
149
150
151if ( ${fg_quiet} ) ; then
152  NbHisto=1
153fi
154
155# Define the catalog in which the known simulations are stored
156# ============================================================
157SimuCatalog="${HOME}/.simucatalog.dat"
158if [ ! -s ${SimuCatalog} ] ; then
159  touch ${SimuCatalog}
160fi
161
162
163for JobName in ${JobNameList[*]} ; do
164
165  # Find SUBMIT_DIR in catalog
166  # ==========================
167  IGCM_check_SearchCatalog
168  Status=$?
169
170  if [ $Status -eq 0 ] ; then
171
172    IGCM_sys_Cd $SUBMIT_DIR
173
174
175    # Extract usefull information from run.card and config.card
176    # =========================================================
177
178    RunFile="${SUBMIT_DIR}/run.card"
179    ConfFile="${SUBMIT_DIR}/config.card"
180
181    IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
182    IGCM_check_CommonDef
183
184
185    if [ -s ${RunFile} ] ; then
186      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
187      PeriodState=${run_Configuration_PeriodState}
188    else
189      PeriodState="Waiting"
190    fi
191
192    JobID="."
193    if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
194      IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
195
196      if [ "${JobID}" == "." ] || [ "${JobID}" == "" ] ; then
197        PeriodState="Fatal"
198        JobID="."
199      fi
200    fi
201
202    DateBegin=${config_UserChoices_DateBegin}
203    DateEnd=${config_UserChoices_DateEnd}
204    TagName=${config_UserChoices_TagName}
205    ExperimentName=${config_UserChoices_ExperimentName}
206    SpaceName=${config_UserChoices_SpaceName}
207
208
209    if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
210      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
211      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
212      IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
213      PeriodDateBegin=${run_Configuration_PeriodDateBegin}
214      PeriodDateEnd=${run_Configuration_PeriodDateEnd}
215      CumulPeriod=${run_Configuration_CumulPeriod}
216    else
217      PeriodDateBegin="."
218      PeriodDateEnd="."
219      CumulPeriod="."
220    fi
221
222    DATA_DIR=${R_SAVE}
223    POST_DIR=${R_BUFR}/Out
224    CWORK_DIR=${R_FIGR}
225
226    if [ ${TargetUsr} != ${CurrentUsr} ] ; then
227      DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
228      POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
229      CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
230      REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
231    fi
232
233    if [ $PeriodState != "Waiting" ] ; then
234      # Check pending REBUILDS
235      # ======================
236      IGCM_check_CheckPendingRebuild
237
238      # Check last REBUILD and PACK* jobs
239      # =================================
240      IGCM_check_CheckRebPackJobs
241
242      # Check last MONITORING jobs
243      # ==========================
244      IGCM_check_CheckMonitoring
245
246      # Check last ATLAS jobs
247      # =====================
248      IGCM_check_CheckAtlas
249
250      # Time of last write on run.card
251      # ==============================
252      IGCM_sys_GetDate_FichWork ${SUBMIT_DIR}/run.card LastWrite "SplitFields" "${DateFormat}"
253
254    else
255
256      NbRebuild="."
257      FirstRebuild="."
258      LastRebuild="."
259
260      NbLines=0
261
262    fi
263
264
265    # Print results
266    # =============
267    IGCM_check_PrintHeader
268    ind=0
269    while [ $ind -lt $NbLines ] ; do
270      IGCM_check_PrintJob
271      (( ind = ind + 1 ))
272    done
273    IGCM_check_PrintFooter
274
275  fi
276
277done
Note: See TracBrowser for help on using the repository browser.