Index: mttroot/mtt/bin/trans/rbg2abg_m ================================================================== --- mttroot/mtt/bin/trans/rbg2abg_m +++ mttroot/mtt/bin/trans/rbg2abg_m @@ -9,10 +9,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.12 1998/07/28 19:07:48 peterg +## Writes out N_ports as well as n_ports +## ## Revision 1.11 1998/07/25 16:14:44 peterg ## *** empty log message *** ## ## Revision 1.10 1998/07/08 15:34:56 peterg ## Sorted out error exit status @@ -123,29 +126,40 @@ [subport,n_sub] = split_port(port_list(i,:), ','); N_ports = N_ports+n_sub; end; - [bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,\ + [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,\ infofile,errorfile); %Write the function m-file for the causal bond graph - filename = '$1_abg.m'; - filenum = fopen(filename,'w'); - c = '%'; - fprintf(filenum, 'function [bonds,components,n_ports,N_ports] = $1_abg\n'); - fprintf(filenum, '%s [bonds,components,n_ports] = $1_abg\n', c); - fprintf(filenum, '%s Acausal bond graph created by MTT on %s\n\n', ... - c, date); - mat2mfile(bonds, 'bonds', filenum); - mat2mfile(components, 'components', filenum); - fprintf(filenum, 'n_ports = %1.0f;\n', n_ports); - fprintf(filenum, 'N_ports = %1.0f;\n', N_ports); + write_abg(name,bonds,components,n_vector_bonds); + +# filename = '$1_abg.m'; +# filenum = fopen(filename,'w'); +# c = '%'; +# fprintf(filenum, 'function [bonds,components,n_ports,N_ports] = $1_abg\n'); +# fprintf(filenum, '%s [bonds,components,n_ports] = $1_abg\n', c); +# fprintf(filenum, '%s Acausal bond graph created by MTT on %s\n\n', ... +# c, date); +# mat2mfile(bonds, 'bonds', filenum); +# mat2mfile(components, 'components', filenum); +# fprintf(filenum, 'n_ports = %1.0f;\n', n_ports); +# fprintf(filenum, 'N_ports = %1.0f;\n', N_ports); EOF +# Append any VAR declarations +if [ -f "$1_lbl.txt" ]; then + echo "# Explicit variable declarations" >> $1_abg.m + grep '^[\s]*[%|#]VAR' $1_lbl.txt | tr '%' '#' >> $1_abg.m +fi + +## Close off the function +echo "endfunction" >> $1_abg.m +## Errors and info if [ "$info" = "info" ]; then cat mtt_info.txt fi if mtt_error mtt_error.txt