Overview
Comment:Now uses tr instead of sed to replace array index parentheses
(tr is better at coping with very, very long lines).

Fixed tidy-up regexps in decrement_indices function.

Fixed comment and function name c_to_fortran_paren.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 64dfc2cb69dfa8239bc2cfc68bcf95cacc799dd63f84d4b6db988bdd9daa0268
User & Date: geraint@users.sourceforge.net on 2003-02-11 19:55:51
Other Links: branch diff | manifest | tags
Context
2003-02-11
20:04:08
Reverted to line-by-line optimisation as default and added caution to
description of -optg.

Global optimisation has been observed to create assignments using
uninitialised temporary variables. check-in: ca64dde77d user: geraint@users.sourceforge.net tags: origin/master, trunk

19:55:51
Now uses tr instead of sed to replace array index parentheses
(tr is better at coping with very, very long lines).

Fixed tidy-up regexps in decrement_indices function.

Fixed comment and function name c_to_fortran_paren. check-in: 64dfc2cb69 user: geraint@users.sourceforge.net tags: origin/master, trunk

2003-02-06
20:28:40
Added -ibg switch to aid testing during development of ibg2abg.m check-in: 20a748db45 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/cc/mtt_m2cc.sh from [8d8e19f056] to [2168007fc9].

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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
    esac
};

decrement_indices ()
{    
    # first section appends '-1' to container indices
    # to convert from FORTRAN-type numbering to C-type numbering

    sed 's/mtta(\([0-9][0-9]*\),\([0-9][0-9]*\))/mtta[\1-1,\2-1]/g'	|\
    sed 's/mttax(\([0-9][0-9]*\))/mttax[\1-1]/g'			|\
    sed 's/mttdx(\([0-9][0-9]*\))/mttdx[\1-1]/g'			|\
    sed 's/mttedx(\([0-9][0-9]*\))/mttedx[\1-1]/g'			|\
    sed 's/mttpar(\([0-9][0-9]*\))/mttpar[\1-1]/g'			|\
    sed 's/mttu(\([0-9][0-9]*\))/mttu[\1-1]/g'				|\
    sed 's/mttx(\([0-9][0-9]*\))/mttx[\1-1]/g'				|\
    sed 's/mtty(\([0-9][0-9]*\))/mtty[\1-1]/g'				|\
    sed 's/mttyz(\([0-9][0-9]*\))/mttyz[\1-1]/g'			|\
    sed 's/mttz(\([0-9][0-9]*\))/mttz[\1-1]/g'				|\
    sed 's/mttopen(\([0-9][0-9]*\))/mttopen[\1-1]/g'				|\
									 \
    # next sections tidy the code up a bit, but are not necessary
    sed 's/1\-1\([\,\)]\)/0\1/g'       			       		|\
    sed 's/2\-1\([\,\)]\)/1\1/g'       			       		|\
    sed 's/3\-1\([\,\)]\)/2\1/g'       			       		|\
    sed 's/4\-1\([\,\)]\)/3\1/g'       			       		|\
    sed 's/5\-1\([\,\)]\)/4\1/g'       			       		|\
    sed 's/6\-1\([\,\)]\)/5\1/g'       			       		|\
    sed 's/7\-1\([\,\)]\)/6\1/g'       			       		|\
    sed 's/8\-1\([\,\)]\)/7\1/g'       			       		|\
    sed 's/9\-1\([\,\)]\)/8\1/g'       			       		|\
									 \
    sed 's/10\-1\([\,\)]\)/9\1/g'     			       		|\
    sed 's/20\-1\([\,\)]\)/19\1/g'	       		       		|\
    sed 's/30\-1\([\,\)]\)/29\1/g'		       	       		|\
    sed 's/40\-1\([\,\)]\)/39\1/g'			       		|\
    sed 's/50\-1\([\,\)]\)/49\1/g'		               		|\
    sed 's/60\-1\([\,\)]\)/59\1/g'		      	       		|\
    sed 's/70\-1\([\,\)]\)/69\1/g'		       	       		|\
    sed 's/80\-1\([\,\)]\)/79\1/g'		       	       		|\
    sed 's/90\-1\([\,\)]\)/89\1/g'		       	       		|\
									 \
    sed 's/100\-1\([\,\)]\)/99\1/g'   			       		|\
    sed 's/200\-1\([\,\)]\)/199\1/g'	       		       		|\
    sed 's/300\-1\([\,\)]\)/299\1/g'		       	       		|\
    sed 's/400\-1\([\,\)]\)/399\1/g'			       		|\
    sed 's/500\-1\([\,\)]\)/499\1/g'			       		|\
    sed 's/600\-1\([\,\)]\)/599\1/g'			       		|\
    sed 's/700\-1\([\,\)]\)/699\1/g'			       	       	|\
    sed 's/800\-1\([\,\)]\)/799\1/g'			       		|\
    sed 's/900\-1\([\,\)]\)/899\1/g'			       		|\
    sed 's/\([(,]\)0\([0-9]\)/\1\2/g'
};

