r87: Upgraded from MPI to MPI++
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 10:12:09 +0000 (10:12 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 10:12:09 +0000 (10:12 +0000)
include/ct.h
include/imagefile.h
include/ir.h
src/Makefile.am
src/Makefile.nt
src/ctrec.cpp
src/phm2if.cpp
src/phm2rs.cpp

index 9aa3639bede2eca972d4ca57da24733889b92331..d43353de489df62088cc859d477eb50d5846c714 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ct.h,v 1.10 2000/06/07 07:43:39 kevin Exp $
+**  $Id: ct.h,v 1.11 2000/06/07 10:12:09 kevin Exp $
 **  $Log: ct.h,v $
 **  $Log: ct.h,v $
+**  Revision 1.11  2000/06/07 10:12:09  kevin
+**  Upgraded from MPI to MPI++
+**
 **  Revision 1.10  2000/06/07 07:43:39  kevin
 **  *** empty log message ***
 **
 **  Revision 1.10  2000/06/07 07:43:39  kevin
 **  *** empty log message ***
 **
 #include <stdint.h>             /* Standard ints on Linux */
 #endif
 
 #include <stdint.h>             /* Standard ints on Linux */
 #endif
 
-#ifdef MPI_CT
-#include "mpi.h"
+#ifdef HAVE_MPI
+#include "mpi++.h"
 #endif
 
 #include "kstddef.h"
 #endif
 
 #include "kstddef.h"
index 4660a92139c91c0fdb9995ee3ff193d685fb7d88..3c1bb9a8ef87fec8fb4b17809350298b4f2fff32 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <string>
 #include "kstddef.h"
 
 #include <string>
 #include "kstddef.h"
+#include <sys/types.h>
+#include <unistd.h>
 #include <array2d.h>
 
 using namespace std;
 #include <array2d.h>
 
 using namespace std;
@@ -633,20 +635,21 @@ public:
   kuint32 ny(void) const
       { return adf.ny(); }
 
   kuint32 ny(void) const
       { return adf.ny(); }
 
-#ifdef MPI_CT
-  MPI_Datatype getMPIDataType (void) const
-      { return MPI_FLOAT; }
+#ifdef HAVE_MPI
+  MPI::Datatype getMPIDataType (void) const
+      { return MPI::FLOAT; }
 #endif
 };
 
 #endif
 };
 
