Fix ICC warnings
[alexxy/gromacs.git] / src / gromacs / fft / fft5d.cpp
index 27d42915fb9065932562a5e7ba93b54a1a272d63..93f518a85b680b9303b3a2ef236882474acebd7e 100644 (file)
  */
 #include "gmxpre.h"
 
-#include "config.h"
+#include "fft5d.h"
 
-#include <algorithm>
+#include "config.h"
 
+#include <assert.h>
+#include <float.h>
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include <algorithm>
+
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/smalloc.h"
+
 #ifdef NOGMX
 #define GMX_PARALLEL_ENV_INITIALIZED 1
 #else
@@ -52,8 +61,6 @@
 #endif
 #endif
 
-#include "gromacs/utility/gmxmpi.h"
-
 #ifdef GMX_OPENMP
 /* TODO: Do we still need this? Are we still planning ot use fftw + OpenMP? */
 #define FFT5D_THREADS
 /* #define FFT5D_FFTW_THREADS (now set by cmake) */
 #endif
 
-#include "fft5d.h"
-#include <float.h>
-#include <math.h>
-#include <assert.h>
-#include "gromacs/utility/smalloc.h"
-
 #ifndef __FLT_EPSILON__
 #define __FLT_EPSILON__ FLT_EPSILON
 #define __DBL_EPSILON__ DBL_EPSILON
 FILE* debug = 0;
 #endif
 
-#include "gromacs/utility/fatalerror.h"
-
-
 #ifdef GMX_FFT_FFTW3
 #include "thread_mpi/mutex.h"
+
 #include "gromacs/utility/exceptions.h"
 /* none of the fftw3 calls, except execute(), are thread-safe, so
    we need to serialize them with this mutex. */
@@ -89,19 +88,18 @@ static tMPI::mutex big_fftw_mutex;
 #define FFTW_UNLOCK try { big_fftw_mutex.unlock(); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
 #endif /* GMX_FFT_FFTW3 */
 
+#ifdef GMX_MPI
 /* largest factor smaller than sqrt */
 static int lfactor(int z)
 {
-    int i;
-    for (i = static_cast<int>(sqrt(static_cast<double>(z)));; i--)
+    int i = static_cast<int>(sqrt(static_cast<double>(z)));
+    while (z%i != 0)
     {
-        if (z%i == 0)
-        {
-            return i;
-        }
+        i--;
     }
-    return 1;
+    return i;
 }
+#endif
 
 /* largest factor */
 static int l2factor(int z)
@@ -109,16 +107,17 @@ static int l2factor(int z)
     int i;
     if (z == 1)
     {
-        return 1;
+        i = 1;
     }
-    for (i = z/2;; i--)
+    else
     {
-        if (z%i == 0)
+        i = z/2;
+        while (z%i != 0)
         {
-            return i;
+            i--;
         }
     }
-    return 1;
+    return i;
 }
 
 /* largest prime factor: WARNING: slow recursion, only use for small numbers */
@@ -1006,7 +1005,7 @@ void fft5d_execute(fft5d_plan plan, int thread, fft5d_time times)
     s = 0;
 
     /*lin: x,y,z*/
-    if (plan->flags&FFT5D_DEBUG && thread == 0)
+    if ((plan->flags&FFT5D_DEBUG) && thread == 0)
     {
         print_localdata(lin, "%d %d: copy in lin\n", s, plan);
     }
@@ -1066,7 +1065,7 @@ void fft5d_execute(fft5d_plan plan, int thread, fft5d_time times)
             time_fft += MPI_Wtime()-time;
         }
 #endif
-        if (plan->flags&FFT5D_DEBUG && thread == 0)
+        if ((plan->flags&FFT5D_DEBUG) && thread == 0)
         {
             print_localdata(lout, "%d %d: FFT %d\n", s, plan);
         }
@@ -1187,7 +1186,7 @@ void fft5d_execute(fft5d_plan plan, int thread, fft5d_time times)
             time_local += MPI_Wtime()-time;
         }
 #endif
-        if (plan->flags&FFT5D_DEBUG && thread == 0)
+        if ((plan->flags&FFT5D_DEBUG) && thread == 0)
         {
             print_localdata(lin, "%d %d: tranposed %d\n", s+1, plan);
         }
@@ -1231,7 +1230,7 @@ void fft5d_execute(fft5d_plan plan, int thread, fft5d_time times)
     }
 #endif
 
-    if (plan->flags&FFT5D_DEBUG && thread == 0)
+    if ((plan->flags&FFT5D_DEBUG) && thread == 0)
     {
         print_localdata(lout, "%d %d: FFT %d\n", s, plan);
     }