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