Overview
Comment:Fixed [ 549658 ] awk should be gawk.
Replaced calls to awk with call to gawk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 66bb5feadf43c0952c9b34dde3a07c2a73a4958cce865f3d4565e8f4caf21224
User & Date: geraint@users.sourceforge.net on 2002-04-28 18:41:27
Other Links: branch diff | manifest | tags
Context
2002-04-28
18:58:07
Fixed [ 549658 ] awk should be gawk.
Replaced calls to awk with call to gawk.
check-in: 636df344ed user: geraint@users.sourceforge.net tags: origin/master, trunk
18:41:27
Fixed [ 549658 ] awk should be gawk.
Replaced calls to awk with call to gawk.
check-in: 66bb5feadf user: geraint@users.sourceforge.net tags: origin/master, trunk
15:38:06
New argument to add zero columns -- useful if less basis functions than inputs check-in: 80a14a1b06 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [0fc79c2700] to [1cae376587].

13
14
15
16
17
18
19



20
21
22
23
24
25
26
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$



## Revision 1.331  2002/04/19 09:24:29  gawthrop
## 2 changes to ode2odes_out generation: only compiles the specified c
## file; outside the computation=c clause
##
## Revision 1.330  2002/04/17 10:03:12  geraint
## Marked .sg as a major representation.
##







>
>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.332  2002/04/26 23:19:00  geraint
## Fixed path to info files for "mtt info".
##
## Revision 1.331  2002/04/19 09:24:29  gawthrop
## 2 changes to ode2odes_out generation: only compiles the specified c
## file; outside the computation=c clause
##
## Revision 1.330  2002/04/17 10:03:12  geraint
## Marked .sg as a major representation.
##
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
  rm -fr MTT_work
  exit
fi

# Recursively clean up
if [ "$1" = "rclean" ]; then
  echo 'Removing intermediate files recursively'
  dir2paths '.' | awk '{print "mtt -q -d " $1 " clean " $2}' | sh
  exit
fi

# The big clean up
if [ "$1" = "Clean" ] && [ "$2" = "" ]; then
  echo 'Removing all generated files for all systems'
  rm -f *.log  mtt_info.txt warning.txt







|







1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
  rm -fr MTT_work
  exit
fi

# Recursively clean up
if [ "$1" = "rclean" ]; then
  echo 'Removing intermediate files recursively'
  dir2paths '.' | gawk '{print "mtt -q -d " $1 " clean " $2}' | sh
  exit
fi

# The big clean up
if [ "$1" = "Clean" ] && [ "$2" = "" ]; then
  echo 'Removing all generated files for all systems'
  rm -f *.log  mtt_info.txt warning.txt
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
     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 [ -d "$dotdot$1" ]; then
	documenttype=book
     fi
else
     documenttype=section
fi








|







1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
     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 | gawk '{print $2}' | grep directory`
     if [ -d "$dotdot$1" ]; then
	documenttype=book
     fi
else
     documenttype=section
fi

1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
      echo Component $name exists already - no action taken
    fi
  else
    if [ $source = "." ]; then
      cp -u *_*.* ${destination}
    else
      comp_path=`mtt_find $source $2 path_only`
      n_found=`echo $comp_path | wc | awk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to ${destination}
         cp $comp_path/*_*.* ${destination}
         exit 0
      elif [ "$n_found" = "0" ]; then
	if [ "$quiet" != "quiet" ]; then    







|







1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
      echo Component $name exists already - no action taken
    fi
  else
    if [ $source = "." ]; then
      cp -u *_*.* ${destination}
    else
      comp_path=`mtt_find $source $2 path_only`
      n_found=`echo $comp_path | wc | gawk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to ${destination}
         cp $comp_path/*_*.* ${destination}
         exit 0
      elif [ "$n_found" = "0" ]; then
	if [ "$quiet" != "quiet" ]; then    
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044

if [ -n "$sensitivity" ]; then
  sys_s=`echo $1 | cut -c 2-`
  sys_abg=${sys_s}_abg
fi

## Check octave version
case `$MATRIX --version | awk -F\. '{print $2}'` in
    0) define_octave_dev="";;			# stable 
    1) define_octave_dev="-DOCTAVE_DEV";;	# development
    *) define_octave_dev="-DOCTAVE_DEV";;
esac

################################
# This is the main mtt programme







|







2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047

if [ -n "$sensitivity" ]; then
  sys_s=`echo $1 | cut -c 2-`
  sys_abg=${sys_s}_abg
fi

## Check octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) define_octave_dev="";;			# stable 
    1) define_octave_dev="-DOCTAVE_DEV";;	# development
    *) define_octave_dev="-DOCTAVE_DEV";;
esac

################################
# This is the main mtt programme

Modified mttroot/mtt/bin/mtt_backup from [c4fb75f9d6] to [390999ad3b].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    mtt="mtt-$1"
    dirs=$mtt
fi

## Create appropriate filename
case $format in
    date)
         filename=`date | awk '{printf("%s_%s%s_%s.tgz\n", mtt, $2,$3,$6)}' mtt=$mtt`;
	 shift
	;;
    version)
         filename=`mtt --version | awk '{printf("%s-%s.tar.gz\n", mtt, $NF)}' mtt=$mtt`;
	 shift
	;;

    *)

esac








|



|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    mtt="mtt-$1"
    dirs=$mtt
fi

## Create appropriate filename
case $format in
    date)
         filename=`date | gawk '{printf("%s_%s%s_%s.tgz\n", mtt, $2,$3,$6)}' mtt=$mtt`;
	 shift
	;;
    version)
         filename=`mtt --version | gawk '{printf("%s-%s.tar.gz\n", mtt, $NF)}' mtt=$mtt`;
	 shift
	;;

    *)

esac

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    exit    
fi

# Listing files to ignore
#echo Finding irrelevant files
#find $dirs -name '*.*' -print |\
#  grep 'dvi$\|ps$\|gif$\|log$\|dat$\|MTT_work\|core\|~$' >IGNORE
#wc IGNORE | awk '{print "Ignoring", $1, "files"}'

#echo examples >> IGNORE

#Inform user
echo Backing up $dirs to $filename

#Tar the files
#tar --exclude-from IGNORE --create --gzip --file $filename $dir
tar --create --gzip --file $filename $dirs
#Size info
ls -l $filename
#







|












55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    exit    
fi

# Listing files to ignore
#echo Finding irrelevant files
#find $dirs -name '*.*' -print |\
#  grep 'dvi$\|ps$\|gif$\|log$\|dat$\|MTT_work\|core\|~$' >IGNORE
#wc IGNORE | gawk '{print "Ignoring", $1, "files"}'

#echo examples >> IGNORE

#Inform user
echo Backing up $dirs to $filename

#Tar the files
#tar --exclude-from IGNORE --create --gzip --file $filename $dir
tar --create --gzip --file $filename $dirs
#Size info
ls -l $filename
#

Modified mttroot/mtt/bin/mtt_find from [f98e05dd96] to [a16165e9f1].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.6  1998/07/17 19:47:35  peterg
## Minor changes
##
## Revision 1.5  1998/07/17 07:50:33  peterg
## Now handles library name
## Returns a status
##   0 if exactly one result







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/10/03 18:29:57  peterg
## *** empty log message ***
##
## Revision 1.6  1998/07/17 19:47:35  peterg
## Minor changes
##
## Revision 1.5  1998/07/17 07:50:33  peterg
## Now handles library name
## Returns a status
##   0 if exactly one result
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    fi
  find $thepath -maxdepth 1 -name $fullname  -printf $format;
 done |\
 tee mtt_junk
fi

# Check exit status and return 
hits=`wc mtt_junk | awk '{print $1}'`
rm -f mtt_junk

if [ $hits = "1" ]; then
    exit 0
elif [ $hits = "0" ]; then
    exit 1
elif [ $hits > "1" ]; then







|







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    fi
  find $thepath -maxdepth 1 -name $fullname  -printf $format;
 done |\
 tee mtt_junk
fi

# Check exit status and return 
hits=`wc mtt_junk | gawk '{print $1}'`
rm -f mtt_junk

if [ $hits = "1" ]; then
    exit 0
elif [ $hits = "0" ]; then
    exit 1
elif [ $hits > "1" ]; then

Modified mttroot/mtt/bin/mtt_help from [67aeffb88f] to [92a6751c3c].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.13  2000/04/04 15:22:44  peterg
## Major changes: simple components now work
## Single components now work
##
## Revision 1.12  1998/07/21 08:47:59  peterg
## Default null $2 (regexp) to '^' - ie match any line
##







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2000/10/03 18:29:26  peterg
## crs now works after a fashion
##
## Revision 1.13  2000/04/04 15:22:44  peterg
## Major changes: simple components now work
## Single components now work
##
## Revision 1.12  1998/07/21 08:47:59  peterg
## Default null $2 (regexp) to '^' - ie match any line
##
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
         echo $comment $blurb
         mtt2reps_txt

	;;
    crs)
	echo  $comment $blurb
        find $find_path -name "$name" -print |\
        awk '{print "grep", key, $1}' key=$key | sh |\
        sed "s/$key //" | $sort
	;;
    *)
	
    fullnames=`mtt_find $find_path "$name" | awk '{printf("%s/%s\n",$1,$2)}'`
    N=`echo $fullnames | wc -w`;
    if [ -z "$fullnames" ]; then
	echo $comment No $blurb found.
    else
    echo $comment $N $blurb found.
    for fullname in $fullnames; do
        name=`basename $fullname`
	if [ -n "$other" ]; then
	cat $fullname | egrep $key 
	else
        info=`cat $fullname | egrep $key | awk '{for (i=2;i<=NF;i++) print $i}'`
	category=`echo $fullname |   sed "s!$find_path/!!" ` 
        category=`dirname $category`
	echo $category $name $info
	fi
    done
    fi
  esac
exit


  awk '{print "cat " $1 "/" $2}'  | sh |\
  egrep $key  | egrep $regexp  |\
  sed "s/$summary[	]*//" |\
  sed "s/$description[	]*/  /" |\
  sed "s/$alias[	]*/  Alias: /" |\
  sed "s!$find_path/!!" |\
  $sort








|




|










|










|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
         echo $comment $blurb
         mtt2reps_txt

	;;
    crs)
	echo  $comment $blurb
        find $find_path -name "$name" -print |\
        gawk '{print "grep", key, $1}' key=$key | sh |\
        sed "s/$key //" | $sort
	;;
    *)
	
    fullnames=`mtt_find $find_path "$name" | gawk '{printf("%s/%s\n",$1,$2)}'`
    N=`echo $fullnames | wc -w`;
    if [ -z "$fullnames" ]; then
	echo $comment No $blurb found.
    else
    echo $comment $N $blurb found.
    for fullname in $fullnames; do
        name=`basename $fullname`
	if [ -n "$other" ]; then
	cat $fullname | egrep $key 
	else
        info=`cat $fullname | egrep $key | gawk '{for (i=2;i<=NF;i++) print $i}'`
	category=`echo $fullname |   sed "s!$find_path/!!" ` 
        category=`dirname $category`
	echo $category $name $info
	fi
    done
    fi
  esac
exit


  gawk '{print "cat " $1 "/" $2}'  | sh |\
  egrep $key  | egrep $regexp  |\
  sed "s/$summary[	]*//" |\
  sed "s/$description[	]*/  /" |\
  sed "s/$alias[	]*/  Alias: /" |\
  sed "s!$find_path/!!" |\
  $sort

Modified mttroot/mtt/bin/mtt_versions from [4c7a6f1126] to [a20bb12cc7].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1998/05/28 09:24:41  peterg
## Initial revision
##
###############################################################

echo Versions of mtt and its components on `date`

## gnu standard --version
mtt_version mtt

echo Doing the GNU components
mtt_version awk
mtt_version basename
mtt_version cat
mtt_version cp
mtt_version dirname
mtt_version gcc
mtt_version grep
mtt_version head







>
>
>











|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/11/13 21:40:26  peterg
## Sorted out the non-gnu
##
## Revision 1.1  1998/05/28 09:24:41  peterg
## Initial revision
##
###############################################################

echo Versions of mtt and its components on `date`

## gnu standard --version
mtt_version mtt

echo Doing the GNU components
mtt_version gawk
mtt_version basename
mtt_version cat
mtt_version cp
mtt_version dirname
mtt_version gcc
mtt_version grep
mtt_version head

Modified mttroot/mtt/bin/mttrc from [5f2c0006b7] to [e928afb320].

11
12
13
14
15
16
17



18
19
20
21
22
23
24


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.26  2002/04/26 16:16:33  geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

    # include paths

    IOCTAVE="-I${PREFIX}/include/octave/ -I${PREFIX}/include/octave/octave"

    # library paths

    OCTAVEVERS=`octave --version | awk '{ print $4 }'`
    LOCTAVE="-L${PREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp"
    LSYSTEM="-ldl -lm -lncurses -lkpathsea -lreadline -lblas -llapack -lfftw -lg2c"

    # compiler options

    DEBUG="-g"
    OPTIM="-O3"







|







192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

    # include paths

    IOCTAVE="-I${PREFIX}/include/octave/ -I${PREFIX}/include/octave/octave"

    # library paths

    OCTAVEVERS=`octave --version | gawk '{ print $4 }'`
    LOCTAVE="-L${PREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp"
    LSYSTEM="-ldl -lm -lncurses -lkpathsea -lreadline -lblas -llapack -lfftw -lg2c"

    # compiler options

    DEBUG="-g"
    OPTIM="-O3"

Modified mttroot/mtt/bin/trans/ICD_txt2lang.sh from [456d58a25f] to [9756a243af].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# $1           $2       $3       $4         $5        $6     $7

cat <<EOF >> ${ICD}

${comment} Inputs

EOF
for name in `cat ${txt} | awk '($1 == "Input:") { print $3 }'`
do
    num=`grep ${name} ${struc} | awk '($1 == "input") { print $2 }'`
    grep ^Input ${txt} |\
	awk '($3 == name) { printf ("\tmttu%c%d%c\t= %s;\n", lb, num-offset, rb, $2) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

cat <<EOF >> ${ICD}

${comment} Outputs

EOF
for name in `cat ${txt} | awk '($1 == "Output:") { print $3 }'`
do
    num=`grep ${name} ${struc} | awk '($1 == "output") { print $2 }'`
    grep ^Output ${txt} |\
	awk '($3 == name) { printf ("\t%-30s = mtty%c%d%c;\n", $2, lb, num-offset, rb) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done








