Xcos-Scicos: indent some files before modification
[scilab.git] / scilab / modules / scicos / src / c / scicos.c
index 32a3a39..d714bef 100644 (file)
@@ -445,7 +445,10 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
         if ((mod = MALLOC(sizeof(int) * nmod)) == NULL )
         {
             *ierr = 5;
-            if (nx > 0) FREE(xprop);
+            if (nx > 0)
+            {
+                FREE(xprop);
+            }
             return 0;
         }
     }
@@ -454,8 +457,14 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
         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;
         }
     }
@@ -467,9 +476,18 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
     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;
     }
 
@@ -808,7 +826,8 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
     {
 
         /*     integration */
-        switch (C2F(cmsolver).solver) {
+        switch (C2F(cmsolver).solver)
+        {
             case 0: // LSodar - Dynamic / Dynamic
             case 1: // CVode - BDF / Newton
             case 2: // CVode - BDF / Functional
@@ -862,7 +881,10 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
             {
                 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)
@@ -1035,7 +1057,10 @@ static void cosini(double *told)
                 *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)
@@ -1119,7 +1144,10 @@ static void cosini(double *told)
                     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;
@@ -1129,7 +1157,10 @@ static void cosini(double *told)
                     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;
@@ -1139,7 +1170,10 @@ static void cosini(double *told)
                     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;
@@ -1149,7 +1183,10 @@ static void cosini(double *told)
                     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;
@@ -1159,7 +1196,10 @@ static void cosini(double *told)
                     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;
@@ -1169,7 +1209,10 @@ static void cosini(double *told)
                     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;
@@ -1179,7 +1222,10 @@ static void cosini(double *told)
                     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;
@@ -1189,7 +1235,10 @@ static void cosini(double *told)
                     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;
@@ -1231,42 +1280,60 @@ L30:
                 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;
 
@@ -1317,7 +1384,8 @@ static void cossim(double *told)
     /* 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;
@@ -1356,7 +1424,9 @@ static void cossim(double *told)
     }
 
     for ( jj = 0 ; jj < ng ; jj++ )
+    {
         jroot[jj] = 0 ;
+    }
 
     zcros = NULL;
     if (ng != 0)
@@ -1364,7 +1434,10 @@ static void cossim(double *told)
         if ((zcros = MALLOC(sizeof(int) * ng)) == NULL )
         {
             *ierr = 10000;
-            if (ng > 0) FREE(jroot);
+            if (ng > 0)
+            {
+                FREE(jroot);
+            }
             return;
         }
     }
@@ -1378,8 +1451,14 @@ static void cossim(double *told)
         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;
         }
 
@@ -1434,7 +1513,9 @@ static void cossim(double *told)
             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);
@@ -1447,7 +1528,9 @@ static void cossim(double *told)
             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);
@@ -1468,7 +1551,9 @@ static void cossim(double *told)
             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);
@@ -1477,8 +1562,10 @@ static void cossim(double *told)
         }
 
         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);
@@ -1545,8 +1632,14 @@ static void cossim(double *told)
             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--------------------*/
 
@@ -1562,7 +1655,10 @@ static void cossim(double *told)
         }
         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;
@@ -1697,7 +1793,10 @@ L30:
                             Discrete_Jump = 1;
                             jroot[jj] = -1;
                         }
-                        else jroot[jj] = 0;
+                        else
+                        {
+                            jroot[jj] = 0;
+                        }
                     }
                 }
                 /*--discrete zero crossings----dzero--------------------*/
@@ -1732,14 +1831,18 @@ L30:
                 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)
@@ -1751,7 +1854,10 @@ L30:
                 }
                 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;
                 }
