#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: mtt
# P.J.Gawthrop Oct 1989, Dec 1989, 1990, 1991, Oct 1993, Dec 1993, Jan 1994, Dec 95, Nov 1996.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996.
###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.120 1998/02/05 16:06:53 peterg
## Removed debugging lines.
## Auto parts in books.
##
## Revision 1.119 1998/02/05 15:04:25 peterg
## Fixed problem with book in tidy mode.
##
## Revision 1.118 1998/02/05 12:00:11 peterg
## Tidy mode now default.
## It seems to work ok but not for book type documents.
##
## Revision 1.117 1998/02/04 16:50:50 peterg
## Introduced the tidy (-t and -T) options
##
## Revision 1.116 1998/02/04 11:00:04 peterg
## Added view of subsystems.
##
## Revision 1.115 1998/01/29 19:37:31 peterg
## Fixed spurious call to X server bug
##
## Revision 1.114 1998/01/23 13:38:07 peterg
## VERSION 2.7
##
## Revision 1.113 1998/01/23 13:27:13 peterg
## Added state-feedback control representations:
## smc,smo,ssk,ssl
##
## Revision 1.112 1998/01/21 09:24:46 peterg
## Removed 'touch $1_rep.txt' -- perhaps best to do this by hand if
## necessary. As it is, it cuased probs wene reediting the _rep.txt file.
##
## Revision 1.111 1998/01/16 14:56:59 peterg
## Argument now correctely recognised as a string beginning with -
## (rather than containing -)
##
# Revision 1.110 1998/01/06 13:59:30 peterg
# Added rename function.
#
# Revision 1.109 1998/01/06 09:20:02 peterg
# Made LATEX2HTML an environment variable.
#
# Revision 1.108 1997/12/19 08:48:55 peterg
# Lille modifications - bicausal algebraic loops supported
#
## Revision 1.107 1997/12/11 10:59:50 peterg
## This is version 2.6
##
# Revision 1.106 1997/12/11 10:59:07 peterg
# Added debug -D switch + echos directory when -d switch used.
#
# Revision 1.105 1997/12/11 09:04:47 peterg
# Reduced default rep.txt file to just abg.txt -- this is to document
# components which may not be causally complete
#
# Revision 1.104 1997/12/07 21:05:10 peterg
# Removed a debbugging echo
#
## Revision 1.103 1997/12/07 20:10:36 peterg
## Fixed bugs with reprots and distinguish between book, article and
## section reports.
##
## Revision 1.102 1997/12/07 12:14:43 peterg
## Hnadles book, article and section reports seperately
##
## Revision 1.101 1997/12/06 18:54:53 peterg
## Now tidies up after itself.
## Major modifications to do a rep on a directory -- creates a book with
## each example as a chapter.
##
## Revision 1.100 1997/12/06 12:14:39 peterg
## Put a conditional around the PS data rep to check for set arguments.
##
## Revision 1.99 1997/12/04 22:06:53 peterg
## Added view arguments for graph plotting
##
## Revision 1.98 1997/12/04 10:58:15 peterg
## Tidied up switches
##
## Revision 1.97 1997/12/04 10:44:33 peterg
## Changed $cc to $CC
##
## Revision 1.96 1997/12/04 10:40:26 peterg
## Added -p switch - print enviromment variables
##
## Revision 1.95 1997/12/04 10:05:02 peterg
## Compiler now symbolocic $cc
##
# Revision 1.94 1997/11/20 11:23:16 peterg
# Changed gcc to cc
#
## Revision 1.93 1997/09/18 16:57:28 peterg
## _sympar.txt now has a second column - the system type from whence the
## parameter (in the first column) came.
## Done on the train Glasgow-Warrington !
##
## Revision 1.92 1997/09/11 17:08:46 peterg
## Added spreadsheet version of odeso
##
## Revision 1.91 1997/09/11 08:21:08 peterg
## copy utility split into two:
## copy: copies examples (copies the entire directory)
## compcopy: (just used internally) copies components.
##
## Revision 1.90 1997/08/30 19:35:39 peterg
## Added date to mtt line
##
## Revision 1.89 1997/08/26 15:20:25 peterg
## Added explicit evaluation of report representations
## Version now 2.5++
##
## Revision 1.88 1997/08/25 07:51:47 peterg
## Version 2.5.
##
## Revision 1.87 1997/07/27 13:11:11 peterg
## Added path checking code -- mtt_check_vars
##
# Revision 1.86 1997/06/29 19:05:51 peterg
# Seascale changes -- mainly to new rep format.
#
## Revision 1.85 1997/06/27 12:14:49 peterg
## Upped version to 2.4++
##
# Revision 1.84 1997/06/13 14:08:23 peterg
# Changed default rep.txt
#
# Revision 1.83 1997/06/13 09:18:28 peterg
# Removed all params.m
#
# Revision 1.82 1997/06/13 08:59:03 peterg
# Set to version 2.4
#
## Revision 1.81 1997/05/22 10:11:04 peterg
## Fixed dat2gdat bug (with parameters)
##
## Revision 1.80 1997/05/22 07:38:27 peterg
## Added command line info to .doc files (makedoc)
##
## Revision 1.79 1997/05/19 16:44:12 peterg
## Many changes to get rep.html mode working properly.
##
# Revision 1.78 1997/05/19 13:17:50 peterg
# Explicit inclusion of mtt.sty in .doc files -- latex2html prefers this
#
# Revision 1.77 1997/05/19 11:29:37 peterg
# Added desc.tex and abg.tex descriptions.
#
# Revision 1.76 1997/05/15 09:43:46 peterg
# New version of _input.txt for -s option
#
# Revision 1.75 1997/05/15 09:15:54 peterg
# Included switch.c in dependancy list for _input.c (when -s switch set)
#
# Revision 1.74 1997/05/13 16:58:02 peterg
# Added -s switch to get mtt to search for (Bond Graph) switches
#
## Revision 1.73 1997/05/09 09:18:45 peterg
## Put ./ in front of a.out (again)
##
# Revision 1.72 1997/05/06 13:54:21 peterg
# Changed gcc arguments for the ode simulation -- all files now included
# in the _odes.c file
#
# Revision 1.71 1997/05/03 15:50:18 peterg
# c functions not included in gcc arg list -- they are now included in
# the main prog.
#
# Revision 1.70 1997/05/03 14:17:13 peterg
# Now copies c utilities (eg dsvdcmp.c) from $MTTPATH/trans/c.
#
# Revision 1.69 1997/05/03 13:58:35 peterg
# Implicit integration for sm representation added.
#
# Revision 1.68 1997/05/01 08:39:20 peterg
# params.c and params.m not used any more.
# _numpar.txt is the common base from which _numpar.c and numpar.m is
# generated.
#
# Revision 1.67 1997/04/23 07:26:49 peterg
# Added -o switch -- ode and dae are the same
# Added switches to default menu
#
# Revision 1.66 1997/04/16 09:46:01 peterg
# More informative copy message
#
# Revision 1.65 1997/04/15 15:16:12 peterg
# Added structure (_struc) files.
# Fixed prob with dvi2ps conversion -- removed .doc extension.
#
# Revision 1.64 1997/04/09 09:26:44 peterg
# Added crcopy feature to pull crs from library -- similar to copy
# feature.
#
# Revision 1.63 1997/03/22 17:09:11 peterg
# Fixed bug in recursive cr.txt generation.
# Fixed bug in recursive sympar.txt generation.
#
# Revision 1.62 1997/03/20 17:48:50 peterg
# Better _input.c file default.
#
# Revision 1.61 1997/03/20 16:53:01 peterg
# Generates c files using include statements.
#
# Revision 1.60 1997/03/20 10:25:41 peterg
# Generates a compehensive default params file.
#
# Revision 1.59 1997/03/19 10:14:04 peterg
# Now produces a stripped acausal bond graph.
#
# Revision 1.58 1997/03/18 17:58:12 peterg
# Generates label files containing all variables in fig file.
# Generates sympar file for all levels in system.
# Generates txt version of sympar file.
#
# Revision 1.57 1997/03/10 09:24:58 peterg
# a.out now deleted in the clean operation
#
# Revision 1.56 1997/03/05 08:24:09 peterg
# Delete a.out after it has run.
#
# Revision 1.55 1997/02/24 19:31:10 peterg
# Removed numpar.m requirement from .m files
#
## Revision 1.54 1997/02/09 20:33:13 peterg
## Replaced a.out with ./a.out
##
## Revision 1.53 1997/02/09 20:30:04 peterg
## Copied from tweedledum.
##
# Revision 1.54 1997/02/07 13:33:03 peterg
# Added ; to _input.c file - bug fix.
#
# Revision 1.53 1997/02/07 13:25:04 peterg
# Version 2.3
#
# Revision 1.52 1997/01/21 22:55:59 peterg
# Minor bug fixes
#
## Revision 1.51 1997/01/21 13:16:40 peterg
## Included transformations to language c for:
## ode
## params
## numpar
##
## Revision 1.50 1996/12/21 19:46:52 peterg
## Set to 2.2++
## Changed \* --> \\* in rbg_fig2m.awk
##
## Revision 1.49 1996/12/19 19:55:22 peterg
## Version 2.2 -- Linux.
##
## Revision 1.48 1996/12/07 21:33:52 peterg
## Changed _input file to give unit step on ALL inputs
##
## Revision 1.47 1996/12/07 20:50:16 peterg
## *** empty log message ***
##
## Revision 1.46 1996/12/05 10:48:51 peterg
## Put sympar in clean list.
## sympar now sucks in params.r file
##
## Revision 1.45 1996/12/05 10:41:39 peterg
## Saved many changes over past 2 weeks.
##
# Revision 1.44 1996/11/12 16:04:25 peterg
# Really VERSION 2.1
#
# Revision 1.43 1996/11/12 08:52:57 peterg
# Fixed bug in test arg to if - missing "".
#
# Revision 1.42 1996/11/11 17:23:03 peterg
# Added numpar.m requirement to all .m targets
#
## Revision 1.41 1996/11/11 17:18:32 peterg
## VERSION 2.1
##
## Revision 1.40 1996/11/09 21:17:38 peterg
## Fixed bug with copying at level 0.
##
## Revision 1.39 1996/11/09 20:22:54 peterg
## VERSION 2.0
##
## Revision 1.38 1996/11/09 20:17:34 peterg
## Fixed bug with null ARGS argument
## Put in new lib paths.
##
## Revision 1.37 1996/11/09 18:47:46 peterg
## Added new copy command (using find).
## More documaentation stuff.
##
# Revision 1.36 1996/11/03 21:19:02 peterg
# Recursice generation of Constitutive Relationship files.
#
## Revision 1.35 1996/11/02 10:19:19 peterg
## Constitutive Relationship generation from lbl file
##
## Revision 1.34 1996/11/01 13:34:35 peterg
## -q (quiet) switch added
##
## Revision 1.33 1996/11/01 12:34:45 peterg
## Added browser - mtt_help
##
## Revision 1.32 1996/10/31 20:48:41 peterg
## Revised html generation.
## Stopped deletion of rep.txt file.
##
# Revision 1.31 1996/10/20 19:23:54 peterg
# Automatic generation of sub-system abg.m files.
#
## Revision 1.30 1996/10/01 14:08:05 peterg
## Replaced $() by ``
## Replaced make with gmake
##
# Revision 1.29 1996/10/01 11:04:05 peter
# Changed name of html document.
#
## Revision 1.28 1996/09/13 18:44:11 peter
## Added params dependencies.
##
## Revision 1.27 1996/09/12 19:24:56 peter
## New numpar/params setup.
##
## Revision 1.26 1996/09/10 17:04:47 peter
## Added impulse response (ir) representation.
##
## Revision 1.25 1996/08/30 20:03:45 peter
## Removed dependencies from vc
##
## Revision 1.24 1996/08/30 18:37:17 peter
## inor changes.
##
## Revision 1.23 1996/08/30 11:10:37 peter
## More files in clean up.
##
## Revision 1.22 1996/08/30 10:07:51 peter
## Removed impicit creation of abg.fig file.
##
## Revision 1.21 1996/08/22 12:19:51 peter
## Added various document viewers.
##
## Revision 1.20 1996/08/20 08:24:53 peter
## Now with version control.
##
## Revision 1.19 1996/08/19 15:33:22 peter
## Included new state matric (sm) rep.
## Generate step response (sr) from sm.
##
## Revision 1.18 1996/08/19 13:30:54 peter
## New CLEAN target.
##
## Revision 1.17 1996/08/19 06:48:14 peter
## Explicit figure editing.
##
## Revision 1.16 1996/08/18 19:58:36 peter
## Report generation included.
##
## Revision 1.15 1996/08/18 12:01:01 peter
## Unified format of time responses.
##
## Revision 1.14 1996/08/16 14:52:24 peter
## Added two alternative view options - dview and pview.
##
## Revision 1.13 1996/08/16 08:24:31 peter
## Correctly chooses how to make a ps file using $REPTYPE.
##
## Revision 1.12 1996/08/15 16:47:47 peter
## DAE solution (experimental) included.
##
## Revision 1.11 1996/08/15 11:55:30 peter
## Checks for changed argument.
## Handles frequency response.
##
## Revision 1.10 1996/08/15 07:44:24 peter
## Now handles generic transformations using %.
##
## Revision 1.9 1996/08/14 09:16:08 peter
## Step response now goes through m, dat and gdat conversions
##
## Revision 1.8 1996/08/12 20:19:52 peter
## Arguments now passed via $1_args.m file
##
## Revision 1.7 1996/08/11 19:49:27 peter
## Parameter passing (via $4) added.
##
## Revision 1.6 1996/08/11 10:40:56 peter
## Added new numpar stuff.
## Added step response.
##
## Revision 1.5 1996/08/10 14:13:47 peter
## Added impulse and frequency response stuff.
##
## Revision 1.4 1996/08/10 09:19:48 peter
## Put in help, info and warranty stuff.
##
## Revision 1.3 1996/08/09 15:13:13 peter
## Generic viewing of any representation via ps files implemented.
##
## Revision 1.2 1996/08/05 19:50:55 peter
## Put in fig.fig target.
##
## Revision 1.1 1996/08/04 17:29:42 peter
## Initial revision
##
###############################################################
#Check $MTTPATH has been set
mtt_check_var "$MTTPATH" "MTTPATH"
# MTT recursion level is zero unless explicitly set
level=0
#Computation mode is octave by default
computation=octave
#By default, the dae and ode representations are different
dae_is_ode=0
# By default, don't look for BG switches
switches=0
#By default, don't print the environment variables
print='';
# By default, make it tidy
tidy=tidy;
#Initialise list
mtt_switches='';
#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-q )
mtt_switches="$mtt_switches $1";
quiet=quiet;;
-p )
mtt_switches="$mtt_switches $1";
print='-p';;
-c )
mtt_switches="$mtt_switches $1";
computation=c ;;
-o )
mtt_switches="$mtt_switches $1";
dae_is_ode=1 ;;
-s )
mtt_switches="$mtt_switches $1";
switches=1 ;;
-d )
directory=$2; cd $directory; shift ;;
-S )
directory=$2; shift;;
-D )
mtt_switches="$mtt_switches $1";
debug=debug ;;
-t )
tidy=tidy ;;
-T )
tidy=tidy;
verytidy=verytidy ;;
-u )
tidy=untidy ;;
-l )
mtt_switches="$mtt_switches $1";
level=$2; shift ;;
*)
echo "$1 is an invalid argument - ignoring" ;;
esac
shift
done
#Print header if not in quiet (-q) mode.
if [ "$quiet" != "quiet" ]; then
echo
echo 'MTT (Model Transformation Tools) version 2.7++ ($Date$)'
echo 'This is free software with ABSOLUTELY NO WARRANTY.'
echo 'Type `mtt warranty'\' 'for details.'
echo
# Print current directory if in -d mode
if [ -n "$directory" ]; then
echo Using directory $directory
echo
fi
fi
#Check the principle paths
mtt_check_vars $print
# Exit if just printing paths
if [ "$print" != "" ]; then
exit
fi
if [ -z "$1" ]; then
if [ -z "$print" ]; then
echo 'Usage: mtt help -- mtt on-line help'
echo ' mtt info -- info-based manual'
echo ' mtt info topic'
echo ' mtt hinfo -- hypertext manual'
echo ' mtt manual -- dvi manual'
echo ' mtt warranty'
echo ' mtt clean'
echo ' mtt <system_name> clean'
echo ' mtt copy <system_name> <path_name>'
echo ' mtt rename <old_name> <new_name>'
echo ' mtt <system_name> <representation> vc'
echo ' mtt <system_name> <representation> <language>'
echo ' mtt <system_name> <representation> <language> <parameters>'
echo 'Options: -q quiet mode'
echo ' -p print environment variables'
echo ' -c c-code generation'
echo ' -o ode and dae are the same'
echo ' -s use switch (ISW and CSW) components'
echo ' -d <dir> use directory <dir>'
echo ' -t tidy mode (default)'
echo ' -u untidy mode (leaves files in current dir)'
echo ' -d <dir> use directory <dir>'
echo ' -D debug -- leave log files etc'
exit
fi
fi
if [ "$1" = "info" ] && [ "$3" = "" ]; then
echo Invoking info
info -f $MTTPATH/doc/mtt.info $2
exit
fi
if [ "$1" = "help" ]; then
mtt_help $2 $3
exit
fi
if [ "$1" = "hinfo" ] && [$2 = ""]; then
echo Invoking $HTMLVIEW
mtt_check_var "$HTMLVIEW" HTMLVIEW
(cd $MTTPATH/doc; $HTMLVIEW ./mtt_toc.html)&
exit
fi
if [ "$1" = "manual" ] && [$2 = ""]; then
mtt_check_var "$DVIVIEW" DVIVIEW
echo Invoking $DVIVIEW
$DVIVIEW $MTTPATH/doc/mtt.dvi &
exit
fi
if [ "$1" = "warranty" ] && [$2 = ""]; then
cat << EOF
Copyright (C) 1989, 1990, 1991, 1992, 1993,
1994, 1995, 1996, 1997 Peter J. Gawthrop
This is free software with ABSOLUTELY NO WARRANTY.
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
EOF
exit
fi
# Clean up
if [ "$1" = "clean" ] && [ "$2" = "" ]; then
echo 'Removing all generated files for all systems'
rm -f *.log mtt_info.txt warning.txt
rm -f *_abg.m *_abg.ps *_args.* *_cr.r *_cr.txt *_abg.tex
rm -f *_sabg.fig *_sabg.ps *_head.fig *_bnd.fig
rm -f *_sympar.r *_sympar.c *_sympar.h *_sympar.txt? *_sympar.tex
rm -f *_rbg.* *_cmp.* *_fig.fig *_*cbg.* *_ese.* *_def.*
rm -f *_sub.* *_type.sh
rm -f *_dae*.* *_cse.* *_ode.*
rm -f *_obs.* *_rfe.* *_ss.*
rm -f *_dm.* *_csm.* *_tf.* *_sr*.* *_ir*.* *_*fr.*
rm -f *_numpar.m *_numpar.c *_input.m *_input.c *_switch.c *_switch.txt
rm -f *_sm.* *_can.*
rm -f *_struc.* *_sympar.txt *_sympar.c *_sympar.h *_sympar.m
rm -f *_odes.c *_odes.dat *_odes.gdat *_odes.m *_odes.ps
rm -f *_odeso.dat *_odeso.gdat *_odeso.sdat *_odeso.m *_odeso.ps
rm -f *_*.doc *_*.idx *_*.ind *_*.ilg *_*.dvi *_*.aux *_*.lof *_*.toc
rm -f *_rep.tex
rm -f *_unique_raw_list *_raw_list
rm -f mtt_error.txt mtt_info.txt a.out
rm -fR *_rep MTT_work
exit
fi
# Clean up named system
if [ "$2" = "clean" ] && [ "$3" = "" ]; then
echo 'Removing all generated files for system ' $1
rm -f *.log mtt_info.txt warning.txt
rm -f $1_abg.m $1_abg.ps $1_args.* $1_cr.r $1_cr.txt $1_abg.tex
rm -f $1_sabg.fig $1_sabg.ps $1_head.fig $1_bnd.fig
rm -f $1_sympar.r $1_sympar.c $1_sympar.h $1_sympar.txt? $1_sympar.tex
rm -f $1_rbg.* $1_cmp.* $1_fig.fig $1*_*cbg.* $1*_ese.* $1_def.*
rm -f $1_sub.* $1_type.sh
rm -f $1_dae*.* $1_cse.* $1_ode.* $1_obs.* $1_rfe.* $1_ss.*
rm -f $1_dm.* $1_csm.* $1_tf.* $1_sr*.* $1_ir*.* $1_*fr.*
rm -f $1_numpar.m $1_numpar.c $1_input.m $1_input.c $1_switch.c $1_switch.txt
rm -f $1_sm*.* $1_can.*
rm -f $1_struc.* $1_sympar.txt $1_sympar.c $1_sympar.h $1_sympar.m
rm -f $1_odes.c $1_odes.dat $1_odes.gdat $1_odes.sdat $1_odes.m $1_odes.ps
rm -f $1_odeso.dat $1_odeso.gdat $1_odeso.m $1_odeso.ps
rm -f $1_*.doc $1_*.idx $1_*.ind $1_*.ilg $1_*.dvi $1_*.aux $1_*.lof $1_*.toc
rm -f $1_rep.tex
rm -f $1_unique_raw_list $1_raw_list
rm -f mtt_error.txt mtt_info.txt a.out
rm -fR $1_rep MTT_work
exit
fi
if [ "$2" = "rep" ]; then
documenttype=article
# See if we are making a book -- ie representation rep on a directory
isMTT_work=`pwd | grep 'MTT_work`
if [ -n "$isMTT_work" ]; then
dotdot='../'
fi
isdirectory=`file $dotdot$1 | awk '{print $2}' | grep directory`
if [ -n "$isdirectory" ]; then
documenttype=book
fi
else
documenttype=section
fi
#SUMMARY abg acausal bond graph (fig)
#SUMMARY abg acausal bond graph (ps)
#SUMMARY abg acausal bond graph (view)
# Invoke explicit requests for modification
if [ "$2" = "abg" ] && [ "$3" = "fig" ]; then
mtt_check_var "$FIG" FIG
echo Editing $1_$2.$3
($FIG $1_$2.$3; cp $1_abg.fig $1_$1_abg.fig) &
exit
fi
# Rename a system
if [ "$1" = "rename" ]; then
mtt_rename_all $2 $3
exit
fi
# Copy systems from the example library
if [ "$1" = "copy" ]; then
#set up source and destination dirs
source=$3
if [ -z "$source" ]; then
source=$MTTPATH/lib/examples
fi
destination=$4
if [ -z "$destination" ]; then
destination=$2
fi
# check that its not here already
file_exists=`ls $destination/$2_abg.fig 2> /dev/null`
if [ -n "$file_exists" ]; then
if [ "$quiet" != "quiet" ]; then
echo System $2 exists already - no action taken
fi
else
source=$3
if [ -z "$source" ]; then
source=$MTTPATH/lib/examples
fi
destination=$4
if [ -z "$destination" ]; then
destination=$2
fi
echo Copying system $2 from $source into directory $destination
find $source -name "$2" -exec cp -rf {} . \;
fi
exit
fi
# Copy components from the library
if [ "$1" = "compcopy" ]; then
#set up source and destination dirs
source=$3
if [ -z "$source" ]; then
source=$MTTPATH/lib/comp/compound
fi
destination=$4
if [ -z "$destination" ]; then
destination='.'
fi
# check that its not here already
file_exists=`ls $destination/$2_abg.fig 2> /dev/null`
if [ -n "$file_exists" ]; then
if [ "$quiet" != "quiet" ]; then
echo $destination/$2_abg.fig exists already - no action taken
fi
else
if [ -z "$source" ]; then
source=$MTTPATH/lib/comp/compound
fi
if [ "$quiet" != "quiet" ]; then
echo Copying component $2 from $source to $destination
fi
if [ $source = "." ]; then
cp -u *_*.* $destination
else
find $source -name "$2_*.*" -exec cp {} $destination \;
fi
fi
exit
fi
# Copy CRs from the library
if [ "$1" = "crcopy" ]; then
# check that its not here already
file_exists=`ls $2.cr 2> /dev/null`
if [ -n "$file_exists" ]; then
if [ "$quiet" != "quiet" ]; then
echo $2.cr exists already - no action taken
fi
else
path_name=$3
if [ -z "$path_name" ]; then
path_name=$MTTPATH/lib/cr/r
fi
echo Copying CR $2 to here from $3
find $path_name -name "$2.cr" -exec cp {} . \;
fi
exit
fi
# Tidy mode - operate in the directory MTT-work
if [ "$tidy" = "tidy" ]; then
mkdir -p MTT_work
cp -u *_*.* MTT_work 2>/dev/null
cd MTT_work
Directory=$directory/MTT_work
mtt -u -q $mtt_switches -S $Directory $1 $2 $3 $4
if [ "$3" != "view" ]; then
echo Copying " " $1_$2.$3
cp -f $1_$2.$3 ..
fi
# Remove the MTT_work directory if very tidy
if [ "$verytidy" = "verytidy" ]; then
echo Removing all working files
rm -rf ../MTT_work
fi
exit
fi
# Save up the argument list in a file; but only if argument has changed
ARGS=$4; _ARGS=_$4
#DIFF doesn't like empty files - so put a blank if empty
if [ -z "$ARGS" ]; then
ARGS=' ';
_ARGS='';
fi
cat > $1_args.new <<EOF
$ARGS
EOF
DIFF=`diff -bq $1_args.m $1_args.new 2>/dev/null`
if [ -n "$DIFF" ]; then
mv $1_args.new $1_args.m
fi
# Classify the representation - needed for conversion route to postscript
PLOTTYPE='single';
case $2 in
abg )
REPTYPE='bg' ;;
sabg )
REPTYPE='bg' ;;
cbg )
REPTYPE='bg' ;;
odes)
REPTYPE='data'; PLOTTYPE='multiple' ;;
odeso)
REPTYPE='data'; PLOTTYPE='multiple' ;;
sms)
REPTYPE='data'; PLOTTYPE='multiple' ;;
smso)
REPTYPE='data'; PLOTTYPE='multiple' ;;
odess)
REPTYPE='data' ;;
odesso)
REPTYPE='data' ;;
daes)
REPTYPE='data'; PLOTTYPE='multiple' ;;
daeso)
REPTYPE='data'; PLOTTYPE='multiple' ;;
ir)
REPTYPE='data' ;;
iro)
REPTYPE='data' ;;
sr)
REPTYPE='data' ;;
sro)
REPTYPE='data' ;;
lmfr)
REPTYPE='data' ;;
lpfr)
REPTYPE='data' ;;
nyfr)
REPTYPE='data' ;;
nifr)
REPTYPE='data' ;;
*)
REPTYPE='tex' ;;
esac
# Version control
VC=''
if [ "$3" = "vc" ]; then
case $2 in
abg )
VC='ok'
VCext='fig' ;;
lbl )
VC='ok'
VCext='txt' ;;
simp )
VC='ok'
VCext='r' ;;
numpar )
VC='ok'
VCext='txt' ;;
input )
VC='ok'
VCext='txt' ;;
sspar )
VC='ok'
VCext='r' ;;
*)
echo Version control is not appropriate for representation $2
exit ;;
esac
fi
################################
# This is the main mtt programme
################################
$MAKE -s -f - $1_$2.$3 << EOF
# Cancel implicit rules I don't want
%.dvi: %.tex
# If level>0, try and get subsystem files
ifneq ("$level","0")
$1_abg.fig:
mtt -q -u compcopy $1
endif
# Create an arg file if it doesn't exist
$1_args.m:
touch $1_args.m
#Create empty files (with titles) if not already there
#SUMMARY lbl label file (txt)
$1_lbl.txt:
abg2lbl_fig2txt $1
#SUMMARY cr constitutive relationship for each subsystem (txt)
$1_cr.txt: $1_sub.sh
lbl2cr_txt2txt $1
if [ "$level" = "0" ]; then \
mv $1_cr.txt MTT_cr.txt; \
else \
cat $1_cr.txt >> MTT_cr.txt; \
fi
sh $1_sub.sh "rm -f " '_cr.txt' # Remove the txt.cr files
sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' cr txt' #Create new ones
if [ "$level" = "0" ]; then \
sort -u MTT_cr.txt> $1_cr.txt; \
fi
#SUMMARY cr constitutive relationship for each subsystem (r)
$1_cr.r: $1_cr.txt
cr_txt2r $1
#SUMMARY sympar symbolic parameters (txt)
# Lbl to sympar conversion
ifeq ($switches,0)
$1_sympar.txt: $1_sub.sh
lbl2sympar_txt2txt $1
if [ "$level" = "0" ]; then \
mv $1_sympar.txt MTT_sympar.txt; \
else \
cat $1_sympar.txt >> MTT_sympar.txt; \
fi
sh $1_sub.sh "rm -f " '_sympar.txt' # Delete sympar files
sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' sympar txt' # and recreate them
if [ "$level" = "0" ]; then \
sort -u +1 +0 MTT_sympar.txt> $1_sympar.txt; \
fi
endif
ifeq ($switches,1)
$1_sympar.txt: $1_sub.sh $1_struc.txt
lbl2sympar_txt2txt $1
if [ "$level" = "0" ]; then \
mv $1_sympar.txt MTT_sympar.txt; \
else \
cat $1_sympar.txt >> MTT_sympar.txt; \
fi
sh $1_sub.sh "rm -f " '_sympar.txt' # Delete sympar files
sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' sympar txt' # and recreate them
if [ "$level" = "0" ]; then \
sort -u +1 +0 MTT_sympar.txt> $1_sympar.txt1; \
struc2switch_txt $1; \
echo "Appending switch declarations"; \
cat $1_sympar.txt1 $1_switch.txt> $1_sympar.txt; \
fi
endif
# ## Old version -- just looks on top level
# ## $1_sympar.r: $1_lbl.txt $1_params.r
# ## lbl2sympar_txt2r $1
# ## echo "IN \"$1_params.r\";" >> $1_sympar.r
# ## echo 'END;' >> $1_sympar.r
#SUMMARY sympar symbolic parameters (r)
$1_sympar.r: $1_sympar.txt
sympar_txt2r $1
#SUMMARY sympar symbolic parameters (c)
# txt to c sympar conversion
$1_sympar.c: $1_sympar.txt
sympar_txt2c $1
#SUMMARY sympar symbolic parameters (h)
# txt to ch (c header file) sympar conversion
$1_sympar.h: $1_sympar.txt
sympar_txt2h $1
#SUMMARY sympar symbolic parameters (tex)
# txt to tex (LaTeX) sympar conversion
$1_sympar.tex: $1_sympar.txt
sympar_txt2tex $1
#SUMMARY simp simplification information (r)
$1_simp.r:
echo Creating $1_simp.r
( \
echo "%% Reduce comands to simplify output for system $1 ($1_simp.r)"; \
cat $MTTPATH/trans/m/rcs_header.txt; \
echo 'END;'; \
)> $1_simp.r
#SUMMARY numpar numerical parameter declaration (txt) -- default
$1_numpar.txt:
mtt $mtt_switches -q -u $1 sympar txt;
mtt $mtt_switches -q -u $1 struc txt;
sympar2numpar_txt2txt $1
#SUMMARY numpar numerical parameter declaration (m)
$1_numpar.m: $1_numpar.txt $1_sympar.txt
numpar_txt2m $1
#SUMMARY numpar numerical parameter declaration (c)
$1_numpar.c: $1_numpar.txt $1_sympar.c
numpar_txt2c $1
#SUMMARY input numerical input declaration (txt) -- default
ifeq ($switches,0)
$1_input.txt:
mtt $mtt_switches $1 struc txt; struc2input_txt2txt $1
endif
ifeq ($switches,1)
$1_input.txt:
mtt $mtt_switches -q -u $1 struc txt;
mtt $mtt_switches -q -u $1 switch txt;
struc2input_txt2txt -s $1
endif
#SUMMARY input numerical input declaration (m)
$1_input.m: $1_input.txt $1_sympar.txt
input_txt2m $1
#SUMMARY input numerical input declaration (c)
ifeq ($switches,0)
$1_input.c: $1_input.txt $1_sympar.c
input_txt2c $1
endif
ifeq ($switches,1)
$1_switch.c: $1_struc.txt
struc2switch_txt2c $1
$1_input.c: $1_input.txt $1_sympar.c $1_switch.c
input_txt2c -s $1
endif
#SUMMARY desc Verbal description of system (tex)
$1_desc.tex:
makedesc $1
#SUMMARY odes ODE simulation header file (h)
$1_odes.h:
echo Creating $1_odes.h
( \
echo '/*'; \
echo "%% Parameter file for system $1 ($1_odes.h)"; \
echo "%% This file provides the params for simulation:";\
echo '*/'; \
echo '#define DT 0.1 /* Time step (for printing) */'; \
echo '#define LAST 10.0 /* Last time */'; \
echo '#define STEPFACTOR 1000 /* Integration steps per time step */'; \
)> $1_odes.h
#SUMMARY smss SM simulation header file (h)
$1_sms.h:
echo Creating $1_sms.h
( \
echo '/*'; \
echo "%% Parameter file for system $1 ($1_sms.h)"; \
echo "%% This file provides the params for simulation:";\
echo '*/'; \
echo '#define DT 0.1 /* Time step (for printing) */'; \
echo '#define LAST 10.0 /* Last time */'; \
echo '#define STEPFACTOR 1 /* Integration steps per time step */'; \
)> $1_sms.h
#SUMMARY params symbolic parameter setting (r)
$1_params.r:
echo Creating $1_params.r
( \
echo "%% Parameter file for system $1 ($1_params.r)"; \
echo "%% This file provides symbolic parameters for simplification";\
cat $MTTPATH/trans/m/rcs_header.txt; \
echo 'END;'; \
)> $1_params.r
#SUMMARY sspar steady-state definition (r)
$1_sspar.r:
echo Creating $1_sspar.r
(\
echo "%% Reduce steady-state parameter file for $1 ($1_sspar.r)"; \
cat $MTTPATH/trans/m/rcs_header.txt; \
echo 'END;'; \
)> $1_sspar.r
#SUMMARY rep report (txt)
#SUMMARY rep report (tex)
#SUMMARY rep report (view)
ifeq ($documenttype,book)
$1_rep.txt:
dir2rep $1 $dotdot;
else
$1_rep.txt:
echo Creating $1_rep.txt;
( \
echo "# Outline report file for system $1 ($1_rep.txt)"; \
cat $MTTPATH/trans/m/rcs_header.txt; \
echo "mtt $1 abg tex"; \
)> $1_rep.txt
endif
#SUMMARY rbg raw bond graph (m)
#Raw bond graph: fig file to mfile
$1_rbg.m: $1_abg.fig $1_lbl.txt
rbg_fig2m $1
$1_cmp.m: $1_rbg.m
$1_fig.fig: $1_rbg.m
#SUMMARY sabg stripped acausal bond graph (fig)
#SUMMARY sabg stripped acausal bond graph (ps)
#SUMMARY sabg stripped acausal bond graph (view)
$1_sabg.fig: $1_rbg.m
#Subsystem creation commands
#SUMMARY sub Executable subsystem list (sh)
$1_sub.sh: $1_cmp.m
cmp2sub_m2sh $1
#SUMMARY sub LaTeX subsystem list (tex)
#SUMMARY sub LaTeX subsystem list (tex)
$1_sub.tex: $1_sub.sh
ifeq ($documenttype,section)
sub_sh2tex $1
else
sub_sh2tex -l $1
endif
#SUMMARY abg acausal bond graph (m)
#Raw bond graph to acausal bond graph: mfile
$1_abg.m: $1_rbg.m $1_sub.sh
sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' abg m'
rbg2abg_m $1
#SUMMARY cbg causal bond graph (m)
#Acausal bond graph to causal bond graph: mfile
$1_cbg.m: $1_abg.m
abg2cbg_m $1
$1_type.sh: $1_cbg.m
#SUMMARY cbg causal bond graph (fig)
#Causal bond graph: mfile to fig conversion
$1_cbg.fig: $1_cbg.m $1_rbg.m $1_fig.fig $1_type.sh
cbg_m2fig $1
#SUMMARY ese elementary system equations (r)
#SUMMARY def definitions - system orders etc. (r)
#SUMMARY def definitions - system orders etc. (m)
#SUMMARY struc structure - list of inputs, outputs and states (txt)
#SUMMARY struc structure - list of inputs, outputs and states (tex)
#SUMMARY struc structure - list of inputs, outputs and states (view)
#Elementary system equations + definitions
$1_ese.r: $1_cbg.m
cbg2ese_m2r $1
$1_def.r: $1_ese.r
touch $1_def.r
$1_struc.txt: $1_ese.r
touch $1_struc.txt
$1_struc.tex: $1_struc.txt
struc_txt2tex $1
$1_struc.m: $1_struc.txt
struc_txt2m $1
$1_def.m: $1_def.r
def_r2m $1; matlab_tidy $1_def.m;
#SUMMARY dae differential-algebraic equations (r)
#SUMMARY dae differential-algebraic equations (m)
#SUMMARY dae differential-algebraic equations (tex)
#SUMMARY dae differential-algebraic equations (view)
#SUMMARY dae differential-algebraic equations (ps)
#Differential-algebraic equations
$1_dae.r: $1_ese.r $1_cr.r $1_sympar.r $1_params.r
ese2dae_r $1; tidy $1_dae.r
$1_dae.m: $1_def.r $1_dae.r $1_sympar.r
dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m
$1_dae.c: $1_def.r $1_dae.r $1_sympar.r
dae_r2c $1; c_tidy $1_dae.c
$1_dae.tex: $1_dae.r $1_simp.r
dae_r2tex $1; latex_tidy $1_dae.tex
#SUMMARY cse constrained-state equations (r)
#SUMMARY cse constrained-state equations (m)
#SUMMARY cse constrained-state equations (tex)
#SUMMARY cse constrained-state equations (view)
#SUMMARY cse constrained-state equations (ps)
#Constrained-state equations
$1_cse.r: $1_dae.r $1_def.r $1_sympar.r
dae2cse_r $1; tidy $1_cse.r
$1_cse.m: $1_def.r $1_cse.r $1_sympar.r
cse_r2m $1; matlab_tidy $1_cse.m
$1_cse.tex: $1_cse.r $1_sympar.r $1_simp.r
cse_r2tex $1; latex_tidy $1_cse.tex
#SUMMARY ode ordinary differential equations (r)
#SUMMARY ode ordinary differential equations (m)
#SUMMARY ode ordinary differential equations (c)
#SUMMARY ode ordinary differential equations (tex)
#SUMMARY ode ordinary differential equations (view)
#SUMMARY ode ordinary differential equations (ps)
#Ordinary differential equations
ifeq ($dae_is_ode,0)
$1_ode.r: $1_cse.r $1_def.r $1_sympar.r
cse2ode_r $1; tidy $1_ode.r
endif
ifeq ($dae_is_ode,1)
$1_ode.r: $1_dae.r
echo Copying $1_dae.r to $1_ode.r
cp $1_dae.r $1_ode.r
endif
$1_ode.m: $1_def.r $1_ode.r $1_sympar.r
ode_r2m $1; matlab_tidy $1_ode.m; matlab_tidy $1_odeo.m
$1_ode.c: $1_def.r $1_ode.r $1_sympar.r $1_sympar.c
ode_r2c $1
$1_ode.tex: $1_ode.r $1_sympar.r $1_simp.r
ode_r2tex $1; latex_tidy $1_ode.tex
#SUMMARY obs observer equations for CGPC (r)
#SUMMARY obs observer equations for CGPC (m)
#SUMMARY obs observer equations for CGPC (tex)
#SUMMARY obs observer equations for CGPC (view)
#SUMMARY obs observer equations for CGPC (ps)
#Observer functions for GPC
$1_obs.r: $1_ode.r $1_def.r $1_sympar.r
ode2obs_r $1; tidy $1_obs.r
$1_obs.m: $1_def.r $1_obs.r $1_sympar.r $1_numpar.m
obs_r2m $1; matlab_tidy $1_obs.m
$1_obs.tex: $1_obs.r $1_sympar.r $1_simp.r
obs_r2tex $1; latex_tidy $1_obs.tex
#SUMMARY rfe robot-form equations (r)
#SUMMARY rfe robot-form equations (tex)
#SUMMARY rfe robot-form equations (view)
#SUMMARY rfe robot-form equations (ps)
#Robot-form equations
$1_rfe.r: $1_cse.r $1_csm.r $1_def.r $1_sympar.r
cse2rfe_r $1; tidy $1_rfe.r
$1_rfe.tex: $1_rfe.r $1_sympar.r $1_simp.r
rfe_r2tex $1; latex_tidy $1_rfe.tex
#SUMMARY ss steady-state equations (r)
#SUMMARY ss steady-state equations (m)
#SUMMARY ss steady-state equations (tex)
#SUMMARY ss steady-state equations (view)
#SUMMARY ss steady-state equations (ps)
#Steady-states
$1_ss.r: $1_def.r $1_sspar.r $1_sympar.r $1_cr.r $1_dae.r
sspar2ss_r $1; tidy $1_ss.r
$1_ss.m: $1_def.r $1_sympar.r $1_ss.r $1_numpar.m
ss_r2m $1; matlab_tidy $1_ss.m
$1_ss.tex: $1_def.r $1_ss.r $1_sympar.r $1_simp.r
ss_r2tex $1; latex_tidy $1_ss.tex
#SUMMARY dm descriptor matrices (r)
#SUMMARY dm descriptor matrices (m)
#SUMMARY dm descriptor matrices (tex)
#SUMMARY dm descriptor matrices (view)
#SUMMARY dm descriptor matrices (ps)
#Linearised system: descriptor matrices
$1_dm.r: $1_dae.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
dae2dm_r $1; tidy $1_dm.r
$1_dm.m: $1_def.m $1_dm.r $1_sympar.r $1_numpar.m
dm_r2m $1; matlab_tidy $1_dm.m
$1_dm.tex: $1_dm.r $1_sympar.r $1_simp.r
dm_r2tex $1; latex_tidy $1_dm.tex
#SUMMARY csm constrained-state matrices (r)
#SUMMARY csm constrained-state matrices (m)
#SUMMARY csm constrained-state matrices (tex)
#SUMMARY csm constrained-state matrices (view)
#SUMMARY csm constrained-state matrices (ps)
#Linearised system: constrained-state matrices
$1_csm.r: $1_cse.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
cse2csm_r $1; tidy $1_csm.r
$1_csm.m: $1_def.r $1_csm.r
csm_r2m $1; matlab_tidy $1_csm.m
$1_csm.tex: $1_csm.r $1_sympar.r $1_simp.r
csm_r2tex $1; latex_tidy $1_csm.tex
#SUMMARY sm state matrices (r)
#SUMMARY sm state matrices (m)
#SUMMARY sm state matrices (tex)
#SUMMARY sm state matrices (c)
#SUMMARY sm state matrices (view)
#SUMMARY sm state matrices (ps)
#Linearised system: state matrices
$1_sm.r: $1_csm.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
csm2sm_r $1; tidy $1_sm.r
$1_sm.m: $1_def.r $1_sm.r
sm_r2m $1; matlab_tidy $1_sm.m
$1_sm.c: $1_def.r $1_sm.r $1_sympar.c
sm_r2c $1
$1_sm.tex: $1_sm.r $1_sympar.r $1_simp.r
sm_r2tex $1; latex_tidy $1_sm.tex
#SUMMARY smc controller form state matrices etc. - siso only (r)
#SUMMARY smc controller form state matrices etc. - siso only (tex)
#SUMMARY smc controller form state matrices etc. - siso only (m)
#SUMMARY smc controller form state matrices etc. - siso only (view)
#SUMMARY smc controller form state matrices etc. - siso only (ps)
#Linearised system: controller form state matrices etc.
$1_smc.r: $1_sm.r $1_def.r $1_tf.r
sm2smc_r $1; tidy $1_smc.r
$1_smc.tex: $1_smc.r $1_simp.r
smc_r2tex $1; latex_tidy $1_smc.tex
$1_smc.m: $1_def.r $1_smc.r $1_numpar.m
smc_r2m $1; matlab_tidy $1_smc.m
#SUMMARY smo observer form state matrices etc. - siso only (r)
#SUMMARY smo observer form state matrices etc. - siso only (tex)
#SUMMARY smo observer form state matrices etc. - siso only (m)
#SUMMARY smo observer form state matrices etc. - siso only (view)
#SUMMARY smo observer form state matrices etc. - siso only (ps)
#Linearised system: observer form state matrices etc.
$1_smo.r: $1_sm.r $1_def.r $1_smc.r
sm2smo_r $1; tidy $1_smo.r
$1_smo.tex: $1_smo.r $1_simp.r
smo_r2tex $1; latex_tidy $1_smo.tex
$1_smo.m: $1_def.r $1_smo.r $1_numpar.m
smo_r2m $1; matlab_tidy $1_smo.m
#SUMMARY ssk State-space controller gain - siso only (r)
#SUMMARY ssk State-space controller gain - siso only (tex)
#SUMMARY ssk State-space controller gain - siso only (m)
#SUMMARY ssk State-space controller gain - siso only (view)
#SUMMARY ssk State-space controller gain - siso only (ps)
#Linearised system: State-space controller gain
$1_ssk.r: $1_def.r $1_smc.r
smc2ssk_r $1; tidy $1_ssk.r
$1_ssk.tex: $1_ssk.r $1_simp.r
ssk_r2tex $1; latex_tidy $1_ssk.tex
$1_ssk.m: $1_def.r $1_ssk.r $1_numpar.m
ssk_r2m $1; matlab_tidy $1_ssk.m
#SUMMARY ssl State-space observer gain - siso only (r)
#SUMMARY ssl State-space observer gain - siso only (tex)
#SUMMARY ssl State-space observer gain - siso only (m)
#SUMMARY ssl State-space observer gain - siso only (view)
#SUMMARY ssl State-space observer gain - siso only (ps)
#Linearised system: State-space observer gain
$1_ssl.r: $1_def.r $1_smo.r
smo2ssl_r $1; tidy $1_ssl.r
$1_ssl.tex: $1_ssl.r $1_simp.r
ssl_r2tex $1; latex_tidy $1_ssl.tex
$1_ssl.m: $1_def.r $1_ssl.r $1_numpar.m
ssl_r2m $1; matlab_tidy $1_ssl.m
#SUMMARY tf transfer function (r)
#SUMMARY tf transfer function (m)
#SUMMARY tf transfer function (tex)
#SUMMARY tf transfer function (view)
#SUMMARY tf transfer function (ps)
#Linearised system: transfer function
$1_tf.r: $1_dm.r $1_sympar.r
dm2tf_r $1; tidy $1_tf.r
$1_tf.m: $1_def.r $1_tf.r
tf_r2m $1; matlab_tidy $1_tf.m
$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
tf_r2tex $1; latex_tidy $1_tf.tex
#SUMMARY ir impulse response - state (m)
#SUMMARY ir impulse response - state (dat)
#SUMMARY ir impulse response - state (ps)
#SUMMARY ir impulse response - state (view)
#SUMMARY iro impulse response - output (m)
#SUMMARY iro impulse response - output (dat)
#SUMMARY iro impulse response - output (ps)
#SUMMARY iro impulse response - output (view)
#SUMMARY sr step response - state (m)
#SUMMARY sr step response - state (dat)
#SUMMARY sr step response - state (ps)
#SUMMARY sr step response - state (view)
#SUMMARY sro step response - output (m)
#SUMMARY sro step response - output (dat)
#SUMMARY sro step response - output (ps)
#SUMMARY sro step response - output (view)
#SUMMARY odes ode solution - state (m)
#SUMMARY odes ode solution - state (dat)
#SUMMARY odes ode solution - state (ps)
#SUMMARY odes ode solution - state (view)
#SUMMARY sms ode (in state matrix form) solution - state & output(c)
#SUMMARY odeso ode solution - output (m)
#SUMMARY odeso ode solution - output (dat)
#SUMMARY odeso ode solution - output for spreadsheet(sdat)
#SUMMARY odeso ode solution - output (ps)
#SUMMARY odeso ode solution - output (view)
#SUMMARY daes dae solution - state (m)
#SUMMARY daes dae solution - state (dat)
#SUMMARY daes dae solution - state (ps)
#SUMMARY daes dae solution - state (view)
#SUMMARY daeso dae solution - output (m)
#SUMMARY daeso dae solution - output (dat)
#SUMMARY daeso dae solution - output (ps)
#SUMMARY daeso dae solution - output (view)
#Time responses
$1_ir.m: $1_sm.m $1_numpar.m $1_args.m $1_def.m
sm2ir_m $1 '$ARGS'
$1_iro.m: $1_ir.m
touch $1_iro.m
$1_sr.m: $1_sm.m $1_numpar.m $1_args.m $1_def.m
sm2sr_m $1 '$ARGS'
$1_sro.m: $1_sr.m
touch $1_sro.m
$1_odes.c: $1_ode.c $1_def.r $1_sympar.r
ode2odes_r2c $1
$1_sms.c: $1_sm.c $1_def.r $1_sympar.r
sm2sms_r2c $1
ifeq ($computation,octave)
$1_odes.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
ode2odes_m $1 '$ARGS'
endif
ifeq ($computation,c)
$1_odes.m: $1_odes.c $1_ode.c $1_numpar.c $1_odes.h\
$1_sympar.c $1_sympar.h\
$1_numpar.c $1_input.c sign.c
echo Creating $1_odes.m
echo Creating $1_odeso.m
echo 'Compiling ...'
$CC $1_odes.c -lm
echo 'Running ...'; time ./a.out; echo 'Done.'
$1_sms.m: $1_sms.c $1_sm.c $1_numpar.c $1_sms.h\
$1_sympar.c $1_sympar.h\
$1_numpar.c $1_input.c dsvdcmp.c
echo Creating $1_sms.m
echo Creating $1_smso.m
echo 'Compiling ...'
$CC $1_sms.c -lm
echo 'Running ...'; time ./a.out; echo 'Done.'
endif
$1_odeso.m: $1_odes.m
touch $1_odeso.m
$1_smso.m: $1_sms.m
touch $1_smso.m
$1_daes.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m
dae2daes_m $1 '$ARGS'
$1_daeso.m: $1_daes.m
touch $1_daeso.m
#Conversion of data files from dat to sdat format
$1_odeso.sdat: $1_odeso.dat $1_struc.txt
odeso_dat2sdat $1
#SUMMARY odess ode numerical steady-states - states (m)
#SUMMARY odess ode numerical steady-states - states (dat)
#SUMMARY odess ode numerical steady-states - states (ps)
#SUMMARY odess ode numerical steady-states - states (view)
#SUMMARY odesso ode numerical steady-states - outputs (m)
#SUMMARY odesso ode numerical steady-states - outputs (dat)
#SUMMARY odesso ode numerical steady-states - outputs (ps)
#SUMMARY odesso ode numerical steady-states - outputs (view)
#Numerical steady states
$1_odess.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
ode2odess_m $1 '$ARGS'
$1_odesso.m: $1_odess.m
touch $1_odesso.m
#SUMMARY fr frequency response (m)
#SUMMARY fr frequency response (dat)
#SUMMARY fr frequency response (ps)
#SUMMARY fr frequency response (view)
#SUMMARY lmfr loglog modulus frequency response (m)
#SUMMARY lmfr loglog modulus frequency response (dat)
#SUMMARY lmfr loglog modulus frequency response (ps)
#SUMMARY lmfr loglog modulus frequency response (view)
#SUMMARY lpfr semilog phase frequency response (m)
#SUMMARY lpfr semilog phase frequency response (dat)
#SUMMARY lpfr semilog phase frequency response (ps)
#SUMMARY lpfr semilog phase frequency response (view)
#SUMMARY nyfr Nyquist style frequency response (m)
#SUMMARY nyfr Nyquist style frequency response (dat)
#SUMMARY nyfr Nyquist style frequency response (ps)
#SUMMARY nyfr Nyquist style frequency response (view)
#SUMMARY nifr Nichols style frequency response (m)
#SUMMARY nifr Nichols style frequency response (dat)
#SUMMARY nifr Nichols style frequency response (ps)
#SUMMARY nifr Nichols style frequency response (view)
#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
dm2fr_m $1 '$ARGS'
$1_lmfr.m: $1_fr.m
touch $1_lmfr.m
$1_lpfr.m: $1_fr.m
touch $1_lpfr.m
$1_nyfr.m: $1_fr.m
touch $1_nyfr.m
$1_nifr.m: $1_fr.m
touch $1_nifr.m
#Partially-known system indentification structure matrices
$1_pkim.r: $1_tf.r $1_sympar.r
tf2pkim_r $1; tidy $1_pki.r
$1_pkim.tex: $1_def.r $1_pkim.r $1_sympar.r
pkim_r2tex $1; latex_tidy $1_pkim.tex
#Generic conversion of data files from m to dat format
$1_$2.dat: $1_$2.m
m2dat $1_$2
#Generic conversion of data files from dat to (gplot) gdat format
$1_$2.gdat: $1_$2.dat $1_args.m $1_struc.txt
dat2gdat $1 $2 $4
#Generic conversion of Latex to latex document
mtt.sty:
echo Copying mtt.sty to here
cp $MTTPATH/trans/mtt.sty .
$1_$2.doc: $1_$2.tex
makedoc "$mtt_switches" "$1" "$2" "$3" "$4" "$documenttype"
#Generic conversion of LaTeX doc to dvi
$1_$2.dvi: $1_$2.doc
echo Creating $1_$2.dvi
latex $1_$2.doc > /dev/null;
latex $1_$2.doc > /dev/null;
#Create PostScript version of fig files
ifeq ($REPTYPE,bg)
$1_$2.ps : $1_$2.fig
echo Creating $1_$2.ps
multi_command2 'fig2dev -Lps' $1 $2.fig $2.ps | sh
endif
ifeq ($REPTYPE,data)
#Create PostScript version of dat file
# + another version with Args added to the name if its appropriate
$1_$2.ps: $1_$2.gdat
gdat2ps $1_$2 '$ARGS';
ifeq ($PLOTTYPE,multiple)
ifneq ($_ARGS,)
echo Creating $1_$2$_ARGS.ps
cp $1_$2.ps $1_$2$_ARGS.ps
endif
endif
endif
ifeq ($REPTYPE,tex)
#Create PostScript version of dvi file
$1_$2.ps: $1_$2.dvi
echo Creating $1_$2.ps
dvips -o $1_$2.ps $1_$2
endif
ifeq ($REPTYPE,tex)
#Create html version of dvi file
$1_$2.html: $1_$2.dvi $1_$2.doc
echo Creating $1_$2/$1_$2.html
$LATEX2HTML $1_$2.doc
endif
#Default view
ifeq ($REPTYPE,bg)
$1_$2.view : $1_$2.pview
endif
ifeq ($REPTYPE,data)
# This is the gnuplot version which leaves lots of defunct processes
# $1_$2.view : $1_$2.dview
$1_$2.view: $1_$2.ps
ghostview $1_$2.ps&
endif
ifeq ($REPTYPE,tex)
$1_$2.view : $1_$2.tview
endif
# Hypertext view
$1_$2.hview: $1_$2.html
$HTMLVIEW $1_$2/$1_$2.html&
#View a ps file
$1_$2.pview: $1_$2.ps
echo Creating view of $1_$2
multi_command $PSVIEW $1 $2.ps | sh
#View a gdat file
$1_$2.dview: $1_$2.gdat
echo Creating view of $1_$2
gdat2view $1_$2 '$ARGS'&
#View a tex file
$1_$2.tview: $1_$2.dvi
echo Creating view of $1_$2
$DVIVIEW $1_$2.dvi&
#Report generation
$1_rep.make: $1_rep.txt $1_args.m
rep_txt2make $1 "$mtt_switches"
make_reps:
rep_txt2sh $1; # touch $1_rep.txt
$1_rep.tex: $1_rep.txt make_reps
rep_txt2tex $1 "$documenttype" "$directory";
#SUMMARY abg Acausal bond graph report (tex)
$1_abg.tex: $1_sub.sh
abg2tex $1
# Version control system - uses RCS
RCS:
echo Creating RCS
mkdir RCS
$1_$2.vc: RCS
echo Version control on $1_$2.$VCext
ci -I $1_$2.$VCext </dev/tty ; co -l $1_$2.$VCext
# Copy c utilities
dsvdcmp.c: dpythag.c nrutil.c nrutil.h
echo Copying dsvdcmp.c; cp $MTTPATH/trans/c/dsvdcmp.c .
dpythag.c:
echo Copying dpythag.c; cp $MTTPATH/trans/c/dpythag.c .
nrutil.c:
echo Copying nrutil.c; cp $MTTPATH/trans/c/nrutil.c .
nrutil.h:
echo Copying nrutil.h; cp $MTTPATH/trans/c/nrutil.h .
sign.c:
echo Copying sign.c; cp $MTTPATH/trans/c/sign.c .
EOF
# Tidy up.
# echo Removing log files and other garbage
rm -f *_unique_raw_list *_raw_list
rm -f mtt_error.txt mtt_info.txt a.out
rm -f mtt_info.txt warning.txt
# rm -f *_*.idx *_*.ind *_*.ilg *_*.lof *_*.toc
# Remove logs if not debugging
if [ "$debug" != "debug" ]; then
rm -f *.log
else
echo Debugging - log files retained in LOGFILES
mkdir -p LOGFILES
mv -f *.log LOGFILES
fi