Skip to content

Commit

Permalink
- BIG CHANGE!
Browse files Browse the repository at this point in the history
- generate Model_init.xml instead of Model_init.txt
- clean objects in Model.makefile before compiling (Make doesn't seem to get that 
  Model.c is newer than Model.o if we issue two simulate commands for the same model,
  even if the model changed via loadFile.)
- check the result of fflush in systemimpl.c and printimpl.c
- fflush in c_runtime/linearize.cpp
- added c_runtime/simulation_input_xml.h and cpp to read the Model_init.xml file.
- link the generated code with the XML parser library -lexpat as libc_runtime needs it now
- Model.c and Model_init.xml will now contain a GUID which is used in c_runtime/simulation_input_xml.cpp
  to check if the Model_init.xml is matched with Model.c (Model.exe)
- The Model_init.xml is based on FMI but with much more information that we need for OMC.
- The Model_init.xml file it has no schema yet as it may change in the near future to include
  more things that are now static in the generated code (Model.c). This will make compilation
  of generated code faster.
- disabled testsuite/interactive-simulation/runInteractiveSimulation.mos and added only a 
  compilation test (more work is needed to make the run test more robust).
- updated tests and compiler files with the name change from _init.txt to _init.xml.



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9222 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed May 31, 2011
1 parent 30e2616 commit 3e680ed
Show file tree
Hide file tree
Showing 22 changed files with 837 additions and 87 deletions.
24 changes: 12 additions & 12 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -30,7 +30,7 @@
*/

encapsulated package SimCode
" file: SimCode.mo
" file: SimCode.mo
package: SimCode
description: Code generation using Susan templates

Expand Down Expand Up @@ -8814,48 +8814,48 @@ algorithm
local
String str,str2,omhome,omhomelib,lpsolvelib;

// Lapack on MinGW/Windows is linked against f2c
// Lapack on MinGW/Windows is linked against f2c
case Absyn.STRING("Lapack")
equation
true = "Windows_NT" ==& System.os();
then {"-llapack-mingw", "-ltmglib-mingw", "-lblas-mingw", "-lf2c"};

// omcruntime on windows needs linking with mico2313 and wsock!
// omcruntime on windows needs linking with mico2313 and wsock and then some :)
case Absyn.STRING(str as "omcruntime")
equation
true = "Windows_NT" ==& System.os();
str = "-l" +& str;
strs = getLibraryStringInGccFormat(Absyn.STRING("Lapack"));
strs = str :: "-lsqlite3" :: "-llpsolve55" :: "-lmico2313" :: "-lws2_32" :: "-lregex" :: strs;
strs = str :: "-lexpat" :: "-lsqlite3" :: "-llpsolve55" :: "-lmico2313" :: "-lws2_32" :: "-lregex" :: strs;
then
strs;

// The library is not actually named libLapack.so.
// Which is a problem, since MSL says it does.
// The library is not actually named libLapack.so.
// Which is a problem, since MSL says it does.
case Absyn.STRING("Lapack") then {"-llapack"};

// Wonder if there may be issues if we have duplicates in the Corba libs
// and the other libs. Some other developer will probably swear over this
// hack some day, but at least I get an early weekend.
// Wonder if there may be issues if we have duplicates in the Corba libs
// and the other libs. Some other developer will probably swear over this
// hack some day, but at least I get an early weekend.
case Absyn.STRING("OpenModelicaCorba")
equation
str = System.getCorbaLibs();
then {str};

// If omcruntime is linked statically against omniORB, we need to include those here as well
// If omcruntime is linked statically against omniORB, we need to include those here as well
case Absyn.STRING(str as "omcruntime")
equation
false = "Windows_NT" ==& System.os();
then
System.getRuntimeLibs();

// If the string contains a dot, it's a good path that should not be prefix -l
// If the string contains a dot, it's a good path that should not be prefix -l
case Absyn.STRING(str)
equation
false = -1 == System.stringFind(str, ".");
then {str};

// If the string starts with a -, it's probably -l or -L gcc flags
// If the string starts with a -, it's probably -l or -L gcc flags
case Absyn.STRING(str)
equation
true = "-" ==& stringGetStringChar(str, 1);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Main/Main.mo
Expand Up @@ -1088,7 +1088,7 @@ algorithm
print("\t Model.cpp the model C++ code\n");
print("\t Model_functions.cpp the model functions C++ code\n");
print("\t Model.makefile the makefile to compile the model.\n");
print("\t Model_init.txt the initial values for parameters\n");
print("\t Model_init.xml the initial values for parameters and start values\n");
print("\t+d=interactive will start omc as a server listening on the socket interface\n");
print("\t+d=interactiveCorba will start omc as a server listening on the Corba interface\n");
print("\t+c=corbaName works togheter with +d=interactiveCorba;\n");
Expand Down
10 changes: 5 additions & 5 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -884,7 +884,7 @@ algorithm

