Differences From Artifact [499a5fe272]:

To Artifact [d21f011f7e]:


45
46
47
48
49
50
51





52
53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
# default file names
$infile	 = "${sys}_ese.r"	if ($infile  eq '');
$outfile = "${sys}_ese.make"	if ($outfile eq '');

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------






# First the elementary system equations are read
# and placed in the "expressions" hash.
read_ese_r ();

# Then the occurence of any lvalue in the expression
# of any other is sought. 
get_dependencies ();

# Finally the expressions are written to a makefile
# where the targets are the left hand values and the
# pre-requisites are the dependencies
write_make ($sys);



#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub read_ese_r {

    open (ESE, $infile)







>
>
>
>
>














>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# default file names
$infile	 = "${sys}_ese.r"	if ($infile  eq '');
$outfile = "${sys}_ese.make"	if ($outfile eq '');

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------

if ($debug) {
    my $logfile = "ese_r2make_${sys}.log";
    open (LOG, ">$logfile") or die ("MTT: ese_r2make, cannot open $logfile");
}

# First the elementary system equations are read
# and placed in the "expressions" hash.
read_ese_r ();

# Then the occurence of any lvalue in the expression
# of any other is sought. 
get_dependencies ();

# Finally the expressions are written to a makefile
# where the targets are the left hand values and the
# pre-requisites are the dependencies
write_make ($sys);

close (LOG) if ($debug);

#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub read_ese_r {

    open (ESE, $infile)
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	next if /^(\s)*$/;	# skip blank lines

	# separate the left and right side of equations
	# and assign them to the expressions hash
	my ($lvar,$expr) = split (/:=/);
	$expressions{$lvar} = $expr;

	print "$lvar\t= $expressions{$lvar}\n" if $debug;
    }
    
    close (ESE);
}
#-------------------------------------------------------------------------------
sub get_dependencies {

    # compare the pattern to each expression
    foreach my $lvar (keys %expressions) {
	$dependencies{$lvar} = "";
	$_ = $expressions{$lvar};
	for my $lvar2 (keys %expressions) {
	    if ($expressions{$lvar} =~ /$lvar2/) {
		# a left value has been found in the expression
		# add it to the dependencies for this lvar
		$dependencies{$lvar} = "$dependencies{$lvar} $lvar2";
	    }
	}
	print "$lvar:\t$dependencies{$lvar}\n" if $debug;
    }
}
#-------------------------------------------------------------------------------
sub write_make {
    
    # create lists of rates, states and tmpvars so that
    # separate rules can be created in the makefile







|


















|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
	next if /^(\s)*$/;	# skip blank lines

	# separate the left and right side of equations
	# and assign them to the expressions hash
	my ($lvar,$expr) = split (/:=/);
	$expressions{$lvar} = $expr;

	print LOG "$lvar\t= $expressions{$lvar}\n" if $debug;
    }
    
    close (ESE);
}
#-------------------------------------------------------------------------------
sub get_dependencies {

    # compare the pattern to each expression
    foreach my $lvar (keys %expressions) {
	$dependencies{$lvar} = "";
	$_ = $expressions{$lvar};
	for my $lvar2 (keys %expressions) {
	    if ($expressions{$lvar} =~ /$lvar2/) {
		# a left value has been found in the expression
		# add it to the dependencies for this lvar
		$dependencies{$lvar} = "$dependencies{$lvar} $lvar2";
	    }
	}
	print LOG "$lvar:\t$dependencies{$lvar}\n" if $debug;
    }
}
#-------------------------------------------------------------------------------
sub write_make {
    
    # create lists of rates, states and tmpvars so that
    # separate rules can be created in the makefile

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