Skip to content

Commit

Permalink
- fixes to make the testsuite run on Linux
Browse files Browse the repository at this point in the history
- for some very obscure reasons in simulation_result.cpp, 
  function: int deinitializeResult(const char * filename)
  code: ofstream f(filename) reset the filename to "" and the creation of the file failed.
- fixed it in solver_dasrt.cpp and solver_euler.cpp
- thanks to William Spinelli for providing a virtual machine where I could
  reproduce this error. 

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2664 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 11, 2007
1 parent cf157b7 commit 6376a7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 5 additions & 3 deletions c_runtime/simulation_result.cpp
Expand Up @@ -44,7 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* 2. Call emit() to store data points at given time (taken from globalData structure)
* 3. Call deinitializeResult with actual number of points produced to store data to file.
*/

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "simulation_result.h"
#include "simulation_runtime.h"

Expand Down Expand Up @@ -135,14 +137,14 @@ int deinitializeResult(const char * filename)
ofstream f(filename);
if (!f)
{
cerr << "Error, couldn't create output file " << filename << endl;
cerr << "Error, couldn't create output file: [" << filename << "] because" << strerror(errno) << "." << endl;
return -1;
}

// Rather ugly numbers than unneccessary rounding.
f.precision(numeric_limits<double>::digits10 + 1);
f << "#Ptolemy Plot file, generated by OpenModelica" << endl;
f << "#IntervalSize=" << actualPoints<< endl;
f << "#IntervalSize=" << actualPoints << endl;
f << "TitleText: OpenModelica simulation plot" << endl;
f << "XLabel: t" << endl << endl;

Expand Down
10 changes: 5 additions & 5 deletions c_runtime/solver_dasrt.cpp
Expand Up @@ -324,14 +324,14 @@ int dassl_main(int argc, char**argv,double &start, double &stop, double &step,

deinitializeEventData();

string * result_file =(string*)getFlagValue("r",argc,argv);
const char * result_file_cstr;
string *result_file =(string*)getFlagValue("r",argc,argv);
string result_file_cstr;
if (!result_file) {
result_file_cstr = string(string(globalData->modelName)+string("_res.plt")).c_str();
result_file_cstr = string(globalData->modelName)+string("_res.plt");
} else {
result_file_cstr = result_file->c_str();
result_file_cstr = *result_file;
}
if (deinitializeResult(result_file_cstr)) {
if (deinitializeResult(result_file_cstr.c_str())) {
status =-1;
}
return status;
Expand Down
11 changes: 5 additions & 6 deletions c_runtime/solver_euler.cpp
Expand Up @@ -100,15 +100,14 @@ int euler_main( int argc, char** argv,double &start, double &stop, double &step
}
}


string * result_file =(string*)getFlagValue("r",argc,argv);
const char * result_file_cstr;
string* result_file =(string*)getFlagValue("r",argc,argv);
string result_file_cstr;
if (!result_file) {
result_file_cstr = string(string(globalData->modelName)+string("_res.plt")).c_str();
result_file_cstr = string(globalData->modelName)+string("_res.plt");
} else {
result_file_cstr = result_file->c_str();
result_file_cstr = *result_file;
}
if (deinitializeResult(result_file_cstr)) {
if (deinitializeResult(result_file_cstr.c_str())) {
return -1;
}
return 0;
Expand Down

0 comments on commit 6376a7f

Please sign in to comment.