|

|

|








|

|

|



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# $1           $2       $3       $4         $5        $6     $7

cat <<EOF >> ${ICD}

${comment} Inputs

EOF
for name in `cat ${txt} | gawk '($1 == "Input:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "input") { print $2 }'`
    grep ^Input ${txt} |\
	gawk '($3 == name) { printf ("\tmttu%c%d%c\t= %s;\n", lb, num-offset, rb, $2) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

cat <<EOF >> ${ICD}

${comment} Outputs

EOF
for name in `cat ${txt} | gawk '($1 == "Output:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "output") { print $2 }'`
    grep ^Output ${txt} |\
	gawk '($3 == name) { printf ("\t%-30s = mtty%c%d%c;\n", $2, lb, num-offset, rb) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

Modified mttroot/mtt/bin/trans/abg2cr_m2txt from [8b839d7a30] to [6c927fa6eb].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


rm -f mtt_error


# This is the main transformation using awk 
# And remove crs with same name as system
grep 'cr = ' $1_abg.m | awk '
BEGIN {
# Include lin cr anyway.
print "lin"
}
{
  crs=substr($3,2,length($3)-3);
    N=split(crs,cr,";");







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


rm -f mtt_error


# This is the main transformation using awk 
# And remove crs with same name as system
grep 'cr = ' $1_abg.m | gawk '
BEGIN {
# Include lin cr anyway.
print "lin"
}
{
  crs=substr($3,2,length($3)-3);
    N=split(crs,cr,";");

Modified mttroot/mtt/bin/trans/abg2lbl_fig2txt from [3e21c7fb36] to [67d597485a].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.25  2001/10/15 14:27:00  gawthrop
## Now handles [1:N] style port labels
##
## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
}

create_lbl_body()
{

## Find names of all components
grep -v '\[[0-9]*:[0-9]*\]' $1_abg.fig  |\
awk '/:/ {print $NF}'  | \
sed 's/\\001//' | \
sort | \
tee $1_raw_list | \
sort -u> $1_unique_raw_list


#Write out non-unique names
#echo 'Non-unique names (if any):'
#diff $1_unique_raw_list  $1_raw_list | grep '>' | sed 's/>/	/'

#Write out the outline lbl file
grep -v  '\[[0-9]*\]'  $1_unique_raw_list | \
awk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
 { 
  Component = $1;
  Name = $2;







|












|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
}

create_lbl_body()
{

## Find names of all components
grep -v '\[[0-9]*:[0-9]*\]' $1_abg.fig  |\
gawk '/:/ {print $NF}'  | \
sed 's/\\001//' | \
sort | \
tee $1_raw_list | \
sort -u> $1_unique_raw_list


#Write out non-unique names
#echo 'Non-unique names (if any):'
#diff $1_unique_raw_list  $1_raw_list | grep '>' | sed 's/>/	/'

#Write out the outline lbl file
grep -v  '\[[0-9]*\]'  $1_unique_raw_list | \
gawk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
 { 
  Component = $1;
  Name = $2;
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
awk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt







|







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
gawk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

Modified mttroot/mtt/bin/trans/abg2sabg_fig from [b4a5f4fe24] to [42ae42721b].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2sabg_fig.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo Creating $1_sabg.txt

awk '{\
    Depth=7;\
    print $Depth}' $1_abg.fig








>
>
>



















|



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:18:40  peterg
## Initial revision
##
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2sabg_fig.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo Creating $1_sabg.txt

gawk '{\
    Depth=7;\
    print $Depth}' $1_abg.fig

Modified mttroot/mtt/bin/trans/abg2sensitivity_fig from [868b237a9b] to [019c577d2e].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    echo "Looking for $1 in library"
    mtt -q  compcopy $1  
fi


echo Creating $sfilename   

awk '
  function modulo10(x) {
    return x-int(x/10)*10
    }
  {

  level_index = 4;
  if ( match($NF,"001")&&(modulo10($level_index)==0)&&(index($NF,"[") != 1) ){







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    echo "Looking for $1 in library"
    mtt -q  compcopy $1  
fi


echo Creating $sfilename   

gawk '
  function modulo10(x) {
    return x-int(x/10)*10
    }
  {

  level_index = 4;
  if ( match($NF,"001")&&(modulo10($level_index)==0)&&(index($NF,"[") != 1) ){

Modified mttroot/mtt/bin/trans/abg2sub_fig2sh from [a2d914eff3] to [aa4b28a58d].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$



  ## Revision 1.3  2001/10/15 14:27:34  gawthrop
  ## Now handles [1:N] style port labels
  ##
  ## Revision 1.2  2001/07/23 23:26:23  gawthrop
  ## Removed some boring user feedback
  ##
  ## Revision 1.1  2001/06/11 19:47:49  gawthrop
  ## Makes the sub.sh file directly from the abg.fig file
  ## Used for making lbl files (abg2lbl_fig2txt)
  ##
  ##
  ###############################################################

# Copyright (C) 1996--2002 by Peter J. Gawthrop



get_valid_components()

{
awk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;







>
>
>




















|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.4  2002/04/22 10:25:47  gawthrop
  ## Handles unnamed components & ingnores artwork
  ##
  ## Revision 1.3  2001/10/15 14:27:34  gawthrop
  ## Now handles [1:N] style port labels
  ##
  ## Revision 1.2  2001/07/23 23:26:23  gawthrop
  ## Removed some boring user feedback
  ##
  ## Revision 1.1  2001/06/11 19:47:49  gawthrop
  ## Makes the sub.sh file directly from the abg.fig file
  ## Used for making lbl files (abg2lbl_fig2txt)
  ##
  ##
  ###############################################################

# Copyright (C) 1996--2002 by Peter J. Gawthrop



get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components from the _abg file
get_valid_components $1 |\
grep -v '\[[0-9]*:[0-9]*\]' |\
grep -v '\[.*\]' |\
awk '{if ($1==4) split($14,a,":"); print a[1]}'  |\
sed 's/\\001//' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  awk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  awk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  awk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?















|








|



|









|












68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components from the _abg file
get_valid_components $1 |\
grep -v '\[[0-9]*:[0-9]*\]' |\
grep -v '\[.*\]' |\
gawk '{if ($1==4) split($14,a,":"); print a[1]}'  |\
sed 's/\\001//' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Modified mttroot/mtt/bin/trans/abg2sub_m2sh from [bfd41abfe9] to [2502a0a331].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/10/03 11:34:53  peterg
## Correct $MTT_LIB
##
## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
awk '/type = / {print substr($3,2,length($3)-3)}' $1_abg.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  awk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  awk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  awk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?















|








|



|









|












36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
gawk '/type = / {print substr($3,2,length($3)-3)}' $1_abg.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Modified mttroot/mtt/bin/trans/abg2sympar_m2txt from [538470dfa1] to [f1c08a0b7a].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
REPS='[,*]'

SystemName=$2
UseLabelFile=$3

if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
     strip_comments < $1_lbl.txt  | tr $SEPS $REPS |\
     awk '{printf("%s %s \"%s\",\n",$1,$2,$3)}' > mtt_stripped_file
else ## Take input from _abg.m
     cat $1_abg.m | grep "arg =" | tr $SEPS $REPS > mtt_stripped_file
fi

rm -f mtt_error
# This is the main transformation using gawk
cat mtt_stripped_file | \
awk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;







|







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
REPS='[,*]'

SystemName=$2
UseLabelFile=$3

if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
     strip_comments < $1_lbl.txt  | tr $SEPS $REPS |\
     gawk '{printf("%s %s \"%s\",\n",$1,$2,$3)}' > mtt_stripped_file
else ## Take input from _abg.m
     cat $1_abg.m | grep "arg =" | tr $SEPS $REPS > mtt_stripped_file
fi

rm -f mtt_error
# This is the main transformation using gawk
cat mtt_stripped_file | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;

Modified mttroot/mtt/bin/trans/abg2tex from [f4bd38e131] to [cf8668b8eb].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.2  2000/11/27 17:45:00  peterg
## Removed "System" from  heading
##
## Revision 1.1  2000/11/27 15:11:15  peterg
## Initial revision
##
## Revision 1.7  1997/12/06 16:20:37  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.2  2000/11/27 17:45:00  peterg
## Removed "System" from  heading
##
## Revision 1.1  2000/11/27 15:11:15  peterg
## Initial revision
##
## Revision 1.7  1997/12/06 16:20:37  peterg
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
 \index{\textbf{$1} -- subsystems} 
EOF
cat $1_sub.tex   >> $filename

#Now do the subsystems (if at top level)
if [ -z "$2" ]; then
 sub2subs $1 | sort -u | \
  awk '{print "abg2tex", pdf, $1, filename}' pdf=$pdf filename=$filename | sh
fi


















|












132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
 \index{\textbf{$1} -- subsystems} 
EOF
cat $1_sub.tex   >> $filename

#Now do the subsystems (if at top level)
if [ -z "$2" ]; then
 sub2subs $1 | sort -u | \
  gawk '{print "abg2tex", pdf, $1, filename}' pdf=$pdf filename=$filename | sh
fi











Modified mttroot/mtt/bin/trans/alias_txt2m from [f172c72e17] to [00b2a256d4].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1998/07/02 09:21:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_alias.m

#Create the alias file complete with headers.
echo "function alias = $1_alias" > $1_alias.m
echo "%% Alias file ($1_alias.m)" >> $1_alias.m
echo "%% Generated by MTT at `date`" >> $1_alias.m

#Write out the variables 
awk '{
       if (NF==2) {i++; print "alias."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "alias = 0;"
        }' $1_alias.txt >> $1_alias.m








>
>
>















|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 19:16:03  peterg
## Prettyfied output
##
## Revision 1.1  1998/07/02 09:21:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_alias.m

#Create the alias file complete with headers.
echo "function alias = $1_alias" > $1_alias.m
echo "%% Alias file ($1_alias.m)" >> $1_alias.m
echo "%% Generated by MTT at `date`" >> $1_alias.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "alias."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "alias = 0;"
        }' $1_alias.txt >> $1_alias.m

Modified mttroot/mtt/bin/trans/cbg2ese_m2r from [0a2c9156c8] to [f8d94a9670].

12
13
14
15
16
17
18



19
20
21
22
23
24
25

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$



## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint
## mtt_xargs.sh eliminates Arg list too long error for large models.
## (UNIX xargs does not work if the environment is too large).
##







>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.31  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint
## mtt_xargs.sh eliminates Arg list too long error for large models.
## (UNIX xargs does not work if the environment is too large).
##
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
}


get_indices ()
{
  sys=$1
  which=$2
  awk '{if ($1==which) print $2}' which=$which < ${sys}_struc.txt
}

convert_indices ()
{
  sys=$1
  Which="input output state"
  for which in $Which; do







|







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
}


get_indices ()
{
  sys=$1
  which=$2
  gawk '{if ($1==which) print $2}' which=$which < ${sys}_struc.txt
}

convert_indices ()
{
  sys=$1
  Which="input output state"
  for which in $Which; do
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Relabel states with multiple ports
relabel_multiple_definitions(){
  mv $structurefile junk
  awk '
  BEGIN{
     var_type_index=1;  
     oldname="";
  }
  {
     name=$4;
     newname=name;







|







341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Relabel states with multiple ports
relabel_multiple_definitions(){
  mv $structurefile junk
  gawk '
  BEGIN{
     var_type_index=1;  
     oldname="";
  }
  {
     name=$4;
     newname=name;

Modified mttroot/mtt/bin/trans/cmp2cmp_m from [3837859c2d] to [da616cbb8d].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################

# Inform user
echo Revising $1_cmp.m

# Copy the alias and cmp files.
cat $1_alias.txt $1_cmp.m > junk

#Create the cmp file complete with headers.
#echo "# Component file ($1_cmp.m)" #> $1_cmp.m
#echo "# Revised by MTT at `date`" #>> $1_cmp.m

#Write out the variables 
awk '
BEGIN{
alias_file=1
Parameter_Regexp = "^_Parameter_"
Line_Regexp = "cr|arg"
quote = "\047"
}
{







>
>
>













|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:20:04  peterg
## Initial revision
##
###############################################################

# Inform user
echo Revising $1_cmp.m

# Copy the alias and cmp files.
cat $1_alias.txt $1_cmp.m > junk

#Create the cmp file complete with headers.
#echo "# Component file ($1_cmp.m)" #> $1_cmp.m
#echo "# Revised by MTT at `date`" #>> $1_cmp.m

#Write out the variables 
gawk '
BEGIN{
alias_file=1
Parameter_Regexp = "^_Parameter_"
Line_Regexp = "cr|arg"
quote = "\047"
}
{

Modified mttroot/mtt/bin/trans/cmp2sub_m2sh from [db33551972] to [abbcf4831f].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.7  2000/01/18 14:22:58  peterg
## Now exits if file already exists
##
## Revision 1.6  1999/08/25 21:20:07  peterg
## Don't list components starting with 0 ot 1
##
## Revision 1.5  1996/11/09 21:09:43  peterg







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/10/03 11:34:29  peterg
## Put in correct $MTT_LIB
##
## Revision 1.7  2000/01/18 14:22:58  peterg
## Now exits if file already exists
##
## Revision 1.6  1999/08/25 21:20:07  peterg
## Don't list components starting with 0 ot 1
##
## Revision 1.5  1996/11/09 21:09:43  peterg
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _cmp file
awk '/comp_type = / {print substr($3,2,length($3)-3)}' $1_cmp.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  awk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  awk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  awk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?















|







|



|









|












50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _cmp file
gawk '/comp_type = / {print substr($3,2,length($3)-3)}' $1_cmp.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Modified mttroot/mtt/bin/trans/cr_txt2r from [50e5d67b45] to [703fda25ba].

12
13
14
15
16
17
18



19
20
21
22
23
24
25
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.11  2000/08/01 07:34:33  peterg
## Replaced printf by echo
##
## Revision 1.10  2000/02/25 09:10:12  peterg
## Changed -e to -f in if [ -f "$crf" ]; then
##  -- cuased probs on SUN
##







>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2002/04/08 17:04:21  geraint
## Removed spurious "\n" from output.
##
## Revision 1.11  2000/08/01 07:34:33  peterg
## Replaced printf by echo
##
## Revision 1.10  2000/02/25 09:10:12  peterg
## Changed -e to -f in if [ -f "$crf" ]; then
##  -- cuased probs on SUN
##
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    echo  >> $crfile

    # Recursively create subsystem CR files -- at lower level
    sh $1_sub.sh 'cr_txt2r ' ' _lower' 
    
    # Include subsystem CR files
    sh $1_sub.sh 'echo ' "_cr.r" |\
    awk '{
      print "in \"" $1 "\";"
    }'  >> $crfile

##  if [ -z "$level" ]; then

    # Copy .cr files
    awk '{
	 if (NF>0) {
         print "mtt -q -u crcopy " $1; 
         }
    }' $1_cr.txt  | sh

    # Include the .cr files
#    awk '{
#	 if (NF>0) {
#         print "in \"" $1 ".cr\";"
#         }
#    }' $1_cr.txt  >> $crfile

    ## list of the crs
    crs=`cat $1_cr.txt`







|






|






|







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    echo  >> $crfile

    # Recursively create subsystem CR files -- at lower level
    sh $1_sub.sh 'cr_txt2r ' ' _lower' 
    
    # Include subsystem CR files
    sh $1_sub.sh 'echo ' "_cr.r" |\
    gawk '{
      print "in \"" $1 "\";"
    }'  >> $crfile

##  if [ -z "$level" ]; then

    # Copy .cr files
    gawk '{
	 if (NF>0) {
         print "mtt -q -u crcopy " $1; 
         }
    }' $1_cr.txt  | sh

    # Include the .cr files
#    gawk '{
#	 if (NF>0) {
#         print "in \"" $1 ".cr\";"
#         }
#    }' $1_cr.txt  >> $crfile

    ## list of the crs
    crs=`cat $1_cr.txt`

Modified mttroot/mtt/bin/trans/cse2scse_r from [f23aba8df6] to [31a5612a2e].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
system_scse=$1_scse.r

# Parameters
n=`echo $2 | sed 's/,/ /g' |wc -w` ## Number of parameters

## Parameter information for reduce.
parameters=`echo $2 | sed 's/,/ /g' |\
 awk '{
   for (i=1; i<=NF; i++) {
      printf("mttpar(%i,1) := %s;\n", i, $i);
      printf("mttcoef(%i,1) := %ss;\n", i, $i);
   }
  }'`

## Update sympar list.
echo Recreating $1_sympar.txt
# Zap any sensitivity coeficients
mv $1_sympar.txt mtt_junk
grep -v MTT_Sensitivity_Coefficients mtt_junk > $1_sympar.txt

# Create the new sens coeffs at end of list.
echo $2 | sed 's/,/ /g' |\
awk '{
   for (i=1; i<=NF; i++) {
      printf("%ss\tMTT_Sensitivity_Coefficients\n",$i);
   }
  }' >> $1_sympar.txt

touch $1_sympar.txt

matrix="matrix mttpar("$n",1); matrix mttcoef("$n",1);"

# Number of states
Nx=`grep "MTTNx " <$system_def | awk '{print $3}' | sed 's/;//'`

#Inform user
echo Creating $system_scse "(for parameters $2, $Nx states)"

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








|














|










|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
system_scse=$1_scse.r

# Parameters
n=`echo $2 | sed 's/,/ /g' |wc -w` ## Number of parameters

## Parameter information for reduce.
parameters=`echo $2 | sed 's/,/ /g' |\
 gawk '{
   for (i=1; i<=NF; i++) {
      printf("mttpar(%i,1) := %s;\n", i, $i);
      printf("mttcoef(%i,1) := %ss;\n", i, $i);
   }
  }'`

## Update sympar list.
echo Recreating $1_sympar.txt
# Zap any sensitivity coeficients
mv $1_sympar.txt mtt_junk
grep -v MTT_Sensitivity_Coefficients mtt_junk > $1_sympar.txt

# Create the new sens coeffs at end of list.
echo $2 | sed 's/,/ /g' |\
gawk '{
   for (i=1; i<=NF; i++) {
      printf("%ss\tMTT_Sensitivity_Coefficients\n",$i);
   }
  }' >> $1_sympar.txt

touch $1_sympar.txt

matrix="matrix mttpar("$n",1); matrix mttcoef("$n",1);"

# Number of states
Nx=`grep "MTTNx " <$system_def | gawk '{print $3}' | sed 's/;//'`

#Inform user
echo Creating $system_scse "(for parameters $2, $Nx states)"

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

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243


## Now reorganise the  states
mv -f $system_scse mtt_junk


##echo "Nx = $Nx"
awk '{
  ## Make sure all MTTn variables are followed by a space
  gsub(/mttx[0-9]*/, "& ");

  for (i=Nx;i>0;i--) {

    state = sprintf("mttx%i ",i);
    newstate = sprintf("mttx%i ",2*i-1);







|







229
230
231
232
233
234
235
236
237
238
239
240
241
242
243


## Now reorganise the  states
mv -f $system_scse mtt_junk


##echo "Nx = $Nx"
gawk '{
  ## Make sure all MTTn variables are followed by a space
  gsub(/mttx[0-9]*/, "& ");

  for (i=Nx;i>0;i--) {

    state = sprintf("mttx%i ",i);
    newstate = sprintf("mttx%i ",2*i-1);

Modified mttroot/mtt/bin/trans/dae2cse_r from [95da3f9a38] to [e055f9ba28].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.16  2001/07/13 04:54:04  geraint







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.19  2001/10/26 01:01:49  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.16  2001/07/13 04:54:04  geraint
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
touch $1_cseo.r2
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    awk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   mv mtt_junk $1_def.r
   for file in `ls $1_def.*`; do
      if [ $file != $1_def.r ]; then
          ext=`echo $file|awk -F\. '{print $2}'`
          mtt -q $1 def $ext
      fi
   done
fi


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







|










|








451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
touch $1_cseo.r2
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    gawk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   mv mtt_junk $1_def.r
   for file in `ls $1_def.*`; do
      if [ $file != $1_def.r ]; then
          ext=`echo $file|gawk -F\. '{print $2}'`
          mtt -q $1 def $ext
      fi
   done
fi


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

Modified mttroot/mtt/bin/trans/dat22dat from [ba08d67a1d] to [cbdbd4dbd6].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.9  2000/09/27 16:12:50  peterg
## Use expr to evaluate arithmetic - compatible with sh (as opposed to
## bash)
##
## Revision 1.8  2000/09/21 10:07:06  peterg
## Now correctely writes out the state into _odes.dat rep.
##







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2000/10/17 12:24:02  peterg
## Three argument generic version
##
## Revision 1.9  2000/09/27 16:12:50  peterg
## Use expr to evaluate arithmetic - compatible with sh (as opposed to
## bash)
##
## Revision 1.8  2000/09/21 10:07:06  peterg
## Now correctely writes out the state into _odes.dat rep.
##
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    *)
	First=1; Last=`expr $Ny + 1`
        ;;
esac

echo Creating $1_$2$3.dat

awk '{
      ## Extract the data
      if (index($1,"#") != 1){
        for (i=First;i<=Last;i++)
	  printf("%s ", $i);
      printf("\n"); 
  }
}' First=$First Last=$Last <$1_$2s.dat2  > $1_$2$3.dat







|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    *)
	First=1; Last=`expr $Ny + 1`
        ;;
esac

echo Creating $1_$2$3.dat

gawk '{
      ## Extract the data
      if (index($1,"#") != 1){
        for (i=First;i<=Last;i++)
	  printf("%s ", $i);
      printf("\n"); 
  }
}' First=$First Last=$Last <$1_$2s.dat2  > $1_$2$3.dat

Modified mttroot/mtt/bin/trans/dat22sg.sh from [e519db8890] to [2702996b8e].

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
    echo ''
    echo '</sgw:Worksheet>'
}

write_column_headings ()
{
    awk '{ printf ("  <sgw:Column No=\"%d\" Width=\"80\" Title=\"%s\" Format=\"0\" Precision=\"3\">\n  </sgw:Column>\n", NR-1,$0) }'
}

write_output_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;







|







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
    echo ''
    echo '</sgw:Worksheet>'
}

write_column_headings ()
{
    gawk '{ printf ("  <sgw:Column No=\"%d\" Width=\"80\" Title=\"%s\" Format=\"0\" Precision=\"3\">\n  </sgw:Column>\n", NR-1,$0) }'
}

write_output_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
EOF
}

file=${sys}_odes.sg

NX=`mtt_getsize ${sys} x`
NY=`mtt_getsize ${sys} y`
NTMP=`wc -l ${sys}_odes.dat2 | awk '{print $1}'`
NROW=`expr ${NTMP} - 4`		# 4 comment lines in mtt_data

{
    write_project_header
    # states
    write_worksheet_header	"X_${sys}" ${NX} ${NROW}
    write_state_headings	${sys}







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
EOF
}

file=${sys}_odes.sg

NX=`mtt_getsize ${sys} x`
NY=`mtt_getsize ${sys} y`
NTMP=`wc -l ${sys}_odes.dat2 | gawk '{print $1}'`
NROW=`expr ${NTMP} - 4`		# 4 comment lines in mtt_data

{
    write_project_header
    # states
    write_worksheet_header	"X_${sys}" ${NX} ${NROW}
    write_state_headings	${sys}

Modified mttroot/mtt/bin/trans/dat2gdat from [6a887e71c9] to [11ab5c7503].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  2000/12/28 12:26:15  peterg
## Put under RCS
##
## Revision 1.8  1998/09/29 20:01:27  peterg
## 4th argument for nyquist style files - ie differnt x for each y
##
## Revision 1.7  1997/12/04 22:10:32  peterg







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2000/12/28 12:26:15  peterg
## Put under RCS
##
## Revision 1.8  1998/09/29 20:01:27  peterg
## 4th argument for nyquist style files - ie differnt x for each y
##
## Revision 1.7  1997/12/04 22:10:32  peterg
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# ie stack two columns vertically separated by blank lines

#Get the desired data index
which=`name2index $1 "$3"`
echo $1 $3 $which

if [ -z "$DifferentX" ]; then
awk '
BEGIN{
  row=0; col=0;
}
{ 
  if (row==0) {
     N=split(which,Which,",");
    }







|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ie stack two columns vertically separated by blank lines

#Get the desired data index
which=`name2index $1 "$3"`
echo $1 $3 $which

if [ -z "$DifferentX" ]; then
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  if (row==0) {
     N=split(which,Which,",");
    }
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  if (col<=cols) {
    printf("\n")
  }
  }
}'  which="$which" <$1_$2.dat >   $1_$2.gdat

else
awk '
BEGIN{
  row=0; col=0;
}
{ 
  row++; cols=NF/2
    for (i=1; i<=cols; i++) {
      ycol=2*i;







|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  if (col<=cols) {
    printf("\n")
  }
  }
}'  which="$which" <$1_$2.dat >   $1_$2.gdat

else
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  row++; cols=NF/2
    for (i=1; i<=cols; i++) {
      ycol=2*i;

Modified mttroot/mtt/bin/trans/dat2siag from [4a36fa9cce] to [ce0ee2cbb1].

12
13
14
15
16
17
18



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1999/03/29 03:35:13  peterg
## Initial revision
##
###############################################################




# This is the main transformation using awk
awk '{
    i++
    for (j=1;j<=NF;j++)
	data[i,j]=$j;
    Cols=NF;
    Rows++;
}
END{







>
>
>









|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/04/16 22:22:06  geraint
## *** empty log message ***
##
## Revision 1.1  1999/03/29 03:35:13  peterg
## Initial revision
##
###############################################################




# This is the main transformation using awk
gawk '{
    i++
    for (j=1;j<=NF;j++)
	data[i,j]=$j;
    Cols=NF;
    Rows++;
}
END{

Modified mttroot/mtt/bin/trans/def2write_r from [6639ce8c03] to [7ef04b9230].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.8  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.7.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.9  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.8  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.7.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nxx=`mtt_getsize $sys xx` # States x States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs 
Nyz=`mtt_getsize $sys yz` # Zero outputs
#Npar=`wc -l $sys\_sympar.txt | awk '{print $1}'`

# Set up representation-specific stuff
case $rep in
    cse)
        matrices='EdX E'
        ns="$Nx $Nx"
        ms="1 $Nx"







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nxx=`mtt_getsize $sys xx` # States x States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs 
Nyz=`mtt_getsize $sys yz` # Zero outputs
#Npar=`wc -l $sys\_sympar.txt | gawk '{print $1}'`

# Set up representation-specific stuff
case $rep in
    cse)
        matrices='EdX E'
        ns="$Nx $Nx"
        ms="1 $Nx"

Modified mttroot/mtt/bin/trans/def_r2m from [8855e20923] to [b27ff6c61a].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1998/07/25 07:10:41  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_def.m







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/25 10:21:37  peterg
## Entirely rewritten
##
## Revision 1.1  1998/07/25 07:10:41  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_def.m
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% System $1, representation def, language m
% File $1_def.m;
% Generated by MTT on `date`;
%
EOF

# Constants
Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'`
Ny=`grep "MTTNy " <$1_def.r | awk '{print $3}' | sed 's/;//'`
Nu=`grep "MTTNu " <$1_def.r | awk '{print $3}' | sed 's/;//'`
Nz=`grep "MTTNz " <$1_def.r | awk '{print $3}' | sed 's/;//'`
Nyz=`grep "MTTNyz " <$1_def.r | awk '{print $3}' | sed 's/;//'`


cat<<EOF >> $1_def.m 
  nx = $Nx;
  ny = $Ny;
  nu = $Nu;
  nz = $Nz;
  nyz = $Nyz;
EOF







|
|
|
|
|









35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
% System $1, representation def, language m
% File $1_def.m;
% Generated by MTT on `date`;
%
EOF

# Constants
Nx=`grep "MTTNx " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Ny=`grep "MTTNy " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nu=`grep "MTTNu " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nz=`grep "MTTNz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nyz=`grep "MTTNyz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`


cat<<EOF >> $1_def.m 
  nx = $Nx;
  ny = $Ny;
  nu = $Nu;
  nz = $Nz;
  nyz = $Nyz;
EOF

Modified mttroot/mtt/bin/trans/dir2paths from [98a433273b] to [45c39d446b].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1998/03/11 10:32:35  peterg
## Initial revision
##
###############################################################


dotdot=$2 # Set to ../ if we are in MTT_work


# Create paths for all valid examples - ie dir name is system name
find $dotdot$1 -name '*_abg.fig' -print |\
  awk '{
   N=split($1,name,"/"); 
   printf("%s", name[1]);
   for (i=2;i<N;i++) printf("/%s", name[i]); 
   printf(" %s %s\n", name[N-1], name[N]);
  }' |\
  awk '{
  correctname=sprintf("%s_abg.fig", $2);
  if ($3==correctname) print  $1,$2
  }'







>
>
>











|





|



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/11/10 17:12:15  peterg
## Removed sorting
##
## Revision 1.1  1998/03/11 10:32:35  peterg
## Initial revision
##
###############################################################


dotdot=$2 # Set to ../ if we are in MTT_work


# Create paths for all valid examples - ie dir name is system name
find $dotdot$1 -name '*_abg.fig' -print |\
  gawk '{
   N=split($1,name,"/"); 
   printf("%s", name[1]);
   for (i=2;i<N;i++) printf("/%s", name[i]); 
   printf(" %s %s\n", name[N-1], name[N]);
  }' |\
  gawk '{
  correctname=sprintf("%s_abg.fig", $2);
  if ($3==correctname) print  $1,$2
  }'

Modified mttroot/mtt/bin/trans/dir2rep from [2f10632b5f] to [bc594f5e2a].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.2  1998/03/11 10:32:11  peterg
## Now uses dir2paths transformation
##
## Revision 1.1  1998/02/05 13:31:25  peterg
## Initial revision
##
###############################################################

dotdot=$2 # Set to ../ if we are in MTT_work

# Inform user
echo "Creating $1_rep.txt (Directory version)"

# Headings
echo "% Verbal description for directory $1 ($1_rep.txt)"> $1_rep.txt
echo "% Generated by MTT on" `date`. >> $1_rep.txt                  	   

# Create paths for all valid examples - ie dir name is system name
dir2paths $1 $2 | sed 's/Introduction/AAAAA/g' | sort | sed 's/AAAAA/Introduction/g' | \
awk '{
     print "mtt -t -d " $1,$2 " rep tex";
  }' >> $1_rep.txt







>
>
>



















|


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/12/28 12:26:45  peterg
## *** empty log message ***
##
## Revision 1.2  1998/03/11 10:32:11  peterg
## Now uses dir2paths transformation
##
## Revision 1.1  1998/02/05 13:31:25  peterg
## Initial revision
##
###############################################################

dotdot=$2 # Set to ../ if we are in MTT_work

# Inform user
echo "Creating $1_rep.txt (Directory version)"

# Headings
echo "% Verbal description for directory $1 ($1_rep.txt)"> $1_rep.txt
echo "% Generated by MTT on" `date`. >> $1_rep.txt                  	   

# Create paths for all valid examples - ie dir name is system name
dir2paths $1 $2 | sed 's/Introduction/AAAAA/g' | sort | sed 's/AAAAA/Introduction/g' | \
gawk '{
     print "mtt -t -d " $1,$2 " rep tex";
  }' >> $1_rep.txt

Modified mttroot/mtt/bin/trans/dm2ir_m2dat from [acb379d922] to [d3255be9a0].

12
13
14
15
16
17
18



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.2  1996/08/11 10:40:00  peter
## Now handles e and NaN numbers.
##
## Revision 1.1  1996/08/10 14:15:03  peter
## Initial revision
##
###############################################################

echo Creating $1_ir.dat

if [ "$2" = "" ]; 
then
  PARAMS='t=[0:0.1:10]'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi


$MATRIX << EOF | awk '$1 !~ /[A-MO-Zb-cf-z]/ && NF>0 {print} '  >$1_ir.dat

  $PARAMS;
  [n,m]=size(t);
  if m>n
    t=t';
  end;








>
>
>



















|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1996/08/11 19:48:29  peter
## Parameter passing added.
##
## Revision 1.2  1996/08/11 10:40:00  peter
## Now handles e and NaN numbers.
##
## Revision 1.1  1996/08/10 14:15:03  peter
## Initial revision
##
###############################################################

echo Creating $1_ir.dat

if [ "$2" = "" ]; 
then
  PARAMS='t=[0:0.1:10]'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi


$MATRIX << EOF | gawk '$1 !~ /[A-MO-Zb-cf-z]/ && NF>0 {print} '  >$1_ir.dat

  $PARAMS;
  [n,m]=size(t);
  if m>n
    t=t';
  end;

Modified mttroot/mtt/bin/trans/examples_txt2tk from [db2fcef527] to [f746b105d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh

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

# Bourne shell script: examples_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999


# Examples menu
awk 'BEGIN{
    basemenu=".exam.exam"
    oldmenu=basemenu
    OLDPATH="";
    }
    {
    if (NF>1){
    PATH=$1;












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh

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

# Bourne shell script: examples_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999


# Examples menu
gawk 'BEGIN{
    basemenu=".exam.exam"
    oldmenu=basemenu
    OLDPATH="";
    }
    {
    if (NF>1){
    PATH=$1;

Modified mttroot/mtt/bin/trans/icd2ICD_txt22txt.sh from [2134e4a645] to [bb77e3bfab].

19
20
21
22
23
24
25
26
27
28
29
30
31
## Interface Control Definition for System ${sys}
## ${ICD}: Generated by MTT `date`

EOF

cat ${icd}		|\
    sed 's/[\,\;]/\ /g'	|\
    awk '
    ($2 != "null" && $6 == "input")  { printf ("Input:  %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "input")  { printf ("Input:  %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ($2 != "null" && $6 == "output") { printf ("Output: %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "output") { printf ("Output: %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ' | sort >> ${ICD}







|





19
20
21
22
23
24
25
26
27
28
29
30
31
## Interface Control Definition for System ${sys}
## ${ICD}: Generated by MTT `date`

EOF

cat ${icd}		|\
    sed 's/[\,\;]/\ /g'	|\
    gawk '
    ($2 != "null" && $6 == "input")  { printf ("Input:  %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "input")  { printf ("Input:  %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ($2 != "null" && $6 == "output") { printf ("Output: %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "output") { printf ("Output: %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ' | sort >> ${ICD}

Modified mttroot/mtt/bin/trans/icd_txt2m.sh from [cb0a719b07] to [9439894fee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! /bin/sh

# Inform user
echo Creating $1_icd.m

#Create the component ICD file complete with headers.
echo "function icd = $1_icd" > $1_icd.m
echo "%% Component icd file ($1_icd.m)" >> $1_icd.m
echo "%% Generated by MTT at `date`" >> $1_icd.m

#Write out the variables 
awk '{
       if (NF==2) {i++; print "icd."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "icd = 0;"
        }' $1_icd.txt >> $1_icd.m











|






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! /bin/sh

# Inform user
echo Creating $1_icd.m

#Create the component ICD file complete with headers.
echo "function icd = $1_icd" > $1_icd.m
echo "%% Component icd file ($1_icd.m)" >> $1_icd.m
echo "%% Generated by MTT at `date`" >> $1_icd.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "icd."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "icd = 0;"
        }' $1_icd.txt >> $1_icd.m

Modified mttroot/mtt/bin/trans/lbl2alias_txt from [19255cbb75] to [5801411229].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
grep '[%|#]ALIAS' $1_lbl.txt |\
awk '{print $2,$3}' >> $1_alias.txt
















>
>
>














|









10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 08:34:00  peterg
## Renamed to lbl2alias_txt2txt
##
## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
grep '[%|#]ALIAS' $1_lbl.txt |\
gawk '{print $2,$3}' >> $1_alias.txt









Modified mttroot/mtt/bin/trans/lbl2alias_txt2txt from [a972903b94] to [8e2770c7f9].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.5  1998/07/17 16:31:37  peterg
## Ignore component aliases (with /)
##
## Revision 1.4  1998/07/03 15:21:26  peterg
## Replace sub by gsub -- need to replace ALL ,
##
## Revision 1.3  1998/07/03 13:49:03  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/07/17 19:46:56  peterg
## No change
##
## Revision 1.5  1998/07/17 16:31:37  peterg
## Ignore component aliases (with /)
##
## Revision 1.4  1998/07/03 15:21:26  peterg
## Replace sub by gsub -- need to replace ALL ,
##
## Revision 1.3  1998/07/03 13:49:03  peterg
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
    grep '[%|#]ALIAS' $1_lbl.txt |\
    awk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          alias=$2; name =$3
        }
        else{
          alias=$3; name =$2
        }







|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
    grep '[%|#]ALIAS' $1_lbl.txt |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          alias=$2; name =$3
        }
        else{
          alias=$3; name =$2
        }

Modified mttroot/mtt/bin/trans/lbl2args_txt2out from [05b9541fdd] to [81dc428574].

1
2
3
4
5
6
7
8
9
10
11
12



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# Writes argument list to standard output ready for use in calling lbl file

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$



  ## Revision 1.1  2001/06/11 15:06:58  gawthrop
  ## Now handles user-defined components
  ##
  ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

if [ -f "$1_lbl.txt" ]; then
grep '[#%]ALIAS' $1_lbl.txt |\

awk '{
  if (match($2,"\\$[0-9]")==1) ## Test if its a argument alias
  {
    i = substr($2,2);
    arg[i] = $3
    N++
  }
}












>
>
>










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# Writes argument list to standard output ready for use in calling lbl file

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:08  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ## Revision 1.1  2001/06/11 15:06:58  gawthrop
  ## Now handles user-defined components
  ##
  ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

if [ -f "$1_lbl.txt" ]; then
grep '[#%]ALIAS' $1_lbl.txt |\

gawk '{
  if (match($2,"\\$[0-9]")==1) ## Test if its a argument alias
  {
    i = substr($2,2);
    arg[i] = $3
    N++
  }
}

Modified mttroot/mtt/bin/trans/lbl2component from [6d85c8fe68] to [57a01a5b67].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.2  1998/07/27 08:38:11  peterg
## Just look for / in the relevant field.
##
## Revision 1.1  1998/07/17 17:04:50  peterg
## Initial revision
##
###############################################################


# Regexp for an alias
alias='^[#%]ALIAS'

grep $alias $1_lbl.txt | awk '{if (match($3,"/")>0) print "mtt -q compcopy " $3}'

















>
>
>












|










10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/07/28 11:23:31  peterg
## Put / explicitly in awk.
##
## Revision 1.2  1998/07/27 08:38:11  peterg
## Just look for / in the relevant field.
##
## Revision 1.1  1998/07/17 17:04:50  peterg
## Initial revision
##
###############################################################


# Regexp for an alias
alias='^[#%]ALIAS'

grep $alias $1_lbl.txt | gawk '{if (match($3,"/")>0) print "mtt -q compcopy " $3}'










Modified mttroot/mtt/bin/trans/lbl2cr_txt2r from [52afa16970] to [44253224e2].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



# Revision 1.3  1996/11/03  21:11:44  peterg
# Removed END; statement
#
## Revision 1.2  1996/11/02 10:20:53  peterg
## Created from lbl2sympar
##
###############################################################


# Inform user
echo "Creating $1_cr.r"

rm -f mtt_error

#Write some file headers
echo "%% constitutive relationship  file ($1_cr.r)" > $1_cr.r
echo "%% Generated by MTT at `date`" >> $1_cr.r

# This is the main transformation using awk
awk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
	sh >> $1_cr.r

# Now invoke the standard error handling.
#mtt_error mtt_error.txt









>
>
>



















|






11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.3  1996/11/03  21:11:44  peterg
# Removed END; statement
#
## Revision 1.2  1996/11/02 10:20:53  peterg
## Created from lbl2sympar
##
###############################################################


# Inform user
echo "Creating $1_cr.r"

rm -f mtt_error

#Write some file headers
echo "%% constitutive relationship  file ($1_cr.r)" > $1_cr.r
echo "%% Generated by MTT at `date`" >> $1_cr.r

# This is the main transformation using awk
gawk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
	sh >> $1_cr.r

# Now invoke the standard error handling.
#mtt_error mtt_error.txt


Modified mttroot/mtt/bin/trans/lbl2icd_txt2txt.sh from [90cc5ce192] to [2a3b38ea21].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#Create the ICD file complete with headers.
echo "# Component ICD file ($1_icd.txt)" > ${icd}
echo "# Generated by MTT at `date`" >> ${icd}

#Write out the variables 
    grep '[%|#]ICD' ${lbl} |\
    awk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          icd=$2; name =$3
        }
        else{
          icd=$3; name =$2
        }







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#Create the ICD file complete with headers.
echo "# Component ICD file ($1_icd.txt)" > ${icd}
echo "# Generated by MTT at `date`" >> ${icd}

#Write out the variables 
    grep '[%|#]ICD' ${lbl} |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          icd=$2; name =$3
        }
        else{
          icd=$3; name =$2
        }

Modified mttroot/mtt/bin/trans/lbl2modpar_txt from [ccd703b3b8] to [7d9600f181].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$



###############################################################

# Inform user
echo Creating $1_modpar.txt

#Create the modpar file complete with headers.
echo "# Modpar file ($1_modpar.txt)" > $1_modpar.txt
echo "# Generated by MTT at `date`" >> $1_modpar.txt

#Write out the variables 
grep '[%|#]MODPAR' $1_lbl.txt |\
awk '{printf("%s\t%s\n", $2,$3)}' >> $1_modpar.txt

echo "# End of $1_modpar.txt" >> $1_modpar.txt















>
>
>











|










10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.1  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
###############################################################

# Inform user
echo Creating $1_modpar.txt

#Create the modpar file complete with headers.
echo "# Modpar file ($1_modpar.txt)" > $1_modpar.txt
echo "# Generated by MTT at `date`" >> $1_modpar.txt

#Write out the variables 
grep '[%|#]MODPAR' $1_lbl.txt |\
gawk '{printf("%s\t%s\n", $2,$3)}' >> $1_modpar.txt

echo "# End of $1_modpar.txt" >> $1_modpar.txt








Modified mttroot/mtt/bin/trans/lbl2sympar_txt2r from [7f7d56852b] to [d2dc2feb77].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



# Revision 1.6  1996/12/07  19:39:51  peterg
# Minor debugging.
#
## Revision 1.5  1996/09/12 17:18:44  peter
## Don't add an RCS header ..
##
## Revision 1.4  1996/08/30 19:01:21  peter







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.6  1996/12/07  19:39:51  peterg
# Minor debugging.
#
## Revision 1.5  1996/09/12 17:18:44  peter
## Don't add an RCS header ..
##
## Revision 1.4  1996/08/30 19:01:21  peter
43
44
45
46
47
48
49
50
51
52
53
54
55

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)" > $1_sympar.r
echo "%% Generated by MTT at `date`" >> $1_sympar.r

# This is the main transformation using awk
tr ';' ',' <  $1_lbl.txt | \
awk -f $MTTPATH/trans/awk/lbl2sympar.awk | sort >> $1_sympar.r 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt









|





46
47
48
49
50
51
52
53
54
55
56
57
58

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)" > $1_sympar.r
echo "%% Generated by MTT at `date`" >> $1_sympar.r

# This is the main transformation using awk
tr ';' ',' <  $1_lbl.txt | \
gawk -f $MTTPATH/trans/awk/lbl2sympar.awk | sort >> $1_sympar.r 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Modified mttroot/mtt/bin/trans/lbl_txt2tex from [0f96c4023e] to [d60cfba198].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.10  2000/12/28 12:32:06  peterg
## Put under RCS
##
## Revision 1.9  2000/11/16 13:11:06  peterg
## Included PAR and UNITS declarations
##
## Revision 1.8  1999/02/17 21:42:19  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2002/04/19 08:39:45  gawthrop
## Changed \# to # and \% to # to avoid warning in latest gawk version
##
## Revision 1.10  2000/12/28 12:32:06  peterg
## Put under RCS
##
## Revision 1.9  2000/11/16 13:11:06  peterg
## Included PAR and UNITS declarations
##
## Revision 1.8  1999/02/17 21:42:19  peterg
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

#Create the alias file complete with headers.
echo "% Label summary file ($1_lbl.tex)" > $1_lbl.tex
echo "% Generated by MTT at `date`" >> $1_lbl.tex

#Write out the Description
    grep '[%|#]SUMMARY' $1_lbl.txt | sed 's/_/\\_/g'  |\
    awk '{
           printf("\\paragraph{System %s:",$2);
           for (i=3;i<=NF;i++) printf("%s ",$i); print ""
           print  "}"
         }' >> $1_lbl.tex
    grep '[%|#]DESCRIPTION' $1_lbl.txt | sed 's/_/\\_/g'  |\
    awk '{
           for (i=2;i<=NF;i++) printf("%s ",$i); print ""
         }' >> $1_lbl.tex

#Write out the aliases
cat <<EOF >> $1_lbl.tex
\paragraph{Interface information:}
\begin{description}
EOF
    grep '[%|#]ALIAS' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
      N=split($2,a,"|");
      for (i=1;i<=N;i++){
        if (match(a[i],"\\$")>0){
          printf("\\item [Parameter \\%s] represents actual parameter ",a[i])
        }
        else if (match($3,"/")>0){
          printf("\\item [Component %s]  is in library ",a[i])







|





|









|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

#Create the alias file complete with headers.
echo "% Label summary file ($1_lbl.tex)" > $1_lbl.tex
echo "% Generated by MTT at `date`" >> $1_lbl.tex

#Write out the Description
    grep '[%|#]SUMMARY' $1_lbl.txt | sed 's/_/\\_/g'  |\
    gawk '{
           printf("\\paragraph{System %s:",$2);
           for (i=3;i<=NF;i++) printf("%s ",$i); print ""
           print  "}"
         }' >> $1_lbl.tex
    grep '[%|#]DESCRIPTION' $1_lbl.txt | sed 's/_/\\_/g'  |\
    gawk '{
           for (i=2;i<=NF;i++) printf("%s ",$i); print ""
         }' >> $1_lbl.tex

#Write out the aliases
cat <<EOF >> $1_lbl.tex
\paragraph{Interface information:}
\begin{description}
EOF
    grep '[%|#]ALIAS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
      N=split($2,a,"|");
      for (i=1;i<=N;i++){
        if (match(a[i],"\\$")>0){
          printf("\\item [Parameter \\%s] represents actual parameter ",a[i])
        }
        else if (match($3,"/")>0){
          printf("\\item [Component %s]  is in library ",a[i])
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

#Write out the VARS
cat <<EOF >> $1_lbl.tex
\paragraph{Variable declarations:}
\begin{description}
EOF
    grep '[%|#][V|P]AR' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
        printf("\\item %s\n",$2)
      }
    END{if (NR==0) print "\\item This component has no PAR declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF


#Write out the UNITS
cat <<EOF >> $1_lbl.tex
\paragraph{Units declarations:}
\begin{description}
EOF
    grep '[%|#]UNITS' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
        printf("\\item [Port %s] has domain %s\n",$2, $3)
	printf("\\begin{description}\n")
        printf("\\item [Effort units] %s\n",$4)
        printf("\\item [Flow units] %s\n",$5)
	printf("\\end{description}\n")
      }
    END{if (NR==0) print "\\item This component has no UNITs declarations"







|















|







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

#Write out the VARS
cat <<EOF >> $1_lbl.tex
\paragraph{Variable declarations:}
\begin{description}
EOF
    grep '[%|#][V|P]AR' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item %s\n",$2)
      }
    END{if (NR==0) print "\\item This component has no PAR declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF


#Write out the UNITS
cat <<EOF >> $1_lbl.tex
\paragraph{Units declarations:}
\begin{description}
EOF
    grep '[%|#]UNITS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item [Port %s] has domain %s\n",$2, $3)
	printf("\\begin{description}\n")
        printf("\\item [Effort units] %s\n",$4)
        printf("\\item [Flow units] %s\n",$5)
	printf("\\end{description}\n")
      }
    END{if (NR==0) print "\\item This component has no UNITs declarations"

Modified mttroot/mtt/bin/trans/m2dat from [943f13e957] to [f209734a96].

11
12
13
14
15
16
17



18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################

echo Creating $1.dat

awk '$1 ~ /[0-9]/ && NF>0 {print} ' <$1.m  >$1.dat








>
>
>




|

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1996/08/14 08:36:16  peter
## Initial revision
##
###############################################################

echo Creating $1.dat

gawk '$1 ~ /[0-9]/ && NF>0 {print} ' <$1.m  >$1.dat

Modified mttroot/mtt/bin/trans/make_ode2odes from [ca4305faeb] to [caab05287b].

1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.68  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.67  2002/04/09 12:04:21  geraint
## Replaced ios:: with std::ios:: for g++-3.0 compatability.
##











>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.69  2002/04/17 13:46:58  geraint
## #include <fstream> for -oct as well as -cc.
##
## Revision 1.68  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.67  2002/04/09 12:04:21  geraint
## Replaced ios:: with std::ios:: for g++-3.0 compatability.
##
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405

EOF
} # make_m

make_cc() 
{
# get octave version
case `$MATRIX --version | awk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	feval_header=toplev.h
	save_ascii_data_function=save_ascii_data
	;;
    1) # development
	vector_value=column_vector_value







|







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408

EOF
} # make_m

