Skip to content

Commit 3f6f37b

Browse files
committed
- activate dtostr in realString.c for MinGW32 too.
- get rid of some warnings in SimulationRuntime/c/ + try to use existing defined types instead of casting as that might generate problems. int is rather a bad type on different platforms so use integer or fortran_integer directly instead of casting. - let's see if we run into any problems. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14275 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0af9f47 commit 3f6f37b

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

SimulationRuntime/c/meta/realString.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ modelica_string realString(modelica_real r)
251251
return MMC_REFSTRINGLIT(_OMC_LIT_POS_INF);
252252
else if (isnan(r))
253253
return MMC_REFSTRINGLIT(_OMC_LIT_NAN);
254-
#if defined(__MINGW32__) || defined(_MSC_VER)
254+
#if defined(_MSC_VER)
255255
return _old_realString(r);
256-
#else /* Linux seems to know how to handle this */
256+
#else /* Linux and MinGW seems to know how to handle this */
257257
return dtostr(r);
258258
#endif
259259
}

SimulationRuntime/c/simulation/solver/dassl.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
303303

304304
if (dasslData->dasslMethod == DASSL_SYMJAC)
305305
{
306-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
306+
DDASRT(functionODE_residual, &mData->nStates,
307307
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
308308
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
309309
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -312,7 +312,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
312312
}
313313
else if (dasslData->dasslMethod == DASSL_NUMJAC)
314314
{
315-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
315+
DDASRT(functionODE_residual, &mData->nStates,
316316
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
317317
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
318318
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -321,7 +321,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
321321
}
322322
else if (dasslData->dasslMethod == DASSL_COLOREDSYMJAC)
323323
{
324-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
324+
DDASRT(functionODE_residual, &mData->nStates,
325325
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
326326
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
327327
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -330,7 +330,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
330330
}
331331
else if (dasslData->dasslMethod == DASSL_INTERNALNUMJAC)
332332
{
333-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
333+
DDASRT(functionODE_residual, &mData->nStates,
334334
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
335335
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
336336
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -339,7 +339,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
339339
}
340340
else if (dasslData->dasslMethod == DASSL_TEST)
341341
{
342-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
342+
DDASRT(functionODE_residual, &mData->nStates,
343343
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
344344
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
345345
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -348,7 +348,7 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
348348
}
349349
else if (dasslData->dasslMethod == DASSL_WORT)
350350
{
351-
DDASRT(functionODE_residual, (fortran_integer*) &mData->nStates,
351+
DDASRT(functionODE_residual, &mData->nStates,
352352
&solverInfo->currentTime, sData->realVars, stateDer, &tout,
353353
dasslData->info, dasslData->rtol, dasslData->atol, &dasslData->idid,
354354
dasslData->rwork, &dasslData->lrw, dasslData->iwork, &dasslData->liw,
@@ -396,16 +396,16 @@ int dasrt_step(DATA* simData, SOLVER_INFO* solverInfo)
396396
if(DEBUG_STREAM(LOG_SOLVER))
397397
{
398398
INFO(LOG_SOLVER, "| DDASRT | dassl call staistics: ");
399-
INFO1(LOG_SOLVER, " | value of idid: %d", dasslData->idid);
399+
INFO1(LOG_SOLVER, " | value of idid: %ld", dasslData->idid);
400400
INFO1(LOG_SOLVER, " | current time value: %0.4g", solverInfo->currentTime);
401401
INFO1(LOG_SOLVER, " | current integration time value: %0.4g", dasslData->rwork[3]);
402402
INFO1(LOG_SOLVER, " | step size H to be attempted on next step: %0.4g", dasslData->rwork[2]);
403403
INFO1(LOG_SOLVER, " | step size used on last successful step: %0.4g", dasslData->rwork[6]);
404-
INFO1(LOG_SOLVER, " | number of steps taken so far: %d", dasslData->iwork[10]);
405-
INFO1(LOG_SOLVER, " | number of calls of functionODE() : %d", dasslData->iwork[11]);
406-
INFO1(LOG_SOLVER, " | number of calculation of jacobian : %d", dasslData->iwork[12]);
407-
INFO1(LOG_SOLVER, " | total number of convergence test failures: %d", dasslData->iwork[13]);
408-
INFO1(LOG_SOLVER, " | total number of error test failures: %d", dasslData->iwork[14]);
404+
INFO1(LOG_SOLVER, " | number of steps taken so far: %ld", dasslData->iwork[10]);
405+
INFO1(LOG_SOLVER, " | number of calls of functionODE() : %ld", dasslData->iwork[11]);
406+
INFO1(LOG_SOLVER, " | number of calculation of jacobian : %ld", dasslData->iwork[12]);
407+
INFO1(LOG_SOLVER, " | total number of convergence test failures: %ld", dasslData->iwork[13]);
408+
INFO1(LOG_SOLVER, " | total number of error test failures: %ld", dasslData->iwork[14]);
409409
}
410410
/* save dassl stats */
411411
for (ui = 0; ui < numStatistics; ui++)
@@ -726,7 +726,7 @@ jacA_num(DATA* data, double *t, double *y, double *yprime, double *delta, double
726726
double delta_h = dasslData->sqrteps;
727727
double delta_hh,delta_hhh, deltaInv;
728728
double ysave;
729-
int ires;
729+
integer ires;
730730
int i,j;
731731

732732
for (i = data->modelData.nStates-1; i >=0 ; i--) {
@@ -811,7 +811,7 @@ jacA_numColored(DATA* data, double *t, double *y, double *yprime, double *delta,
811811
DASSL_DATA* dasslData = (DASSL_DATA*)(void*)((double**)rpar)[1];
812812
double delta_h = dasslData->sqrteps;
813813
double delta_hhh;
814-
int ires;
814+
integer ires;
815815
double* delta_hh = dasslData->delta_hh;
816816
double* ysave = dasslData->ysave;
817817

SimulationRuntime/c/simulation/solver/nonlinearSolverHybrd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int freeHybrdData(void **voiddata){
122122
*
123123
*
124124
*/
125-
void wrapper_fvec_hybrd(int* n, double* x, double* f, int* iflag, void* data){
125+
void wrapper_fvec_hybrd(integer* n, double* x, double* f, int* iflag, void* data){
126126

127127
int i,currentSys = ((DATA*)data)->simulationInfo.currentNonlinearSystemIndex;
128128
NONLINEAR_SYSTEM_DATA* systemData = &(((DATA*)data)->simulationInfo.nonlinearSystemData[currentSys]);
@@ -376,7 +376,6 @@ int solveHybrd(DATA *data, int sysNumber) {
376376

377377
/* Scaling residual vector */
378378
{
379-
double tmp;
380379
int i,j,l=0;
381380
for(i=0;i<solverData->n;i++){
382381
solverData->resScaling[i] = 1e-16;

SimulationRuntime/c/simulation/solver/nonlinearSolverHybrd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ extern "C" {
4848
#endif
4949

5050
extern
51-
void * _omc_hybrj_(void(*) (int*, double*, double*, double *, int*, int*, void* data),
52-
int *n,double*x,double*fvec,double*fjac,int *ldfjac,double*xtol,int* maxfev,
51+
void * _omc_hybrj_(void(*) (integer*, double*, double*, double *, int*, int*, void* data),
52+
integer *n,double*x,double*fvec,double*fjac,int *ldfjac,double*xtol,int* maxfev,
5353
double* diag,int *mode,double*factor,int *nprint,int*info,int*nfev,int*njev,
5454
double* r,int *lr,double*qtf,double*wa1,double*wa2,
5555
double* wa3,double* wa4, void* userdata);
5656

5757
extern
58-
void _omc_hybrd_(void (*) (int*, double *, double*, int*, void*),
59-
int* n, double* x ,double* fvec, double* xtol,
58+
void _omc_hybrd_(void (*) (integer*, double *, double*, int*, void*),
59+
integer* n, double* x ,double* fvec, double* xtol,
6060
int* maxfev, int* ml, int* mu, double* epsfcn, double* diag,
6161
int* mode, double* factor, int* nprint, int* info, int* nfev,
6262
double* fjac, double* fjacobian, int* ldfjac, double* r__,
@@ -75,7 +75,7 @@ typedef struct DATA_HYBRD
7575
double* xScalefactors;
7676
double* fvecScaled;
7777

78-
int n;
78+
integer n;
7979
double* x;
8080
double* fvec;
8181
double xtol;

SimulationRuntime/c/simulation_data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
modelica_string_t modelDir;
286286
modelica_string_t modelGUID;
287287

288-
long nStates;
288+
fortran_integer nStates;
289289
long nVariablesReal; /* all Real Variables of the model (states,statesderivatives,algebraics) */
290290
long nVariablesInteger;
291291
long nVariablesBoolean;
@@ -320,7 +320,7 @@
320320
long nJacobians;
321321
}MODEL_DATA;
322322

323-
typedef struct SIMULTAION_INFO
323+
typedef struct SIMULATION_INFO
324324
{
325325
modelica_real startTime;
326326
modelica_real stopTime;

0 commit comments

Comments
 (0)