+
 class F64Image 
 {
 public:
   Array2dFile<kfloat64> adf;
 
 class F64Image 
 {
 public:
   Array2dFile<kfloat64> adf;
 
-#ifdef MPI_CT
-  MPI_Datatype getMPIDataType (void) const
-      { return MPI_DOUBLE; }
+#ifdef HAVE_MPI
+  MPI::Datatype getMPIDataType (void) const
+      { return MPI::DOUBLE; }
 #endif
 
   F64Image (const char* const fname, unsigned int nx, unsigned int ny) : adf (fname, nx, ny)
 #endif
 
   F64Image (const char* const fname, unsigned int nx, unsigned int ny) : adf (fname, nx, ny)
index 7da06ffd46b6da0e7060aedef91bd4d37cd98f0f..e1661dbf42f0e90f4d0ac3574356675f4849ad1a 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.22 2000/06/07 07:43:39 kevin Exp $
+**  $Id: ir.h,v 1.23 2000/06/07 10:12:09 kevin Exp $
 **  $Log: ir.h,v $
 **  $Log: ir.h,v $
+**  Revision 1.23  2000/06/07 10:12:09  kevin
+**  Upgraded from MPI to MPI++
+**
 **  Revision 1.22  2000/06/07 07:43:39  kevin
 **  *** empty log message ***
 **
 **  Revision 1.22  2000/06/07 07:43:39  kevin
 **  *** empty log message ***
 **
@@ -352,17 +355,17 @@ const static int RAYSUM_TRACE_ROW_ATTEN=18;
 extern "C" {
 #endif /* __cplusplus */
 
 extern "C" {
 #endif /* __cplusplus */
 
-#ifdef MPI_CT
-#define MPI_MAX_PROCESS 128 
+#ifdef HAVE_MPI
+#define CT_MPI_MAX_PROCESS 128 
 struct mpi_ct_st
 {
   int my_rank;
   int nproc;
   int base_local_work_units;
   int remainder_work_units;
 struct mpi_ct_st
 {
   int my_rank;
   int nproc;
   int base_local_work_units;
   int remainder_work_units;
-  int local_work_units[MPI_MAX_PROCESS];
-  int start_work_unit[MPI_MAX_PROCESS];
-  MPI_Comm comm;
+  int local_work_units [CT_MPI_MAX_PROCESS];
+  int start_work_unit [CT_MPI_MAX_PROCESS];
+  MPI::Intracomm comm;
 };
 
 extern struct mpi_ct_st mpi_ct;
 };
 
 extern struct mpi_ct_st mpi_ct;
@@ -370,25 +373,22 @@ void mpi_ct_calc_work_units(const unsigned int global_work_units);
 #endif
 
 
 #endif
 
 
-/* bspline.c */
-int bspline(int samples, int zoom_factor, int spline_order, double input[], double output[]);
-
 /* convolve.c */
 /* convolve.c */
-double convolve(const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
-double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np);
+double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
+double convolve_both (const double f1[], const double f2[], const double dx, const int n, const int np);
 
 /* dialogs.c */
 
 /* dialogs.c */
-int phm_add_pelm_kb(PHANTOM *phm);
-PHANTOM *phm_select(void);
-int interpolation_select(void);
-int filter_select(double *filter_param);
+int phm_add_pelm_kb (PHANTOM *phm);
+PHANTOM *phm_select (void);
+int interpolation_select (void);
+int filter_select (double *filter_param);
 
 /* filter.c */
 
 /* filter.c */
-double *filter_generate(const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
-double filter_spatial_response_calc(int filt_type, double x, double bw, double param, int n);
-double filter_spatial_response_analytic(int filt_type, double x, double bw, double param);
-double filter_frequency_response(int filt_type, double u, double bw, double param);
-double sinc(double x, double mult);
+double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
+double filter_spatial_response_calc (int filt_type, double x, double bw, double param, int n);
+double filter_spatial_response_analytic (int filt_type, double x, double bw, double param);
+double filter_frequency_response (int filt_type, double u, double bw, double param);
+double sinc (double x, double mult);
 double integral_abscos(double u, double w);
 
 /* options.c */
 double integral_abscos(double u, double w);
 
 /* options.c */
@@ -439,7 +439,7 @@ int pelm_clip_line (const PELM *pelm, double *x1, double *y1, double *x2, double
 void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
 
 /* scanner.c */
 void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
 
 /* scanner.c */
-DETECTOR *detector_create(const PHANTOM *phm, int geometry, int ndet, int nview, int nsample, const double rot_anglen);
+DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
 void detector_free(DETECTOR *det);
 
 /* rayio.c */
 void detector_free(DETECTOR *det);
 
 /* rayio.c */
index ae3993856b0be392364102a39d5bd95793a3e54e..61ef42b355a3d0eb3011ab7ccf40ce588c9b9222 100644 (file)
@@ -32,15 +32,16 @@ phm2rs_lam_LDADD=@ctlamlibs@
 
 if USE_LAM
 CC_LAM = $(lamdir)/bin/balky
 
 if USE_LAM
 CC_LAM = $(lamdir)/bin/balky
+LAM_EXTRA_SRC = ../libir/mpi_ct.cpp
 
 ctrec-lam: ctrec.cpp
 
 ctrec-lam: ctrec.cpp
-       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.cpp -o ctrec-lam $(LDFLAGS) @ctlamlibs@
+       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI ctrec.cpp -o ctrec-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
 
 phm2rs-lam: phm2rs.cpp
 
 phm2rs-lam: phm2rs.cpp
-       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.cpp -o phm2rs-lam $(LDFLAGS) @ctlamlibs@
+       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI phm2rs.cpp -o phm2rs-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
 
 phm2if-lam: phm2if.cpp
 
 phm2if-lam: phm2if.cpp
-       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2if.cpp -o phm2if-lam $(LDFLAGS) @ctlamlibs@
+       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI phm2if.cpp -o phm2if-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
 
 endif
 
 
 endif
 
index cbfe390ee7660a17e34923317fa6cb95a4c6ff3d..8237a414f5eeac1cb5dcaa0c8b61f596f99140ea 100644 (file)
@@ -1,54 +1,53 @@
-# Makefile for libk\r
-\r
-!include <ntwin32.mak>\r
-\r
-CC=cl\r
-LD=link\r
-CFLAGS=-O -nologo -I..\include -I..\getopt -DHAVE_GETOPT_H\r
-LDFLAGS=..\getopt\getopt.lib ..\libkmath\libkmath.lib ..\libcio\libcio.lib ..\libgraph\libgraph.lib ..\libezplot\libezplot.lib ..\libir\libir.lib ..\libk\libk.lib  \r
-O=.obj\r
-\r
-# variables\r
-OBJ1 = ctrec$(O) phm2rs$(O) phm2sdf$(O) rs2sdf$(O) sdf-1$(O) sdf-2$(O) sdf2img$(O) sdfinfo$(O)\r
-\r
-all:  ctrec.exe phm2rs.exe phm2sdf.exe rs2sdf.exe sdf-1.exe sdf-2.exe sdf2img.exe sdfinfo.exe\r
-\r
-.obj: .c\r
-       $(CC) -c $(cvarsdll) $(CFLAGS) $*.c\r
-\r
-\r
-.obj: .cpp\r
-       $(CC) -c $(cvarsdll) $(CFLAGS) $*.cpp\r
-\r
-\r
-ctrec.exe: ctrec.obj\r
-        link ctrec.obj  $(LDFLAGS)\r
-\r
-phm2rs.exe: phm2rs.obj\r
-        link phm2rs.obj $(LDFLAGS)\r
-\r
-phm2sdf.exe: phm2sdf.obj\r
-        link phm2sdf.obj $(LDFLAGS)\r
-\r
-rs2sdf.exe: rs2sdf.obj\r
-        link rs2sdf.obj $(LDFLAGS)\r
-\r
-sdf-1.exe: sdf-1.obj\r
-        link sdf-1.obj $(LDFLAGS)\r
-\r
-sdf-2.exe: sdf-2.obj\r
-        link sdf-2.obj $(LDFLAGS)\r
-\r
-sdfinfo.exe: sdfinfo.obj\r
-        link sdfinfo.obj $(LDFLAGS)\r
-\r
-sdf2img.exe: sdf2img.obj\r
-        link sdf2img.obj $(LDFLAGS)\r
-\r
-clean:\r
-        echo dummy > a.obj\r
-        echo dummy > a.exe\r
-        echo dummy > a.lib\r
-       del *.obj\r
-       del *.exe\r
-       del *.lib\r
+# Makefile for libk
+
+!include <ntwin32.mak>
+
+CC=cl
+LD=link
+CFLAGS=-O -nologo -I..\include -I..\getopt -DHAVE_GETOPT_H
+LDFLAGS=..\getopt\getopt.lib ..\libkmath\libkmath.lib ..\libcio\libcio.lib ..\libgraph\libgraph.lib ..\libezplot\libezplot.lib ..\libir\libir.lib ..\libk\libk.lib  
+O=.obj
+
+# variables
+OBJ1 = ctrec$(O) phm2rs$(O) phm2if$(O) rs2if$(O) if-1$(O) if-2$(O) if2img$(O) ifinfo$(O)
+
+all:  ctrec.exe phm2rs.exe phm2if.exe rs2if.exe if-1.exe if-2.exe if2img.exe ifinfo.exe
+
+.obj: .c
+       $(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+.obj: .cpp
+       $(CC) -c $(cvarsdll) $(CFLAGS) $*.cpp
+
+
+ctrec.exe: ctrec.obj
+        link ctrec.obj  $(LDFLAGS)
+
+phm2rs.exe: phm2rs.obj
+        link phm2rs.obj $(LDFLAGS)
+
+phm2if.exe: phm2if.obj
+        link phm2if.obj $(LDFLAGS)
+
+rs2if.exe: rs2if.obj
+        link rs2if.obj $(LDFLAGS)
+
+if-1.exe: if-1.obj
+        link if-1.obj $(LDFLAGS)
+
+if-2.exe: if-2.obj
+        link if-2.obj $(LDFLAGS)
+
+ifinfo.exe: ifinfo.obj
+        link ifinfo.obj $(LDFLAGS)
+
+if2img.exe: if2img.obj
+        link if2img.obj $(LDFLAGS)
+
+clean:
+        echo dummy > a.obj
+        echo dummy > a.exe
+        echo dummy > a.lib
+       del *.obj
+       del *.exe
+       del *.lib
index a7b8ee575f98a6d575a8c0317c5ad405ec69177e..6ed8bd98fc2ad4f621f5ca510c52ff66cbc758eb 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $
+**  $Id: ctrec.cpp,v 1.3 2000/06/07 10:12:05 kevin Exp $
 **  $Log: ctrec.cpp,v $
 **  $Log: ctrec.cpp,v $
+**  Revision 1.3  2000/06/07 10:12:05  kevin
+**  Upgraded from MPI to MPI++
+**
 **  Revision 1.2  2000/06/07 07:43:19  kevin
 **  Converted to IF data files and C++
 **
 **  Revision 1.2  2000/06/07 07:43:19  kevin
 **  Converted to IF data files and C++
 **
@@ -141,7 +144,7 @@ ctrec_usage (const char *program)
 }
 
 
 }
 
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int debug);
 #endif
 
 static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int debug);
 #endif
 
@@ -166,7 +169,7 @@ ctrec_main (const int argc, char *const argv[])
   int opt_interp_param = 1;
   BackprojType opt_backproj = O_BPROJ_DIFF2;
   int nx, ny;
   int opt_interp_param = 1;
   BackprojType opt_backproj = O_BPROJ_DIFF2;
   int nx, ny;
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   ImageFile *im_local;
   RAYSUM *rs_local;
   int mpi_argc = argc;
   ImageFile *im_local;
   RAYSUM *rs_local;
   int mpi_argc = argc;
@@ -175,25 +178,25 @@ ctrec_main (const int argc, char *const argv[])
   double mpi_detinc, mpi_rotinc, mpi_phmlen;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
 
   double mpi_detinc, mpi_rotinc, mpi_phmlen;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
 
-  MPI_Init(&mpi_argc, &mpi_argv);
-  MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm);
-  MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc);
-  MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank);
+  MPI::Init (mpi_argc, mpi_argv);
+  mpi_ct.comm = MPI::COMM_WORLD.Dup();
+  mpi_ct.nproc = mpi_ct.comm.Get_size();
+  mpi_ct.my_rank = mpi_ct.comm.Get_rank();
 
 
-  if (mpi_ct.nproc > MPI_MAX_PROCESS) {
+  if (mpi_ct.nproc > CT_MPI_MAX_PROCESS) {
     sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
     sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
-             mpi_ct.nproc, MPI_MAX_PROCESS);
+             mpi_ct.nproc, CT_MPI_MAX_PROCESS);
     exit(1);
   }
 #endif
 
     exit(1);
   }
 #endif
 
