if ((mod = MALLOC(sizeof(int) * nmod)) == NULL )
{
*ierr = 5;
- if (nx > 0) FREE(xprop);
+ if (nx > 0)
+ {
+ FREE(xprop);
+ }
return 0;
}
}
if ((g = MALLOC(sizeof(double) * ng)) == NULL )
{
*ierr = 5;
- if (nmod > 0) FREE(mod);
- if (nx > 0) FREE(xprop);
+ if (nmod > 0)
+ {
+ FREE(mod);
+ }
+ if (nx > 0)
+ {
+ FREE(xprop);
+ }
return 0;
}
}
if ((Blocks = MALLOC(sizeof(scicos_block) * nblk)) == NULL )
{
*ierr = 5;
- if (nx > 0) FREE(xprop);
- if (nmod > 0) FREE(mod);
- if (ng > 0) FREE(g);
+ if (nx > 0)
+ {
+ FREE(xprop);
+ }
+ if (nmod > 0)
+ {
+ FREE(mod);
+ }
+ if (ng > 0)
+ {
+ FREE(g);
+ }
return 0;
}
{
/* integration */
- switch (C2F(cmsolver).solver) {
+ switch (C2F(cmsolver).solver)
+ {
case 0: // LSodar - Dynamic / Dynamic
case 1: // CVode - BDF / Newton
case 2: // CVode - BDF / Functional
{
zdoit(t0, x, x + nx, W); /* updating modes as a function of state values; this was necessary in iGUI*/
}
- for (jj = 0; jj < nx; jj++) W[jj] = 0.0;
+ for (jj = 0; jj < nx; jj++)
+ {
+ W[jj] = 0.0;
+ }
C2F(ierode).iero = 0;
*ierr = 0;
if (C2F(cmsolver).solver < 100)
*ierr = 5 - flag__;
kfune = C2F(curblk).kfun;
}
- if ((Jacobian_Flag == 1) && (AJacobian_block == 0)) AJacobian_block = C2F(curblk).kfun;
+ if ((Jacobian_Flag == 1) && (AJacobian_block == 0))
+ {
+ AJacobian_block = C2F(curblk).kfun;
+ }
}
}
if (*ierr != 0)
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbdptr[kk] != (SCSREAL_COP)outtbd[curouttbd + kk]) goto L30;
+ if (outtbdptr[kk] != (SCSREAL_COP)outtbd[curouttbd + kk])
+ {
+ goto L30;
+ }
}
curouttbd += sszz;
break;
sszz = 2 * outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbdptr[kk] != (SCSCOMPLEX_COP)outtbd[curouttbd + kk]) goto L30;
+ if (outtbdptr[kk] != (SCSCOMPLEX_COP)outtbd[curouttbd + kk])
+ {
+ goto L30;
+ }
}
curouttbd += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbcptr[kk] != (SCSINT8_COP)outtbc[curouttbc + kk]) goto L30;
+ if (outtbcptr[kk] != (SCSINT8_COP)outtbc[curouttbc + kk])
+ {
+ goto L30;
+ }
}
curouttbc += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbsptr[kk] != (SCSINT16_COP)outtbs[curouttbs + kk]) goto L30;
+ if (outtbsptr[kk] != (SCSINT16_COP)outtbs[curouttbs + kk])
+ {
+ goto L30;
+ }
}
curouttbs += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtblptr[kk] != (SCSINT32_COP)outtbl[curouttbl + kk]) goto L30;
+ if (outtblptr[kk] != (SCSINT32_COP)outtbl[curouttbl + kk])
+ {
+ goto L30;
+ }
}
curouttbl += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbucptr[kk] != (SCSUINT8_COP)outtbuc[curouttbuc + kk]) goto L30;
+ if (outtbucptr[kk] != (SCSUINT8_COP)outtbuc[curouttbuc + kk])
+ {
+ goto L30;
+ }
}
curouttbuc += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbusptr[kk] != (SCSUINT16_COP)outtbus[curouttbus + kk]) goto L30;
+ if (outtbusptr[kk] != (SCSUINT16_COP)outtbus[curouttbus + kk])
+ {
+ goto L30;
+ }
}
curouttbus += sszz;
break;
sszz = outtbsz[jj] * outtbsz[jj + nlnk];
for (kk = 0; kk < sszz; kk++)
{
- if (outtbulptr[kk] != (SCSUINT32_COP)outtbul[curouttbul + kk]) goto L30;
+ if (outtbulptr[kk] != (SCSUINT32_COP)outtbul[curouttbul + kk])
+ {
+ goto L30;
+ }
}
curouttbul += sszz;
break;
case SCSINT8_N :
outtbcptr = (SCSINT8_COP *)outtbptr[ii]; /*int8*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbc[curouttbc + kk] = (SCSINT8_COP)outtbcptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbc[curouttbc + kk] = (SCSINT8_COP)outtbcptr[kk];
+ }
curouttbc += sszz;
break;
case SCSINT16_N :
outtbsptr = (SCSINT16_COP *)outtbptr[ii]; /*int16*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbs[curouttbs + kk] = (SCSINT16_COP)outtbsptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbs[curouttbs + kk] = (SCSINT16_COP)outtbsptr[kk];
+ }
curouttbs += sszz;
break;
case SCSINT32_N :
outtblptr = (SCSINT32_COP *)outtbptr[ii]; /*int32*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbl[curouttbl + kk] = (SCSINT32_COP)outtblptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbl[curouttbl + kk] = (SCSINT32_COP)outtblptr[kk];
+ }
curouttbl += sszz;
break;
case SCSUINT8_N :
outtbucptr = (SCSUINT8_COP *)outtbptr[ii]; /*uint8*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbuc[curouttbuc + kk] = (SCSUINT8_COP)outtbucptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbuc[curouttbuc + kk] = (SCSUINT8_COP)outtbucptr[kk];
+ }
curouttbuc += sszz;
break;
case SCSUINT16_N :
outtbusptr = (SCSUINT16_COP *)outtbptr[ii]; /*uint16*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbus[curouttbus + kk] = (SCSUINT16_COP)outtbusptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbus[curouttbus + kk] = (SCSUINT16_COP)outtbusptr[kk];
+ }
curouttbus += sszz;
break;
case SCSUINT32_N :
outtbulptr = (SCSUINT32_COP *)outtbptr[ii]; /*uint32*/
sszz = outtbsz[ii] * outtbsz[ii + nlnk];
- for (kk = 0; kk < sszz; kk++) outtbul[curouttbul + kk] = (SCSUINT32_COP)outtbulptr[kk];
+ for (kk = 0; kk < sszz; kk++)
+ {
+ outtbul[curouttbul + kk] = (SCSUINT32_COP)outtbulptr[kk];
+ }
curouttbul += sszz;
break;
/* Generic flags for stop mode */
int ODE_NORMAL = 1; /* ODE_NORMAL = CV_NORMAL = LS_NORMAL = 1 */
int ODE_ONE_STEP = 2; /* ODE_ONE_STEP = CV_ONE_STEP = LS_ONE_STEP = 2 */
- switch (C2F(cmsolver).solver) {
+ switch (C2F(cmsolver).solver)
+ {
case 0: // LSodar
ODE = &LSodar;
ODEReInit = &LSodarReInit;
}
for ( jj = 0 ; jj < ng ; jj++ )
+ {
jroot[jj] = 0 ;
+ }
zcros = NULL;
if (ng != 0)
if ((zcros = MALLOC(sizeof(int) * ng)) == NULL )
{
*ierr = 10000;
- if (ng > 0) FREE(jroot);
+ if (ng > 0)
+ {
+ FREE(jroot);
+ }
return;
}
}
if (check_flag((void *)y, "N_VNewEmpty_Serial", 0))
{
*ierr = 10000;
- if (ng > 0) FREE(jroot);
- if (ng > 0) FREE(zcros);
+ if (ng > 0)
+ {
+ FREE(jroot);
+ }
+ if (ng > 0)
+ {
+ FREE(zcros);
+ }
return;
}
flag = LSodarSetErrHandlerFn(ode_mem, SundialsErrHandler, NULL);
}
else
- flag = CVodeSetErrHandlerFn(ode_mem, SundialsErrHandler, NULL);
+ {
+ flag = CVodeSetErrHandlerFn(ode_mem, SundialsErrHandler, NULL);
+ }
if (check_flag(&flag, "CVodeSetErrHandlerFn", 1))
{
*ierr = 300 + (-flag);
flag = LSodarInit (ode_mem, simblklsodar, T0, y);
}
else
- flag = CVodeInit (ode_mem, simblk, T0, y);
+ {
+ flag = CVodeInit (ode_mem, simblk, T0, y);
+ }
if (check_flag(&flag, "CVodeInit", 1))
{
*ierr = 300 + (-flag);
flag = LSodarRootInit(ode_mem, ng, grblklsodar);
}
else
- flag = CVodeRootInit(ode_mem, ng, grblk);
+ {
+ flag = CVodeRootInit(ode_mem, ng, grblk);
+ }
if (check_flag(&flag, "CVodeRootInit", 1))
{
*ierr = 300 + (-flag);
}
if (C2F(cmsolver).solver != 0)
- /* Call CVDense to specify the CVDENSE dense linear solver */
- flag = CVDense(ode_mem, *neq);
+ /* Call CVDense to specify the CVDENSE dense linear solver */
+ {
+ flag = CVDense(ode_mem, *neq);
+ }
if (check_flag(&flag, "CVDense", 1))
{
*ierr = 300 + (-flag);
return;
}
for (jj = 0; jj < ng; ++jj)
- if (g[jj] >= 0) jroot[jj] = 5;
- else jroot[jj] = -5;
+ if (g[jj] >= 0)
+ {
+ jroot[jj] = 5;
+ }
+ else
+ {
+ jroot[jj] = -5;
+ }
}
/*--discrete zero crossings----dzero--------------------*/
}
if (C2F(coshlt).halt != 0)
{
- if (C2F(coshlt).halt == 2) *told = *tf; /* end simulation */
+ if (C2F(coshlt).halt == 2)
+ {
+ *told = *tf; /* end simulation */
+ }
C2F(coshlt).halt = 0;
freeall;
return;
Discrete_Jump = 1;
jroot[jj] = -1;
}
- else jroot[jj] = 0;
+ else
+ {
+ jroot[jj] = 0;
+ }
}
}
/*--discrete zero crossings----dzero--------------------*/
if (flag >= 0)
{
if ((C2F(cosdebug).cosd >= 1) && (C2F(cosdebug).cosd != 3))
+ {
sciprint(_("****SUNDIALS.Cvode reached: %f\n"), *told);
+ }
hot = 1;
cnt = 0;
}
else if ( flag == CV_TOO_MUCH_WORK || flag == CV_CONV_FAILURE || flag == CV_ERR_FAILURE)
{
if ((C2F(cosdebug).cosd >= 1) && (C2F(cosdebug).cosd != 3))
+ {
sciprint(_("****SUNDIALS.Cvode: too much work at time=%g (stiff region, change RTOL and ATOL)\n"), *told);
+ }
hot = 0;
cnt++;
if (cnt > 5)
}
else
{
- if (flag < 0) *ierr = 300 + (-flag); /* raising errors due to internal errors, otherwise error due to flagr*/
+ if (flag < 0)
+ {
+ *ierr = 300 + (-flag); /* raising errors due to internal errors, otherwise error due to flagr*/
+ }
freeall;
return;
}
/* Generic flag for stop mode */
int DAE_NORMAL = 1; /* IDA_NORMAL = 1 */
int DAE_ONE_STEP = 2; /* IDA_ONE_STEP = 2 */
- switch (C2F(cmsolver).solver) {
+ switch (C2F(cmsolver).solver)
+ {
case 100: // IDA
DAESolve = &IDASolve;
DAEReInit = &IDAReInit;
return;
}
}
- for ( jj = 0 ; jj < ng ; jj++ ) jroot[jj] = 0 ;
+ for ( jj = 0 ; jj < ng ; jj++ )
+ {
+ jroot[jj] = 0 ;
+ }
zcros = NULL;
if (ng != 0)
if ((zcros = MALLOC(sizeof(int) * ng)) == NULL )
{
*ierr = 10000;
- if (ng != 0) FREE(jroot);
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
return;
}
}
if ((Mode_save = MALLOC(sizeof(int) * nmod)) == NULL )
{
*ierr = 10000;
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
return;
}
}
yy = N_VNewEmpty_Serial(*neq);
if (check_flag((void *)yy, "N_VNew_Serial", 0))
{
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
}
NV_DATA_S(yy) = x;
yp = N_VNewEmpty_Serial(*neq);
if (check_flag((void *)yp, "N_VNew_Serial", 0))
{
- if (*neq > 0) N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
NV_DATA_S(yp) = xd;
if (check_flag((void *)IDx, "N_VNew_Serial", 0))
{
*ierr = 10000;
- if (*neq > 0) N_VDestroy_Serial(yp);
- if (*neq > 0) N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
dae_mem = IDACreate();
if (check_flag((void *)dae_mem, "IDACreate", 0))
{
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
copy_IDA_mem = (IDAMem) dae_mem;
if (C2F(cmsolver).solver == 100)
- flag = IDASetErrHandlerFn(dae_mem, SundialsErrHandler, NULL);
+ {
+ flag = IDASetErrHandlerFn(dae_mem, SundialsErrHandler, NULL);
+ }
if (check_flag(&flag, "IDASetErrHandlerFn", 1))
{
*ierr = 200 + (-flag);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if (C2F(cmsolver).solver == 100)
- flag = IDAInit(dae_mem, simblkdaskr, T0, yy, yp);
+ {
+ flag = IDAInit(dae_mem, simblkdaskr, T0, yy, yp);
+ }
if (check_flag(&flag, "IDAInit", 1))
{
*ierr = 200 + (-flag);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if (check_flag(&flag, "IDASStolerances", 1))
{
*ierr = 200 + (-flag);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if (C2F(cmsolver).solver == 100)
- flag = IDARootInit(dae_mem, ng, grblkdaskr);
+ {
+ flag = IDARootInit(dae_mem, ng, grblkdaskr);
+ }
if (check_flag(&flag, "IDARootInit", 1))
{
*ierr = 200 + (-flag);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if (C2F(cmsolver).solver == 100)
- flag = IDADense(dae_mem, *neq);
+ {
+ flag = IDADense(dae_mem, *neq);
+ }
if (check_flag(&flag, "IDADense", 1))
{
*ierr = 200 + (-flag);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if ((data = (UserData) MALLOC(sizeof(*data))) == NULL)
{
*ierr = 10000;
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
data->dae_mem = dae_mem;
if (check_flag((void *)data->ewt, "N_VNew_Serial", 0))
{
*ierr = 200 + (-flag);
- if (*neq > 0)FREE(data);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)
+ {
+ FREE(data);
+ }
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
if ( ng > 0 )
{
if ((data->gwork = (double *) MALLOC(ng * sizeof(double))) == NULL)
{
- if (*neq > 0)N_VDestroy_Serial(data->ewt);
- if (*neq > 0)FREE(data);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(data->ewt);
+ }
+ if (*neq > 0)
+ {
+ FREE(data);
+ }
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
return;
}
}
if ((data->rwork = (double *) MALLOC(Jactaille * sizeof(double))) == NULL)
{
- if ( ng > 0 )FREE(data->gwork);
- if (*neq > 0)N_VDestroy_Serial(data->ewt);
- if (*neq > 0)FREE(data);
- if (*neq > 0)if (C2F(cmsolver).solver == 100) IDAFree(&dae_mem);
- if (*neq > 0)N_VDestroy_Serial(IDx);
- if (*neq > 0)N_VDestroy_Serial(yp);
- if (*neq > 0)N_VDestroy_Serial(yy);
- if (ng != 0) FREE(jroot);
- if (ng != 0) FREE(zcros);
- if (nmod != 0) FREE(Mode_save);
+ if ( ng > 0 )
+ {
+ FREE(data->gwork);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(data->ewt);
+ }
+ if (*neq > 0)
+ {
+ FREE(data);
+ }
+ if (*neq > 0)if (C2F(cmsolver).solver == 100)
+ {
+ IDAFree(&dae_mem);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(IDx);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yp);
+ }
+ if (*neq > 0)
+ {
+ N_VDestroy_Serial(yy);
+ }
+ if (ng != 0)
+ {
+ FREE(jroot);
+ }
+ if (ng != 0)
+ {
+ FREE(zcros);
+ }
+ if (nmod != 0)
+ {
+ FREE(Mode_save);
+ }
*ierr = 10000;
return;
}
if (C2F(cmsolver).solver == 100)
- flag = IDADlsSetDenseJacFn(dae_mem, Jacobians);
+ {
+ flag = IDADlsSetDenseJacFn(dae_mem, Jacobians);
+ }
if (check_flag(&flag, "IDADlsSetDenseJacFn", 1))
{
*ierr = 200 + (-flag);
maxnj = 100; /* setting the maximum number of Jacobian evaluations during a Newton step */
if (C2F(cmsolver).solver == 100)
- flag = IDASetMaxNumJacsIC(dae_mem, maxnj);
+ {
+ flag = IDASetMaxNumJacsIC(dae_mem, maxnj);
+ }
if (check_flag(&flag, "IDASetMaxNumJacsIC", 1))
{
*ierr = 200 + (-flag);
maxnit = 10; /* setting the maximum number of Newton iterations in any attempt to solve CIC */
if (C2F(cmsolver).solver == 100)
- flag = IDASetMaxNumItersIC(dae_mem, maxnit);
+ {
+ flag = IDASetMaxNumItersIC(dae_mem, maxnit);
+ }
if (check_flag(&flag, "IDASetMaxNumItersIC", 1))
{
*ierr = 200 + (-flag);
/* setting the maximum number of steps in an integration interval */
if (C2F(cmsolver).solver == 100)
- flag = IDASetMaxNumSteps(dae_mem, 2000);
+ {
+ flag = IDASetMaxNumSteps(dae_mem, 2000);
+ }
if (check_flag(&flag, "IDASetMaxNumSteps", 1))
{
*ierr = 200 + (-flag);
return;
}
for (jj = 0; jj < ng; ++jj)
- if (g[jj] >= 0) jroot[jj] = 5;
- else jroot[jj] = -5;
+ if (g[jj] >= 0)
+ {
+ jroot[jj] = 5;
+ }
+ else
+ {
+ jroot[jj] = -5;
+ }
}
/* main loop on time */
while (*told < *tf)
}
if (C2F(coshlt).halt != 0)
{
- if (C2F(coshlt).halt == 2) *told = *tf; /* end simulation */
+ if (C2F(coshlt).halt == 2)
+ {
+ *told = *tf; /* end simulation */
+ }
C2F(coshlt).halt = 0;
freeallx;
return;
}
for (jj = 0; jj < *neq; jj++)
{
- if (xprop[jj] == 1) scicos_xproperty[jj] = ONE;
- if (xprop[jj] == -1) scicos_xproperty[jj] = ZERO;
+ if (xprop[jj] == 1)
+ {
+ scicos_xproperty[jj] = ONE;
+ }
+ if (xprop[jj] == -1)
+ {
+ scicos_xproperty[jj] = ZERO;
+ }
}
/* CI=0.0;CJ=100.0; // for functions Get_Jacobian_ci and Get_Jacobian_cj
Jacobians(*neq, (realtype) (*told), yy, yp, bidon, (realtype) CJ, data, TJacque, tempv1, tempv2, tempv3);
/* printf("\n"); for(jj=0;jj<*neq;jj++) { printf("x%d=%g ",jj,scicos_xproperty[jj]); }*/
if (C2F(cmsolver).solver == 100)
- flag = IDASetId(dae_mem, IDx);
+ {
+ flag = IDASetId(dae_mem, IDx);
+ }
if (check_flag(&flag, "IDASetId", 1))
{
*ierr = 200 + (-flag);
}
if (C2F(coshlt).halt != 0)
{
- if (C2F(coshlt).halt == 2) *told = *tf; /* end simulation */
+ if (C2F(coshlt).halt == 2)
+ {
+ *told = *tf; /* end simulation */
+ }
C2F(coshlt).halt = 0;
freeallx;
return;
// the initial conditons y0 and yp0 do not satisfy the DAE
if (C2F(cmsolver).solver == 100)
- flagr = IDACalcIC(dae_mem, IDA_YA_YDP_INIT, (realtype)(t));
+ {
+ flagr = IDACalcIC(dae_mem, IDA_YA_YDP_INIT, (realtype)(t));
+ }
phase = 1;
if (C2F(cmsolver).solver == 100)
- flag = IDAGetConsistentIC(dae_mem, yy, yp); /* PHI->YY */
+ {
+ flag = IDAGetConsistentIC(dae_mem, yy, yp); /* PHI->YY */
+ }
if (*ierr > 5) /* *ierr>5 => singularity in block */
{
{
/* IDASetMaxNumStepsIC(mem,10); */ /* maxnh (def=5) */
if (C2F(cmsolver).solver == 100)
- IDASetMaxNumJacsIC(dae_mem, 10); /* maxnj 100 (def=4)*/
+ {
+ IDASetMaxNumJacsIC(dae_mem, 10); /* maxnj 100 (def=4)*/
+ }
/* IDASetMaxNumItersIC(mem,100000); */ /* maxnit in IDANewtonIC (def=10) */
if (C2F(cmsolver).solver == 100)
- IDASetLineSearchOffIC(dae_mem, TRUE); /* (def=false) */
+ {
+ IDASetLineSearchOffIC(dae_mem, TRUE); /* (def=false) */
+ }
/* IDASetNonlinConvCoefIC(mem,1.01);*/ /* (def=0.01-0.33*/
if (C2F(cmsolver).solver == 100)
- flag = IDASetMaxNumItersIC(dae_mem, 1000);
+ {
+ flag = IDASetMaxNumItersIC(dae_mem, 1000);
+ }
if (check_flag(&flag, "IDASetMaxNumItersIC", 1))
{
*ierr = 200 + (-flag);
phase = 1;
copy_IDA_mem->ida_kk = 1;
if (C2F(cmsolver).solver == 100)
- flagr = IDACalcIC(dae_mem, IDA_YA_YDP_INIT, (realtype)(t));
+ {
+ flagr = IDACalcIC(dae_mem, IDA_YA_YDP_INIT, (realtype)(t));
+ }
phase = 1;
if (C2F(cmsolver).solver == 100)
- flag = IDAGetConsistentIC(dae_mem, yy, yp); /* PHI->YY */
+ {
+ flag = IDAGetConsistentIC(dae_mem, yy, yp); /* PHI->YY */
+ }
if ((flagr < 0) || (*ierr > 5)) /* *ierr>5 => singularity in block */
{
*ierr = 23;
Discrete_Jump = 1;
jroot[jj] = -1;
}
- else jroot[jj] = 0;
+ else
+ {
+ jroot[jj] = 0;
+ }
}
}
if (flagr >= 0)
{
if ((C2F(cosdebug).cosd >= 1) && (C2F(cosdebug).cosd != 3))
+ {
sciprint(_("****SUNDIALS.Ida reached: %f\n"), *told);
+ }
hot = 1;
cnt = 0;
}
else if ( flagr == IDA_TOO_MUCH_WORK || flagr == IDA_CONV_FAIL || flagr == IDA_ERR_FAIL)
{
if ((C2F(cosdebug).cosd >= 1) && (C2F(cosdebug).cosd != 3))
+ {
sciprint(_("**** SUNDIALS.Ida: too much work at time=%g (stiff region, change RTOL and ATOL)\n"), *told);
+ }
hot = 0;
cnt++;
if (cnt > 5)
}
else
{
- if (flagr < 0) *ierr = 200 + (-flagr); /* raising errors due to internal errors, otherwise error due to flagr*/
+ if (flagr < 0)
+ {
+ *ierr = 200 + (-flagr); /* raising errors due to internal errors, otherwise error due to flagr*/
+ }
freeallx;
return;
}
}
for (j = 0; j < *neq; j++) /* Adjust xprop for IDx */
{
- if (xprop[j] == 1) scicos_xproperty[j] = ONE;
- if (xprop[j] == -1) scicos_xproperty[j] = ZERO;
+ if (xprop[j] == 1)
+ {
+ scicos_xproperty[j] = ONE;
+ }
+ if (xprop[j] == -1)
+ {
+ scicos_xproperty[j] = ZERO;
+ }
}
}
}
if (C2F(coshlt).halt != 0)
{
- if (C2F(coshlt).halt == 2) *told = *tf; /* end simulation */
+ if (C2F(coshlt).halt == 2)
+ {
+ *told = *tf; /* end simulation */
+ }
C2F(coshlt).halt = 0;
freeallx;
return;
/* debug block is never called */
/*if (kf==(debug_block+1)) return;*/
- if (block->type == 99) return;
+ if (block->type == 99)
+ {
+ return;
+ }
/* flag 7 implicit initialization */
flagi = (int) * flag;
}
if (debug_block > -1)
{
- if (cosd != 3) sciprint(_("Entering the block \n"));
+ if (cosd != 3)
+ {
+ sciprint(_("Entering the block \n"));
+ }
call_debug_scicos(block, flag, flagi, debug_block);
- if (*flag < 0) return; /* error in debug block */
+ if (*flag < 0)
+ {
+ return; /* error in debug block */
+ }
}
}
{
if (debug_block > -1)
{
- if (*flag < 0) return; /* error in block */
- if (cosd != 3) sciprint(_("Leaving block %d \n"), C2F(curblk).kfun);
+ if (*flag < 0)
+ {
+ return; /* error in block */
+ }
+ if (cosd != 3)
+ {
+ sciprint(_("Leaving block %d \n"), C2F(curblk).kfun);
+ }
call_debug_scicos(block, flag, flagi, debug_block);
/*call_debug_scicos(flag,kf,flagi,debug_block);*/
}
}
}
- if (*flag < 0) sciprint(_("Error in the Debug block \n"));
+ if (*flag < 0)
+ {
+ sciprint(_("Error in the Debug block \n"));
+ }
} /* call_debug_scicos */
/*--------------------------------------------------------------------------*/
/* simblk */
x = (double *) NV_DATA_S(yy);
xd = (double *) NV_DATA_S(yp);
- for (i = 0; i < *neq; i++) xd[i] = 0; /* Ã la place de "C2F(dset)(neq, &c_b14,xcdot , &c__1);"*/
+ for (i = 0; i < *neq; i++)
+ {
+ xd[i] = 0; /* Ã la place de "C2F(dset)(neq, &c_b14,xcdot , &c__1);"*/
+ }
C2F(ierode).iero = 0;
*ierr = 0;
odoit(&tx, x, xd, xd);
break;
}
}
- if (nantest == 1) return 349; /* recoverable error; */
+ if (nantest == 1)
+ {
+ return 349; /* recoverable error; */
+ }
}
return (abs(*ierr)); /* ierr>0 recoverable error; ierr>0 unrecoverable error; ierr=0: ok*/
nantest = 1;
break;
} /* NaN checking */
- if (nantest == 1) return 350; /* recoverable error; */
+ if (nantest == 1)
+ {
+ return 350; /* recoverable error; */
+ }
}
C2F(ierode).iero = *ierr;
double tx = 0.;
int i = 0, nantest = 0;
- tx = (double) *tOld;
+ tx = (double) * tOld;
- for (i = 0; i < *nequations; ++i) res[i] = 0; /* Ã la place de "C2F(dset)(neq, &c_b14,xcdot , &c__1);"*/
+ for (i = 0; i < *nequations; ++i)
+ {
+ res[i] = 0; /* Ã la place de "C2F(dset)(neq, &c_b14,xcdot , &c__1);"*/
+ }
C2F(ierode).iero = 0;
*ierr = 0;
odoit(&tx, actual, res, res);
break;
}
}
- if (nantest == 1) return 349; /* recoverable error; */
+ if (nantest == 1)
+ {
+ return 349; /* recoverable error; */
+ }
}
return (abs(*ierr)); /* ierr>0 recoverable error; ierr>0 unrecoverable error; ierr=0: ok*/
double tx = 0.;
int jj = 0, nantest = 0;
- tx = (double) *tOld;
+ tx = (double) * tOld;
C2F(ierode).iero = 0;
*ierr = 0;
nantest = 1;
break;
} /* NaN checking */
- if (nantest == 1) return 350; /* recoverable error; */
+ if (nantest == 1)
+ {
+ return 350; /* recoverable error; */
+ }
}
C2F(ierode).iero = *ierr;
alpha = ZERO;
for (jj = 0; jj < qlast; jj++)
+ {
alpha = alpha - ONE / (jj + 1);
+ }
if (hh != 0)
// CJ=-alpha/hh; // For function Get_Jacobian_cj
+ {
CJJ = -alpha / hh;
+ }
else
{
*ierr = 217;
nantest = 1;
break;
}
- if (nantest == 1) return 257; /* recoverable error; */
+ if (nantest == 1)
+ {
+ return 257; /* recoverable error; */
+ }
}
return (abs(*ierr)); /* ierr>0 recoverable error; ierr>0 unrecoverable error; ierr=0: ok*/
flag = 0;
if (((*job == 1) && (scs_imp->oord[ii] == AJacobian_block)) || (*job != 1))
{
- if (*job == 1) flag = 10;
+ if (*job == 1)
+ {
+ flag = 10;
+ }
/* continuous state */
if (scs_imp->blocks[*kf - 1].nx > 0)
{
flag = 0;
if (((*job == 1) && (scs_imp->oord[ii - 1] == AJacobian_block)) || (*job != 1))
{
- if (*job == 1) flag = 10;
+ if (*job == 1)
+ {
+ flag = 10;
+ }
/* continuous state */
if (scs_imp->blocks[*kf - 1].nx > 0)
{
}
FREE(Blocks);
- if (nx > 0) FREE(xprop);
+ if (nx > 0)
+ {
+ FREE(xprop);
+ }
- if (nmod > 0) FREE(mod);
+ if (nmod > 0)
+ {
+ FREE(mod);
+ }
- if (ng > 0) FREE(g);
+ if (ng > 0)
+ {
+ FREE(g);
+ }
return;
} /* FREE_blocks */
int loc = -1;
while ( tabsim[i].name != (char *) NULL)
{
- if ( strcmp(fname, tabsim[i].name) == 0 ) return(i + 1);
+ if ( strcmp(fname, tabsim[i].name) == 0 )
+ {
+ return(i + 1);
+ }
i++;
}
ln = (int)strlen(fname);
C2F(iislink)(fname, &loc);
C2F(iislink)(fname, &loc);
- if (loc >= 0) return(ntabsim + (int)loc + 1);
+ if (loc >= 0)
+ {
+ return(ntabsim + (int)loc + 1);
+ }
return(0);
}/* funnum */
/*--------------------------------------------------------------------------*/
/* read residuals;*/
job = 0;
Jdoit(&ttx, xc, xcdot, residual, &job);
- if (*ierr < 0) return -1;
+ if (*ierr < 0)
+ {
+ return -1;
+ }
/* "residual" already contains the current residual,
so the first call to Jdoit can be remoevd*/
for (i = 0; i < m; i++)
for (j = 0; j < ni; j++)
+ {
Kx[j + i * ni] = u[j][0];
+ }
for (i = 0; i < m; i++)
{
xi = xc[i];
xpi = xcdot[i];
inc = MAX( srur * MAX( ABS(xi), ABS(hh * xpi)), ONE / ewt_data[i] );
- if (hh * xpi < ZERO) inc = -inc;
+ if (hh * xpi < ZERO)
+ {
+ inc = -inc;
+ }
inc = (xi + inc) - xi;
/* if (CI==0) {
del=SQUR[0]*Max(a,b); */
job = 0; /* read residuals */
Jdoit(&ttx, xc, xcdot, ERR2, &job);
- if (*ierr < 0) return -1;
+ if (*ierr < 0)
+ {
+ return -1;
+ }
inc_inv = ONE / inc;
for (j = 0; j < m; j++)
+ {
Hx[m * i + j] = (ERR2[j] - residual[j]) * inc_inv;
+ }
for (j = 0; j < ni; j++)
+ {
Kx[j + i * ni] = (u[j][0] - Kx[j + i * ni]) * inc_inv;
+ }
xc[i] = xi;
xcdot[i] = xpi;
}
Jdoit(&ttx, xc, xcdot, ERR1, &job);
for (i = 0; i < no; i++)
for (j = 0; j < ni; j++)
+ {
Ku[j + i * ni] = u[j][0];
+ }
for (i = 0; i < no; i++)
{
y[i][0] += inc;
job = 2; /* applying y[i][0] to the output of imp block*/
Jdoit(&ttx, xc, xcdot, ERR2, &job);
- if (*ierr < 0) return -1;
+ if (*ierr < 0)
+ {
+ return -1;
+ }
inc_inv = ONE / inc;
for (j = 0; j < m; j++)
+ {
Hu[m * i + j] = (ERR2[j] - ERR1[j]) * inc_inv;
+ }
for (j = 0; j < ni; j++)
+ {
Ku[j + i * ni] = (u[j][0] - Ku[j + i * ni]) * inc_inv;
+ }
y[i][0] = ysave;
}
/*----------------------------------------------*/
job = 1; /* read jacobian through flag=10; */
Jdoit(&ttx, xc, xcdot, &Fx[-m], &job);/* Filling up the FX:Fu:Gx:Gu*/
- if (*block_error != 0) sciprint(_("\n error in Jacobian"));
+ if (*block_error != 0)
+ {
+ sciprint(_("\n error in Jacobian"));
+ }
/*-------------------------------------------------*/
Multp(Fu, Ku, RX, nx, ni, ni, no);
{
R[i + ra * j] = 0.0;
for (k = 0; k < ca; k++)
+ {
R[i + ra * j] += A[i + k * ra] * B[k + j * rb];
+ }
}
return;
}
int result = 0, i = 0;
double vr = 0.;
- if (nvar == 0) return 0;
+ if (nvar == 0)
+ {
+ return 0;
+ }
result = 0;
for (i = 0; i < nvar; i++)
{
break;
}
}
- if (result == 0) return 0;
+ if (result == 0)
+ {
+ return 0;
+ }
model = ezxml_parse_file(xmlfile);
{
vr = 0.0;
result = read_id(&elements, ids[i], &vr);
- if (result == 1) svars[i] = vr;
+ if (result == 1)
+ {
+ svars[i] = vr;
+ }
}
ezxml_free(model);
return 0;
char V1[100], V2[100];
int ok = 0, i = 0, ln = 0;
- if (strcmp(id, "") == 0) return 0;
+ if (strcmp(id, "") == 0)
+ {
+ return 0;
+ }
ok = search_in_child(elements, id, V1);
if (ok == 0 )
{
ln = (int)(strlen(V1));
if (ln > 2)
{
- for (i = 1; i <= ln - 2; i++) V2[i - 1] = V1[i];
+ for (i = 1; i <= ln - 2; i++)
+ {
+ V2[i - 1] = V1[i];
+ }
V2[ln - 2] = '\0';
ok = read_id(elements, V2, value);
return ok;
}
- else return 0;
+ else
+ {
+ return 0;
+ }
}
else
{
char *s = NULL;
char **xv = NULL;
- if (nvar == 0) return 0;
+ if (nvar == 0)
+ {
+ return 0;
+ }
result = 0;
for (i = 0; i < nvar; i++)
{
break;
}
}
- if (result == 0) return 0;
+ if (result == 0)
+ {
+ return 0;
+ }
xv = MALLOC(nvar * sizeof(char*));
for (i = 0; i < nvar; i++)
for (i = 0; i < nvar; i++)
{
- if (strcmp(ids[i], "") == 0) continue;
+ if (strcmp(ids[i], "") == 0)
+ {
+ continue;
+ }
result = write_in_child(&elements, ids[i], xv[i]);
if (result == 0 )
{
fx_(x, rho);
for (i = 0; i < N; i++)
+ {
rho[i] += (-1 + *L) * a[i];
+ }
return 0;
}
/*--------------------------------------------------------------------------*/
if (*col == 1)
{
for (j = 0; j < N; j++)
+ {
jac[j] = a[j];
+ }
}
else
{
inc_inv = 1.0 / inc;
for (j = 0; j < N; j++)
+ {
jac[j] = (jac[j] - work[j]) * inc_inv;
+ }
x[*col - 2] = xi;
FREE(work);
inc_inv = ONE / inc;
for (j = 0; j < N; j++)
+ {
jac[j] = (jac[j] - work[j]) * inc_inv;
+ }
x[*col - 1] = xi;
residual = (double *) NV_DATA_S(resval);
data = (UserData) rdata;
xcdot = xc;
- if (phase == 1) if ( ng > 0 && nmod > 0 ) zdoit(&t, xc, xcdot, g);
+ if (phase == 1) if ( ng > 0 && nmod > 0 )
+ {
+ zdoit(&t, xc, xcdot, g);
+ }
*ierr = 0;
C2F(ierode).iero = 0;
double ratio = 0.;
N = *neq;
- if (N <= 0) return 0;
+ if (N <= 0)
+ {
+ return 0;
+ }
reltol = (realtype) rtol;
abstol = (realtype) Atol;
fsdata[j] = 1;
}
/*========================================================*/
- if (PH == 2) PH = 1;
- else PH = 2; /* remind that PH is a static variable*/
+ if (PH == 2)
+ {
+ PH = 1;
+ }
+ else
+ {
+ PH = 2; /* remind that PH is a static variable*/
+ }
status = -1;
N_iters = 10 + nmod * 3;
ratio = 0.3;
for ( j = 0; j < N; j++)
{
- if (x[j] == 0) ysdata[j] += 1 * ratio;
- else ysdata[j] += ratio / fabs(x[j]);
- if (fsdata[j] == 0) fsdata[j] = 1;
- else fsdata[j] = 1 / fabs(fsdata[j]);
+ if (x[j] == 0)
+ {
+ ysdata[j] += 1 * ratio;
+ }
+ else
+ {
+ ysdata[j] += ratio / fabs(x[j]);
+ }
+ if (fsdata[j] == 0)
+ {
+ fsdata[j] = 1;
+ }
+ else
+ {
+ fsdata[j] = 1 / fabs(fsdata[j]);
+ }
ysdata[j] /= ratio + 1;
}
status = KINSol(kin_mem, y, strategy, yscale, fscale);/* Calling the Newton Solver */
- if (status >= 0) break;
+ if (status >= 0)
+ {
+ break;
+ }
/* Serge Steer 29/06/2009 */
while (ismenu()) //** if the user has done something, do the actions
{
}
}
- if (Mode_change == 0 && status >= 0 ) break; /*Successful termination*/
+ if (Mode_change == 0 && status >= 0 )
+ {
+ break; /*Successful termination*/
+ }
}
else
{
/* calling with phase=1*/
- if (status >= 0) break;
+ if (status >= 0)
+ {
+ break;
+ }
}
} /* end of the loop for mode fixing*/
return status;
} /* CallKinSol_ */
/*--------------------------------------------------------------------------*/
+