Artifact 016a2f4250e67f8372f1138f8c2de08dc62a5b7065d6cd31b5c547f29e839c16:


#! /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.15  2000/12/28 12:44:31  peterg
## *** empty log message ***
##
## Revision 1.14  2000/10/16 08:28:56  peterg
## Tidied up:
## SS broken due to incorrect ss.r file
## Switches??
##
## Revision 1.13  2000/03/03 11:33:19  peterg
## *** empty log message ***
##
## Revision 1.12  1998/08/10 14:29:05  peterg
## Removed -s (switches) stuff
##
## 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

# Default input
default='1.0'

#Create the input file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_input.txt
echo "# Input specification ($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/\$//' |\
gawk '{
  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 ")"
    printf("%s =\t%s # MTT initial value from steady state\n", $4, u[i]);
  }
}'  >> $1_input.txt
else
#Write out the defaults -- unit inputs
echo Creating $1_input.txt - using defaults

gawk '{
  if ($1=="input") {
      if ($2==1)
        printf("%s = \t%s; # MTT initial value\n", $4, default)
      else
        printf("%s = \t%s; # MTT initial value\n", $4, "0.0")
  }
}' Nu=$Nu  default=$default <$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 |\
#  gawk '{if (length($1)>0) print  tolower($1) "= (t>=0);"}'  >> $1_input.txt





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