File mttroot/mtt/bin/trans/cbg2ese_m2r artifact 52836d7a05 part of check-in 287b5fa097


#! /bin/sh

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

# Bourne shell script: cbg2ese_m
#
#
# P.J.Gawthrop June 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.12  1998/01/23 13:30:46  peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.11  1997/12/16 18:05:03  peterg
## Increased size of structure vector by on to include unknown_inputs as
## 6th element
##
## Revision 1.10  1997/04/15 09:18:26  peterg
## Added structure file
##
# Revision 1.9  1996/12/07  18:21:25  peterg
# Now uses fopen + file number
#
## Revision 1.8  1996/12/05 10:05:28  peterg
## Removed the Octave switch: empty_list_elements_ok = 1;
## This is now in .octaverc
##
# Revision 1.7  1996/08/30  11:29:49  peter
# Added constitutive relationship to argument list.
# Put in explicit argument list to cbg2ese.
#
# Revision 1.6  1996/08/26  13:25:07  peterg
# Corrected error handling.
#
# Revision 1.5  1996/08/24  14:38:11  peter
# Error handling included.
#
## Revision 1.4  1996/08/19 09:02:12  peter
## Errors go to user - not log.
##
## Revision 1.3  1996/08/18 20:05:55  peter
## Included zero outputs.
##
## Revision 1.2  1996/08/08 18:08:37  peter
## Sorted out file naming scheme.
##
## Revision 1.1  1996/08/08 15:57:15  peter
## Initial revision
##
###############################################################

infofile='mtt_info.txt';
structurefile="$1_struc.txt";
eqnfile="$1_ese.r";
deffile="$1_def.r";

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

# Remove relevent ese files
rm -f $1_ese.r $1_*_ese.r 

#Inform user
echo Creating $eqnfile
echo Creating $deffile
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
$MATRIX > cbg2ese_m2r.log 2>mtt_error.txt << EOF

infofile = '$infofile';;
infofilenum = fopen(infofile,'w');
structurefile = '$structurefile';;
structurefilenum = fopen(structurefile,'w');
deffile = '$1_def.r';
deffilenum = fopen(deffile,'w');

system_name = '$1';
system_type = '';
system_cr = '';
system_args = '';
full_name = '';
full_name_repetition = '';


% Structure matrix [states,nonstates,inputs,outputs,zero_outputs]

structure = zeros(1,6);

structure = cbg2ese(system_name, system_type, system_cr, ...
                     system_args, full_name, full_name_repetition, ...
                     1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
  
EOF

cat $infofile

# Create the composite ese file
cat $1_ese.r $1_*_ese.r  > $1_ese.tmp 2>> /dev/null

mv $1_ese.tmp $1_ese.r

# Zap the sub ese files
rm -f $1_*_ese.r

# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Now invoke the standard error handling.
mtt_error mtt_error.txt





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