make_cc() 
{
# get octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	feval_header=toplev.h
	save_ascii_data_function=save_ascii_data
	;;
    1) # development
	vector_value=column_vector_value

Modified mttroot/mtt/bin/trans/makesubs from [070575132f] to [409b406455].

11
12
13
14
15
16
17



18
19
20
21
22
23
24


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  2000/12/28 09:09:52  peterg
## Initial revision
##
##
###############################################################

#Inform user







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.1  2000/12/28 09:09:52  peterg
## Initial revision
##
##
###############################################################

#Inform user
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## NB the following messes up the expansion switch ????
cat >> $1_subs.r <<EOF
% Ordering switch
ORDER
EOF

# Symbolic params first
awk '{
  print $1 ","
}' < $1_sympar.txt >> $1_subs.r

# Then states
Nx=`mtt_getsize $1 x` # States

awk 'END{
  for (k=1;k<Nx;k++){
    printf("mttx%i,\n", k);
  }
    printf("mttx%i;\n", Nx);
  
}' Nx=$Nx < $1_sympar.txt >> $1_subs.r








|






|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## NB the following messes up the expansion switch ????
cat >> $1_subs.r <<EOF
% Ordering switch
ORDER
EOF

# Symbolic params first
gawk '{
  print $1 ","
}' < $1_sympar.txt >> $1_subs.r

