File mttroot/mtt/bin/trans/sympar2numpar_r2c artifact d052149f27 part of check-in 3c858121cf


#! /bin/sh

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

# Bourne shell script: sympar2numpar_r2m
# Creates the deafault numerical parameters file for the system

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1997/01/21 11:36:26  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_numpar.c

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

# Use reduce to accomplish the transformation
reduce >sympar2numpar_r2c.log 2>mtt_error.txt << EOF

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
IN "$1_sympar.r";

OUT "$1_numpar1.c";

IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE  
      BEGIN
        write "extern float ", MTTVar(i,1)$
      END;
END; 


IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
    THEN 
    BEGIN
     write "/* Variable ", i, " has already been set to ",   MTTVar(i,1), "*/";
    END
    ELSE
    BEGIN
      write MTTVar(i,1), "  = 1;	/* Default value */";
    END;
END;


SHUT "$1_numpar1.c";

EOF

matlab_tidy $1_numpar1.c

#Create the numpar file complete with headers.
echo "/*" > $1_numpar.c
echo "%% Numerical parameter file ($1_numpar.c)" >> $1_numpar.c
echo "%% Generated by MTT at `date`" >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_numpar()"  >> $1_numpar.c
echo "{" >> $1_numpar.c
echo "  extern $1_params();" >> $1_numpar.c

cat $1_numpar1.c >> $1_numpar.c

echo "/*" >> $1_numpar.c
echo '%% Input the user-defined parameters'  >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_params;"   >> $1_numpar.c
echo "};" >> $1_numpar.c

rm $1_numpar1.c

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


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