-#ifdef MPI_CT
-  time_start = MPI_Wtime();
+#ifdef HAVE_MPI
+  time_start = MPI::Wtime();
 #else
   time_start = td_current_sec();
 #endif
 
 #else
   time_start = td_current_sec();
 #endif
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) {
 #endif
     while (1) {
   if (mpi_ct.my_rank == 0) {
 #endif
     while (1) {
@@ -281,11 +284,11 @@ ctrec_main (const int argc, char *const argv[])
   
     if (opt_verbose)
       fprintf (stdout, "%s\n", remark);
   
     if (opt_verbose)
       fprintf (stdout, "%s\n", remark);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   }
 #endif
 
   }
 #endif
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) {
     rs_global = raysum_open (rs_name);
     raysum_read (rs_global);
   if (mpi_ct.my_rank == 0) {
     rs_global = raysum_open (rs_name);
     raysum_read (rs_global);
@@ -299,26 +302,26 @@ ctrec_main (const int argc, char *const argv[])
     mpi_rotinc = rs_global->rot_inc;
   }
 
     mpi_rotinc = rs_global->rot_inc;
   }
 
-  mpi_t1 = MPI_Wtime();
-  MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_interp, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_interp_param, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_backproj, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&mpi_ndet, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&mpi_nview, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&mpi_detinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&mpi_phmlen, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&mpi_rotinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&nx, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&ny, 1, MPI_INT, 0, mpi_ct.comm);
+  mpi_t1 = MPI::Wtime();
+  mpi_ct.comm.Bcast (&opt_verbose, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_debug, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_trace, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_filter, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_interp, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&opt_interp_param, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_backproj, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&mpi_ndet, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&mpi_nview, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&mpi_detinc, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&mpi_phmlen, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&mpi_rotinc, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&nx, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&ny, 1, MPI::INT, 0);
   if (opt_verbose) {
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
   }
     if (mpi_ct.my_rank == 0)
       printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
   }
