Code cleanup to avoid name collisions
authorRoland Schulz <roland@utk.edu>
Wed, 23 May 2012 00:30:08 +0000 (20:30 -0400)
committerRoland Schulz <roland@utk.edu>
Wed, 23 May 2012 00:35:40 +0000 (20:35 -0400)
- Adding missing prepropessor guards
- Renaming functions defined using same name as other function
- Removing unused magic.h

Change-Id: I1375097eb7eced2dafb30222c9986ac24f45fb08

include/constr.h
include/gmxcpp.h
include/magic.h [deleted file]
include/types/constr.h
src/gmxlib/statistics/gmx_statistics.c
src/gmxlib/trxio.c
src/gmxlib/typedefs.c
src/kernel/readrot.c
src/mdlib/fft5d.c
src/tools/gmx_trjcat.c
src/tools/gmx_trjconv.c

index bc0419e42803004073a315d75913c51aed322be3..92d4cb520ca119f60d6606a7a7d01aabfdd66c39 100644 (file)
@@ -34,6 +34,8 @@
  * Gromacs Runs On Most of All Computer Systems
  */
 
+#ifndef _constr_h
+#define _constr_h
 #include "typedefs.h"
 
 #ifdef __cplusplus
@@ -253,3 +255,4 @@ gmx_bool constrain_lincs(FILE *log,gmx_bool bLog,gmx_bool bEner,
 #ifdef __cplusplus
 }
 #endif
+#endif
index 3ed2b48a6f012f43dcf87373088c001dc8b99c49..d260545a36edcda49be3b8a2abd152c0d607c547 100644 (file)
@@ -33,7 +33,8 @@
  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
  */
 
-
+#ifndef _gmxcpp_h
+#define _gmxcpp_h
 typedef struct gmx_cpp *gmx_cpp_t; 
        
        /* The possible return codes for these functions */
@@ -82,3 +83,4 @@ int cpp_close_file(gmx_cpp_t *handlep);
    NOT THREAD SAFE 
    */
 char *cpp_error(gmx_cpp_t *handlep,int status);
+#endif
diff --git a/include/magic.h b/include/magic.h
deleted file mode 100644 (file)
index c493295..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 
- *                This source code is part of
- * 
- *                 G   R   O   M   A   C   S
- * 
- *          GROningen MAchine for Chemical Simulations
- * 
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- * 
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- * 
- * For more info, check our website at http://www.gromacs.org
- * 
- * And Hey:
- * Gromacs Runs On Most of All Computer Systems
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GROMACS_MAGIC
-#define GROMACS_MAGIC 0xff0d
-#endif
-
-#ifdef __cplusplus
-}
-#endif
index 9f5420ceb9c72d9118e7c5a14d6055f570606b31..7630a02629078012689e45b8c3acba656ff8cbed 100644 (file)
@@ -33,8 +33,8 @@
  * GRoups of Organic Molecules in ACtion for Science
  */
 
