mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
consistency fix for scripts: foamCheckJobs, foamPrintJobs, foamLog
- drop reference to license directory
- check -help before checking directories
- search for foamLog.db is more consistent with foamEtcFile
$HOME/.OpenFOAM/$WM_PROJECT_VERSION
$HOME/.OpenFOAM
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION
$WM_PROJECT_INST_DIR/site
$WM_PROJECT_DIR/etc
$PROGDIR/tools
This commit is contained in:
@ -38,7 +38,7 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
PROGNAME=${0##*/}
|
||||
Script=${0##*/}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#- User settings
|
||||
@ -48,9 +48,9 @@ NDAYSLIMIT=7
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#- work file
|
||||
TMPFILE=/tmp/${PROGNAME}$$.tmp
|
||||
TMPFILE=/tmp/${Script}$$.tmp
|
||||
#- work dir. Needs to be accessible for all machines
|
||||
MACHDIR=$HOME/.OpenFOAM/${PROGNAME}
|
||||
MACHDIR=$HOME/.OpenFOAM/${Script}
|
||||
DEFSTATEFILE=$HOME/.OpenFOAM/foamCheckJobs.out
|
||||
|
||||
|
||||
@ -62,6 +62,29 @@ else
|
||||
fi
|
||||
|
||||
|
||||
usage() {
|
||||
cat<<USAGE
|
||||
Usage: $Script [stateFile]
|
||||
|
||||
This program checks all the locks in the FOAM_JOB_DIR directory to see if
|
||||
their processes are still running. Processes will not release their
|
||||
lock if they exit abnormally. This program will try to obtain process
|
||||
information on the machine the process ran on and release the lock
|
||||
if the program is no longer running.
|
||||
|
||||
Note: all machines have to be reachable using ssh.
|
||||
|
||||
The output from checking all running jobs is collected in an optional
|
||||
file.
|
||||
|
||||
FILES:
|
||||
\$FOAM_JOB_DIR/runningJobs locks for running processes
|
||||
/finishedJobs locks for finished processes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Functions
|
||||
@ -83,7 +106,8 @@ getEntry() {
|
||||
# notEmpty directory
|
||||
# Returns 0 if directory contains files/directories
|
||||
notEmpty() {
|
||||
if [ "`ls $1`" ]; then
|
||||
if [ "`ls $1`" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@ -96,7 +120,8 @@ notEmpty() {
|
||||
# ==> 13
|
||||
dayDiff() {
|
||||
date -d "$1" > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
#- option '-d' on date not supported. Give up.
|
||||
echo "0"
|
||||
else
|
||||
@ -119,12 +144,14 @@ dayDiff() {
|
||||
# Also handles 'slaves' entries in jobInfo:
|
||||
# slaves 1 ( penfold.23766 );
|
||||
getAllJobs() {
|
||||
if notEmpty $1; then
|
||||
if notEmpty $1
|
||||
then
|
||||
jobs=$1/*
|
||||
for f in $jobs
|
||||
do
|
||||
line=`grep '^[ ]*slaves' $f 2>/dev/null`
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
slaveJobs=`echo "$line" | sed -e 's/.*(\(.*\)).*/\1/'`
|
||||
jobs="$jobs $slaveJobs"
|
||||
fi
|
||||
@ -138,34 +165,12 @@ getAllJobs() {
|
||||
# releaseLock jobId lockFile
|
||||
# Releases lock on jobId
|
||||
releaseLock () {
|
||||
if [ -f $2 ]; then
|
||||
if [ -f $2 ]
|
||||
then
|
||||
#- move lock to finishedJobs
|
||||
mv $2 $FOAM_JOB_DIR/finishedJobs/
|
||||
fi
|
||||
$ECHO "Lock on job $1 released."
|
||||
}
|
||||
|
||||
|
||||
printUsage() {
|
||||
cat << LABEL
|
||||
Usage: $PROGNAME [stateFile]
|
||||
|
||||
This program checks all the locks in the license directory to see if
|
||||
their processes are still running. Processes will not release their
|
||||
lock if they exit abnormally. This program will try to obtain process
|
||||
information on the machine the process ran on and release the lock
|
||||
if the program is no longer running.
|
||||
|
||||
Requirements: the environment variable FOAM_JOB_DIR needs to point to the
|
||||
license directory and all machines have to be reachable using ssh.
|
||||
|
||||
The output from checking all running jobs is collected in an optional
|
||||
file.
|
||||
|
||||
FILES:
|
||||
\$FOAM_JOB_DIR/runningJobs locks for running processes
|
||||
/finishedJobs ,, finished processes
|
||||
LABEL
|
||||
echo "Lock on job $1 released."
|
||||
}
|
||||
|
||||
|
||||
@ -175,39 +180,50 @@ LABEL
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#- Check a few things
|
||||
|
||||
if [ ! "$FOAM_JOB_DIR" ]; then
|
||||
$ECHO "$PROGNAME : FOAM_JOB_DIR environment variable not set."
|
||||
$ECHO "This should point to your central license directory."
|
||||
exit 1
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
if [ "$1" = "-h" -o "$1" = "-help" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ ! -d "$FOAM_JOB_DIR" ]; then
|
||||
$ECHO "$PROGNAME : The license directory accoring to FOAM_JOB_DIR is not valid."
|
||||
$ECHO "FOAM_JOB_DIR: $FOAM_JOB_DIR"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]; then
|
||||
$ECHO "$PROGNAME : The license directory according to FOAM_JOB_DIR is not valid."
|
||||
$ECHO "FOAM_JOB_DIR: $FOAM_JOB_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
STATEFILE=$1
|
||||
elif [ $# -eq 0 ]; then
|
||||
STATEFILE="$1"
|
||||
elif [ $# -eq 0 ]
|
||||
then
|
||||
STATEFILE=${STATEFILE:-$DEFSTATEFILE}
|
||||
else
|
||||
printUsage
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
#- Check a few things
|
||||
|
||||
if [ ! "$FOAM_JOB_DIR" ]
|
||||
then
|
||||
echo "$Script : FOAM_JOB_DIR environment variable not set."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$FOAM_JOB_DIR" ]
|
||||
then
|
||||
echo "$Script : directory does not exist."
|
||||
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]
|
||||
then
|
||||
echo "$Script : invalid directory."
|
||||
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#- obtain rsh method
|
||||
RSH='ssh'
|
||||
echo "Using remote shell type : $RSH"
|
||||
|
||||
echo ""
|
||||
echo "Collecting information on jobs in"
|
||||
echo " $FOAM_JOB_DIR"
|
||||
@ -226,13 +242,14 @@ do
|
||||
pid=`echo $machinePid | sed -e 's/.*\.\([0-9][0-9]*\)$/\1/'`
|
||||
|
||||
fgrep "$machine" $TMPFILE >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
$ECHO "$machine" >> $TMPFILE
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$machine" >> $TMPFILE
|
||||
fi
|
||||
done
|
||||
$ECHO "Found machines:"
|
||||
echo "Found machines:"
|
||||
cat $TMPFILE
|
||||
$ECHO ""
|
||||
echo ""
|
||||
|
||||
|
||||
|
||||
@ -243,31 +260,34 @@ cnt=1
|
||||
while true
|
||||
do
|
||||
machine=`sed -n -e "${cnt}p" $TMPFILE`
|
||||
if [ ! "$machine" ]; then
|
||||
if [ ! "$machine" ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
machFile=$MACHDIR/$machine
|
||||
rm -f $machFile
|
||||
$ECHO "Contacting $machine to collect process information:"
|
||||
if [ $machine = `hostname` ]; then
|
||||
$ECHO " foamProcessInfo $machFile"
|
||||
echo "Contacting $machine to collect process information:"
|
||||
if [ $machine = `hostname` ]
|
||||
then
|
||||
echo " foamProcessInfo $machFile"
|
||||
foamProcessInfo $machFile >/dev/null 2>&1
|
||||
else
|
||||
$ECHO " $RSH $machine foamProcessInfo $machFile"
|
||||
echo " $RSH $machine foamProcessInfo $machFile"
|
||||
$RSH $machine foamProcessInfo $machFile >/dev/null 2>&1
|
||||
fi
|
||||
if [ $? -ne 0 -o ! -s $machFile ]; then
|
||||
$ECHO "** Failed collecting process information on $machine."
|
||||
$ECHO "Check $machFile and run foamProcessInfo by hand"
|
||||
if [ $? -ne 0 -o ! -s $machFile ]
|
||||
then
|
||||
echo "** Failed collecting process information on $machine."
|
||||
echo "Check $machFile and run foamProcessInfo by hand"
|
||||
rm -f $machFile
|
||||
else
|
||||
$ECHO "Succesfully collected information in $machFile ..."
|
||||
echo "Succesfully collected information in $machFile ..."
|
||||
fi
|
||||
|
||||
cnt=`expr $cnt + 1`
|
||||
done
|
||||
$ECHO ""
|
||||
echo ""
|
||||
|
||||
|
||||
#- Construct state for runningJobs; move non runnning jobs to finishedJobs
|
||||
@ -281,27 +301,32 @@ do
|
||||
pid=`echo $machinePid | sed -e 's/.*\.\([0-9][0-9]*\)$/\1/'`
|
||||
|
||||
machFile=$MACHDIR/$machine
|
||||
if [ -r $machFile ]; then
|
||||
if [ -r $machFile ]
|
||||
then
|
||||
entry=`grep "^$pid " $machFile 2>/dev/null`
|
||||
if [ $? -ne 0 -o ! "$entry" ]; then
|
||||
if [ "$releaseAll" ]; then
|
||||
if [ $? -ne 0 -o ! "$entry" ]
|
||||
then
|
||||
if [ "$releaseAll" ]
|
||||
then
|
||||
releaseLock $machinePid $f
|
||||
else
|
||||
$ECHO "Job $machinePid seems to be no longer running. Release lock? (y/a)\c"
|
||||
echo "Job $machinePid seems to be no longer running. Release lock? (y/a)\c"
|
||||
read answ
|
||||
if [ "${answ:-y}" = 'y' ]; then
|
||||
if [ "${answ:-y}" = 'y' ]
|
||||
then
|
||||
releaseLock $machinePid $f
|
||||
elif [ "${answ:-y}" = 'a' ]; then
|
||||
elif [ "${answ:-y}" = 'a' ]
|
||||
then
|
||||
releaseAll='yes'
|
||||
releaseLock $machinePid $f
|
||||
else
|
||||
state='OTHR'
|
||||
$ECHO "$machinePid $state" >> $STATEFILE
|
||||
echo "$machinePid $state" >> $STATEFILE
|
||||
fi
|
||||
fi
|
||||
else
|
||||
state=`echo "$entry" | awk '{print $2}'`
|
||||
$ECHO "$machinePid $state" >> $STATEFILE
|
||||
echo "$machinePid $state" >> $STATEFILE
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@ -314,29 +339,33 @@ OLDFILES=`find $FOAM_JOB_DIR/finishedJobs -mtime +$NDAYSLIMIT -print`
|
||||
|
||||
#- Construct state for finishedJobs and check on date of files.
|
||||
|
||||
if notEmpty $FOAM_JOB_DIR/finishedJobs; then
|
||||
if notEmpty $FOAM_JOB_DIR/finishedJobs
|
||||
then
|
||||
dateNow=`date '+%b %d %Y'`
|
||||
for f in $FOAM_JOB_DIR/finishedJobs/*
|
||||
do
|
||||
sz=`ls -s $f | awk '{print $1}'`
|
||||
if [ "$sz" -gt 0 ]; then
|
||||
if [ "$sz" -gt 0 ]
|
||||
then
|
||||
machinePid=`basename $f`
|
||||
machine=`echo $machinePid | sed -e 's/\.[0-9][0-9]*$//'`
|
||||
pid=`echo $machinePid | sed -e 's/.*\.\([0-9][0-9]*\)$/\1/'`
|
||||
|
||||
end=`getEntry $f endDate`
|
||||
if [ ! "$end" ]; then
|
||||
if [ ! "$end" ]
|
||||
then
|
||||
state='ABRT'
|
||||
else
|
||||
nDaysOld=`dayDiff "$dateNow" "$end"`
|
||||
if [ "$nDaysOld" -gt $NDAYSLIMIT ]; then
|
||||
if [ "$nDaysOld" -gt $NDAYSLIMIT ]
|
||||
then
|
||||
OLDFILES="$OLDFILES $f"
|
||||
fi
|
||||
|
||||
state='FINI'
|
||||
fi
|
||||
|
||||
$ECHO "$machinePid $state" >> $STATEFILE
|
||||
echo "$machinePid $state" >> $STATEFILE
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -345,11 +374,13 @@ fi
|
||||
#- Remove old locks
|
||||
|
||||
nOldFiles=`echo "$OLDFILES" | wc -w`
|
||||
if [ "$nOldFiles" -gt 0 ]; then
|
||||
$ECHO "You seem to have $nOldFiles locks older than $NDAYSLIMIT days in finishedJobs/"
|
||||
if [ "$nOldFiles" -gt 0 ]
|
||||
then
|
||||
echo "You seem to have $nOldFiles locks older than $NDAYSLIMIT days in finishedJobs/"
|
||||
$ECHO "Do you want to remove these? (y)\c"
|
||||
read answ
|
||||
if [ "${answ:-y}" = 'y' ]; then
|
||||
if [ "${answ:-y}" = 'y' ]
|
||||
then
|
||||
rm -f $OLDFILES
|
||||
fi
|
||||
fi
|
||||
@ -358,9 +389,9 @@ fi
|
||||
rm -f $TMPFILE
|
||||
rm -r $MACHDIR
|
||||
|
||||
$ECHO ""
|
||||
$ECHO "Updated stateFile:"
|
||||
$ECHO " $STATEFILE"
|
||||
$ECHO ""
|
||||
echo ""
|
||||
echo "Updated stateFile:"
|
||||
echo " $STATEFILE"
|
||||
echo ""
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
131
bin/foamLog
131
bin/foamLog
@ -35,17 +35,11 @@
|
||||
|
||||
PROGDIR=`dirname $0`
|
||||
PROGNAME=`basename $0`
|
||||
|
||||
if [ -r $HOME/.${PROGNAME}.db ]; then
|
||||
DBFILE=$HOME/.${PROGNAME}.db
|
||||
else
|
||||
DBFILE=$PROGDIR/$PROGNAME.db
|
||||
fi
|
||||
|
||||
DBFILE=${PROGNAME}.db
|
||||
|
||||
printUsage() {
|
||||
cat <<LABUSAGE
|
||||
$PROGNAME - extracts xy files from Foam logs.
|
||||
cat <<USAGE
|
||||
$PROGNAME - extracts xy files from OpenFOAM logs.
|
||||
|
||||
Usage: $PROGNAME [-n][-s] <log>
|
||||
extracts xy files from log
|
||||
@ -54,26 +48,26 @@ Usage: $PROGNAME [-n][-s] <log>
|
||||
$PROGNAME -h
|
||||
for a help message
|
||||
|
||||
LABUSAGE
|
||||
USAGE
|
||||
}
|
||||
|
||||
|
||||
printHelp() {
|
||||
printUsage
|
||||
cat <<LABHELP
|
||||
The default is to extract for all the 'Solved for' variables the
|
||||
initial residual, the final residual and the number of iterations. On
|
||||
top of this a (user editable) database of standard non-solved for
|
||||
variables is used to extract data like Courant number, execution time.
|
||||
The default is to extract for all the 'Solved for' variables the initial
|
||||
residual, the final residual and the number of iterations. Additionally, a
|
||||
(user editable) database is used to extract data for standard non-solved for
|
||||
variables like Courant number, execution time.
|
||||
|
||||
$PROGNAME -l shows all the possible variables but does not extract them.
|
||||
$PROGNAME -l lists all the possible variables without extract them.
|
||||
|
||||
The program will generate and run an awk script which writes a set of
|
||||
files, logs/<var>_<subIter>, for every <var> specified, for every
|
||||
occurrence inside a time step.
|
||||
The program will generate and run an awk script which writes a set of files,
|
||||
logs/<var>_<subIter>, for every <var> specified, for every occurrence inside
|
||||
a time step.
|
||||
|
||||
For variables that are 'Solved for' the initial residual name will
|
||||
be <var>, the final residual will get name <var>FinalRes,
|
||||
For variables that are 'Solved for', the initial residual name will be
|
||||
<var>, the final residual receive the name <var>FinalRes,
|
||||
|
||||
The files are a simple xy format with the first column Time (default)
|
||||
and the second the extracted values. Option -n creates single column
|
||||
@ -81,12 +75,19 @@ files with the extracted data only.
|
||||
|
||||
|
||||
The query database is a simple text format with three entries per line,
|
||||
separated with '/'. Column 1 is the name of the variable (cannot contain
|
||||
spaces), column 2 is the extended regular expression (egrep) to select
|
||||
the line and column 3 is the string (fgrep) to select the column inside the
|
||||
line. The value taken will be the first (non-space)word after this
|
||||
column. The database will either be \$HOME/.${PROGNAME}.db or if not
|
||||
found $PROGDIR/${PROGNAME}.db.
|
||||
separated with '/' :
|
||||
Column 1 is the name of the variable (cannot contain spaces).
|
||||
Column 2 is the extended regular expression (egrep) to select the line.
|
||||
Column 3 is the string (fgrep) to select the column inside the line.
|
||||
The value taken will be the first (non-space)word after this column.
|
||||
The database ($PROGNAME.db) will taken from these locations:
|
||||
|
||||
$HOME/.OpenFOAM/$WM_PROJECT_VERSION
|
||||
$HOME/.OpenFOAM
|
||||
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION
|
||||
$WM_PROJECT_INST_DIR/site
|
||||
$WM_PROJECT_DIR/etc
|
||||
$PROGDIR/tools
|
||||
|
||||
Option -s suppresses the default information and only prints the extracted
|
||||
variables.
|
||||
@ -95,9 +96,28 @@ LABHELP
|
||||
}
|
||||
|
||||
|
||||
# The various places to be searched:
|
||||
for i in \
|
||||
$HOME/.OpenFOAM/$WM_PROJECT_VERSION \
|
||||
$HOME/.OpenFOAM \
|
||||
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION \
|
||||
$WM_PROJECT_INST_DIR/site \
|
||||
$WM_PROJECT_DIR/etc \
|
||||
$PROGDIR/tools \
|
||||
;
|
||||
do
|
||||
if [ -r $i/$DBFILE ]
|
||||
then
|
||||
DBFILE="$i/$DBFILE"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
myEcho() {
|
||||
if [ "$VERBOSE" ]; then
|
||||
if [ "$VERBOSE" ]
|
||||
then
|
||||
echo "$*"
|
||||
fi
|
||||
}
|
||||
@ -112,7 +132,8 @@ getSolvedVars() {
|
||||
# getQueries dbFile queryName
|
||||
# Gets regular expressions for a certain queryName from the database
|
||||
getQueries() {
|
||||
if [ ! -f "$1" ]; then
|
||||
if [ ! -f "$1" ]
|
||||
then
|
||||
echo "Cannot find dbFile $1"
|
||||
exit 1
|
||||
fi
|
||||
@ -123,7 +144,8 @@ getQueries() {
|
||||
NUMQ=`grep -v '^#' $1 | awk -F '/' "/$queryName/ {if (\"$queryName\" "'!= $1) next; print $3}'`
|
||||
|
||||
#echo "For $queryName found line selection /$LINEQ/ , column selection /$NUMQ/" 1>&2
|
||||
#if [ ! "$LINEQ" -o ! "$NUMQ" ]; then
|
||||
#if [ ! "$LINEQ" -o ! "$NUMQ" ]
|
||||
#then
|
||||
# echo "Did not find query for $2 in database $1" 1>&2
|
||||
#fi
|
||||
}
|
||||
@ -164,9 +186,11 @@ getAllQueries() {
|
||||
do
|
||||
getQueries $1 "$var"
|
||||
line=`egrep "$LINEQ" $2`
|
||||
if [ "$line" ]; then
|
||||
if [ "$line" ]
|
||||
then
|
||||
column=`echo "$line" | fgrep "$NUMQ"`
|
||||
if [ "$column" ]; then
|
||||
if [ "$column" ]
|
||||
then
|
||||
queries="$queries $var"
|
||||
fi
|
||||
fi
|
||||
@ -190,16 +214,21 @@ LISTONLY=''
|
||||
while getopts nslh flags
|
||||
do
|
||||
case $flags in
|
||||
n) TIMENAME=""
|
||||
n)
|
||||
TIMENAME=""
|
||||
;;
|
||||
h) printHelp
|
||||
h)
|
||||
printHelp
|
||||
exit 0
|
||||
;;
|
||||
s) VERBOSE=""
|
||||
s)
|
||||
VERBOSE=""
|
||||
;;
|
||||
l) LISTONLY='yes'
|
||||
l)
|
||||
LISTONLY='yes'
|
||||
;;
|
||||
\?) printUsage
|
||||
\?)
|
||||
printUsage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@ -209,18 +238,22 @@ done
|
||||
# Shift options
|
||||
shift `expr $OPTIND - 1`
|
||||
|
||||
if [ ! -f $DBFILE ]; then
|
||||
if [ ! -f $DBFILE ]
|
||||
then
|
||||
echo "$PROGNAME: Cannot read database $DBFILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$LISTONLY" ]; then
|
||||
if [ $# -ne 1 ]; then
|
||||
if [ "$LISTONLY" ]
|
||||
then
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
printUsage
|
||||
exit 1
|
||||
fi
|
||||
LOG=$1;
|
||||
if [ ! -r $LOG ]; then
|
||||
if [ ! -r $LOG ]
|
||||
then
|
||||
echo "$PROGNAME: Cannot read log $LOG"
|
||||
exit 1
|
||||
fi
|
||||
@ -228,14 +261,16 @@ if [ "$LISTONLY" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
printUsage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CASEDIR=.
|
||||
LOG=$1
|
||||
if [ ! -r $LOG ]; then
|
||||
if [ ! -r $LOG ]
|
||||
then
|
||||
echo "$PROGNAME: Cannot read log $LOG"
|
||||
exit 1
|
||||
fi
|
||||
@ -243,17 +278,20 @@ fi
|
||||
QUERYNAMES=`getAllQueries $DBFILE $LOG`
|
||||
|
||||
|
||||
if [ ! "$CASEDIR" ]; then
|
||||
if [ ! "$CASEDIR" ]
|
||||
then
|
||||
printUsage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$CASEDIR" ]; then
|
||||
if [ ! -d "$CASEDIR" ]
|
||||
then
|
||||
echo "$PROGNAME: Cannot read $CASEDIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$LOG" ]; then
|
||||
if [ ! -f "$LOG" ]
|
||||
then
|
||||
echo "$PROGNAME: Cannot read log file $LOG"
|
||||
exit 1
|
||||
fi
|
||||
@ -384,7 +422,8 @@ LABSOLVE
|
||||
for queryName in $QUERYNAMES
|
||||
do
|
||||
getQueries $DBFILE $queryName
|
||||
if [ "$LINEQ" -a "$NUMQ" ]; then
|
||||
if [ "$LINEQ" -a "$NUMQ" ]
|
||||
then
|
||||
counter=${queryName}Cnt
|
||||
|
||||
echo "#-- Extraction of $queryName" >> $AWKFILE
|
||||
|
||||
@ -30,10 +30,8 @@
|
||||
# Uses finishedJobs/ and runningJobs/ and stateFile to print job info
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
|
||||
PROGNAME=`basename $0`
|
||||
TMPFILE=/tmp/${PROGNAME}$$.tmp
|
||||
TMPFILE2=/tmp/${PROGNAME}$$.tmp2
|
||||
JOBSTRING='%4s %8s %20s %10s %8s %4s %12s %12s %20s\n'
|
||||
DEFSTATEFILE=$HOME/.OpenFOAM/foamCheckJobs.out
|
||||
|
||||
@ -44,18 +42,19 @@ DEFSTATEFILE=$HOME/.OpenFOAM/foamCheckJobs.out
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
printUsage() {
|
||||
cat << LABEL
|
||||
Usage: $PROGNAME [stateFile]
|
||||
usage() {
|
||||
cat<<USAGE
|
||||
Usage: $Script [stateFile]
|
||||
|
||||
This program prints a table of all the running and finished jobs.
|
||||
This program prints a table of all running and finished jobs.
|
||||
|
||||
It is normally used in conjunction with foamCheckJobs which outputs
|
||||
a "stateFile" containing the actual process status of all jobs.
|
||||
|
||||
If stateFile is not supplied the default $DEFSTATEFILE
|
||||
is used.
|
||||
LABEL
|
||||
If stateFile is not supplied, the default is used:
|
||||
$DEFSTATEFILE
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +80,8 @@ getEntry() {
|
||||
# notEmpty directory
|
||||
# Returns 0 if directory contains files/directories
|
||||
notEmpty() {
|
||||
if [ "`ls $1`" ]; then
|
||||
if [ "`ls $1`" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@ -104,37 +104,47 @@ leftStr() {
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ ! "$FOAM_JOB_DIR" ]; then
|
||||
echo "$PROGNAME : FOAM_JOB_DIR environment variable not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$FOAM_JOB_DIR" ]; then
|
||||
echo "$PROGNAME : directory does not exist."
|
||||
echo " FOAM_JOB_DIR: $FOAM_JOB_DIR"
|
||||
fi
|
||||
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]; then
|
||||
echo "$PROGNAME : invalid directory."
|
||||
echo " FOAM_JOB_DIR: $FOAM_JOB_DIR"
|
||||
fi
|
||||
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
if [ "$1" = '-h' ]; then
|
||||
printUsage
|
||||
exit 1
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
if [ "$1" = "-h" -o "$1" = "-help" ]
|
||||
then
|
||||
usage
|
||||
else
|
||||
STATEFILE=$1
|
||||
STATEFILE="$1"
|
||||
fi
|
||||
elif [ $# -eq 0 ]; then
|
||||
elif [ $# -eq 0 ]
|
||||
then
|
||||
STATEFILE=${STATEFILE:-$DEFSTATEFILE}
|
||||
else
|
||||
printUsage
|
||||
usage
|
||||
fi
|
||||
|
||||
#- Check a few things
|
||||
|
||||
if [ ! "$FOAM_JOB_DIR" ]
|
||||
then
|
||||
echo "$Script : FOAM_JOB_DIR environment variable not set."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$FOAM_JOB_DIR" ]
|
||||
then
|
||||
echo "$Script : directory does not exist."
|
||||
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]
|
||||
then
|
||||
echo "$Script : invalid directory."
|
||||
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -f "$STATEFILE" ]; then
|
||||
if [ -f "$STATEFILE" ]
|
||||
then
|
||||
echo ""
|
||||
echo "Using process information from"
|
||||
echo " $STATEFILE"
|
||||
@ -160,7 +170,8 @@ printJob '----' '----' '----' '-------' '---' '----' '-----' '---' '----'
|
||||
|
||||
#-- print running
|
||||
echo "Running:"
|
||||
if notEmpty $FOAM_JOB_DIR/runningJobs; then
|
||||
if notEmpty $FOAM_JOB_DIR/runningJobs
|
||||
then
|
||||
for f in `ls -t $FOAM_JOB_DIR/runningJobs/*`
|
||||
do
|
||||
machinePid=`basename $f`
|
||||
@ -170,14 +181,15 @@ if notEmpty $FOAM_JOB_DIR/runningJobs; then
|
||||
|
||||
pid=`echo $machinePid | sed -e 's/.*\.\([0-9][0-9]*\)$/\1/'`
|
||||
|
||||
if [ "$STATEFILE" ]; then
|
||||
if [ "$STATEFILE" ]
|
||||
then
|
||||
stat=`getEntry $STATEFILE $machinePid`
|
||||
fi
|
||||
stat=${stat:-'UNKN'}
|
||||
|
||||
case=`getEntry $f 'case'`
|
||||
case=${case:-'---'}
|
||||
case=`echo $case | sed -e 's!/.*!!'` #strip of processorXXX ending
|
||||
case=`echo $case | sed -e 's!/.*!!'` # strip processorXXX ending
|
||||
case=`rightStr 20 "$case"`
|
||||
|
||||
start=`getEntry $f 'startDate'`
|
||||
@ -187,7 +199,8 @@ if notEmpty $FOAM_JOB_DIR/runningJobs; then
|
||||
end='---'
|
||||
|
||||
code=`getEntry $f 'code'`
|
||||
if [ "$code" ]; then
|
||||
if [ "$code" ]
|
||||
then
|
||||
code=`basename $code`
|
||||
else
|
||||
code='---'
|
||||
@ -196,7 +209,8 @@ if notEmpty $FOAM_JOB_DIR/runningJobs; then
|
||||
|
||||
nProcs=`getEntry $f 'nProcs'`
|
||||
nProcs=${nProcs:-'1'}
|
||||
if [ $nProcs -eq 1 ]; then
|
||||
if [ $nProcs -eq 1 ]
|
||||
then
|
||||
nProcs='---'
|
||||
fi
|
||||
nProcs=`rightStr 3 "$nProcs"`
|
||||
@ -213,7 +227,8 @@ fi
|
||||
#-- print finished
|
||||
echo ""
|
||||
echo "Finished:"
|
||||
if notEmpty $FOAM_JOB_DIR/finishedJobs; then
|
||||
if notEmpty $FOAM_JOB_DIR/finishedJobs
|
||||
then
|
||||
for f in `ls -t $FOAM_JOB_DIR/finishedJobs/*`
|
||||
do
|
||||
machinePid=`basename $f`
|
||||
@ -227,13 +242,14 @@ if notEmpty $FOAM_JOB_DIR/finishedJobs; then
|
||||
end=${end:-'---'}
|
||||
end=`leftStr 12 "$end"`
|
||||
|
||||
if [ "$STATEFILE" ]; then
|
||||
if [ "$STATEFILE" ]
|
||||
then
|
||||
stat=`getEntry $STATEFILE $machinePid`
|
||||
fi
|
||||
stat=${stat:-'UNKN'}
|
||||
|
||||
case=`getEntry $f case`
|
||||
case=`echo $case | sed -e 's!/.*!!'` #strip of processorXXX ending
|
||||
case=`echo $case | sed -e 's!/.*!!'` # strip processorXXX ending
|
||||
case=${case:-'---'}
|
||||
case=`rightStr 20 "$case"`
|
||||
|
||||
@ -242,7 +258,8 @@ if notEmpty $FOAM_JOB_DIR/finishedJobs; then
|
||||
start=`leftStr 12 "$start"`
|
||||
|
||||
code=`getEntry $f code`
|
||||
if [ "$code" ]; then
|
||||
if [ "$code" ]
|
||||
then
|
||||
code=`basename $code`
|
||||
else
|
||||
code='---'
|
||||
@ -251,7 +268,8 @@ if notEmpty $FOAM_JOB_DIR/finishedJobs; then
|
||||
|
||||
nProcs=`getEntry $f 'nProcs'`
|
||||
nProcs=${nProcs:-'1'}
|
||||
if [ $nProcs -eq 1 ]; then
|
||||
if [ $nProcs -eq 1 ]
|
||||
then
|
||||
nProcs='---'
|
||||
fi
|
||||
nProcs=`rightStr 3 "$nProcs"`
|
||||
|
||||
Reference in New Issue
Block a user