case (cache,env,"translateModel",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1,_,_,_,_) = translateModel(cache,env, className, st, filenameprefix,true,NONE());
(cache,ret_val,st_1,_,_,_,_) = translateModel(cache, env, className, st, filenameprefix, true, NONE());
then
(cache,ret_val,st_1);

Expand All @@ -899,7 +899,7 @@ algorithm

case (cache,env,"translateModelFMU",{Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(filenameprefix)},st,msg)
equation
(cache,ret_val,st_1) = translateModelFMU(cache,env, className, st, filenameprefix, true, NONE());
(cache,ret_val,st_1) = translateModelFMU(cache, env, className, st, filenameprefix, true, NONE());
then
(cache,ret_val,st_1);

Expand Down Expand Up @@ -2325,7 +2325,7 @@ algorithm
true = (build >. edit);
oldDir = System.pwd();
changeToTempDirectory(cdToTemp);
init_filename = stringAppendList({filenameprefix,"_init.txt"});
init_filename = stringAppendList({filenameprefix,"_init.xml"});
exeFile = filenameprefix +& System.getExeExt();
existFile = System.regularFileExists(exeFile);
_ = System.cd(oldDir);
Expand All @@ -2352,7 +2352,7 @@ algorithm
// starttime_r, stoptime_r, interval_r, tolerance_r, method_str,options_str,outputFormat_str);

System.realtimeTick(RT_CLOCK_BUILD_MODEL);
init_filename = filenameprefix +& "_init.txt"; //a hack ? should be at one place somewhere
init_filename = filenameprefix +& "_init.xml"; //a hack ? should be at one place somewhere
//win1 = getWithinStatement(classname);
s3 = extractNoCleanCommand(noClean);

Expand Down Expand Up @@ -2471,7 +2471,7 @@ algorithm
stringAppendList({omhome,
omhome_1,pd,"share",pd,"omc",pd,"scripts",pd,"Compile"," ",fileprefix," ",noClean});
Debug.fprintln("dynload", "compileModel: running " +& s_call);
0 = System.systemCall(s_call) ;
0 = System.systemCall(s_call);
Debug.fprintln("dynload", "compileModel: successful! ");
then
();
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/config.h
Expand Up @@ -36,7 +36,7 @@
#define DEFAULT_CC "gcc"
#define DEFAULT_CXX "g++"

#define DEFAULT_LDFLAGS "-lc_runtime -lregex"
#define DEFAULT_LDFLAGS "-lc_runtime -lregex -lexpat"

#define CONFIG_PLATFORM "WIN32"
#define CONFIG_MODELICA_SPEC_PLATFORM "win32"
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/config.unix.h.in
Expand Up @@ -44,4 +44,4 @@
#define CONFIG_LPSOLVE55 "@LIBLPSOLVE55@"
#define CONFIG_REVISION "@SOURCE_REVISION@"

#define CONFIG_SYSTEMLIBS mk_cons(mk_scon("-lomcruntime"),mk_cons(mk_scon("-lsqlite3"),mk_cons(mk_scon(CONFIG_LPSOLVE55),mk_cons(mk_scon(CONFIG_CORBALIBS),mk_nil()))))
#define CONFIG_SYSTEMLIBS mk_cons(mk_scon("-lomcruntime"),mk_cons(mk_scon("-lexpat"),mk_cons(mk_scon("-lsqlite3"),mk_cons(mk_scon(CONFIG_LPSOLVE55),mk_cons(mk_scon(CONFIG_CORBALIBS),mk_nil())))))
6 changes: 5 additions & 1 deletion Compiler/runtime/printimpl.c
Expand Up @@ -289,10 +289,14 @@ static int PrintImpl__writeBuf(const char* filename)
"Error writing to file %s.",
c_tokens,
1);
fprintf(stderr, "Print.writeBuf: error writing to file: %s!\n", filename);
fclose(file);
return 1;
}
fflush(file);
if (fflush(file) != 0)
{
fprintf(stderr, "Print.writeBuf: error flushing file: %s!\n", filename);
}
fclose(file);
return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion Compiler/runtime/systemimpl.c
Expand Up @@ -386,7 +386,10 @@ int SystemImpl__writeFile(const char* filename, const char* data)
fclose(file);
return 1;
}
fflush(file);
if (fflush(file) != 0)
{
fprintf(stderr, "System.writeFile: error flushing file: %s!\n", filename);
}
fclose(file);
return 0;
}
Expand Down

0 comments on commit 3e680ed

Please sign in to comment.