Skip to content

Commit

Permalink
- Fixed getVars in SimulationResultsCmp so that variable names don't get
Browse files Browse the repository at this point in the history
  corrupted and make the Compare.mos test fail.
- Got rid of Clang warning in optimization runtime.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22171 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Sep 8, 2014
1 parent 2845735 commit fe07115
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
56 changes: 18 additions & 38 deletions Compiler/runtime/SimulationResultsCmp.c
Expand Up @@ -115,48 +115,28 @@ static inline void fixCommaInName(char **str, size_t len)
*str = newvar;
}
}

static char ** getVars(void *vars, unsigned int* nvars)
{
char **cmpvars=NULL;
char *var;
unsigned int i;
char **cmpvars = NULL;
unsigned int ncmpvars = 0;
char **newvars=NULL;
*nvars=0;
#ifdef DEBUGOUTPUT
fprintf(stderr, "getVars\n");
#endif
while (RML_NILHDR != RML_GETHDR(vars)) {
var = RML_STRINGDATA(RML_CAR(vars));
unsigned int i = 0;
void *v;

// if var is empty, continue
if (strcmp(var, "\"\"") == 0) {
#ifdef DEBUGOUTPUT
fprintf(stderr, "skip Var: %s\n", var);
#endif
vars = RML_CDR(vars);
continue;
}
#ifdef DEBUGOUTPUT
fprintf(stderr, "Var: %s\n", var);
#endif
newvars = (char**)malloc(sizeof(char*)*(ncmpvars+1));

for (i=0;i<ncmpvars;i++)
newvars[i] = cmpvars[i];
newvars[ncmpvars] = var;
ncmpvars += 1;
if(cmpvars) free(cmpvars);
cmpvars = newvars;
#ifdef DEBUGOUTPUT
fprintf(stderr, "NVar: %d\n", ncmpvars);
#endif
vars = RML_CDR(vars);
/* Count the number of variables in the list. */
for(v = vars; RML_NILHDR != RML_GETHDR(v); v = RML_CDR(v)) {
++ncmpvars;
}

/* Allocate a new string array to contain the variable names. */
cmpvars = (char**)GC_malloc(sizeof(char*)*(ncmpvars));

/* Copy the variable names from the RML list to the string array. */
for(; RML_NILHDR != RML_GETHDR(vars); vars = RML_CDR(vars)) {
cmpvars[i++] = GC_strdup(RML_STRINGDATA(RML_CAR(vars)));
}

*nvars = ncmpvars;
#ifdef DEBUGOUTPUT
fprintf(stderr, "found %d Vars\n", ncmpvars);
#endif
return cmpvars;
}

Expand Down Expand Up @@ -719,7 +699,7 @@ void* SimulationResultsCmp_compareResults(int isResultCmp, int runningTestsuite,
ngetfailedvars++;
continue;
}
}
}
/* check if in file */
data = getData(var1,filename,size,suggestReadAll,&simresglob_c,runningTestsuite);
if (data.n==0) {
Expand Down Expand Up @@ -774,7 +754,7 @@ void* SimulationResultsCmp_compareResults(int isResultCmp, int runningTestsuite,
// if (var1) free(var1);
// if (var2) free(var2);
if (ddf.data) free(ddf.data);
if (cmpvars) free(cmpvars);
if (cmpvars) GC_free(cmpvars);
if (time.data) free(time.data);
if (timeref.data) free(timeref.data);
if (cmpdiffvars) free(cmpdiffvars);
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/optimization/DataManagement/MoveData.c
Expand Up @@ -608,7 +608,7 @@ void diffSynColoredOptimizerSystem(OptData *optData, modelica_real **J, const in
DATA * data = optData->data;
int i,j,l,ii, ll;

const h_index = optData->s.indexABCD[index];
const int h_index = optData->s.indexABCD[index];
const long double * scaldt = optData->bounds.scaldt[m];
const unsigned int * const cC = data->simulationInfo.analyticJacobians[h_index].sparsePattern.colorCols;
const unsigned int * const lindex = optData->s.lindex[index];
Expand Down

0 comments on commit fe07115

Please sign in to comment.