# Then states
Nx=`mtt_getsize $1 x` # States

gawk 'END{
  for (k=1;k<Nx;k++){
    printf("mttx%i,\n", k);
  }
    printf("mttx%i;\n", Nx);
  
}' Nx=$Nx < $1_sympar.txt >> $1_subs.r

Modified mttroot/mtt/bin/trans/modpar_txt2r from [0459392ef4] to [46d5afca36].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$



## Revision 1.1  2001/04/02 08:19:18  gawthrop
## Translates modulated parameters into reduce
##
###############################################################

# Inform user
echo Creating $1_modpar.r

#Create the modpar file complete with headers.
echo "% Modpar file ($1_modpar.r)" > $1_modpar.r
echo "% Generated by MTT at `date`" >> $1_modpar.r

parameters=`strip_comments < $1_modpar.txt |  cut -f1`
inputs=`strip_comments < $1_modpar.txt |  cut -f2`


for parameter in $parameters; do
    grep $1_${parameter}_ $1_struc.txt |\
    awk 'BEGIN{
               name["input"] = "u";
               name["output"] = "y";
               name["state"] = "x";
               name["nonstate"] = "z";
	      }
	 {
           printf("%s := mtt%s(%i,1);\n", parameter, name[$1],  $2)
         }' parameter=$parameter >> $1_modpar.r