@@ -334,12 +337,12 @@ ctrec_main (const int argc, char *const argv[])
   rs_local->rot_inc = mpi_rotinc;
 
   if (opt_verbose)
   rs_local->rot_inc = mpi_rotinc;
 
   if (opt_verbose)
-    mpi_t1 = MPI_Wtime();
+    mpi_t1 = MPI::Wtime();
   mpi_scatter_rs(rs_global, rs_local, opt_debug);
   if (opt_verbose) {
   mpi_scatter_rs(rs_global, rs_local, opt_debug);
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to scatter rs = %f secs, Max time = %f sec\n", mpi_t, mpi_t_g);
   }
     if (mpi_ct.my_rank == 0)
       printf("Time to scatter rs = %f secs, Max time = %f sec\n", mpi_t, mpi_t_g);
   }
@@ -361,13 +364,13 @@ ctrec_main (const int argc, char *const argv[])
 
 #endif
 
 
 #endif
 
-#ifdef MPI_CT
-  mpi_t1 = MPI_Wtime();
+#ifdef HAVE_MPI
+  mpi_t1 = MPI::Wtime();
   proj_reconst (*im_local, rs_local, opt_filter, opt_filter_param, 
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
   proj_reconst (*im_local, rs_local, opt_filter, opt_filter_param, 
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
-  mpi_t2 = MPI_Wtime();
+  mpi_t2 = MPI::Wtime();
   mpi_t = mpi_t2 - mpi_t1;
   mpi_t = mpi_t2 - mpi_t1;
-  MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+  mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
   if (mpi_ct.my_rank == 0 && opt_verbose)
     printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g);
 #else
   if (mpi_ct.my_rank == 0 && opt_verbose)
     printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g);
 #else
@@ -375,9 +378,9 @@ ctrec_main (const int argc, char *const argv[])
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
 #endif
 
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
 #endif
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (opt_verbose)
   if (opt_verbose)
-    mpi_t1 = MPI_Wtime();
+    mpi_t1 = MPI::Wtime();
 
   int nxLocal = im_local->adf.nx();
   int nyLocal = im_local->adf.ny();
 
   int nxLocal = im_local->adf.nx();
   int nyLocal = im_local->adf.ny();
@@ -389,25 +392,25 @@ ctrec_main (const int argc, char *const argv[])
     if (mpi_ct.my_rank == 0)
       recvbuf = vGlobal[ix];
 
     if (mpi_ct.my_rank == 0)
       recvbuf = vGlobal[ix];
 
-    MPI_Reduce(vLocal[ix], recvbuf, nyLocal, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(vLocal[ix], recvbuf, nyLocal, MPI::FLOAT, MPI::SUM, 0);
   }
 
   if (opt_verbose) {
   }
 
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce (&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g);
   }
 
   if (mpi_ct.my_rank == 0)
     if (mpi_ct.my_rank == 0)
       printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g);
   }
 
   if (mpi_ct.my_rank == 0)
-      time_end = MPI_Wtime();
+      time_end = MPI::Wtime();
 #else
   time_end = td_current_sec();
 #endif
 
 
 #else
   time_end = td_current_sec();
 #endif
 
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0)
 #endif
     {
   if (mpi_ct.my_rank == 0)
 #endif
     {
@@ -421,15 +424,15 @@ ctrec_main (const int argc, char *const argv[])
        cout << "Time active = " << calctime << " sec" << endl;
     }
 
        cout << "Time active = " << calctime << " sec" << endl;
     }
 
