From 2bfd7047aaad966b69052fd4b54e813180da7d5f Mon Sep 17 00:00:00 2001
From: Chichi Lalescu <clalesc1@jhu.edu>
Date: Sat, 11 Jul 2015 21:22:52 +0200
Subject: [PATCH] use MPI C data types instead of fortran

I think. I can't really figure out why they have so many different names
for these things, and in principle the C data types should be bit
compatible with the fortran data types, but I figured I may as well make
sure...
---
 bfps/base.py                 |  2 +-
 src/fluid_solver.cpp         |  8 ++++----
 src/fluid_solver_base.cpp    | 12 ++++++------
 src/slab_field_particles.cpp | 14 +++++++-------
 src/tracers.cpp              |  6 +++---
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/bfps/base.py b/bfps/base.py
index 52451d94..559089d1 100644
--- a/bfps/base.py
+++ b/bfps/base.py
@@ -71,7 +71,7 @@ class base(object):
             elif type(self.parameters[key[i]]) == str:
                 src_txt += 'MPI_Bcast((void*)(' + key[i] + '), {0}, MPI_CHAR, {1}, MPI_COMM_WORLD);\n'.format(self.string_length, self.iorank)
             else:
-                src_txt += 'MPI_Bcast((void*)(&' + key[i] + '), 1, MPI_REAL8, {0}, MPI_COMM_WORLD);\n'.format(self.iorank)
+                src_txt += 'MPI_Bcast((void*)(&' + key[i] + '), 1, MPI_DOUBLE, {0}, MPI_COMM_WORLD);\n'.format(self.iorank)
         src_txt += ('MPI_Allreduce((void*)(&err_while_reading), (void*)(&errr), 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD);\n'
                   + 'if (errr > 0)\n{\n'
                   + 'fprintf(stderr, "Error reading parameters.\\nAttempting to exit.\\n");\n'
diff --git a/src/fluid_solver.cpp b/src/fluid_solver.cpp
index 26ec1305..b2082d30 100644
--- a/src/fluid_solver.cpp
+++ b/src/fluid_solver.cpp
@@ -420,14 +420,14 @@ FLUID_SOLVER_DEFINITIONS(
         FFTW_MANGLE_FLOAT,
         float,
         fftwf_complex,
-        MPI_REAL4,
-        MPI_COMPLEX8)
+        MPI_FLOAT,
+        MPI_C_FLOAT_COMPLEX)
 //FLUID_SOLVER_DEFINITIONS(
 //        FFTW_MANGLE_DOUBLE,
 //        double,
 //        fftw_complex,
-//        MPI_REAL8,
-//        MPI_COMPLEX16)
+//        MPI_DOUBLE,
+//        MPI_C_DOUBLE_COMPLEX)
 /*****************************************************************************/
 
 
diff --git a/src/fluid_solver_base.cpp b/src/fluid_solver_base.cpp
index 931fd69a..86d566ca 100644
--- a/src/fluid_solver_base.cpp
+++ b/src/fluid_solver_base.cpp
@@ -59,7 +59,7 @@ void fluid_solver_base<rnumber>::cospectrum(cnumber *a, cnumber *b, double *spec
             (void*)cospec_local,
             (void*)spec,
             this->nshells,
-            MPI_REAL8, MPI_SUM, this->cd->comm);
+            MPI_DOUBLE, MPI_SUM, this->cd->comm);
     for (int n=0; n<this->nshells; n++)
     {
         spec[n] *= 12.5663706144*pow(this->kshell[n], 2) / this->nshell[n];
@@ -211,7 +211,7 @@ fluid_solver_base<R>::fluid_solver_base( \
             (void*)(kshell_local), \
             (void*)(this->kshell), \
             this->nshells, \
-            MPI_REAL8, MPI_SUM, this->cd->comm); \
+            MPI_DOUBLE, MPI_SUM, this->cd->comm); \
     for (int n=0; n<this->nshells; n++) \
     { \
         this->kshell[n] /= this->nshell[n]; \
@@ -450,14 +450,14 @@ FLUID_SOLVER_BASE_DEFINITIONS(
         FFTW_MANGLE_FLOAT,
         float,
         fftwf_complex,
-        MPI_REAL4,
-        MPI_COMPLEX8)
+        MPI_FLOAT,
+        MPI_C_FLOAT_COMPLEX)
 //FLUID_SOLVER_BASE_DEFINITIONS(
 //        FFTW_MANGLE_DOUBLE,
 //        double,
 //        fftw_complex,
