Code beautification with uncrustify
[alexxy/gromacs.git] / src / gromacs / mdlib / gmx_parallel_3dfft.c
index d80364e00d7aaf99696d58482b600705a1d6a718..306ee0e0a611dc707e6e66469c6d3c13570d156c 100644 (file)
@@ -1,20 +1,20 @@
 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
-*
-*
-* Gromacs                               Copyright (c) 1991-2005
-* David van der Spoel, Erik Lindahl, University of Groningen.
-*
-* 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.
-*
-* To help us fund GROMACS development, we humbly ask that you cite
-* the research papers on the package. Check out http://www.gromacs.org
-* 
-* And Hey:
-* Gnomes, ROck Monsters And Chili Sauce
-*/
+ *
+ *
+ * Gromacs                               Copyright (c) 1991-2005
+ * David van der Spoel, Erik Lindahl, University of Groningen.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org
+ *
+ * And Hey:
+ * Gnomes, ROck Monsters And Chili Sauce
+ */
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -23,7 +23,7 @@
 #include <string.h>
 #include <errno.h>
 
-#ifdef GMX_LIB_MPI 
+#ifdef GMX_LIB_MPI
 #include <mpi.h>
 #endif
 #ifdef GMX_THREAD_MPI
 
 #include "fft5d.h"
 