-#ifdef MPI_CT
-       MPI_Finalize();
+#ifdef HAVE_MPI
+       MPI::Finalize();
 #endif
 
        return (0);
 }
 
 
 #endif
 
        return (0);
 }
 
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
 {
   int iproc;
 static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
 {
   int iproc;
@@ -441,9 +444,9 @@ static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_d
       end_work_unit = mpi_ct.start_work_unit[iproc] + mpi_ct.local_work_units[iproc]  - 1;
 
       for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
       end_work_unit = mpi_ct.start_work_unit[iproc] + mpi_ct.local_work_units[iproc]  - 1;
 
       for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
-       MPI_Send(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm);
-       MPI_Send(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm);
-       MPI_Send(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm);
+       mpi_ct.comm.Send(&rs_global->view[iw]->ndet, 1, MPI::INT, iproc, 0);
+       mpi_ct.comm.Send(&rs_global->view[iw]->view_angle, 1, MPI::DOUBLE, iproc, 0);
+       mpi_ct.comm.Send(rs_global->view[iw]->detval, rs_global->ndet, MPI::FLOAT, iproc, 0);
       }
     }
   }
       }
     }
   }
@@ -453,15 +456,15 @@ static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_d
 
   end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (iw = 0; iw <= end_work_unit; iw++) {
 
   end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (iw = 0; iw <= end_work_unit; iw++) {
-    MPI_Status status;
+    MPI::Status status;
 
 
-    MPI_Recv(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm, &status);
-    MPI_Recv(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm, &status);
-    MPI_Recv(rs_local->view[iw]->detval, rs_local->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm, &status);
+    mpi_ct.comm.Recv(&rs_local->view[iw]->ndet, 1, MPI::INT, 0, 0, status);
+    mpi_ct.comm.Recv(&rs_local->view[iw]->view_angle, 1, MPI::DOUBLE, 0, 0, status);
+    mpi_ct.comm.Recv(rs_local->view[iw]->detval, rs_local->ndet, MPI::FLOAT, 0, 0, status);
   }
   rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank];
   if (opt_debug) {
   }
   rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank];
   if (opt_debug) {
-    MPI_Barrier(MPI_COMM_WORLD);
+    mpi_ct.comm.Barrier();
     fprintf(stdout, "Done with mpi_scatter_rs in process %2d\n", mpi_ct.my_rank);
   }
 }
     fprintf(stdout, "Done with mpi_scatter_rs in process %2d\n", mpi_ct.my_rank);
   }
 }
index 2afac40c8030132cec197c927aa62f3610d05087..0d1a09f5fe37cb5ad81af4b74a9b22740275724d 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $
+**  $Id: phm2if.cpp,v 1.4 2000/06/07 10:12:05 kevin Exp $
 **  $Log: phm2if.cpp,v $
 **  $Log: phm2if.cpp,v $
+**  Revision 1.4  2000/06/07 10:12:05  kevin
+**  Upgraded from MPI to MPI++
+**
 **  Revision 1.3  2000/06/07 07:43:19  kevin
 **  Converted to IF data files and C++
 **
 **  Revision 1.3  2000/06/07 07:43:19  kevin
 **  Converted to IF data files and C++
 **
@@ -137,7 +140,7 @@ phm2sdf_usage (const char *program)
   fprintf(stdout,"     --help          Print this help message\n");
 }
 
   fprintf(stdout,"     --help          Print this help message\n");
 }
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug);
 #endif
 
 void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug);
 #endif
 
@@ -161,30 +164,30 @@ phm2sdf_main (const int argc, char *const argv[])
   int opt_trace = TRACE_NONE;
   int opt_verbose = 0;
   double time_start=0, time_end=0;
   int opt_trace = TRACE_NONE;
   int opt_verbose = 0;
   double time_start=0, time_end=0;
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   ImageFile* im_local = NULL;
   int mpi_argc = argc;
   char **mpi_argv = (char **) argv;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
 
   ImageFile* im_local = NULL;
   int mpi_argc = argc;
   char **mpi_argv = (char **) argv;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
 
-  MPI_Init(&mpi_argc, &mpi_argv);
-  MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm);
-  MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc);
-  MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank);
+  MPI::Init (mpi_argc, mpi_argv);
+  mpi_ct.comm = MPI::COMM_WORLD.Dup ();
+  mpi_ct.nproc = mpi_ct.comm.Get_size();
+  mpi_ct.my_rank = mpi_ct.comm.Get_rank();
 
 
-  if (mpi_ct.nproc > MPI_MAX_PROCESS) {
+  if (mpi_ct.nproc > CT_MPI_MAX_PROCESS) {
     sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
     sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
-             mpi_ct.nproc, MPI_MAX_PROCESS);
+             mpi_ct.nproc, CT_MPI_MAX_PROCESS);
   }
 #endif
 
   }
 #endif
 