-//        MPI_REAL8,
-//        MPI_COMPLEX16)
+//        MPI_DOUBLE,
+//        MPI_C_DOUBLE_COMPLEX)
 /*****************************************************************************/
 
 
diff --git a/src/slab_field_particles.cpp b/src/slab_field_particles.cpp
index e21d8fb6..0fd1bdfa 100644
--- a/src/slab_field_particles.cpp
+++ b/src/slab_field_particles.cpp
@@ -77,7 +77,7 @@ slab_field_particles<rnumber>::slab_field_particles(
             tbound,
             this->lbound,
             nprocs,
-            MPI_REAL8,
+            MPI_DOUBLE,
             MPI_SUM,
             this->fs->rd->comm);
     std::fill_n(tbound, nprocs, 0.0);
@@ -86,7 +86,7 @@ slab_field_particles<rnumber>::slab_field_particles(
             tbound,
             this->ubound,
             nprocs,
-            MPI_REAL8,
+            MPI_DOUBLE,
             MPI_SUM,
             this->fs->rd->comm);
     delete[] tbound;
@@ -140,7 +140,7 @@ void slab_field_particles<rnumber>::synchronize_single_particle(int p)
                 MPI_Send(
                         this->state + p*this->ncomponents,
                         this->ncomponents,
-                        MPI_REAL8,
+                        MPI_DOUBLE,
                         r,
                         p*this->computing[p],
                         this->fs->rd->comm);
@@ -148,7 +148,7 @@ void slab_field_particles<rnumber>::synchronize_single_particle(int p)
                 MPI_Recv(
                         this->state + p*this->ncomponents,
                         this->ncomponents,
-                        MPI_REAL8,
+                        MPI_DOUBLE,
                         this->computing[p],
                         p*this->computing[p],
                         this->fs->rd->comm,
@@ -176,7 +176,7 @@ void slab_field_particles<rnumber>::synchronize()
             tstate,
             this->state,
             this->array_size,
-            MPI_REAL8,
+            MPI_DOUBLE,
             MPI_SUM,
             this->fs->rd->comm);
     fftw_free(tstate);
@@ -291,7 +291,7 @@ void slab_field_particles<rnumber>::read()
     MPI_Bcast(
             this->state,
             this->array_size,
-            MPI_REAL8,
+            MPI_DOUBLE,
             0,
             this->fs->rd->comm);
     // initial assignment of particles
@@ -325,7 +325,7 @@ ptrdiff_t slab_field_particles<rnumber>::buffered_local_size()
 template <class rnumber>
 void slab_field_particles<rnumber>::rFFTW_to_buffered(rnumber *src, rnumber *dst)
 {
-    const MPI_Datatype MPI_RNUM = (sizeof(rnumber) == 4) ? MPI_REAL4 : MPI_REAL8;
+    const MPI_Datatype MPI_RNUM = (sizeof(rnumber) == 4) ? MPI_FLOAT : MPI_DOUBLE;
     const ptrdiff_t bsize = this->buffer_size*this->fs->rd->slice_size;
     MPI_Request *mpirequest = new MPI_Request;
     /* do big copy of middle stuff */
diff --git a/src/tracers.cpp b/src/tracers.cpp
index bb82010a..e1496c85 100644
--- a/src/tracers.cpp
+++ b/src/tracers.cpp
@@ -54,7 +54,7 @@ void tracers<rnumber>::jump_estimate(double *jump)
             tjump,
             jump,
             this->nparticles,
-            MPI_REAL8,
+            MPI_DOUBLE,
             MPI_SUM,
             this->fs->rd->comm);
     delete[] tjump;
@@ -125,8 +125,8 @@ TRACERS_DEFINITIONS(
         FFTW_MANGLE_FLOAT,
         float,
         fftwf_complex,
-        MPI_REAL4,
-        MPI_COMPLEX8)
+        MPI_FLOAT,
+        MPI_C_FLOAT_COMPLEX)
 /*****************************************************************************/
 
 
-- 
GitLab