done







>
>
>


















|









10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2001/04/02 08:19:18  gawthrop
## Translates modulated parameters into reduce
##
###############################################################

# Inform user
echo Creating $1_modpar.r

#Create the modpar file complete with headers.
echo "% Modpar file ($1_modpar.r)" > $1_modpar.r
echo "% Generated by MTT at `date`" >> $1_modpar.r

parameters=`strip_comments < $1_modpar.txt |  cut -f1`
inputs=`strip_comments < $1_modpar.txt |  cut -f2`


for parameter in $parameters; do
    grep $1_${parameter}_ $1_struc.txt |\
    gawk 'BEGIN{
               name["input"] = "u";
               name["output"] = "y";
               name["state"] = "x";
               name["nonstate"] = "z";
	      }
	 {
           printf("%s := mtt%s(%i,1);\n", parameter, name[$1],  $2)
         }' parameter=$parameter >> $1_modpar.r
done

Modified mttroot/mtt/bin/trans/mtt2reps_txt from [38143b0d0c] to [14bdc5a92e].

1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
#! /bin/sh

# mtt2reps_txt: Gives a tabular listing of representations and languages
# P J Gawthrop July 1998, October 1998
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.11  2001/04/28 03:38:36  geraint
## Refined selection of matching patterns - checks for exact match.
##
## Revision 1.10  2000/09/14 07:54:13  peterg
## Removed -e option in echo
##
## Revision 1.9  2000/04/05 08:34:30  peterg











>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

# mtt2reps_txt: Gives a tabular listing of representations and languages
# P J Gawthrop July 1998, October 1998
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/07/24 04:18:32  gawthrop
## Fixed problem with shell expanding * (used as important rep marker)
##
## Revision 1.11  2001/04/28 03:38:36  geraint
## Refined selection of matching patterns - checks for exact match.
##
## Revision 1.10  2000/09/14 07:54:13  peterg
## Removed -e option in echo
##
## Revision 1.9  2000/04/05 08:34:30  peterg
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

## List of all representations (deleting the *)
representations=`grep '#SUMMARY' $MTTPATH/mtt | awk '{sub("\*","+"); print $2'} | sort -u `


for rep in $representations ; do
    Rep=`echo $rep | tr '+' '*'`
    ## Title should be same for all languages -- but extract the first non-empty version
      title=`grep '#SUMMARY' $MTTPATH/mtt | tr '\t' ' ' | grep "[ *]$Rep[ *]" | \
      awk  '{if (NF>2) {for (i=3;i<NF-1;i++) printf("%s ",$i); NF1=NF-1; printf("%s\n",$NF1)}}' |\
      head -1`
      
    language=`grep '#SUMMARY' $MTTPATH/mtt |\
      awk '
        {
          if (index(rep,"*")==length(rep)){
            if ($2==rep) print $NF
          }
          else
            if (($2==rep)||($2==sprintf("%s*",rep))) print $NF
        }' rep=$Rep |\







|






|



|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

## List of all representations (deleting the *)
representations=`grep '#SUMMARY' $MTTPATH/mtt | gawk '{sub("\*","+"); print $2'} | sort -u `


for rep in $representations ; do
    Rep=`echo $rep | tr '+' '*'`
    ## Title should be same for all languages -- but extract the first non-empty version
      title=`grep '#SUMMARY' $MTTPATH/mtt | tr '\t' ' ' | grep "[ *]$Rep[ *]" | \
      gawk  '{if (NF>2) {for (i=3;i<NF-1;i++) printf("%s ",$i); NF1=NF-1; printf("%s\n",$NF1)}}' |\
      head -1`
      
    language=`grep '#SUMMARY' $MTTPATH/mtt |\
      gawk '
        {
          if (index(rep,"*")==length(rep)){
            if ($2==rep) print $NF
          }
          else
            if (($2==rep)||($2==sprintf("%s*",rep))) print $NF
        }' rep=$Rep |\

Modified mttroot/mtt/bin/trans/mtt_error from [8a6269ba81] to [36e03ad5ab].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.7  1998/03/06 17:14:09  peterg
## Cospetic change to message
##
## Revision 1.6  1998/03/05 10:17:41  peterg
## Cosmetic change
##
## Revision 1.5  1998/03/05 10:14:37  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/12/28 12:34:49  peterg
## Put under RCS
##
## Revision 1.7  1998/03/06 17:14:09  peterg
## Cospetic change to message
##
## Revision 1.6  1998/03/05 10:17:41  peterg
## Cosmetic change
##
## Revision 1.5  1998/03/05 10:14:37  peterg
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Initial revision
#
###############################################################

error_file=$1;

# Test for errors and print if any
err_length=`wc -c <$error_file | awk '{print $1}'`
if [ "$err_length" != "0" ]
then
  echo "INFORMATION: An MTT transformation has generated the following messages"
#  echo "             (which may not be important)"
  cat $error_file
  exit 1
else
  exit 0
fi







|


|






40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Initial revision
#
###############################################################

error_file=$1;

# Test for errors and print if any
err_length=`wc -c <$error_file | gawk '{print $1}'`
if [ "$err_length" != "0" ]
then
    echo "INFORMATION: An MTT transformation has generated the following messages"
