Skip to content

Commit

Permalink
Fixed bug with input variables to models. Fixed segfault when writing…
Browse files Browse the repository at this point in the history
… open file in windows.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1829 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jun 23, 2005
1 parent d85f508 commit 82f7613
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
10 changes: 6 additions & 4 deletions Compiler/Ceval.rml
Expand Up @@ -1092,6 +1092,8 @@ end
=> (Values.REAL(stoptime_r),SOME(st)) &
ceval(env,interval,true,SOME(st),NONE)
=> (Values.INTEGER(interval_i),SOME(st)) &
ceval(env,method,true,SOME(st),NONE)
=> (Values.STRING(method_str),SOME(st)) &
real_sub(stoptime_r,starttime_r) => delta_time &
int_real(interval_i) => interval_r &
real_div(delta_time,interval_r) => stepsize_r &
Expand Down Expand Up @@ -1124,7 +1126,7 @@ end
Util.string_append_list([omhome, pd, "Compiler", pd, "scripts", pd, "Compile ", makefilename]) => s_call &

System.system_call(s_call) => 0 &
Util.string_append_list([".", pd, cname_str]) => sim_call &
Util.string_append_list([".", pd, cname_str, " -m ",method_str]) => sim_call &
System.system_call(sim_call) => _ &
Util.string_append_list([cname_str,"_res.plt"]) => result_file &
let simValue = Values.RECORD(Absyn.IDENT("SimulationResult"),[Values.STRING(result_file)],["resultFile"]) &
Expand All @@ -1141,7 +1143,7 @@ end
=> newst &
Print.clear_error_buf()
------------------------------------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval,method],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
=> (simValue,newst)

rule
Expand All @@ -1151,13 +1153,13 @@ end
Util.string_append_list(["Simulation failed.\n",str,"\n"]) => res &
let simValue = Values.RECORD(Absyn.IDENT("SimulationResult"),[Values.STRING(res)],["resultFile"])
------------------------------------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval,method],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
=> (simValue,st)

rule
let simValue = Values.RECORD(Absyn.IDENT("SimulationResult"),[Values.STRING("Simulation Failed. Environment variable OPENMODELICAHOME not set.")],["resultFile"])
------------------------------------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("simulate"),[Exp.CREF(cr,_),starttime,stoptime,interval,method],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))
=> (simValue,st)

rule Static.component_ref_to_path(cr) => path &
Expand Down
16 changes: 5 additions & 11 deletions Compiler/DAELow.rml
Expand Up @@ -1360,9 +1360,7 @@ end
**)
relation is_var_on_top_level_and_input:(Var) => bool =

rule top_level_input(cr,dir,flow) => () &
Exp.print_component_ref_str(cr) => cr_str &
print cr_str & print " " & print old_name & print "WWWWWWWWWWWWWWWWWWW\n"
rule top_level_input(Exp.CREF_IDENT(old_name,[]),dir,flow) => ()
---------------------------------------------
is_var_on_top_level_and_input(VAR(cr,kind,dir,_,_,_,_,_,_,old_name,_,_,_,flow)) => true

Expand Down Expand Up @@ -2140,23 +2138,19 @@ end
relation top_level_input: (Exp.ComponentRef,
DAE.VarDirection,
DAE.Flow) => () =


rule (* top level ident, no dots *)
Util.string_split_at_char(name, #".") => cr_str_lst &
list_length(cr_str_lst) => 1
Util.string_split_at_char(name, #".") => [_]
--------------------
top_level_input(cr as Exp.CREF_IDENT(name,_), DAE.INPUT,_) => ()

(* Connector input variables at top level for crefs that are stringified*)
rule Util.string_split_at_char(name, #".") => cr_str_lst &
list_length(cr_str_lst) => len &
int_eq(len,2) => true
rule Util.string_split_at_char(name, #".") => [_,_]
----------------------
top_level_input(Exp.CREF_IDENT(name,_), DAE.INPUT, DAE.NON_FLOW) =>()

rule Util.string_split_at_char(name, #".") => cr_str_lst &
list_length(cr_str_lst) => len &
int_eq(len,2) => true
rule Util.string_split_at_char(name, #".") => [_,_]
----------------------
top_level_input(Exp.CREF_IDENT(name,_), DAE.INPUT, DAE.FLOW) =>()

Expand Down
5 changes: 4 additions & 1 deletion Compiler/winruntime/systemimpl.c
Expand Up @@ -326,7 +326,10 @@ RML_BEGIN_LABEL(System__write_5ffile)
char* filename = RML_STRINGDATA(rmlA0);
FILE * file=NULL;
file = fopen(filename,"w");
assert(file != NULL);
if (file == NULL) {
printf("error opening file: %s\n",filename);
RML_TAILCALLK(rmlFC);
}
fprintf(file,"%s",data);
fclose(file);
RML_TAILCALLK(rmlSC);
Expand Down

0 comments on commit 82f7613

Please sign in to comment.