#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: modpar_txt2r
# Creates the reduce code for modulated parameters
# 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