#  echo "             (which may not be important)"
  cat $error_file
  exit 1
else
  exit 0
fi

Modified mttroot/mtt/bin/trans/mtt_get_subsystems from [f462408545] to [368cf1b1dc].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

subsystems=`sh $1_sub.sh "echo grep " " $1_abg.m" |\
            sh | awk -F '.' '{print $3}'`

if [ -n "$strip" ]; then
      echo $subsystems  
   else
      for subsystem in $subsystems; do
	# echo -n $1_$subsystem' '
        echo $1_$subsystem #| awk '{printf("%s ",$1)}'
    done
    echo
fi

















|






|













10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

subsystems=`sh $1_sub.sh "echo grep " " $1_abg.m" |\
            sh | gawk -F '.' '{print $3}'`

if [ -n "$strip" ]; then
      echo $subsystems  
   else
      for subsystem in $subsystems; do
	# echo -n $1_$subsystem' '
        echo $1_$subsystem #| gawk '{printf("%s ",$1)}'
    done
    echo
fi










Modified mttroot/mtt/bin/trans/mtt_getsize from [ca21605aad] to [59fbe2a583].

40
41
42
43
44
45
46
47
48
49
50
fi

## The original version for external sizes.
if [ "$2" = "xx" ]; then
  n=`mtt_getsize $1 x`
  N=`echo "$n * $n" | bc` 
else
  N=`grep "MTTN$2 " <$1_def.r | awk '{print $3}' | sed 's/;//'`
fi

echo $N







|



40
41
42
43
44
45
46
47
48
49
50
fi

## The original version for external sizes.
if [ "$2" = "xx" ]; then
  n=`mtt_getsize $1 x`
  N=`echo "$n * $n" | bc` 
else
  N=`grep "MTTN$2 " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
fi

echo $N

Modified mttroot/mtt/bin/trans/mtt_header from [83dcd3c682] to [6c32b8d392].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.40  2002/04/17 16:23:59  geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).







>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##
## Revision 1.40  2002/04/17 16:23:59  geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
if [ -z "$system" ]; then
  echo 'Usage: mtt_header sys rep lang [stdin]'
  exit
fi


# get octave version
octave_development=`octave --version | awk '{print $4}' | awk -F\. '{print $2}'`
case `$MATRIX --version | awk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	;;
    1) # development
	vector_value=column_vector_value
	;;
    *)







|
|







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
if [ -z "$system" ]; then
  echo 'Usage: mtt_header sys rep lang [stdin]'
  exit
fi


# get octave version
octave_development=`octave --version | gawk '{print $4}' | gawk -F\. '{print $2}'`
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	;;
    1) # development
	vector_value=column_vector_value
	;;
    *)
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
get_sizes()
    {
    Nx=`mtt_getsize $system x` # States
    Nxx=`mtt_getsize $system xx` # States x States
    Nu=`mtt_getsize $system u` # Inputs 
    Ny=`mtt_getsize $system y` # Outputs 
    Nyz=`mtt_getsize $system yz` # Zero outputs
    ##Npar=`wc -l $system\_sympar.txt | awk '{print $1}'`
    }

zero_matrices()
{
## Set matrices to zero
echo
 ## echo '## Set matrices to zero'







|







444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
get_sizes()
    {
    Nx=`mtt_getsize $system x` # States
    Nxx=`mtt_getsize $system xx` # States x States
    Nu=`mtt_getsize $system u` # Inputs 
    Ny=`mtt_getsize $system y` # Outputs 
    Nyz=`mtt_getsize $system yz` # Zero outputs
    ##Npar=`wc -l $system\_sympar.txt | gawk '{print $1}'`
    }

zero_matrices()
{
## Set matrices to zero
echo
 ## echo '## Set matrices to zero'
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
    grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
    awk '{ 
          if (match($1,dummy)==1)
             print $1
         }' dummy=$dummy >> mtt_dummies
done

dummy_list=`sort -u mtt_dummies`








|







498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
    grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
    gawk '{ 
          if (match($1,dummy)==1)
             print $1
         }' dummy=$dummy >> mtt_dummies
done

dummy_list=`sort -u mtt_dummies`

521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
declare_switches ()
{
cat <<EOF

$Lc  Declarations of switches $Rc
EOF
 strip_comments <${system}_switch.txt |\
 awk '{printf("  double %s_logic = 0;\n", tolower($1))}' 
} # declare_switches

declare_vars()
{
# Grab the names
names=`awk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`

# Comments
cat <<EOF

$Lc  Declarations for $1 names $Rc
EOF
# Declarations







|





|







524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
declare_switches ()
{
cat <<EOF

$Lc  Declarations of switches $Rc
EOF
 strip_comments <${system}_switch.txt |\
 gawk '{printf("  double %s_logic = 0;\n", tolower($1))}' 
} # declare_switches

declare_vars()
{
# Grab the names
names=`gawk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`

# Comments
cat <<EOF

$Lc  Declarations for $1 names $Rc
EOF
# Declarations
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
get_field ()
{ # parse comma separated string
    s=${1:-""}					# comma separated string
    i=${2:-0}					# field number in string

    if [ 0 -eq ${i} ]; then			# return number of fields
	echo ${s} |\
	awk -F\, '{ print NF }'
    else					# return ith field
	echo ${s} |\
	awk -F\, -v i=${i} '{ print $i }'
    fi
}


get_extra_fields ()
{ # return list of words in s2 and not in s1
    s1=${1:-""}					# comma separated list







|


|







675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
get_field ()
{ # parse comma separated string
    s=${1:-""}					# comma separated string
    i=${2:-0}					# field number in string

    if [ 0 -eq ${i} ]; then			# return number of fields
	echo ${s} |\
	gawk -F\, '{ print NF }'
    else					# return ith field
	echo ${s} |\
	gawk -F\, -v i=${i} '{ print $i }'
    fi
}


get_extra_fields ()
{ # return list of words in s2 and not in s1
    s1=${1:-""}					# comma separated list

Modified mttroot/mtt/bin/trans/mtt_langname from [c54b9eac8f] to [080d1d07c0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_langname

# Returns the language name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | awk -F '.' '{print $2}'













|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_langname

# Returns the language name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '.' '{print $2}'

Modified mttroot/mtt/bin/trans/mtt_m2p from [82311a7db2] to [5aa349fe2c].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.66  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.65  2001/02/09 02:56:46  geraint
## Translate some binary operators
## Allows use of ! in logic.txt
##







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2002/04/18 17:02:15  gawthrop
## foo=zeros(3,1) translated as zero_state(foo,3)
##
## Revision 1.66  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.65  2001/02/09 02:56:46  geraint
## Translate some binary operators
## Allows use of ! in logic.txt
##
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
##
###############################################################



# Set up variables
args=`echo $1 | sed 's/_/ /' | sed 's/\./ /'`
Sys=`echo $args  | awk '{print $1}'`
sys=`echo $Sys  | awk '{print tolower($1)}'`
rep=`echo $args  | awk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method







|
|
|







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
##
###############################################################



# Set up variables
args=`echo $1 | sed 's/_/ /' | sed 's/\./ /'`
Sys=`echo $args  | gawk '{print $1}'`
sys=`echo $Sys  | gawk '{print tolower($1)}'`
rep=`echo $args  | gawk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nxx=`mtt_getsize $Sys xx` # States x States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | awk '{print $1}'`


#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading







|







254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nxx=`mtt_getsize $Sys xx` # States x States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`


#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
	echo "    AA,mtte                     : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open_switches  : StateVector;"
	echo "    numparfile, statefile, simparfile  : TEXT;"
        strip_comments <${Sys}_switch.txt |\
          awk '{printf("%s_logic : REAL;\n", tolower($1))}' 
	echo ""
        mtt_txt2declare $Sys sympar p
        mtt_txt2declare $Sys struc p
        ;;
#    switchopen)
#	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
#	echo "VAR"







|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
	echo "    AA,mtte                     : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open_switches  : StateVector;"
	echo "    numparfile, statefile, simparfile  : TEXT;"
        strip_comments <${Sys}_switch.txt |\
          gawk '{printf("%s_logic : REAL;\n", tolower($1))}' 
	echo ""
        mtt_txt2declare $Sys sympar p
        mtt_txt2declare $Sys struc p
        ;;
#    switchopen)
#	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
#	echo "VAR"
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457

cat $Sys_rep.m |\
grep -v 'Remove in mtt_m2p'  |\
grep -v '^[ ]*function'  |\
grep -v '^[ ]*endfunction'  |\
grep -v 'MTT_data'  |\
sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\
awk -F# '{printf("%s",$1) 
          if (NF>1) printf("{* %s *}", $2)
          printf("\n") 
         }' |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)/\2(\1)/" |\
sed "s/$space\($non_space\)$spaces=${spaces}zeros(\([0-9]*\),1)/zero_state(\1,\2)/" |\
sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/,)/)/" |\
fix_operators |\
awk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)







|










|







435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460

cat $Sys_rep.m |\
grep -v 'Remove in mtt_m2p'  |\
grep -v '^[ ]*function'  |\
grep -v '^[ ]*endfunction'  |\
grep -v 'MTT_data'  |\
sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\
gawk -F# '{printf("%s",$1) 
          if (NF>1) printf("{* %s *}", $2)
          printf("\n") 
         }' |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)/\2(\1)/" |\
sed "s/$space\($non_space\)$spaces=${spaces}zeros(\([0-9]*\),1)/zero_state(\1,\2)/" |\
sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/,)/)/" |\
fix_operators |\
gawk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)

Modified mttroot/mtt/bin/trans/mtt_make_menu from [b7552da8d5] to [7786b633df].

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
EOF

for sys in $systems; do
    echo .sys.sys add radio -label "$sys"  -command {set system "$sys"} 
done

# Create the options menu
mtt |  awk '{
  if (Options) {
    option=substr($1,2);
    label="";
    for (i=2;i<=NF;i++)
      label = sprintf("%s %s",label,$i);
    printf(".opt.opt add check -label \"%s (-%s)\" -variable %s -command {set args \"$args -%s\" }\n", label, option, option, option); 
  }







|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
EOF

for sys in $systems; do
    echo .sys.sys add radio -label "$sys"  -command {set system "$sys"} 
done

# Create the options menu
mtt |  gawk '{
  if (Options) {
    option=substr($1,2);
    label="";
    for (i=2;i<=NF;i++)
      label = sprintf("%s %s",label,$i);
    printf(".opt.opt add check -label \"%s (-%s)\" -variable %s -command {set args \"$args -%s\" }\n", label, option, option, option); 
  }

Modified mttroot/mtt/bin/trans/mtt_make_sim from [d2886556d7] to [0eacf885ca].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.6  2000/05/17 17:20:49  peterg
## Fixed bugs with ny>1. Could be made faster by not generating y when
## y_sim >1
##
## Revision 1.5  2000/05/17 16:01:42  peterg
## Fixed bug for n_y>1
##







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/05/19 17:47:35  peterg
## Fixed bug in oct version but still needs proper check
##
## Revision 1.6  2000/05/17 17:20:49  peterg
## Fixed bugs with ny>1. Could be made faster by not generating y when
## y_sim >1
##
## Revision 1.5  2000/05/17 16:01:42  peterg
## Fixed bug for n_y>1
##
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    odeo=odeo
fi

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | awk '{print $1}'`

# Header
lang_header -noglobals $1 sim m 'x0,u,t,par,sensitivities' '[y,ys]' > $1_sim.m

cat >> $1_sim.m <<EOF
##  tick=time; 
  if nargin<5







|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    odeo=odeo
fi

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`

# Header
lang_header -noglobals $1 sim m 'x0,u,t,par,sensitivities' '[y,ys]' > $1_sim.m

cat >> $1_sim.m <<EOF
##  tick=time; 
  if nargin<5

Modified mttroot/mtt/bin/trans/mtt_make_sympar from [fab900c9ec] to [7c246fcfb8].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.9  2001/07/23 05:16:39  geraint
## Simple filter for Reduce reserved words in sympar.
##
## Revision 1.8  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.7  2001/04/13 07:14:12  geraint







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2001/07/28 21:10:18  geraint
## Generate warning instead of error if reserved word used.
##
## Revision 1.9  2001/07/23 05:16:39  geraint
## Simple filter for Reduce reserved words in sympar.
##
## Revision 1.8  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.7  2001/04/13 07:14:12  geraint
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
sys=$1 # System name
filename=$1_sympar.txt
# Inform user
echo Creating $filename

# Create list of all sympars including those that are aliased
sh $1_type.sh 'echo ' ' ' ' ' |\
awk '{printf("abg2sympar_m2txt %s %s\n ", $1, $2)}' |\
sh | sort -u > mtt_all_sympar.txt

# Sort the aliased list
mtt_strip_args < $1_aliased.txt | sort -u  > mtt_aliased_sort.txt

# Create list of unwanted stuff
cat  mtt_aliased_sort.txt> mtt_unwanted.txt

notvar="[%|#]NOT[V|P]AR";
sh $1_type.sh 'strip_notvars.sh ' ' ' ' mtt_unwanted.txt'

sort -u mtt_unwanted.txt > mtt_unwanted_sort.txt

# Compare it with the aliased list and show the differences
diff mtt_all_sympar.txt mtt_unwanted_sort.txt |\
awk '{if ($1=="<") printf("%s\t%s\n", $2,$3)}' > mtt_sympar.txt

# Assume same name in different system is the same
awk '{
    if ($1==name){
	sysname[i++]=$2
    }
    
    if ($1!=name){
        if (length(name)>0){
          printf("%s\t",name)







|















|


|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
sys=$1 # System name
filename=$1_sympar.txt
# Inform user
echo Creating $filename

# Create list of all sympars including those that are aliased
sh $1_type.sh 'echo ' ' ' ' ' |\
gawk '{printf("abg2sympar_m2txt %s %s\n ", $1, $2)}' |\
sh | sort -u > mtt_all_sympar.txt

# Sort the aliased list
mtt_strip_args < $1_aliased.txt | sort -u  > mtt_aliased_sort.txt

# Create list of unwanted stuff
cat  mtt_aliased_sort.txt> mtt_unwanted.txt

notvar="[%|#]NOT[V|P]AR";
sh $1_type.sh 'strip_notvars.sh ' ' ' ' mtt_unwanted.txt'

sort -u mtt_unwanted.txt > mtt_unwanted_sort.txt

# Compare it with the aliased list and show the differences
diff mtt_all_sympar.txt mtt_unwanted_sort.txt |\
gawk '{if ($1=="<") printf("%s\t%s\n", $2,$3)}' > mtt_sympar.txt

# Assume same name in different system is the same
gawk '{
    if ($1==name){
	sysname[i++]=$2
    }
    
    if ($1!=name){
        if (length(name)>0){
          printf("%s\t",name)
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
        }
        printf("\n")

}' < mtt_sympar.txt >$filename

reserved_words=`\
    cat ${MTT_LIB}/reduce/reserved_words.txt	|\
    awk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
sympar_words=`\
    cat ${filename}				|\
    cut -f1					|\
    awk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
flag=0
for reserved_word in ${reserved_words}; do
    for sympar_word in ${sympar_words}; do
	if [ ${sympar_word} = ${reserved_word} ]; then
	    echo ""
	    echo "*** MTT Warning:"
	    echo "    ${sympar_word} is reserved (Reduce)"
	    echo ""
	fi
    done
done







|




|












102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
        }
        printf("\n")

}' < mtt_sympar.txt >$filename

reserved_words=`\
    cat ${MTT_LIB}/reduce/reserved_words.txt	|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
sympar_words=`\
    cat ${filename}				|\
    cut -f1					|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
flag=0
for reserved_word in ${reserved_words}; do
    for sympar_word in ${sympar_words}; do
	if [ ${sympar_word} = ${reserved_word} ]; then
	    echo ""
	    echo "*** MTT Warning:"
	    echo "    ${sympar_word} is reserved (Reduce)"
	    echo ""
	fi
    done
done

Modified mttroot/mtt/bin/trans/mtt_mend_lines from [b94de50d4f] to [0579d4ac5f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# Copyright (C) 2000 by Peter J. Gawthrop

# Fixes broken lines from reduce.

#sed 's/[^#]\(.*\)[^;]$/\1\\/' 

awk '{
  if ((match($1,"#")==0)&&(match($1,"global")==0)&&(match($1,"endfunction")==0)) {
    if(match($0,";")!=length($0))
      printf("%s \\\n",$0)
    else
      print $0
  }
  else print $0
   
}'








|









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# Copyright (C) 2000 by Peter J. Gawthrop

# Fixes broken lines from reduce.

#sed 's/[^#]\(.*\)[^;]$/\1\\/' 

gawk '{
  if ((match($1,"#")==0)&&(match($1,"global")==0)&&(match($1,"endfunction")==0)) {
    if(match($0,";")!=length($0))
      printf("%s \\\n",$0)
    else
      print $0
  }
  else print $0
   
}'

Modified mttroot/mtt/bin/trans/mtt_multi from [c98cabcb91] to [cdd0534fee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

# Does mutiple commands down the hierarchy

command=$1
system=$2
rep=$3
lang=$4
relative_level=$5

current_level=`echo $system | awk '{N=split($1,foo,"_"); print N-1}'`

if [ -z "$relative_level" ]; then
  relative_level=0;    
fi

mtt_xargs.sh "ls" "$2*_$3.$4"  |\
awk '{
  level=split($1,foo,"_")-2;
  maxlevel = current_level +  relative_level;
  if (level<=maxlevel) print command, $0, "&";
'} command=$command relative_level=$relative_level current_level=$current_level










|






|




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

# Does mutiple commands down the hierarchy

command=$1
system=$2
rep=$3
lang=$4
relative_level=$5

current_level=`echo $system | gawk '{N=split($1,foo,"_"); print N-1}'`

if [ -z "$relative_level" ]; then
  relative_level=0;    
fi

mtt_xargs.sh "ls" "$2*_$3.$4"  |\
gawk '{
  level=split($1,foo,"_")-2;
  maxlevel = current_level +  relative_level;
  if (level<=maxlevel) print command, $0, "&";
'} command=$command relative_level=$relative_level current_level=$current_level

Modified mttroot/mtt/bin/trans/mtt_name2array from [6eeef7468b] to [3800132da3].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
case $2 in
    numpar)
        name=mttpar
	cat $1_sympar.txt>mtt_infile
	;;
    state)
        name=mttx
	awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    input)
        name=mttu
	awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    *)
	echo Repesentation $2 not supported
