File mttroot/mtt/bin/trans/struc2input_txt2txt artifact 9bc5f2af80 part of check-in 252807ac6d


#! /bin/sh

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

# Bourne shell script: struc2input_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  1998/08/10 14:23:58  peterg
## Added -ss option
##
## Revision 1.10  1998/07/27 11:10:38  peterg
## Put in octave-mode line for Emacs
##
## Revision 1.9  1998/07/25 20:10:37  peterg
## lower case mttu
##
## Revision 1.8  1998/07/25 09:42:09  peterg
## Just sets finrst input to 1 - rest to zero
##
## Revision 1.7  1998/07/25 08:05:41  peterg
## Reverted to original default - not using SS mechanism
##
## Revision 1.6  1998/02/24 10:14:56  peterg
## Now defaults to the steady-state values
##
## Revision 1.5  1998/02/04 12:26:47  peterg
## Simplified output format
##
## Revision 1.4  1998/02/04 11:45:05  peterg
## Less verbose comments.
##
## Revision 1.3  1998/01/29 17:06:21  peterg
## Better annotation of each input
##
## Revision 1.2  1997/05/15 09:44:12  peterg
## Put switches into the input file.
##
# Revision 1.1  1997/05/03  14:55:17  peterg
# Initial revision
#
###############################################################

#Look for a command line argument
# By default, don't look for BG switches

while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-ss )
		steadystate_computation=yes ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


#Create the input file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_input.txt
echo "# Numerical parameter file ($1_input.txt)" >> $1_input.txt
echo "# Generated by MTT at `date`" >> $1_input.txt
cat $MTTPATH/trans/rcs_header.sh  >> $1_input.txt
echo "# Set the inputs"  >> $1_input.txt

if [ -n "$steadystate_computation" ]; then 
# Compute inputs from ss.r file
# Inform user
echo Creating $1_input.txt - compute from steady-state information

cat $1_ss.r  $1_struc.txt | sed 's/\$//' |\
awk '{
  if(match($1,"MTTu")>0) {
    j++
    split($0,a,"=");
    u[j]=a[2];
  }
    
  if($1=="input") {
    i++; 
    if (length(u[i])==0) u[i]="0.0;";
    print  "u(" i ") =\t", u[i], " \# " $4 " (" $3 ")"
  }
}'  >> $1_input.txt
else
#Write out the defaults -- unit inputs
echo Creating $1_input.txt - defaults

awk '{
  if ($1=="input") {
    if ($2==1)
      printf("mttu(%s) = 1.0; \t\# %s (%s)\n", $2,$3,$4)
    else
      printf("mttu(%s) = 0.0; \t\# %s (%s)\n", $2,$3,$4)
  }
}' Nu=$Nu  <$1_struc.txt >> $1_input.txt
fi

#Set some switches
  echo  >> $1_input.txt
  echo "# Set the switches"  >> $1_input.txt
  strip_comments<$1_switch.txt |\
  awk '{if (length($1)>0) print  tolower($1) "= (t>=0);"}'





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