Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  "Too many points
   Error, could not save data. Not enought space."
- now the simulationResultData is reallocated with a bigger size when needed.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@3504 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed May 1, 2008
1 parent 9218576 commit a6caf88
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions c_runtime/simulation_result.cpp
Expand Up @@ -50,7 +50,8 @@
double* simulationResultData=0;
long currentPos=0;
long actualPoints=0; // the number of actual points saved
int maxPoints;
long maxPoints;
long dataSize = 0;

void add_result(double *data, long *actualPoints);

Expand All @@ -68,8 +69,22 @@ int emit()
return 0;
}
else {
cout << "Too many points: " << actualPoints << " max points: " << maxPoints << endl;
return -1;
/* increase the maxPoints by (maxPoints-actualPoints) + 2000 */
maxPoints = maxPoints + (maxPoints-actualPoints) + 2000;
/*
* cerr << "realloc simulationResultData to a size of " << maxPoints * dataSize * sizeof(double) << endl;
*/
simulationResultData = (double*)realloc(simulationResultData, maxPoints * dataSize * sizeof(double));
if (!simulationResultData) {
cerr << "Error allocating simulation result data of size " << maxPoints * dataSize << endl;
return -1;
}
add_result(simulationResultData,&actualPoints);
return 0;
/* adrpo - realloc the result array instead of fixed size!
* cout << "Too many points: " << actualPoints << " max points: " << maxPoints << endl;
* return -1;
*/
}
}

Expand Down Expand Up @@ -147,11 +162,10 @@ int initializeResult(long numpoints,long nx, long ny, long np)
numpoints = abs(numpoints);
maxPoints = abs(numpoints);
}

simulationResultData = new double[numpoints*(nx*2+ny+1)];
dataSize = (nx*2+ny+1);
simulationResultData = (double*)malloc(numpoints * dataSize * sizeof(double));
if (!simulationResultData) {
cerr << "Error allocating simulation result data of size " << numpoints *(nx*2+ny)
<< endl;
cerr << "Error allocating simulation result data of size " << numpoints * dataSize << endl;
return -1;
}
currentPos = 0;
Expand Down

0 comments on commit a6caf88

Please sign in to comment.