esac

case $3 in
    zero)
	  strip_comments <mtt_infile | grep "$filter"  |\
          awk '{
          i++; printf("  %s = 0.0;\n", tolower($1));
          }'
	;;
    set)
	  strip_comments <mtt_infile  |\
         awk '{
           i++; printf("  %s(%i)\t= %s;\n", name, i, tolower($1));
         }' name=$name
        ;;
    *)
         strip_comments <mtt_infile  |\
         awk '{
           i++; printf("  %s \t= %s(%i);\n", tolower($1), name, i);
         }' name=$name
	;;
esac











|




|









|





|





|








13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
case $2 in
    numpar)
        name=mttpar
	cat $1_sympar.txt>mtt_infile
	;;
    state)
        name=mttx
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    input)
        name=mttu
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    *)
	echo Repesentation $2 not supported
esac

case $3 in
    zero)
	  strip_comments <mtt_infile | grep "$filter"  |\
          gawk '{
          i++; printf("  %s = 0.0;\n", tolower($1));
          }'
	;;
    set)
	  strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s(%i)\t= %s;\n", name, i, tolower($1));
         }' name=$name
        ;;
    *)
         strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s \t= %s(%i);\n", tolower($1), name, i);
         }' name=$name
	;;
esac




Modified mttroot/mtt/bin/trans/mtt_p2C from [15da882620] to [4c8ad0a9b3].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

# Find system constants
Nx=`mtt_getsize $1 x`
Nxx=`mtt_getsize $1 xx`
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

Npar=`wc -l $1_sympar.txt | awk '{print $1}'`


echo "PROCEDURE $1_$2;" > $1_$2.pas
echo "TYPE"             >>$1_$2.pas
echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"        >>$1_$2.pas
echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;" >>$1_$2.pas
echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;" >>$1_$2.pas
echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"        >>$1_$2.pas
echo "    OutputVector  = ARRAY[1..$Ny] OF REAL;"       >>$1_$2.pas
echo "    ParameterVector  = ARRAY[1..$Npar] OF REAL;"  >>$1_$2.pas


# Create the predefined vars
echo "VAR"     >>$1_$2.pas
awk '{
       printf("%s,", $1)
     }
     END{print "JUNK : REAL;"}'< $1_sympar.txt     >>$1_$2.pas

if [ "$2" = "ode2odes" ]; then
    first='PROCEDURE'
    awk '
    {
    if (writing) print $0;
    if (i++==0) writing=1
    if (match($1,"PROCEDURE")==1) writing=0;
    }'  < $1_$2.p >>$1_$2.pas
else
    first='BEGIN'

 # Convert VAR format in the headings
    awk 'BEGIN{writing=1}
    {
    if (match($1,"BEGIN")==1) writing=0;
    if (writing) print $0;
    }'  < $1_$2.p | \
    sed \
	-e 's/PROCEDURE [a-zA-Z_0-9]*(VAR/VAR/' \
	-e 's/PROCEDURE [a-zA-Z_0-9]*;//' \
	-e 's/REAL);/REAL;/' \
	-e 's/OutputVector);/OutputVector;/' \
	-e 's/ParameterVector);/ParameterVector;/' \
	>>$1_$2.pas
fi

# Write out the actual code until the begining of the procedure
awk 'BEGIN{writing=0}
{
  if (match($1,first)==1) writing=1;
  if (writing) print $0;
  if (match($1,begin)==1) writing=0;

}' begin=$begin first=$first   < $1_$2.p  >>$1_$2.pas

# Write out the parameters
echo {Parameters}   >>$1_$2.pas
awk '{
       printf("  %s \t:= mttpar[%i];\n", $1, ++i);
     }'< $1_sympar.txt  >>$1_$2.pas

# Write out the actual code from the end of the procedure
awk 'BEGIN{writing=0}
{
  if (writing) print $0;
  if (match($1,begin)==1) writing=1;
}' begin=$begin   < $1_$2.p  >>$1_$2.pas

#echo "Creating $1_$2.C"
p2c -o $1_$2.C $1_$2.pas > mtt_p2C.log 2>> mtt_p2C.log









|














|






|









|














|









|




|









21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

# Find system constants
Nx=`mtt_getsize $1 x`
Nxx=`mtt_getsize $1 xx`
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

Npar=`wc -l $1_sympar.txt | gawk '{print $1}'`


echo "PROCEDURE $1_$2;" > $1_$2.pas
echo "TYPE"             >>$1_$2.pas
echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"        >>$1_$2.pas
echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;" >>$1_$2.pas
echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;" >>$1_$2.pas
echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"        >>$1_$2.pas
echo "    OutputVector  = ARRAY[1..$Ny] OF REAL;"       >>$1_$2.pas
echo "    ParameterVector  = ARRAY[1..$Npar] OF REAL;"  >>$1_$2.pas


# Create the predefined vars
echo "VAR"     >>$1_$2.pas
gawk '{
       printf("%s,", $1)
     }
     END{print "JUNK : REAL;"}'< $1_sympar.txt     >>$1_$2.pas

if [ "$2" = "ode2odes" ]; then
    first='PROCEDURE'
    gawk '
    {
    if (writing) print $0;
    if (i++==0) writing=1
    if (match($1,"PROCEDURE")==1) writing=0;
    }'  < $1_$2.p >>$1_$2.pas
else
    first='BEGIN'

 # Convert VAR format in the headings
    gawk 'BEGIN{writing=1}
    {
    if (match($1,"BEGIN")==1) writing=0;
    if (writing) print $0;
    }'  < $1_$2.p | \
    sed \
	-e 's/PROCEDURE [a-zA-Z_0-9]*(VAR/VAR/' \
	-e 's/PROCEDURE [a-zA-Z_0-9]*;//' \
	-e 's/REAL);/REAL;/' \
	-e 's/OutputVector);/OutputVector;/' \
	-e 's/ParameterVector);/ParameterVector;/' \
	>>$1_$2.pas
fi

# Write out the actual code until the begining of the procedure
gawk 'BEGIN{writing=0}
{
  if (match($1,first)==1) writing=1;
  if (writing) print $0;
  if (match($1,begin)==1) writing=0;

}' begin=$begin first=$first   < $1_$2.p  >>$1_$2.pas

# Write out the parameters
echo {Parameters}   >>$1_$2.pas
gawk '{
       printf("  %s \t:= mttpar[%i];\n", $1, ++i);
     }'< $1_sympar.txt  >>$1_$2.pas

# Write out the actual code from the end of the procedure
gawk 'BEGIN{writing=0}
{
  if (writing) print $0;
  if (match($1,begin)==1) writing=1;
}' begin=$begin   < $1_$2.p  >>$1_$2.pas

#echo "Creating $1_$2.C"
p2c -o $1_$2.C $1_$2.pas > mtt_p2C.log 2>> mtt_p2C.log


Modified mttroot/mtt/bin/trans/mtt_p2cc from [7206315b5e] to [9cd1ab95be].

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#Extract Type info
echo '/* Types */'                >> $sys_rep.cc
grep typedef $sys_rep.C              >> $sys_rep.cc

#Extract the rep code converting [] to () and deleting mtt variables etc
#The awk part detects the begin and end of the relevant code.
echo "/* Representation $rep information */" >> $sys_rep.cc
awk '{
  if ( (match($1,"}")==1)&&(NF>1)) writing=0;
  if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0;
  if (match($1,"{")==1) writing=1;
}' <$sys_rep.C |\
sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\
sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc








|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#Extract Type info
echo '/* Types */'                >> $sys_rep.cc
grep typedef $sys_rep.C              >> $sys_rep.cc

#Extract the rep code converting [] to () and deleting mtt variables etc
#The awk part detects the begin and end of the relevant code.
echo "/* Representation $rep information */" >> $sys_rep.cc
gawk '{
  if ( (match($1,"}")==1)&&(NF>1)) writing=0;
  if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0;
  if (match($1,"{")==1) writing=1;
}' <$sys_rep.C |\
sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\
sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc

Modified mttroot/mtt/bin/trans/mtt_p2m from [2ad4e8ad5c] to [a6fa5071b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /bin/sh
## Chages the Pascal output from gentran to octave form
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/begin$//' |\
sed 's/end$//' |\
sed 's/end;$/;/' |\
sed 's/\[\([0-9,]*\)\]/(\1)/g' |\
sed 's/:=/ = /' |\
sed 's/\*\*/\^/g' |\
sed 's/mtt\([a-z]\)\([a-z]*\)\([0-9]\)\([0-9]*\)/mtt\1\2(\3\4)/g' |\
awk '{
  sub(/^[\ ]*/, "", $0)
  sub(/\$$/, ";", $0)
  
  if (match($NF,"[;#.%]$")==0){
    Previous[++i] = $0
  }
  else {
    for (j=1;j<=i;j++) printf("%s", Previous[j]);
    printf("%s\n", $0) 
    i=0;
  }
}' |\
sed 's/#/%/g'











|













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /bin/sh
## Chages the Pascal output from gentran to octave form
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/begin$//' |\
sed 's/end$//' |\
sed 's/end;$/;/' |\
sed 's/\[\([0-9,]*\)\]/(\1)/g' |\
sed 's/:=/ = /' |\
sed 's/\*\*/\^/g' |\
sed 's/mtt\([a-z]\)\([a-z]*\)\([0-9]\)\([0-9]*\)/mtt\1\2(\3\4)/g' |\
gawk '{
  sub(/^[\ ]*/, "", $0)
  sub(/\$$/, ";", $0)
  
  if (match($NF,"[;#.%]$")==0){
    Previous[++i] = $0
  }
  else {
    for (j=1;j<=i;j++) printf("%s", Previous[j]);
    printf("%s\n", $0) 
    i=0;
  }
}' |\
sed 's/#/%/g'

Modified mttroot/mtt/bin/trans/mtt_pinclude from [dd55a77a76] to [2dabecc7a7].

1
2
3
4
5
6
7
8



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# pinclude - explicitly includes Pascal files - p2c has probs. doing this

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################



awk ' {
  if ( (match($1,"{\\$I")>0) || (match($1,"\\*\\$I")>0) ) {
    sub(/}/,"",$2); 
    command=sprintf("mtt_pinclude %s",$2); 
    system(command)
  }
  else{
  print $0
  }
  

}' <$1