-#ifndef _constr_h
-#define _constr_h
+#ifndef _types_constr_h
+#define _types_constr_h
 
 #ifdef __cplusplus
 extern "C" {
index 7b50f924ae28a92aa4cb5ca9c2f94d808218457c..e57e4fe94296e10dbf6ccf68ec74f03bb222af3d 100644 (file)
 #include <math.h>
 #include "typedefs.h"
 #include "smalloc.h"
+#include "vec.h"
 #include "gmx_statistics.h"
 
-static double sqr(double x)
-{
-    return x*x;
-}
-
-static int gmx_nint(double x)
+static int gmx_dnint(double x)
 {
     return (int) (x+0.5);
 }
@@ -189,10 +185,10 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
         d2   = 0;
         for(i=0; (i<N); i++) 
         {
-            d2 += sqr(stats->x[i]-stats->y[i]);
+            d2 += dsqr(stats->x[i]-stats->y[i]);
             if ((stats->dy[i]) && (weight == elsqWEIGHT_Y))
             {
-                w = 1/sqr(stats->dy[i]);
+                w = 1/dsqr(stats->dy[i]);
             }
             else
             {
@@ -201,11 +197,11 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
             
             wtot  += w;
             
-            xx    += w*sqr(stats->x[i]);
-            xx_nw += sqr(stats->x[i]);
+            xx    += w*dsqr(stats->x[i]);
+            xx_nw += dsqr(stats->x[i]);
             
-            yy    += w*sqr(stats->y[i]);
-            yy_nw += sqr(stats->y[i]);
+            yy    += w*dsqr(stats->y[i]);
+            yy_nw += dsqr(stats->y[i]);
             
             yx    += w*stats->y[i]*stats->x[i];
             yx_nw += stats->y[i]*stats->x[i];
@@ -219,7 +215,7 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
       
         /* Compute average, sigma and error */
         stats->aver       = sy_nw/N;
-        stats->sigma_aver = sqrt(yy_nw/N - sqr(sy_nw/N));
+        stats->sigma_aver = sqrt(yy_nw/N - dsqr(sy_nw/N));
         stats->error      = stats->sigma_aver/sqrt(N);
 
         /* Compute RMSD between x and y */
@@ -231,10 +227,10 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
         yy_nw /= N;
         sx_nw /= N;
         sy_nw /= N;
-        ssxx = N*(xx_nw - sqr(sx_nw));
-        ssyy = N*(yy_nw - sqr(sy_nw));
+        ssxx = N*(xx_nw - dsqr(sx_nw));
+        ssyy = N*(yy_nw - dsqr(sy_nw));
         ssxy = N*(yx_nw - (sx_nw*sy_nw));
-        stats->Rdata = sqrt(sqr(ssxy)/(ssxx*ssyy)); 
+        stats->Rdata = sqrt(dsqr(ssxy)/(ssxx*ssyy));
         
         /* Compute straight line through datapoints, either with intercept
            zero (result in aa) or with intercept variable (results in a
@@ -262,8 +258,8 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
             {
                 dy = 1;
             }
-            chi2aa += sqr((stats->y[i]-(stats->aa*stats->x[i]))/dy);
-            chi2   += sqr((stats->y[i]-(stats->a*stats->x[i]+stats->b))/dy);
+            chi2aa += dsqr((stats->y[i]-(stats->aa*stats->x[i]))/dy);
+            chi2   += dsqr((stats->y[i]-(stats->a*stats->x[i]+stats->b))/dy);
         }
         if (N > 2) 
         {
@@ -542,7 +538,7 @@ int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb,
     }
     else
     {
-        nbins = gmx_nint((delta)/binwidth + 0.5);
+        nbins = gmx_dnint((delta)/binwidth + 0.5);
     }
     snew(*x,nbins);
     snew(nindex,nbins);
@@ -683,10 +679,10 @@ static int low_lsq_y_ax_b(int n, real *xr, double *xd, real yr[],
       chi2 = 0;
       if (xd != NULL) {
       for(i=0; i<n; i++)
-      chi2 += sqr(yr[i] - ((*a)*xd[i] + (*b)));
+      chi2 += dsqr(yr[i] - ((*a)*xd[i] + (*b)));
       } else {
       for(i=0; i<n; i++)
-      chi2 += sqr(yr[i] - ((*a)*xr[i] + (*b)));
+      chi2 += dsqr(yr[i] - ((*a)*xr[i] + (*b)));
       }
   
       if (n > 2)
@@ -744,10 +740,10 @@ int lsq_y_ax_b_error(int n, real x[], real y[], real dy[],
       gmx_fatal(FARGS,"Zero or negative weigths in linear regression analysis");
     
       for (i=0; i<n; i++) {
-      s_2  = sqr(1.0/dy[i]);
-      sxx += s_2*sqr(x[i]);
+      s_2  = dsqr(1.0/dy[i]);
+      sxx += s_2*dsqr(x[i]);
       sxy += s_2*y[i]*x[i];
-      syy += s_2*sqr(y[i]);
+      syy += s_2*dsqr(y[i]);
       sx  += s_2*x[i];
       sy  += s_2*y[i];
       w   += s_2;
@@ -764,7 +760,7 @@ int lsq_y_ax_b_error(int n, real x[], real y[], real dy[],
   
       *chi2=0;
       for(i=0; i<n; i++)
-      *chi2+=sqr((y[i]-((*a)*x[i]+(*b)))/dy[i]);
+      *chi2+=dsqr((y[i]-((*a)*x[i]+(*b)))/dy[i]);
       *chi2 = *chi2/w;
   
       *da = sqrt(*chi2/((n-2)*dx2));
index 8dab18c9bea7b0f47f6f1ee19e82d0c3756fa389..f9d807c224921e218f248d21dc4bd23ece9f709c 100644 (file)
@@ -436,7 +436,7 @@ static gmx_bool gmx_next_frame(t_trxstatus *status,t_trxframe *fr)
   return bRet;    
 }
 
-static void choose_ff(FILE *fp)
+static void choose_file_format(FILE *fp)
 {
   int i,m,c;
   int rc;
@@ -585,7 +585,7 @@ static int xyz_first_x(t_trxstatus *status, FILE *fp, const output_env_t oenv,
   initcount(status);
 
   clear_mat(box);
-  choose_ff(fp);
+  choose_file_format(fp);
 
   for(m=0; (m<DIM); m++)
     box[m][m]=status->BOX[m];
index 96a6ccf32aa3557dc37c198b7d4e8c083a9f9164..897d2f82a78598ddeb3fe2ed14f7d7a51b6a207a 100644 (file)
@@ -421,7 +421,7 @@ void done_inputrec(t_inputrec *ir)
   }
 }
 
-static void init_ekinstate(ekinstate_t *eks)
+static void zero_ekinstate(ekinstate_t *eks)
 {
   eks->ekin_n         = 0;
   eks->ekinh          = NULL;
@@ -555,7 +555,7 @@ void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainle
   state->sd_X = NULL;
   state->cg_p = NULL;
 
-  init_ekinstate(&state->ekinstate);
+  zero_ekinstate(&state->ekinstate);
 
   init_energyhistory(&state->enerhist);
 
index eb8644418e0db3c5b9b37101ac1b1fbf4dcabb53..bc5f2582991c528de354f67bce323b9a1651c3f6 100644 (file)
@@ -194,7 +194,7 @@ extern char **read_rotparams(int *ninp_p,t_inpfile **inp_p,t_rot *rot,
 
 
 /* Check whether the box is unchanged */
-static void check_box(matrix f_box, matrix box, char fn[], warninp_t wi)
+static void check_box_unchanged(matrix f_box, matrix box, char fn[], warninp_t wi)
 {
     int i,ii;
     gmx_bool bSame=TRUE;
@@ -265,7 +265,7 @@ extern void set_reference_positions(
              read_trn(reffile, &header.step, &header.t, &header.lambda, f_box, &header.natoms, rotg->x_ref, NULL, NULL);
 
              /* Check whether the box is unchanged and output a warning if not: */
-             check_box(f_box,box,reffile,wi);
+             check_box_unchanged(f_box,box,reffile,wi);
          }
          else
          {
index 7f99a6598b9de8e5febb59ffdd1f5eba80076774..19fd35f4d5e588eead52fe671296ac45b6a9530b 100644 (file)
@@ -727,7 +727,7 @@ static void joinAxesTrans12(t_complex* lout,const t_complex* lin,int maxN,int ma
 }
 
 
-static void rotate(int x[]) {
+static void rotate_offsets(int x[]) {
     int t=x[0];
 /*    x[0]=x[2];
     x[2]=x[1];
@@ -789,15 +789,15 @@ static void compute_offsets(fft5d_plan plan, int xs[], int xl[], int xc[], int N
     /*input order is different for test program to match FFTW order 
       (important for complex to real)*/
     if (plan->flags&FFT5D_BACKWARD) {
-        rotate(xs);
-        rotate(xl);
-        rotate(xc);
-        rotate(NG);
+        rotate_offsets(xs);
+        rotate_offsets(xl);
+        rotate_offsets(xc);
+        rotate_offsets(NG);
         if (plan->flags&FFT5D_ORDER_YZ) {
-            rotate(xs);
-            rotate(xl);
-            rotate(xc);
-            rotate(NG);            
+            rotate_offsets(xs);
+            rotate_offsets(xl);
+            rotate_offsets(xc);
+            rotate_offsets(NG);
         }
     }
     if ((plan->flags&FFT5D_REALCOMPLEX) && ((!(plan->flags&FFT5D_BACKWARD) && s==0) || ((plan->flags&FFT5D_BACKWARD) && s==2))) {
index de3c248a81a14c8433332a16985e5627c41f5052..cbac2309df0abb0534b328f1c72d5e0f1403b5ac 100644 (file)
@@ -57,7 +57,6 @@
 #include "do_fit.h"
 #include "rmpbc.h"
 #include "wgms.h"
-#include "magic.h"
 #include "pbc.h"
 #include "xvgr.h"
 #include "xdrf.h"
index de4f3ce88b650a1a1e11b09f1a4927e30e1bd93f..330a67766809387e604a768ad9b28968eb2e87a1 100644 (file)
@@ -59,7 +59,6 @@
 #include "do_fit.h"
 #include "rmpbc.h"
 #include "wgms.h"
-#include "magic.h"
 #include "pbc.h"
 #include "viewit.h"
 #include "xvgr.h"