Page 1 of 1

Monitoring script

Posted: Thu Feb 04, 2016 9:21 am
by joschilly
Hey,
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

Re: Monitoring script

Posted: Thu Feb 04, 2016 6:57 pm
by Yvan Fournier
Hello,

I suspect the "[" and "]" charecters are causing issues with your regular expressions, so you may need to escape them (but I'm not an expert on the syntax; I can only suggest what to search for).

Otherwise, you can use probes for monitoring, but this is not identical to checking the min/max/mean.

Regards,

Yvan

Re: Monitoring script

Posted: Fri Feb 05, 2016 8:32 am
by joschilly
Do you mean with probes monitoring points in the output control? Because I always set some point, but the calculation does not write the files before the end of the simulation.

Re: Monitoring script

Posted: Fri Feb 05, 2016 10:35 am
by Yvan Fournier
Hello,

Which version of the code are you using ? In versions 3.0 to 4.1, you can set advanced parameters to force flushing of files. For example, in cs_user_parameters.f90, in usipes, set: "tplflw = n" to flush the file every n seconds (this may impact performance if you force writes at a too high frequency).

En version 4.2, you can also type "touch control_file" in the execution directory, to force update/flush of the probes.

Regards,

Yvan