#!/bin/sh
#
# $Id$
#
# Copyright 1989-2016 MINES ParisTech
#
# This file is part of PIPS.
#
# PIPS is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PIPS.  If not, see .
#
# Formattage sous latex de certaines des informations conservees
# optionnellement lors du calcul des regions
# Be'atrice Creusillet, Septembre 1994
workspace=$1
global=tmp$$
if [ ! -d $workspace.database ]
then
	echo Workspace $workspace does not exist!
	exit
fi
optypes="proj_var_op_stat proj_param_op_stat umust_op_stat umay_op_stat dsup_op_stat "
default_binary="umay_op_stat dsup_op_stat " 
## regions read et write, ou in, ou out.
for prefix in rrw rin rout 
do
	case $prefix in
		rrw) nompref="";;
		rin) nompref="IN";;
		rout) nompref="OUT";;
	esac
	cat >$workspace-$prefix.tex <$global.$optype
	for source in $workspace.database/*.f
	do
		module=`basename $source .f`
		module=`echo $module | tr a-z A-Z`
		#echo module=$module
		stats=$workspace.database/$module.$prefix-$optype
		#echo stats="$stats"
		if [ -f $stats ]
		then
			cat $stats >>$global.$optype
		else
			echo $0: missing statistics for module $module and operator $optype
			echo "$module 0 0 0 0 0 0 0 0 0 0 ">>$global.$prefix_$optype
		fi
	done
done
for optype in $optypes
do 
	case $optype in
		proj_param*) nomop="parameter projection";;
		proj_var*) nomop="variable projection";;
		umust*) nomop="$\cup_{must}$";;
		umay*) nomop="$\cup_{may}$";;
		dsup*) nomop="$ -_{sup}$";;
	esac
	cat >>$workspace-$prefix.tex <>$workspace-$prefix.tex <>$workspace-$prefix.tex
elif [ $optype = proj_var_op_stat ]
then 
	cat >>$workspace-$prefix.tex <>$workspace-$prefix.tex
#
## union must
elif [ $optype = umust_op_stat ]
then
	cat >>$workspace-$prefix.tex <>$workspace-$prefix.tex
#
## operateur binaires a affichage standard.
else
	cat >>$workspace-$prefix.tex <>$workspace-$prefix.tex
fi
	cat >>$workspace-$prefix.tex <>$workspace-$prefix.tex <