I found this script in an old thread on this forum.
http://code-saturne.org/forum/viewtopic.php?f=7&t=919
It seems to work, but it can not find the value of the VelocityX and so on. I am not very good at scripting. So does anyone knows how to modify the tabnum variable? The listing file does not use tab as spacing. I am using Code Saturne 4.0
Or is there already another method of monitoring real time the variables?
Thanks guys!
Here is to code:
Code: Select all
#!/bin/bash
###############################################################################
#
# Author: Alexandre CHATELAIN, AREVA NP
#
#
# Creation:06/08/2010
#
# Version: 08/11/2010
#
# Purpose: Monitoring with xmgrace a Code_Saturne calculation
# Must be launched in the temporary calculation folder
#
# Usage:
# Vectors tabvar, tabnum and tableg may be edited by the user following these rules:
# tabvar: indicate the "unique" pattern to be searched for in the listing file
# to retrieve the line containing it
# tabnum: indicate the position of the wanted value inside the line
# tableg: legend of the graph inside xmgrace
#
# PART TO BE ADAPTED BY USER
#
listing="listing"
xmgrace='/usr/bin/xmgrace'
declare -a tabvar
declare -a tabnum
declare -a tableg
tabvar[0]='v Velocity[X] ' ; tabnum[0]=3 ; tableg[0]='Min VelocityX'
tabvar[1]='v Velocity[X] ' ; tabnum[1]=4 ; tableg[1]='Max VelocityX'
tabvar[2]='v Velocity[Y] ' ; tabnum[2]=3 ; tableg[2]='Min VelocityY'
tabvar[3]='v Velocity[Y] ' ; tabnum[3]=4 ; tableg[3]='Max VelocityY'
tabvar[4]='v Velocity[Z] ' ; tabnum[4]=3 ; tableg[4]='Min VelocityZ'
tabvar[5]='v Velocity[Z] ' ; tabnum[5]=4 ; tableg[5]='Max VelocityZ'
fifo="Velocity"
nbItem=${#tabvar[*]}
function reScan()
{
for ((i=0;i<$nbItem;i++)); do
grep -h "${tabvar[${i}]}" $listing > temp
awk -v n=${tabnum[${i}]} '{print $n}' temp > temp.$i
done
# rm -f temp
}
function refresh()
{
reScan
for ((i=0;i<$nbItem;i++)); do
echo "WITH G$i
KILL G$i.S0
READ \"temp.$i\"
G$i.S0 line linewidth 2.0
G$i.S0 line color 2
UPDATEALL
AUTOSCALE XAXES
" > $fifo
done
sleep 3
echo REDRAW > $fifo
}
old_IFS=$IFS
rm -f $fifo
mkfifo $fifo
$xmgrace -npipe $fifo &
echo ARRANGE\(3, 2, 0.05, 0.05, 0.9\) > $fifo
echo SUBTITLE SIZE 0.7 > $fifo
reScan
for ((i=0;i<$nbItem;i++)); do
echo -e "* ${tabvar[${i}]}
Col. number: ${tabnum[${i}]}
Legend : ${tableg[${i}]}"
echo "WITH G$i
SUBTITLE \"${tableg[${i}]}\"
SUBTITLE SIZE .7
READ \"temp.$i\"
G$i.S0 line linewidth 2.0
G$i.S0 line color 2
AUTOSCALE
REDRAW
AUTOSCALE
" > $fifo
done
#echo " ======================================"
#echo " *** Automatic (a) or Manual (m) mode:"
#echo " ======================================"
#read auto
auto="a"
if [ "$auto" = "a" ]
then
echo " *** Press CTRL+C to Exit Monitoring "
#echo " ===================================="
while :
do
refresh
sleep 3
done
else
echo "==================================="
echo " *** Manual mode: u=update | q=quit "
echo "==================================="
read choice
until [ "$choice" = "q" ]
do
case $choice in
u )
refresh ;;
* )
echo "Impossible choice..." ;;
esac
read choice
done
fi
echo "exit" > $fifo
rm -f $fifo