-struct gmx_parallel_3dfft  { 
-    fft5d_plan p1,p2;    
+struct gmx_parallel_3dfft  {
+    fft5d_plan p1, p2;
 };
 
 int
-gmx_parallel_3dfft_init   (gmx_parallel_3dfft_t *    pfft_setup,
-                           ivec                      ndata,
-                                                  real **                   real_data,
-                                                  t_complex **              complex_data,
-                           MPI_Comm                  comm[2],
-                           int *                     slab2index_major,
-                           int *                     slab2index_minor,
+gmx_parallel_3dfft_init   (gmx_parallel_3dfft_t     *    pfft_setup,
+                           ivec                          ndata,
+                           real     **                   real_data,
+                           t_complex     **              complex_data,
+                           MPI_Comm                      comm[2],
+                           int     *                     slab2index_major,
+                           int     *                     slab2index_minor,
                            gmx_bool                      bReproducible,
-                           int nthreads)
+                           int                           nthreads)
 {
-    int rN=ndata[2],M=ndata[1],K=ndata[0];
-    int flags = FFT5D_REALCOMPLEX | FFT5D_ORDER_YZ; /* FFT5D_DEBUG */
-    MPI_Comm rcomm[]={comm[1],comm[0]};
-    int Nb,Mb,Kb; /* dimension for backtransform (in starting order) */
-    t_complex *buf1, *buf2; /*intermediate buffers - used internally.*/
-    
-    snew(*pfft_setup,1);
-    if (bReproducible) flags |= FFT5D_NOMEASURE; 
-    
-    if (!(flags&FFT5D_ORDER_YZ)) { 
-        Nb=M;Mb=K;Kb=rN;               
-    } else {
-        Nb=K;Mb=rN;Kb=M;  /* currently always true because ORDER_YZ always set */
+    int        rN      = ndata[2], M = ndata[1], K = ndata[0];
+    int        flags   = FFT5D_REALCOMPLEX | FFT5D_ORDER_YZ; /* FFT5D_DEBUG */
+    MPI_Comm   rcomm[] = {comm[1], comm[0]};
+    int        Nb, Mb, Kb;                                   /* dimension for backtransform (in starting order) */
+    t_complex *buf1, *buf2;                                  /*intermediate buffers - used internally.*/
+
+    snew(*pfft_setup, 1);
+    if (bReproducible)
+    {
+        flags |= FFT5D_NOMEASURE;
+    }
+
+    if (!(flags&FFT5D_ORDER_YZ))
+    {
+        Nb = M; Mb = K; Kb = rN;
     }
-    
-    (*pfft_setup)->p1 = fft5d_plan_3d(rN,M,K,rcomm, flags, (t_complex**)real_data, complex_data, &buf1, &buf2, nthreads);
-    
-    (*pfft_setup)->p2 = fft5d_plan_3d(Nb,Mb,Kb,rcomm,
+    else
+    {
+        Nb = K; Mb = rN; Kb = M;  /* currently always true because ORDER_YZ always set */
+    }
+
+    (*pfft_setup)->p1 = fft5d_plan_3d(rN, M, K, rcomm, flags, (t_complex**)real_data, complex_data, &buf1, &buf2, nthreads);
+
+    (*pfft_setup)->p2 = fft5d_plan_3d(Nb, Mb, Kb, rcomm,
                                       (flags|FFT5D_BACKWARD|FFT5D_NOMALLOC)^FFT5D_ORDER_YZ, complex_data, (t_complex**)real_data, &buf1, &buf2, nthreads);
-    
-    return (*pfft_setup)->p1 != 0 && (*pfft_setup)->p2 !=0;
+
+    return (*pfft_setup)->p1 != 0 && (*pfft_setup)->p2 != 0;
 }
 
 
 static int
-fft5d_limits(fft5d_plan p, 
+fft5d_limits(fft5d_plan                p,
              ivec                      local_ndata,
              ivec                      local_offset,
-             ivec                      local_size) 
+             ivec                      local_size)
 {
-    local_offset[2]=0;
-    local_offset[1]=p->oM[0];  /*=p->coor[0]*p->MG/p->P[0]; */
-    local_offset[0]=p->oK[0];  /*=p->coor[1]*p->KG/p->P[1]; */
-    
-    local_ndata[2]=p->rC[0];
-    local_ndata[1]=p->pM[0]; 
-    local_ndata[0]=p->pK[0]; 
-    
-    if ((!(p->flags&FFT5D_BACKWARD)) && (p->flags&FFT5D_REALCOMPLEX)) {
+    local_offset[2] = 0;
+    local_offset[1] = p->oM[0];  /*=p->coor[0]*p->MG/p->P[0]; */
+    local_offset[0] = p->oK[0];  /*=p->coor[1]*p->KG/p->P[1]; */
+
+    local_ndata[2] = p->rC[0];
+    local_ndata[1] = p->pM[0];
+    local_ndata[0] = p->pK[0];
+
+    if ((!(p->flags&FFT5D_BACKWARD)) && (p->flags&FFT5D_REALCOMPLEX))
+    {
         //C is length in multiples of complex local_size in multiples of real
-        local_size[2]=p->C[0]*2;
-    } else {
-        local_size[2]=p->C[0];
+        local_size[2] = p->C[0]*2;
     }
-    local_size[1]=p->pM[0]; 
-    local_size[0]=p->pK[0]; 
+    else
+    {
+        local_size[2] = p->C[0];
+    }
+    local_size[1] = p->pM[0];
+    local_size[0] = p->pK[0];
     return 0;
 }
 
@@ -106,8 +115,9 @@ int
 gmx_parallel_3dfft_real_limits(gmx_parallel_3dfft_t      pfft_setup,
                                ivec                      local_ndata,
                                ivec                      local_offset,
-                               ivec                      local_size) {
-    return fft5d_limits(pfft_setup->p1,local_ndata,local_offset,local_size);
+                               ivec                      local_size)
+{
+    return fft5d_limits(pfft_setup->p1, local_ndata, local_offset, local_size);
 }
 
 static void reorder_ivec_yzx(ivec v)
@@ -125,7 +135,7 @@ gmx_parallel_3dfft_complex_limits(gmx_parallel_3dfft_t      pfft_setup,
                                   ivec                      complex_order,
                                   ivec                      local_ndata,
                                   ivec                      local_offset,
-                                  ivec                      local_size) 
+                                  ivec                      local_size)
 {
     int ret;
 
@@ -134,7 +144,7 @@ gmx_parallel_3dfft_complex_limits(gmx_parallel_3dfft_t      pfft_setup,
     complex_order[1] = 1;
     complex_order[2] = 2;
 
-    ret = fft5d_limits(pfft_setup->p2,local_ndata,local_offset,local_size);
+    ret = fft5d_limits(pfft_setup->p2, local_ndata, local_offset, local_size);
 
     reorder_ivec_yzx(local_ndata);
     reorder_ivec_yzx(local_offset);
@@ -150,21 +160,26 @@ gmx_parallel_3dfft_execute(gmx_parallel_3dfft_t    pfft_setup,
                            void *                  in_data,
                            void *                  out_data,
                            int                     thread,
-                           gmx_wallcycle_t         wcycle) {
-    if ((!(pfft_setup->p1->flags&FFT5D_REALCOMPLEX)) ^ (dir==GMX_FFT_FORWARD ||dir==GMX_FFT_BACKWARD))
+                           gmx_wallcycle_t         wcycle)
+{
+    if ((!(pfft_setup->p1->flags&FFT5D_REALCOMPLEX)) ^ (dir == GMX_FFT_FORWARD || dir == GMX_FFT_BACKWARD))
     {
-        gmx_fatal(FARGS,"Invalid transform. Plan and execution don't match regarding reel/complex");
+        gmx_fatal(FARGS, "Invalid transform. Plan and execution don't match regarding reel/complex");
     }
-    if (dir==GMX_FFT_FORWARD || dir==GMX_FFT_REAL_TO_COMPLEX) {
-        fft5d_execute(pfft_setup->p1,thread,wcycle);
-    } else {
-        fft5d_execute(pfft_setup->p2,thread,wcycle);
+    if (dir == GMX_FFT_FORWARD || dir == GMX_FFT_REAL_TO_COMPLEX)
+    {
+        fft5d_execute(pfft_setup->p1, thread, wcycle);
+    }
+    else
+    {
+        fft5d_execute(pfft_setup->p2, thread, wcycle);
     }
     return 0;
 }
 
 int
-gmx_parallel_3dfft_destroy(gmx_parallel_3dfft_t    pfft_setup) {
+gmx_parallel_3dfft_destroy(gmx_parallel_3dfft_t    pfft_setup)
+{
     if (pfft_setup)
     {
         fft5d_destroy(pfft_setup->p2);
@@ -173,8 +188,3 @@ gmx_parallel_3dfft_destroy(gmx_parallel_3dfft_t    pfft_setup) {
     }
     return 0;
 }
-
-
-
-
-