File mttroot/mtt/bin/trans/mtt_r2m artifact 33d2b02988 part of check-in 70d4b27beb


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_r2m
# Reduce to octave conversion
# Based on obsolete ode_r2m  and ode_r2lang
# Based on obsolete mtt_r2m_old
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, May 1998
# July 1998
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.23  2000/10/10 21:00:43  peterg
## More reps added
##
## Revision 1.22  2000/09/15 08:27:07  peterg
## Removed debugging lines
##
## Revision 1.21  2000/08/30 11:43:40  peterg
## -optimise switch added
##
## Revision 1.20  2000/08/30 10:43:17  peterg
## Simplified version using GENTRAN matrix :=: matrix
## lang_matrix is no longer used at all
##
## Revision 1.19  2000/08/28 20:17:59  peterg
## Put in Winfried Neun's bug fix
## -- prevents segmentation violation using optimised gentran when matrix
## comtains a number
##
## Revision 1.18  2000/08/24 17:11:40  peterg
## Now optimises as well as segmenting - uses the SCOPE package
##
## Revision 1.17  2000/05/20 15:23:56  peterg
## Paramererised version of sm etc etc (using -parameter switch)
##
## Revision 1.16  2000/04/18 11:14:18  peterg
## Put in the -parameters option
##
## Revision 1.15  2000/02/10 14:58:57  peterg
## *** empty log message ***
##
## Revision 1.14  1999/12/08 02:06:00  peterg
## Now incudes csm rep.
##
## Revision 1.13  1999/11/23 00:59:14  peterg
## Now does ssm.m
##
## Revision 1.12  1999/11/15 22:57:20  peterg
## Removed a debugging line
##
## Revision 1.11  1999/11/01 21:20:14  peterg
## Removed the E matrix from the cse file.
##
## Revision 1.10  1999/10/27 07:38:30  peterg
## Now does cse version -- but not needed now exept for Euler integration
##
## Revision 1.9  1999/10/26 23:47:58  peterg
## Now does cse.m file
##
## Revision 1.8  1999/07/26 06:07:19  peterg
## Reinstated removal of the odeo.p file
##
## Revision 1.7  1999/03/16 00:38:06  peterg
## Done some more tidying up
##
## Revision 1.6  1999/03/15 07:29:25  peterg
## Fixed various obscure reduce bugs
## THIS NEEDS A MAJOR REWRITE!!!!
##
## Revision 1.5  1998/08/13 16:25:07  peterg
## Removed some documentation form odeo.m
##
## Revision 1.4  1998/08/13 15:10:47  peterg
## Change temp var name to mtt_t1 etc
##
## Revision 1.3  1998/08/13 12:43:19  peterg
## Cahnged tmp variable to mtt_1 etc
##
## Revision 1.2  1998/07/27 20:26:44  peterg
## Put in correct N and M values for dm rep
##
## Revision 1.1  1998/07/27 16:30:26  peterg
## Initial revision
##
###############################################################


# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals='-noglobals';
	;;
    -parameters)
	parameters='-parameters';
        par='mttpar'
	;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

# Set up some strings
rep=$2
ext=m
out=$1"_"$rep.$ext

#Inform user
echo Creating $out

# Remove the old log file
rm -f mtt_r2m.log

#Header
case $rep in
    cse)
    mtt_header  $1 $rep $ext 'mttx,mttu,mttt,mttpar' 'mttedx,mtte' > mtt_junk
       ;;
    csex)
    mtt_header  $1 $rep $ext 'mttx,mttu,mttt,mttpar' 'mttedx' > mtt_junk
    vectorise=yes
       ;;
    cseo)
    mtt_header  $1 $rep $ext 'mttx,mttu,mttt,mttpar' mtty > mtt_junk
    vectorise=yes
       ;;
    ode)
    mtt_header  $1 $rep $ext 'mttx,mttu,mttt,mttpar' mttdx > mtt_junk
    vectorise=yes
       ;;
    odeo)
    vectorise=yes
    mtt_header  $1 $rep $ext 'mttx,mttu,mttt,mttpar' mtty > mtt_junk
       ;;
    sm)
    mtt_header  $1 $rep $ext mttpar 'mtta,mttb,mttc,mttd' > mtt_junk
       ;;
    *)
esac

#Convert from the (optimised) r file
echo >> mtt_junk
echo '## Code' >> mtt_junk
grep 'mtt'  $1_$2.r |\
sed \
    -e "s/^mtt/  mtt/" \
    -e "s/:=/=/" \
    -e "s/\\$/;/" \
 >> mtt_junk


echo endfunction >> mtt_junk

# Vectorise (n,1) arrays when appropriate
if [ -n "$vectorise" ]; then
     mtt_vectorise <mtt_junk >$out
else
     mv mtt_junk $out
fi

# Now invoke the standard error handling.
#mtt_error_r mtt_r2m.log





MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]