>
>
>




|











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# pinclude - explicitly includes Pascal files - p2c has probs. doing this

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:56:46  peterg
## Put under RCS
##
###############################################################



gawk ' {
  if ( (match($1,"{\\$I")>0) || (match($1,"\\*\\$I")>0) ) {
    sub(/}/,"",$2); 
    command=sprintf("mtt_pinclude %s",$2); 
    system(command)
  }
  else{
  print $0
  }
  

}' <$1

Modified mttroot/mtt/bin/trans/mtt_repname from [35f149671a] to [bde7d0e306].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_repname

# Returns the representation name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | tr '.' '_' | awk -F '_' '{print $2}'













|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_repname

# Returns the representation name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | tr '.' '_' | gawk -F '_' '{print $2}'

Modified mttroot/mtt/bin/trans/mtt_strip_args from [9071d8da44] to [bcb8540542].

1
2
3
4
5
6
7
8
9
10
11
12
13



14
15
16
17
18
19
20
#! /bin/sh

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

# Bourne shell script: strip args
# Strips unwanted bits from a list of arguments
# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

## $Id$  ##
## $Log$



## Revision 1.5  2001/06/13 14:50:13  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.4  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.3  2000/10/17 12:33:13  peterg













>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh

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

# Bourne shell script: strip args
# Strips unwanted bits from a list of arguments
# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

## $Id$  ##
## $Log$
## Revision 1.6  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.5  2001/06/13 14:50:13  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.4  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.3  2000/10/17 12:33:13  peterg
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'


# This is the main transformation using gawk
tr $SEPS $REPS | \
awk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'


# This is the main transformation using gawk
tr $SEPS $REPS | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;

Modified mttroot/mtt/bin/trans/mtt_sysname from [61d88d20d5] to [4a73c625bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_sysname

# Returns the system name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | awk -F '_' '{print $1}'













|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh

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

# Bourne shell script: mtt_sysname

# Returns the system name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '_' '{print $1}'

Modified mttroot/mtt/bin/trans/mtt_txt2declare from [f28a37be46] to [63bdb9c744].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.1  2000/10/14 09:26:48  peterg
## Initial revision
##
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##








>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/10/14 09:32:50  peterg
## struc version only does state and input
##
## Revision 1.1  2000/10/14 09:26:48  peterg
## Initial revision
##
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

case $what in
    struc)
	strip_comments < $sys"_"$what".txt" | awk '{if (($1=="state")||($1=="input"))
                                                      print $4;
                                                   }' >mtt_names
	;;
    sympar)
      	strip_comments < $sys"_"$what".txt" | awk '{print $1}' >mtt_names
	;;
    *)
	echo Argument 2 must be struc or sympar
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
awk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);







|




|










|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

case $what in
    struc)
	strip_comments < $sys"_"$what".txt" | gawk '{if (($1=="state")||($1=="input"))
                                                      print $4;
                                                   }' >mtt_names
	;;
    sympar)
      	strip_comments < $sys"_"$what".txt" | gawk '{print $1}' >mtt_names
	;;
    *)
	echo Argument 2 must be struc or sympar
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);

Modified mttroot/mtt/bin/trans/mtt_txt2m from [4f5082efa1] to [cf306685c7].

11
12
13
14
15
16
17



18
19
20
21
22
23
24


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$



# %% Revision 1.15  2002/03/26 12:00:37  geraint
# %% Escaped characters to eliminate awk warnings.
# %%
# %% Revision 1.14  2001/07/13 04:54:04  geraint
# %% Branch merge: numerical-algebraic-solution back to main.
# %%
# %% Revision 1.13.4.2  2001/07/09 00:24:58  geraint







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.16  2002/04/18 17:51:11  gawthrop
# %% Put default values in _simpar.m in case of missing values in txt file
# %%
# %% Revision 1.15  2002/03/26 12:00:37  geraint
# %% Escaped characters to eliminate awk warnings.
# %%
# %% Revision 1.14  2001/07/13 04:54:04  geraint
# %% Branch merge: numerical-algebraic-solution back to main.
# %%
# %% Revision 1.13.4.2  2001/07/09 00:24:58  geraint
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
EOF
fi

# Write out the code from the txt file
echo >> $outfile
echo "## User defined code from $1_$2.txt" >> $outfile
cat  $1_$2.txt | strip_comments | grep -v METHOD |\
awk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];







|







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
EOF
fi

# Write out the code from the txt file
echo >> $outfile
echo "## User defined code from $1_$2.txt" >> $outfile
cat  $1_$2.txt | strip_comments | grep -v METHOD |\
gawk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];

Modified mttroot/mtt/bin/trans/mtt_update from [da39fd9946] to [9bbb28550a].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.15  2000/10/17 09:53:05  peterg
## More on logic rep
##
## Revision 1.14  2000/10/17 08:36:56  peterg
## Included logic rep.
##
## Revision 1.13  2000/10/15 09:27:13  peterg







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.16  2000/10/17 13:45:18  peterg
## split up state and input - different defaults
##
## Revision 1.15  2000/10/17 09:53:05  peterg
## More on logic rep
##
## Revision 1.14  2000/10/17 08:36:56  peterg
## Included logic rep.
##
## Revision 1.13  2000/10/15 09:27:13  peterg
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	    default='1.0'
	;;
    input)
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='1.0'
         ;;
    state)
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='0.0'
         ;;
    logic) 
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            awk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='1.0'
	;;
    *)
	    echo Representation $rep not implemented
	    exit
esac

# Create a string containing the variables
if [ -f "$textfile" ]; then
  # Inform User
  echo Checking $textfile
else
  echo Creating $textfile
  mtt_header $sys $rep $lang > $textfile 
  info=`cut -f1 $infofile | sort`
  for new in $info; do
    echo $new $default  |\
    awk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
  done
  exit    
fi

# Remove tmp files
rm -f mtt_in_text mtt_in_info

# Strip files
strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
strip_comments <$moreinfofile  | tr 'A-Z' 'a-z' >mtt_moreinfo

# Use awk to check file
awk '{
  if (FILENAME=="mtt_text") {
    gsub("[\t ]" ,""); # Remove whitespace
    split($0,a,"=");
    text[a[1]] = a[2];
  }
  if (FILENAME=="mtt_info"){
     info[$1] = default;







|









|









|



















|













|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	    default='1.0'
	;;
    input)
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='1.0'
         ;;
    state)
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='0.0'
         ;;
    logic) 
	    lang=txt
	    textfile=$1_$2.$lang
	    infofile=mtt_list.$lang
	    moreinfofile=mtt_list_numpar.$lang
            gawk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
            <$1_struc.txt >$infofile
	    cat $infofile $1_sympar.$lang> $moreinfofile  
	    default='1.0'
	;;
    *)
	    echo Representation $rep not implemented
	    exit
esac

# Create a string containing the variables
if [ -f "$textfile" ]; then
  # Inform User
  echo Checking $textfile
else
  echo Creating $textfile
  mtt_header $sys $rep $lang > $textfile 
  info=`cut -f1 $infofile | sort`
  for new in $info; do
    echo $new $default  |\
    gawk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
  done
  exit    
fi

# Remove tmp files
rm -f mtt_in_text mtt_in_info

# Strip files
strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
strip_comments <$moreinfofile  | tr 'A-Z' 'a-z' >mtt_moreinfo

# Use awk to check file
gawk '{
  if (FILENAME=="mtt_text") {
    gsub("[\t ]" ,""); # Remove whitespace
    split($0,a,"=");
    text[a[1]] = a[2];
  }
  if (FILENAME=="mtt_info"){
     info[$1] = default;
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  }
  }'  default=$default mtt_text mtt_info mtt_moreinfo


if [ -z "$update" ]; then
  if [ -f "mtt_in_text" ]; then
    echo "The following variables are defined in $textfile, but do not exist:"
    sort mtt_in_text | awk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  if [ -f "mtt_in_info" ]; then
    echo "The following variables exist, but are not defined in $textfile:"
    sort mtt_in_info | awk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  exit    
fi
answered=''
if [ -f "mtt_in_text" ]; then
  in_text=`sort mtt_in_text`
  echo "The following variables are defined in $textfile, but do not exist:"
  sort mtt_in_text | awk '{printf("\t%s\n",$1)}'


  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)







|




|








|







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
  }
  }'  default=$default mtt_text mtt_info mtt_moreinfo


if [ -z "$update" ]; then
  if [ -f "mtt_in_text" ]; then
    echo "The following variables are defined in $textfile, but do not exist:"
    sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  if [ -f "mtt_in_info" ]; then
    echo "The following variables exist, but are not defined in $textfile:"
    sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  exit    
fi
answered=''
if [ -f "mtt_in_text" ]; then
  in_text=`sort mtt_in_text`
  echo "The following variables are defined in $textfile, but do not exist:"
  sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'


  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    esac
  done      
fi

answered=''
if [ -f "mtt_in_info" ]; then
  echo "The following variables exist, but are not defined in $textfile:"
  sort mtt_in_info | awk '{printf("\t%s\n",$1)}'

  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
            in_info=`sort mtt_in_info`
 	    for new in $in_info; do
                echo Adding $new
                echo $new $default  |\
                awk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
                >> $textfile
                changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi







|











|











211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    esac
  done      
fi

answered=''
if [ -f "mtt_in_info" ]; then
  echo "The following variables exist, but are not defined in $textfile:"
  sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'

  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
            in_info=`sort mtt_in_info`
 	    for new in $in_info; do
                echo Adding $new
                echo $new $default  |\
                gawk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
                >> $textfile
                changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi

Modified mttroot/mtt/bin/trans/name2index from [23ba065049] to [f7933c91d6].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.4  1997/12/04 22:10:18  peterg
## Handles argument list - variable names.
##
## Revision 1.3  1997/05/22 09:42:48  peterg
## Returns 0 if no names.
##
## Revision 1.2  1997/05/22 09:28:22  peterg
## Removed trailing , in output.
##
## Revision 1.1  1997/05/22 08:48:21  peterg
## Initial revision
##
###############################################################

awk '
{
  name_index[$4]=$2;
}
END{
  M=split(names,xynames,":");
  if (M==0)
    printf("0\n")







>
>
>














|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/11/27 18:06:33  peterg
## *** empty log message ***
##
## Revision 1.4  1997/12/04 22:10:18  peterg
## Handles argument list - variable names.
##
## Revision 1.3  1997/05/22 09:42:48  peterg
## Returns 0 if no names.
##
## Revision 1.2  1997/05/22 09:28:22  peterg
## Removed trailing , in output.
##
## Revision 1.1  1997/05/22 08:48:21  peterg
## Initial revision
##
###############################################################

gawk '
{
  name_index[$4]=$2;
}
END{
  M=split(names,xynames,":");
  if (M==0)
    printf("0\n")

Modified mttroot/mtt/bin/trans/numpar_txt2c from [a692cf3be8] to [c7bf2ec183].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.5  1997/06/13 09:42:25  peterg
## Auto change of () to []
##
# Revision 1.4  1997/05/15  08:33:07  peterg
# Declare state array (x).
#
# Revision 1.3  1997/05/03  15:01:42  peterg







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/12/28 12:52:13  peterg
## *** empty log message ***
##
## Revision 1.5  1997/06/13 09:42:25  peterg
## Auto change of () to []
##
# Revision 1.4  1997/05/15  08:33:07  peterg
# Declare state array (x).
#
# Revision 1.3  1997/05/03  15:01:42  peterg
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
echo "extern double x[MTTNX1];"  >> $1_numpar.c
echo "#include \"$1_sympar.c\""  >> $1_numpar.c
echo "$1_numpar()" >> $1_numpar.c
echo '{' >> $1_numpar.c

#Write out the variables in c format.
sed 's/#C-CODE //'< $1_numpar.txt |\
awk -F#  '{
  if (NF<2) print $1
  if (NF>1)  print $1 "/* " $2 " */"
}' | sed 's/(\([0-9]*\))/[\1]/'  >> $1_numpar.c

echo '}'  >> $1_numpar.c









|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
echo "extern double x[MTTNX1];"  >> $1_numpar.c
echo "#include \"$1_sympar.c\""  >> $1_numpar.c
echo "$1_numpar()" >> $1_numpar.c
echo '{' >> $1_numpar.c

#Write out the variables in c format.
sed 's/#C-CODE //'< $1_numpar.txt |\
gawk -F#  '{
  if (NF<2) print $1
  if (NF>1)  print $1 "/* " $2 " */"
}' | sed 's/(\([0-9]*\))/[\1]/'  >> $1_numpar.c

echo '}'  >> $1_numpar.c


Modified mttroot/mtt/bin/trans/numpar_txt2m from [55a143892d] to [73ccf44327].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.3  1998/07/25 18:26:33  peterg
## *** empty log message ***
##
# Revision 1.2  1997/05/01  08:24:38  peterg
# Now uses # as the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  07:45:17  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:52:22  peterg
## *** empty log message ***
##
## Revision 1.3  1998/07/25 18:26:33  peterg
## *** empty log message ***
##
# Revision 1.2  1997/05/01  08:24:38  peterg
# Now uses # as the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  07:45:17  peterg
33
34
35
36
37
38
39
40
41
42
43
44
45
46

# Global variable list
#echo  >>  $1_numpar.m
#echo "# Global variable list" >>  $1_numpar.m
#sympar2global_txt2m $1 >> $1_numpar.m

#Write out the variables in m format.
awk -F#  '{
  if (NF==1) print $1
  if (NF==2)  print $1 "# " $2
}' $1_numpar.txt |\
sed 's/double/global/' >> $1_numpar.m









|






36
37
38
39
40
41
42
43
44
45
46
47
48
49

# Global variable list
#echo  >>  $1_numpar.m
#echo "# Global variable list" >>  $1_numpar.m
#sympar2global_txt2m $1 >> $1_numpar.m

#Write out the variables in m format.
gawk -F#  '{
  if (NF==1) print $1
  if (NF==2)  print $1 "# " $2
}' $1_numpar.txt |\
sed 's/double/global/' >> $1_numpar.m


Modified mttroot/mtt/bin/trans/obs_r2m from [425f980273] to [1411db277c].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?
rm -f $1_obsa.m

# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | awk '{print $3}' | sed 's/;//'`


# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?
rm -f $1_obsa.m

# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | gawk '{print $3}' | sed 's/;//'`


# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";


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