source: trunk/libIGCM/AA_RunChecker @ 953

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

RunChecker? : use getopts built-in function to parse command line options.

  • Property svn:keywords set to Revision Author Date
File size: 6.1 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#======================================================================#
20
[835]21#D- Task type (computing, post-processing or checking)
[775]22TaskType=checking
[753]23typeset -i Verbosity=0
[751]24
[753]25CurrentUsr=$( whoami )
26
[751]27if ( [ $# -eq 0 ] ) ; then
28  $0 -h
29  exit
30fi
31
[754]32# Arguments
33# =========
[751]34# Default argument values
[754]35# -----------------------
[753]36TargetUsr=${CurrentUsr}
[751]37HostName=$( hostname | sed -e "s/[0-9].*//" )
38
[754]39fg_color=true
[756]40fg_search=false
[754]41fg_quiet=false
[755]42fg_path=false
[827]43NbHisto=20
[751]44
45# Get arguments from command line
[754]46# -------------------------------
[953]47while getopts :hj:p:qsu: Opt ; do
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."
[843]63      exit 0 ;;
[953]64    j)
65      NbHisto=${OPTARG}
66      ;;
67    p)
[755]68      fg_path=true
[953]69      ConfigPath=${OPTARG}
70      ;;
71    q)
[762]72      fg_quiet=true
[953]73      ;;
74    s)
[762]75      fg_search=true
[953]76      ;;
77    u)
78      TargetUsr=${OPTARG}
79      ;;
80    :)
81      echo "$0: -"${OPTARG}" option: missing value"
82      exit 1
83      ;;
84    \?)
85      echo "$0: -"${OPTARG}" option: not supported"
86      exit 1
87      ;;
[751]88  esac
89done
[953]90shift $(($OPTIND-1))
[751]91
[953]92if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then
[754]93  $0 -h
94  exit
95fi
96
[756]97if ( ( ${fg_path} ) && ( ${fg_search} ) ) ; then
98  echo "You cannot use -s and -p at the same time"
99  exit
100fi
[754]101
[756]102
[754]103# Load libIGCM library
104# ====================
105libIGCM=${libIGCM:=::modipsl::/libIGCM}
106
[834]107DEBUG_debug=false
[835]108DEBUG_sys=false
[834]109
[754]110. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
111. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
112. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
113#-------
114. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
[952]115. ${libIGCM}/libIGCM_check/libIGCM_check.ksh
[754]116. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
[832]117#-------
118( ${DEBUG_debug} ) && IGCM_debug_Check
119( ${DEBUG_debug} ) && IGCM_card_Check
120( ${DEBUG_debug} ) && IGCM_date_Check
[754]121
[952]122
[751]123JobName=$1
124
[754]125if ( ${fg_quiet} ) ; then
126  NbHisto=1
127fi
128
[751]129# Define the catalog in which the known simulations are stored
[952]130# ============================================================
[768]131SimuCatalog="${HOME}/.simucatalog.dat"
[751]132if [ ! -s ${SimuCatalog} ] ; then
133  touch ${SimuCatalog}
134fi
135
[754]136# Find SUBMIT_DIR in catalog
137# ==========================
[952]138IGCM_check_SearchCatalog
[751]139
140if [ ! X${SUBMIT_DIR} == X ] ; then
141
[835]142  IGCM_sys_Cd $SUBMIT_DIR
[751]143
144
[753]145  # Extract usefull information from run.card and config.card
[754]146  # =========================================================
[751]147
148  RunFile="${SUBMIT_DIR}/run.card"
149  ConfFile="${SUBMIT_DIR}/config.card"
150
[753]151  IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
[952]152  IGCM_check_CommonDef
[753]153
154
[751]155  if [ -s ${RunFile} ] ; then
156    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
157    PeriodState=${run_Configuration_PeriodState}
158  else
159    PeriodState="Waiting"
160  fi
161
162  if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
[768]163    #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
164    IGCM_sys_CountJobInQueue ${JobName} NbRun
[751]165
166    if [ ${NbRun} -eq 0 ] ; then
167      PeriodState="Fatal"
168    fi
169  fi
170
171  DateBegin=${config_UserChoices_DateBegin}
172  DateEnd=${config_UserChoices_DateEnd}
173  TagName=${config_UserChoices_TagName}
174  ExperimentName=${config_UserChoices_ExperimentName}
175  SpaceName=${config_UserChoices_SpaceName}
176
177
178  if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
179    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
180    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
[768]181    IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
[751]182    PeriodDateBegin=${run_Configuration_PeriodDateBegin}
183    PeriodDateEnd=${run_Configuration_PeriodDateEnd}
[762]184    CumulPeriod=${run_Configuration_CumulPeriod}
[751]185  else
186    PeriodDateBegin="."
187    PeriodDateEnd="."
[762]188    CumulPeriod="."
[751]189  fi
190
[753]191  DATA_DIR=${R_SAVE}
192  POST_DIR=${R_BUFR}/Out
193  CWORK_DIR=${R_FIGR}
[751]194
[753]195  if [ ${TargetUsr} != ${CurrentUsr} ] ; then
[952]196    DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
197    POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
198    CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
199    REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
[753]200  fi
201
[751]202  if [ $PeriodState != "Waiting" ] ; then
[952]203    # Check pending REBUILDS
[754]204    # ======================
[952]205    IGCM_check_CheckPendingRebuild
[751]206
[762]207    # Check last REBUILD and PACK* jobs
208    # =================================
[952]209    IGCM_check_CheckRebPackJobs
[751]210
[762]211    # Check last MONITORING jobs
212    # ==========================
[952]213    IGCM_check_CheckMonitoring
[751]214
[762]215    # Check last ATLAS jobs
216    # =====================
[952]217    IGCM_check_CheckAtlas
[751]218
[762]219    # Time of last write on run.card
220    # ==============================
[768]221    LastWrite=$( ls -l --time-style=+"${DateFormat}" ${SUBMIT_DIR}/run.card | gawk '{print $6 " " $7}' )
[756]222
[762]223  else
224
[952]225    NbRebuild="."
226    FirstRebuild="."
227    LastRebuild="."
228
[762]229    NbLines=0
230
231  fi
[751]232
[834]233
[751]234  # Print results
[754]235  # =============
[952]236  IGCM_check_PrintHeader
[754]237  ind=0
[756]238  while [ $ind -lt $NbLines ] ; do
[952]239    IGCM_check_PrintJob
[754]240    (( ind = ind + 1 ))
241  done
[952]242  IGCM_check_PrintFooter
[751]243
244fi
Note: See TracBrowser for help on using the repository browser.