-#ifdef MPI_CT
-  time_start = MPI_Wtime();
+#ifdef HAVE_MPI
+  time_start = MPI::Wtime();
 #else
   time_start = td_current_sec();
 #endif
   
 #else
   time_start = td_current_sec();
 #endif
   
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) {
 #endif
 
   if (mpi_ct.my_rank == 0) {
 #endif
 
@@ -208,7 +211,7 @@ phm2sdf_main (const int argc, char *const argv[])
       case O_PHMFILE:
        strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
        phm = phm_create_from_file(opt_phmfilename);
       case O_PHMFILE:
        strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
        phm = phm_create_from_file(opt_phmfilename);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
        if (mpi_ct.my_rank == 0) 
          fprintf(stderr, "Can't use phantom from file in MPI mode\n");
        return (1);
        if (mpi_ct.my_rank == 0) 
          fprintf(stderr, "Can't use phantom from file in MPI mode\n");
        return (1);
@@ -333,28 +336,28 @@ phm2sdf_main (const int argc, char *const argv[])
     
     if (opt_verbose)
       printf("Rasterize Phantom to Image\n\n");
     
     if (opt_verbose)
       printf("Rasterize Phantom to Image\n\n");
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   }
 #endif
 
   }
 #endif
 
-#ifdef MPI_CT
-  mpi_t1 = MPI_Wtime();
-  MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_nx, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_ny, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_nsample, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter_domain, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_filter_bw, 1, MPI_DOUBLE, 0, mpi_ct.comm);
+#ifdef HAVE_MPI
+  mpi_t1 = MPI::Wtime();
+  mpi_ct.comm.Bcast (&opt_verbose, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_debug, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_trace, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_nx, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_ny, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_nsample, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_phmnum, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_filter, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_filter_domain, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&opt_filter_bw, 1, MPI::DOUBLE, 0);
 
   if (opt_verbose) {
 
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
   }
     if (mpi_ct.my_rank == 0)
       printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
   }
@@ -375,7 +378,7 @@ phm2sdf_main (const int argc, char *const argv[])
   if (opt_phmnum >= 0)
       phm = phm_create (opt_phmnum);
 
   if (opt_phmnum >= 0)
       phm = phm_create (opt_phmnum);
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   else {
     if (mpi_ct.my_rank == 0)
       fprintf(stderr, "phmnum < 0\n");
   else {
     if (mpi_ct.my_rank == 0)
       fprintf(stderr, "phmnum < 0\n");
@@ -386,7 +389,7 @@ phm2sdf_main (const int argc, char *const argv[])
   ImageFileArray v = im_global->getArray ();
   double calctime = 0;
 
   ImageFileArray v = im_global->getArray ();
   double calctime = 0;
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (phm->type == P_UNIT_PULSE) {
     if (mpi_ct.my_rank == 0) {
       v[opt_nx/2][opt_ny/2] = 1.;
   if (phm->type == P_UNIT_PULSE) {
     if (mpi_ct.my_rank == 0) {
       v[opt_nx/2][opt_ny/2] = 1.;
@@ -399,12 +402,12 @@ phm2sdf_main (const int argc, char *const argv[])
     }
   } else {
     if (opt_verbose)
     }
   } else {
     if (opt_verbose)
-      mpi_t1 = MPI_Wtime();
+      mpi_t1 = MPI::Wtime();
     phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],  mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
     if (opt_verbose) {
     phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],  mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
     if (opt_verbose) {
-      mpi_t2 = MPI_Wtime();
+      mpi_t2 = MPI::Wtime();
       mpi_t = mpi_t2 - mpi_t1;
       mpi_t = mpi_t2 - mpi_t1;
-      MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+      mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
       if (mpi_ct.my_rank == 0)
        printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
     }
       if (mpi_ct.my_rank == 0)
        printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
     }
@@ -426,13 +429,13 @@ phm2sdf_main (const int argc, char *const argv[])
   }
 #endif
 
   }
 #endif
 
-#ifdef MPI_CT
-  time_end = MPI_Wtime();
+#ifdef HAVE_MPI
+  time_end = MPI::Wtime();
 #else
   time_end = td_current_sec();
 #endif
 
 #else
   time_end = td_current_sec();
 #endif
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) 
 #endif
   {
   if (mpi_ct.my_rank == 0) 
 #endif
   {
@@ -462,7 +465,7 @@ phm2sdf_main (const int argc, char *const argv[])
 
 
 
 
 
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug)
 {
   ImageFileArray vLocal = im_local.getArray();
 void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug)
 {
   ImageFileArray vLocal = im_local.getArray();
@@ -472,7 +475,7 @@ void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_
   
   int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (int iw = 0; iw <= end_work_unit; iw++) {
   
   int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (int iw = 0; iw <= end_work_unit; iw++) {
-    MPI_Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0, mpi_ct.comm);
+    mpi_ct.comm.Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0);
   }
 
   if (mpi_ct.my_rank == 0) {
   }
 
   if (mpi_ct.my_rank == 0) {
@@ -485,8 +488,8 @@ void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_
       }
 
       for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
       }
 
       for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
-       MPI_Status status;
-       MPI_Recv(vGlobal[iw], nyGlobal, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
+       MPI::Status status;
+       mpi_ct.comm.Recv(vGlobal[iw], nyGlobal, MPI::FLOAT, iproc, 0, status);
       }
     }
   }
       }
     }
   }
index 1e158836251c4f5ee1c3405d4420e1c3b7705480..78a9f5faf2905acfa8d19f882dee779a2395d003 100644 (file)
@@ -9,8 +9,11 @@
 **   1984 -- Final DOS version  
 **   1999 -- First UNIX version
 **
 **   1984 -- Final DOS version  
 **   1999 -- First UNIX version
 **