fortran_to_c_paren ()
{
    # converts [i] to (i)
    sed 's/\[\([^[]*\)\]/(\1)/g'
}
	
fix_pow ()
{
    # matches number^number where number is one or more digits and one or zero decimal points
    # converts to pow (number, number)
    sed 's/\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)\^\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)/pow \(\1\2\3,\4\5\6\)/g'







>













|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|



|

<
|







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
157
158
159
160
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175
    esac
};

decrement_indices ()
{    
    # first section appends '-1' to container indices
    # to convert from FORTRAN-type numbering to C-type numbering
    # and C-type indices () to FORTRAN-type []
    sed 's/mtta(\([0-9][0-9]*\),\([0-9][0-9]*\))/mtta[\1-1,\2-1]/g'	|\
    sed 's/mttax(\([0-9][0-9]*\))/mttax[\1-1]/g'			|\
    sed 's/mttdx(\([0-9][0-9]*\))/mttdx[\1-1]/g'			|\
    sed 's/mttedx(\([0-9][0-9]*\))/mttedx[\1-1]/g'			|\
    sed 's/mttpar(\([0-9][0-9]*\))/mttpar[\1-1]/g'			|\
    sed 's/mttu(\([0-9][0-9]*\))/mttu[\1-1]/g'				|\
    sed 's/mttx(\([0-9][0-9]*\))/mttx[\1-1]/g'				|\
    sed 's/mtty(\([0-9][0-9]*\))/mtty[\1-1]/g'				|\
    sed 's/mttyz(\([0-9][0-9]*\))/mttyz[\1-1]/g'			|\
    sed 's/mttz(\([0-9][0-9]*\))/mttz[\1-1]/g'				|\
    sed 's/mttopen(\([0-9][0-9]*\))/mttopen[\1-1]/g'				|\
									 \
    # next sections tidy the code up a bit, but are not necessary
    sed 's/1\-1\([],]\)/0\1/g'       			       		|\
    sed 's/2\-1\([],]\)/1\1/g'       			       		|\
    sed 's/3\-1\([],]\)/2\1/g'       			       		|\
    sed 's/4\-1\([],]\)/3\1/g'       			       		|\
    sed 's/5\-1\([],]\)/4\1/g'       			       		|\
    sed 's/6\-1\([],]\)/5\1/g'       			       		|\
    sed 's/7\-1\([],]\)/6\1/g'       			       		|\
    sed 's/8\-1\([],]\)/7\1/g'       			       		|\
    sed 's/9\-1\([],]\)/8\1/g'       			       		|\
									 \
    sed 's/10\-1\([],]\)/9\1/g'     			       		|\
    sed 's/20\-1\([],]\)/19\1/g'	       		       		|\
    sed 's/30\-1\([],]\)/29\1/g'		       	       		|\
    sed 's/40\-1\([],]\)/39\1/g'			       		|\
    sed 's/50\-1\([],]\)/49\1/g'		               		|\
    sed 's/60\-1\([],]\)/59\1/g'		      	       		|\
    sed 's/70\-1\([],]\)/69\1/g'		       	       		|\
    sed 's/80\-1\([],]\)/79\1/g'		       	       		|\
    sed 's/90\-1\([],]\)/89\1/g'		       	       		|\
									 \
    sed 's/100\-1\([],]\)/99\1/g'   			       		|\
    sed 's/200\-1\([],]\)/199\1/g'	       		       		|\
    sed 's/300\-1\([],]\)/299\1/g'		       	       		|\
    sed 's/400\-1\([],]\)/399\1/g'			       		|\
    sed 's/500\-1\([],]\)/499\1/g'			       		|\
    sed 's/600\-1\([],]\)/599\1/g'			       		|\
    sed 's/700\-1\([],]\)/699\1/g'			       	       	|\
    sed 's/800\-1\([],]\)/799\1/g'			       		|\
    sed 's/900\-1\([],]\)/899\1/g'			       		|\
    sed 's/\([(,]\)0\([0-9]\)/\1\2/g'
};

c_to_fortran_paren ()
{

    tr "[]" "()"
}
	
fix_pow ()
{
    # matches number^number where number is one or more digits and one or zero decimal points
    # converts to pow (number, number)
    sed 's/\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)\^\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)/pow \(\1\2\3,\4\5\6\)/g'
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	;;
    cc | *)
	mtt_header ${SYS} ${REP} "oct"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	rep_declarations		>> ${OUT}
	find_code ${IN} body   		|\
	    decrement_indices		|\
	    fortran_to_c_paren		|\
	    fix_comment_delimiter cc	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	rep_footer			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
esac









|











193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	;;
    cc | *)
	mtt_header ${SYS} ${REP} "oct"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	rep_declarations		>> ${OUT}
	find_code ${IN} body   		|\
	    decrement_indices		|\
	    c_to_fortran_paren		|\
	    fix_comment_delimiter cc	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	rep_footer			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
esac



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