Overview
Comment: | Initial revision |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a64332785f9b6b0730ee83cd83154158 |
User & Date: | gawthrop@users.sourceforge.net on 2000-04-07 13:25:27 |
Other Links: | branch diff | manifest | tags |
Context
2000-04-07
| ||
13:25:52 | Modified for smx, smxa, smxax check-in: 7356caf5d0 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
13:25:27 | Initial revision check-in: a64332785f user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
13:24:41 | Modified for smxa and smxax check-in: 0cddda5337 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
Changes
Added mttroot/mtt/bin/trans/mtt_p2C version [af8e9bf1d7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 | #! /bin/sh ###################################### ##### Model Transformation Tools ##### ###################################### # Bourne shell script: p2C # Pascal to a c program - intermediate step for mtt_p2oct # P.J.Gawthrop Feb 2000 # Copyright (C) 2000 by Peter J. Gawthrop #$Id$ sys_rep="$1_$2" begin="BEGIN{$sys_rep}" # Inform user echo "Creating $1_$2.pas" # Find system constants Nx=`mtt_getsize $1 x` 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 " 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 |