-**  $Id: phm2rs.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
+**  $Id: phm2rs.cpp,v 1.2 2000/06/07 10:12:05 kevin Exp $
 **  $Log: phm2rs.cpp,v $
 **  $Log: phm2rs.cpp,v $
+**  Revision 1.2  2000/06/07 10:12:05  kevin
+**  Upgraded from MPI to MPI++
+**
 **  Revision 1.1  2000/06/07 02:29:05  kevin
 **  Initial C++ versions
 **
 **  Revision 1.1  2000/06/07 02:29:05  kevin
 **  Initial C++ versions
 **
@@ -89,7 +92,7 @@ static struct option phm2rs_options[] =
 void 
 phm2rs_usage (const char *program)
 {
 void 
 phm2rs_usage (const char *program)
 {
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 if (mpi_ct.my_rank == 0)
   {
 #endif  
 if (mpi_ct.my_rank == 0)
   {
 #endif  
@@ -120,13 +123,13 @@ if (mpi_ct.my_rank == 0)
   fprintf(stdout,"     --debug      Debug mode\n");
   fprintf(stdout,"     --version    Print version\n");
   fprintf(stdout,"     --help       Print this help message\n");
   fprintf(stdout,"     --debug      Debug mode\n");
   fprintf(stdout,"     --version    Print version\n");
   fprintf(stdout,"     --help       Print this help message\n");
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   }
   }
-  MPI_Abort(mpi_ct.comm, 1);
+  mpi_ct.comm.Abort(1);
 #endif
 }
 
 #endif
 }
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug);
 #endif
 
 void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug);
 #endif
 
@@ -147,7 +150,7 @@ phm2rs_main (const int argc, char *const argv[])
   double opt_rotangle = 1;
   double time_start = 0, time_end = 0;
 
   double opt_rotangle = 1;
   double time_start = 0, time_end = 0;
 
-#ifndef MPI_CT
+#ifndef HAVE_MPI
   time_start = td_current_sec();
 #else
   RAYSUM *rs_local;
   time_start = td_current_sec();
 #else
   RAYSUM *rs_local;
@@ -155,19 +158,20 @@ phm2rs_main (const int argc, char *const argv[])
   char **mpi_argv = (char **) argv;
   double mpi_t1 = 0, mpi_t2 = 0, mpi_t, mpi_t_g;
 
   char **mpi_argv = (char **) argv;
   double mpi_t1 = 0, mpi_t2 = 0, mpi_t, mpi_t_g;
 
-  MPI_Init(&mpi_argc, &mpi_argv);
-  MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm);
-  MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc);
-  MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank);
+  MPI::Init (mpi_argc, mpi_argv);
+  mpi_ct.comm = MPI::COMM_WORLD.Dup ();
+  mpi_ct.nproc = mpi_ct.comm.Get_size();
+  mpi_ct.my_rank = mpi_ct.comm.Get_rank();
 
 
-  if (mpi_ct.nproc > MPI_MAX_PROCESS) {
-    sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)", mpi_ct.nproc, MPI_MAX_PROCESS);
-    exit(1);
+  if (mpi_ct.nproc > CT_MPI_MAX_PROCESS) {
+    sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
+             mpi_ct.nproc, CT_MPI_MAX_PROCESS);
   }
   }
-  time_start = MPI_Wtime();
+
+  time_start = MPI::Wtime();
 #endif
   
 #endif
   
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) {
 #endif
     strcpy(opt_desc, "");
   if (mpi_ct.my_rank == 0) {
 #endif
     strcpy(opt_desc, "");
@@ -189,7 +193,7 @@ phm2rs_main (const int argc, char *const argv[])
        phm = phm_create (opt_phmnum);
        break;
       case O_PHMFILE:
        phm = phm_create (opt_phmnum);
        break;
       case O_PHMFILE:
-#ifdef MPI_CT
+#ifdef HAVE_MPI
        if (mpi_ct.my_rank == 0)
          fprintf(stderr, "Can not read phantom from file in MPI mode\n");
        return (1);
        if (mpi_ct.my_rank == 0)
          fprintf(stderr, "Can not read phantom from file in MPI mode\n");
        return (1);
@@ -289,20 +293,20 @@ phm2rs_main (const int argc, char *const argv[])
       strncat(str, opt_desc, sizeof(str));
     }
     strncpy(opt_desc, str, sizeof(opt_desc));
       strncat(str, opt_desc, sizeof(str));
     }
     strncpy(opt_desc, str, sizeof(opt_desc));
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   }
 #endif
 
   }
 #endif
 
-#ifdef MPI_CT
-  MPI_Barrier(mpi_ct.comm);
-  MPI_Bcast(&opt_rotangle, 1, MPI_DOUBLE, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_nview, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_ndet, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_nray, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm);
-  MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm);
+#ifdef HAVE_MPI
+  mpi_ct.comm.Barrier ();
+  mpi_ct.comm.Bcast (&opt_rotangle, 1, MPI::DOUBLE, 0);
+  mpi_ct.comm.Bcast (&opt_nview, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_ndet, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_nray, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_phmnum, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_verbose, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_debug, 1, MPI::INT, 0);
+  mpi_ct.comm.Bcast (&opt_trace, 1, MPI::INT, 0);
 
   if (mpi_ct.my_rank > 0 && opt_phmnum >= 0)
     phm = phm_create (opt_phmnum);
 
   if (mpi_ct.my_rank > 0 && opt_phmnum >= 0)
     phm = phm_create (opt_phmnum);