@@ -1981,7 +2087,8 @@ static void cossimdaskr(double *told)
     /* 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;
@@ -2010,7 +2117,10 @@ static void cossimdaskr(double *told)
             return;
         }
     }
-    for ( jj = 0 ; jj < ng ; jj++ )  jroot[jj] = 0 ;
+    for ( jj = 0 ; jj < ng ; jj++ )
+    {
+        jroot[jj] = 0 ;
+    }
 
     zcros = NULL;
     if (ng != 0)
@@ -2018,7 +2128,10 @@ static void cossimdaskr(double *told)
         if ((zcros = MALLOC(sizeof(int) * ng)) == NULL )
         {
             *ierr = 10000;
-            if (ng != 0) FREE(jroot);
+            if (ng != 0)
+            {
+                FREE(jroot);
+            }
             return;
         }
     }
@@ -2029,8 +2142,14 @@ static void cossimdaskr(double *told)
         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;
         }
     }
@@ -2044,9 +2163,18 @@ static void cossimdaskr(double *told)
         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;
 
@@ -2054,10 +2182,22 @@ static void cossimdaskr(double *told)
         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;
@@ -2067,11 +2207,26 @@ static void cossimdaskr(double *told)
         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;
         }
 
@@ -2080,43 +2235,107 @@ static void cossimdaskr(double *told)
         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;
         }
 
@@ -2124,43 +2343,110 @@ static void cossimdaskr(double *told)
         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;
         }
 
@@ -2168,13 +2454,34 @@ static void cossimdaskr(double *told)
         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;
@@ -2187,29 +2494,80 @@ static void cossimdaskr(double *told)
         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;
             }
         }
@@ -2232,22 +2590,54 @@ static void cossimdaskr(double *told)
 
         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);
@@ -2278,7 +2668,9 @@ static void cossimdaskr(double *told)
 
         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);
@@ -2288,7 +2680,9 @@ static void cossimdaskr(double *told)
 
         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);
@@ -2298,7 +2692,9 @@ static void cossimdaskr(double *told)
 
         /* 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);
@@ -2362,8 +2758,14 @@ static void cossimdaskr(double *told)
             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)
@@ -2377,7 +2779,10 @@ static void cossimdaskr(double *told)
         }
         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;
@@ -2484,8 +2889,14 @@ L30:
                     }
                     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);
@@ -2508,7 +2919,9 @@ L30:
                     /* 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);
@@ -2555,7 +2968,10 @@ L30:
                         }
                         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;
@@ -2575,11 +2991,15 @@ L30:
 
                         // 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 */
                         {
@@ -2634,13 +3054,19 @@ L30:
                             {
                                 /* 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);
@@ -2657,10 +3083,14 @@ L30:
                         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;
@@ -2706,7 +3136,10 @@ L30:
                             Discrete_Jump = 1;
                             jroot[jj] = -1;
                         }
-                        else jroot[jj] = 0;
+                        else
+                        {
+                            jroot[jj] = 0;
+                        }
                     }
                 }
 
@@ -2729,14 +3162,18 @@ L30:
                 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)
@@ -2748,7 +3185,10 @@ L30:
                 }
                 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;
                 }
@@ -2872,8 +3312,14 @@ L30:
                                     }
                                     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;
+                                        }
                                     }
                                 }
                             }
@@ -2891,7 +3337,10 @@ L30:
 
                 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;
@@ -3028,7 +3477,10 @@ void callf(double *t, scicos_block *block, scicos_flag *flag)
 
     /* 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;
@@ -3049,9 +3501,15 @@ void callf(double *t, scicos_block *block, scicos_flag *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 */
+            }
         }
     }
 
@@ -3455,8 +3913,14 @@ void callf(double *t, scicos_block *block, scicos_flag *flag)
     {
         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);*/
         }
@@ -3507,7 +3971,10 @@ static void call_debug_scicos(scicos_block *block, scicos_flag *flag, int flagi,
         }
     }
 
-    if (*flag < 0) sciprint(_("Error in the Debug block \n"));
+    if (*flag < 0)
+    {
+        sciprint(_("Error in the Debug block \n"));
+    }
 } /* call_debug_scicos */
 /*--------------------------------------------------------------------------*/
 /* simblk */
@@ -3520,7 +3987,10 @@ static int simblk(realtype t, N_Vector yy, N_Vector yp, void *f_data)
     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);
@@ -3538,7 +4008,10 @@ static int simblk(realtype t, N_Vector yy, N_Vector yp, void *f_data)
                 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*/
@@ -3569,7 +4042,10 @@ static int grblk(realtype t, N_Vector yy, realtype *gout, void *g_data)
                 nantest = 1;
                 break;
             } /* NaN checking */
-        if (nantest == 1) return 350; /* recoverable error; */
+        if (nantest == 1)
+        {
+            return 350;    /* recoverable error; */
+        }
     }
     C2F(ierode).iero = *ierr;
 
@@ -3582,9 +4058,12 @@ static int simblklsodar(int * nequations, realtype * tOld, realtype * actual, re
     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);
