Redefine the default boolean type to gmx_bool.
[alexxy/gromacs.git] / src / kernel / md.c
index 5e52e6c8d0e881b2ddbb0ba3f21d5b01d63ec650..8cde3adb58de6d0aa3fac7ae7cf93e2f8b4a2f25 100644 (file)
    negative or zero. */
 enum { eglsNABNSB, eglsCHKPT, eglsSTOPCOND, eglsRESETCOUNTERS, eglsNR };
 /* Is the signal in one simulation independent of other simulations? */
-bool gs_simlocal[eglsNR] = { TRUE, FALSE, FALSE, TRUE };
+gmx_bool gs_simlocal[eglsNR] = { TRUE, FALSE, FALSE, TRUE };
 
 typedef struct {
     int nstms;       /* The frequency for intersimulation communication */
@@ -121,7 +121,7 @@ typedef struct {
 static int multisim_min(const gmx_multisim_t *ms,int nmin,int n)
 {
     int  *buf;
-    bool bPos,bEqual;
+    gmx_bool bPos,bEqual;
     int  s,d;
 
     snew(buf,ms->nsim);
@@ -306,30 +306,34 @@ static void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr,
                             t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
                             gmx_enerdata_t *enerd,tensor force_vir, tensor shake_vir, tensor total_vir, 
                             tensor pres, rvec mu_tot, gmx_constr_t constr, 
-                            globsig_t *gs,bool bInterSimGS,
+                            globsig_t *gs,gmx_bool bInterSimGS,
                             matrix box, gmx_mtop_t *top_global, real *pcurr, 
-                            int natoms, bool *bSumEkinhOld, int flags)
+                            int natoms, gmx_bool *bSumEkinhOld, int flags)
 {
     int  i,gsi;
     real gs_buf[eglsNR];
     tensor corr_vir,corr_pres,shakeall_vir;
-    bool bEner,bPres,bTemp, bVV;
-    bool bRerunMD, bStopCM, bGStat, bIterate, 
+    gmx_bool bEner,bPres,bTemp, bVV;
+    gmx_bool bRerunMD, bStopCM, bGStat, bIterate, 
         bFirstIterate,bReadEkin,bEkinAveVel,bScaleEkin, bConstrain;
     real ekin,temp,prescorr,enercorr,dvdlcorr;
     
-    /* translate CGLO flags to booleans */
+    /* translate CGLO flags to gmx_booleans */
     bRerunMD = flags & CGLO_RERUNMD;
     bStopCM = flags & CGLO_STOPCM;
     bGStat = flags & CGLO_GSTAT;
-    bReadEkin = flags & CGLO_READEKIN;
-    bScaleEkin = flags & CGLO_SCALEEKIN;
+
+/* FIX ME after 4.5 */
+/* temporary hack because we are using gmx_bool (unsigned char) */
+
+    bReadEkin = (flags & CGLO_READEKIN) != 0;
+    bScaleEkin = (flags & CGLO_SCALEEKIN) != 0;
     bEner = flags & CGLO_ENERGY;
     bTemp = flags & CGLO_TEMPERATURE;
-    bPres  = flags & CGLO_PRESSURE;
-    bConstrain = flags & CGLO_CONSTRAINT;
-    bIterate = flags & CGLO_ITERATE;
-    bFirstIterate = flags & CGLO_FIRSTITERATE;
+    bPres  = (flags & CGLO_PRESSURE) != 0;
+    bConstrain = (flags & CGLO_CONSTRAINT) != 0;
+    bIterate = (flags & CGLO_ITERATE) != 0;
+    bFirstIterate = (flags & CGLO_FIRSTITERATE) != 0;
 
     /* we calculate a full state kinetic energy either with full-step velocity verlet
        or half step where we need the pressure */
@@ -532,7 +536,7 @@ typedef struct
 {
     real f,fprev,x,xprev;  
     int iter_i;
-    bool bIterate;
+    gmx_bool bIterate;
     real allrelerr[MAXITERCONST+2];
     int num_close; /* number of "close" violations, caused by limited precision. */
 } gmx_iterate_t;
@@ -554,7 +558,7 @@ typedef struct
 /* maximum length of cyclic traps to check, emerging from limited numerical precision  */
 #define CYCLEMAX            20
 
-static void gmx_iterate_init(gmx_iterate_t *iterate,bool bIterate)
+static void gmx_iterate_init(gmx_iterate_t *iterate,gmx_bool bIterate)
 {
     int i;
 
@@ -567,7 +571,7 @@ static void gmx_iterate_init(gmx_iterate_t *iterate,bool bIterate)
     }
 }
 
-static bool done_iterating(const t_commrec *cr,FILE *fplog, int nsteps, gmx_iterate_t *iterate, bool bFirstIterate, real fom, real *newf) 
+static gmx_bool done_iterating(const t_commrec *cr,FILE *fplog, int nsteps, gmx_iterate_t *iterate, gmx_bool bFirstIterate, real fom, real *newf) 
 {    
     /* monitor convergence, and use a secant search to propose new
        values.  
@@ -594,7 +598,7 @@ static bool done_iterating(const t_commrec *cr,FILE *fplog, int nsteps, gmx_iter
     real relerr,err,xmin;
     char buf[256];
     int i;
-    bool incycle;
+    gmx_bool incycle;
     
     if (bFirstIterate) 
     {
@@ -913,7 +917,7 @@ void check_ir_old_tpx_versions(t_commrec *cr,FILE *fplog,
 }
 
 typedef struct {
-    bool       bGStatEveryStep;
+    gmx_bool       bGStatEveryStep;
     gmx_large_int_t step_ns;
     gmx_large_int_t step_nscheck;
     gmx_large_int_t nns;
@@ -934,7 +938,7 @@ static void reset_nlistheuristics(gmx_nlheur_t *nlh,gmx_large_int_t step)
 }
 
 static void init_nlistheuristics(gmx_nlheur_t *nlh,
-                                 bool bGStatEveryStep,gmx_large_int_t step)
+                                 gmx_bool bGStatEveryStep,gmx_large_int_t step)
 {
     nlh->bGStatEveryStep = bGStatEveryStep;
     nlh->nns       = 0;
@@ -996,7 +1000,7 @@ static void update_nliststatistics(gmx_nlheur_t *nlh,gmx_large_int_t step)
     }
 }
 
-static void set_nlistheuristics(gmx_nlheur_t *nlh,bool bReset,gmx_large_int_t step)
+static void set_nlistheuristics(gmx_nlheur_t *nlh,gmx_bool bReset,gmx_large_int_t step)
 {
     int d;
 
@@ -1019,9 +1023,9 @@ static void set_nlistheuristics(gmx_nlheur_t *nlh,bool bReset,gmx_large_int_t st
 }
 
 static void rerun_parallel_comm(t_commrec *cr,t_trxframe *fr,
-                                bool *bNotLastFrame)
+                                gmx_bool *bNotLastFrame)
 {
-    bool bAlloc;
+    gmx_bool bAlloc;
     rvec *xp,*vp;
 
     bAlloc = (fr->natoms == 0);
@@ -1060,7 +1064,7 @@ static void rerun_parallel_comm(t_commrec *cr,t_trxframe *fr,
 }
 
 double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
-             const output_env_t oenv, bool bVerbose,bool bCompact,
+             const output_env_t oenv, gmx_bool bVerbose,gmx_bool bCompact,
              int nstglobalcomm,
              gmx_vsite_t *vsite,gmx_constr_t constr,
              int stepout,t_inputrec *ir,
@@ -1080,15 +1084,15 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
     gmx_large_int_t step,step_rel;
     double     run_time;
     double     t,t0,lam0;
-    bool       bGStatEveryStep,bGStat,bNstEner,bCalcEnerPres;
-    bool       bNS,bNStList,bSimAnn,bStopCM,bRerunMD,bNotLastFrame=FALSE,
+    gmx_bool       bGStatEveryStep,bGStat,bNstEner,bCalcEnerPres;
+    gmx_bool       bNS,bNStList,bSimAnn,bStopCM,bRerunMD,bNotLastFrame=FALSE,
                bFirstStep,bStateFromTPX,bInitStep,bLastStep,
                bBornRadii,bStartingFromCpt;
-    bool       bDoDHDL=FALSE;
-    bool       do_ene,do_log,do_verbose,bRerunWarnNoV=TRUE,
+    gmx_bool       bDoDHDL=FALSE;
+    gmx_bool       do_ene,do_log,do_verbose,bRerunWarnNoV=TRUE,
                bForceUpdate=FALSE,bCPT;
     int        mdof_flags;
-    bool       bMasterState;
+    gmx_bool       bMasterState;
     int        force_flags,cglo_flags;
     tensor     force_vir,shake_vir,total_vir,tmp_vir,pres;
     int        i,m;
@@ -1115,18 +1119,18 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
     t_graph    *graph=NULL;
     globsig_t   gs;
 
-    bool        bFFscan;
+    gmx_bool        bFFscan;
     gmx_groups_t *groups;
     gmx_ekindata_t *ekind, *ekind_save;
     gmx_shellfc_t shellfc;
     int         count,nconverged=0;
     real        timestep=0;
     double      tcount=0;
-    bool        bIonize=FALSE;
-    bool        bTCR=FALSE,bConverged=TRUE,bOK,bSumEkinhOld,bExchanged;
-    bool        bAppend;
-    bool        bResetCountersHalfMaxH=FALSE;
-    bool        bVV,bIterations,bFirstIterate,bTemp,bPres,bTrotter;
+    gmx_bool        bIonize=FALSE;
+    gmx_bool        bTCR=FALSE,bConverged=TRUE,bOK,bSumEkinhOld,bExchanged;
+    gmx_bool        bAppend;
+    gmx_bool        bResetCountersHalfMaxH=FALSE;
+    gmx_bool        bVV,bIterations,bFirstIterate,bTemp,bPres,bTrotter;
     real        temp0,mu_aver=0,dvdl;
     int         a0,a1,gnx=0,ii;
     atom_id     *grpindex=NULL;
@@ -2621,7 +2625,7 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
         /* Output stuff */
         if (MASTER(cr))
         {
-            bool do_dr,do_or;
+            gmx_bool do_dr,do_or;
             
             if (!(bStartingFromCpt && (EI_VV(ir->eI)))) 
             {