@@ -311,7 +315,7 @@ phm2rs_main (const int argc, char *const argv[])
   opt_rotangle *= PI;
   det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
 
   opt_rotangle *= PI;
   det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   mpi_ct_calc_work_units(opt_nview);
   if (mpi_ct.my_rank == 0) {
     rs_global = raysum_create_from_det (opt_outfile, det);
   mpi_ct_calc_work_units(opt_nview);
   if (mpi_ct.my_rank == 0) {
     rs_global = raysum_create_from_det (opt_outfile, det);
@@ -324,23 +328,23 @@ phm2rs_main (const int argc, char *const argv[])
     printf("rs_local->nview = %d (process %d)\n", rs_local->nview, mpi_ct.my_rank);
 
   if (opt_verbose)
     printf("rs_local->nview = %d (process %d)\n", rs_local->nview, mpi_ct.my_rank);
 
   if (opt_verbose)
-    mpi_t1 = MPI_Wtime();
+    mpi_t1 = MPI::Wtime();
   raysum_collect (rs_local, det, phm, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE);
   if (opt_verbose) {
   raysum_collect (rs_local, det, phm, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE);
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to collect rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
   }
 
   if (opt_verbose)
     if (mpi_ct.my_rank == 0)
       printf("Time to collect rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
   }
 
   if (opt_verbose)
-    mpi_t1 = MPI_Wtime();
+    mpi_t1 = MPI::Wtime();
   mpi_gather_rs(rs_global, rs_local, opt_debug);
   if (opt_verbose) {
   mpi_gather_rs(rs_global, rs_local, opt_debug);
   if (opt_verbose) {
-    mpi_t2 = MPI_Wtime();
+    mpi_t2 = MPI::Wtime();
     mpi_t = mpi_t2 - mpi_t1;
     mpi_t = mpi_t2 - mpi_t1;
-    MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+    mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
     if (mpi_ct.my_rank == 0)
       printf("Time to gather rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
   }
     if (mpi_ct.my_rank == 0)
       printf("Time to gather rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
   }
@@ -349,10 +353,10 @@ phm2rs_main (const int argc, char *const argv[])
   raysum_collect (rs_global, det, phm, 0, opt_trace, FALSE);
 #endif
   
   raysum_collect (rs_global, det, phm, 0, opt_trace, FALSE);
 #endif
   
-#ifndef MPI_CT
+#ifndef HAVE_MPI
   time_end = td_current_sec();
 #else
   time_end = td_current_sec();
 #else
-  time_end = MPI_Wtime();
+  time_end = MPI::Wtime();
   if (mpi_ct.my_rank == 0) 
 #endif
     {
   if (mpi_ct.my_rank == 0) 
 #endif
     {
@@ -364,7 +368,7 @@ phm2rs_main (const int argc, char *const argv[])
       }
     }
 
       }
     }
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
   if (mpi_ct.my_rank == 0) 
 #endif
     {
   if (mpi_ct.my_rank == 0) 
 #endif
     {
@@ -386,7 +390,7 @@ phm2rs_main (const int argc, char *const argv[])
  *    Gather's raysums from all processes in rs_local in rs_global in process 0
  */
 
  *    Gather's raysums from all processes in rs_local in rs_global in process 0
  */
 
-#ifdef MPI_CT
+#ifdef HAVE_MPI
 void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
 {
   int iproc;
 void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
 {
   int iproc;
@@ -395,9 +399,9 @@ void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
 
   end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (iw = 0; iw <= end_work_unit; iw++) {
 
   end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
   for (iw = 0; iw <= end_work_unit; iw++) {
-    MPI_Send(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm);
-    MPI_Send(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm);
-    MPI_Send(rs_local->view[iw]->detval, rs_local->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm);
+    mpi_ct.comm.Send(&rs_local->view[iw]->view_angle, 1, MPI::DOUBLE, 0, 0);
+    mpi_ct.comm.Send(&rs_local->view[iw]->ndet, 1, MPI::INT, 0, 0);
+    mpi_ct.comm.Send(rs_local->view[iw]->detval, rs_local->ndet, MPI::FLOAT, 0, 0);
   }
 
   if (mpi_ct.my_rank == 0) {
   }
 
   if (mpi_ct.my_rank == 0) {
@@ -410,11 +414,11 @@ void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
        fprintf(stdout, "Recv rs data from process %d\n", iproc);
 
       for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
        fprintf(stdout, "Recv rs data from process %d\n", iproc);
 
       for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
-       MPI_Status status;
+       MPI::Status status;
 
 
-       MPI_Recv(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm, &status);
-       MPI_Recv(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm, &status);
-       MPI_Recv(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
+       mpi_ct.comm.Recv(&rs_global->view[iw]->view_angle, 1, MPI::DOUBLE, iproc, 0, status);
+       mpi_ct.comm.Recv(&rs_global->view[iw]->ndet, 1, MPI::INT, iproc, 0, status);
+       mpi_ct.comm.Recv(rs_global->view[iw]->detval, rs_global->ndet, MPI::FLOAT, iproc, 0, status);
       }
     }
   }
       }
     }
   }