@@ -3602,7 +4081,10 @@ static int simblklsodar(int * nequations, realtype * tOld, realtype * actual, re
                 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*/
@@ -3615,7 +4097,7 @@ static int grblklsodar(int * nequations, realtype * tOld, realtype * actual, int
     double tx = 0.;
     int jj = 0, nantest = 0;
 
-   tx = (double) *tOld;
+    tx = (double) * tOld;
 
     C2F(ierode).iero = 0;
     *ierr = 0;
@@ -3632,7 +4114,10 @@ static int grblklsodar(int * nequations, realtype * tOld, realtype * actual, int
                 nantest = 1;
                 break;
             } /* NaN checking */
-        if (nantest == 1) return 350; /* recoverable error; */
+        if (nantest == 1)
+        {
+            return 350;    /* recoverable error; */
+        }
     }
     C2F(ierode).iero = *ierr;
 
@@ -3680,10 +4165,14 @@ static int simblkdaskr(realtype tres, N_Vector yy, N_Vector yp, N_Vector resval,
 
     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;
@@ -3711,7 +4200,10 @@ static int simblkdaskr(realtype tres, N_Vector yy, N_Vector yp, N_Vector resval,
                 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*/
@@ -4885,7 +5377,10 @@ void Jdoit(double *told, double *xt, double *xtd, double *residual, int *job)
             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)
                 {
@@ -4919,7 +5414,10 @@ void Jdoit(double *told, double *xt, double *xtd, double *residual, int *job)
                 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)
                     {
@@ -5340,11 +5838,20 @@ static void FREE_blocks()
     }
     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 */
@@ -5356,13 +5863,19 @@ int C2F(funnum)(char * fname)
     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 */
 /*--------------------------------------------------------------------------*/
@@ -5609,21 +6122,29 @@ static int Jacobians(long int Neq, realtype tt, realtype cj, N_Vector yy,
     /* 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) {
@@ -5640,12 +6161,19 @@ static int Jacobians(long int Neq, realtype tt, realtype cj, N_Vector yy,
         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;
     }
@@ -5669,7 +6197,9 @@ static int Jacobians(long int Neq, realtype tt, realtype cj, N_Vector yy,
     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++)
     {
@@ -5681,18 +6211,28 @@ static int Jacobians(long int Neq, realtype tt, realtype cj, N_Vector yy,
         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);
@@ -5757,7 +6297,9 @@ static void Multp(double *A, double *B, double *R, int ra, int rb, int ca, int c
         {
             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;
 }
@@ -5768,7 +6310,10 @@ int read_xml_initial_states(int nvar, const char * xmlfile, char **ids, double *
     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++)
     {
@@ -5778,7 +6323,10 @@ int read_xml_initial_states(int nvar, const char * xmlfile, char **ids, double *
             break;
         }
     }
-    if (result == 0) return 0;
+    if (result == 0)
+    {
+        return 0;
+    }
 
     model = ezxml_parse_file(xmlfile);
 
@@ -5793,7 +6341,10 @@ int read_xml_initial_states(int nvar, const char * xmlfile, char **ids, double *
     {
         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;
@@ -5804,7 +6355,10 @@ static int read_id(ezxml_t *elements, char *id, double *value)
     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 )
     {
@@ -5818,12 +6372,18 @@ static int read_id(ezxml_t *elements, char *id, double *value)
             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
         {
@@ -5870,7 +6430,10 @@ int write_xml_states(int nvar, const char * xmlfile, char **ids, double *x)
     char *s = NULL;
     char **xv = NULL;
 
-    if (nvar == 0) return 0;
+    if (nvar == 0)
+    {
+        return 0;
+    }
     result = 0;
     for (i = 0; i < nvar; i++)
     {
@@ -5880,7 +6443,10 @@ int write_xml_states(int nvar, const char * xmlfile, char **ids, double *x)
             break;
         }
     }
-    if (result == 0) return 0;
+    if (result == 0)
+    {
+        return 0;
+    }
 
     xv = MALLOC(nvar * sizeof(char*));
     for (i = 0; i < nvar; i++)
@@ -5905,7 +6471,10 @@ int write_xml_states(int nvar, const char * xmlfile, char **ids, double *x)
 
     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 )
         {
@@ -5955,7 +6524,9 @@ int rho_(double *a, double *L, double *x, double *rho, double *rpar, int *ipar)
 
     fx_(x, rho);
     for (i = 0; i < N; i++)
+    {
         rho[i] += (-1 + *L) * a[i];
+    }
     return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -5969,7 +6540,9 @@ int rhojac_(double *a, double *lambda, double  *x, double  *jac, int *col, doubl
     if (*col == 1)
     {
         for (j = 0; j < N; j++)
+        {
             jac[j] = a[j];
+        }
     }
     else
     {
@@ -5989,7 +6562,9 @@ int rhojac_(double *a, double *lambda, double  *x, double  *jac, int *col, doubl
         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);
@@ -6030,7 +6605,9 @@ int C2F(hfjac)(double *x, double *jac, int *col)
     inc_inv = ONE / inc;
 
     for (j = 0; j < N; j++)
+    {
         jac[j] = (jac[j] - work[j]) * inc_inv;
+    }
 
     x[*col - 1] = xi;
 
@@ -6050,7 +6627,10 @@ int simblkKinsol(N_Vector yy, N_Vector resval, void *rdata)
     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;
@@ -6101,7 +6681,10 @@ static int CallKinsol(double *told)
     double ratio = 0.;
 
     N = *neq;
-    if (N <= 0) return 0;
+    if (N <= 0)
+    {
+        return 0;
+    }
 
     reltol = (realtype) rtol;
     abstol = (realtype) Atol;
@@ -6174,8 +6757,14 @@ static int CallKinsol(double *told)
         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;
@@ -6200,14 +6789,29 @@ static int CallKinsol(double *told)
             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
             {
@@ -6254,13 +6858,19 @@ static int CallKinsol(double *told)
                 }
             }
 
-            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*/
@@ -6274,3 +6884,4 @@ static int CallKinsol(double *told)
     return status;
 } /* CallKinSol_ */
 /*--------------------------------------------------------------------------*/
+