r89: *** empty log message ***
[ctsim.git] / src / ctrec.cpp
index 6ed8bd98fc2ad4f621f5ca510c52ff66cbc758eb..fed86ee0504ebe45c5fa537ed842488133bbc1db 100644 (file)
@@ -1,59 +1,15 @@
 /*****************************************************************************
-**  This is part of the CTSim program
-**  Copyright (C) 1983-2000 Kevin Rosenberg
-**
-**  $Id: ctrec.cpp,v 1.3 2000/06/07 10:12:05 kevin Exp $
-**  $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.1  2000/06/07 02:29:05  kevin
-**  Initial C++ versions
-**
-**  Revision 1.13  2000/06/05 01:33:25  kevin
-**  BSpline changes
-**
-**  Revision 1.12  2000/05/24 22:50:04  kevin
-**  Added support for new SGP library
-**
-**  Revision 1.11  2000/05/16 04:33:59  kevin
-**  Improved option processing
-**
-**  Revision 1.10  2000/05/11 01:06:30  kevin
-**  Changed sprintf to snprintf
-**
-**  Revision 1.9  2000/05/08 20:02:32  kevin
-**  ANSI C changes
-**
-**  Revision 1.8  2000/05/04 18:16:34  kevin
-**  renamed filter definitions
-**
-**  Revision 1.7  2000/05/03 08:49:50  kevin
-**  Code cleanup
-**
-**  Revision 1.6  2000/05/02 15:31:47  kevin
-**  code cleaning
+** FILE IDENTIFICATION
 **
-**  Revision 1.5  2000/04/30 11:41:06  kevin
-**  Cleaned up debugging code
-**
-**  Revision 1.4  2000/04/30 10:13:27  kevin
-**  Fixed MPI bugs
-**
-**  Revision 1.3  2000/04/30 04:06:13  kevin
-**  Update Raysum i/o routines
-**  Fix MPI bug in ctrec (scatter_raysum) that referenced rs_global
-**
-**  Revision 1.2  2000/04/29 23:24:56  kevin
-**  *** empty log message ***
-**
-**  Revision 1.1.1.1  2000/04/28 13:02:44  kevin
-**  Initial CVS import for first public release
+**   Name:          ctrec.cpp
+**   Purpose:       Reconstruct an image from projections
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  Aug 1984
 **
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
 **
+**  $Id: ctrec.cpp,v 1.4 2000/06/08 16:43:10 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
 
-/* FILE
- *   ctrec.c           Reconstruct an image from raysums
- *
- * DATE
- *   Aug 84
- *   Jul 99  -- Converted to ANSI C
- *              Added MPI parallel processing
- */
-
 #include "ct.h"
 
 enum {O_INTERP, O_FILTER, O_FILTER_PARAM, O_BACKPROJ, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION};
@@ -351,8 +298,8 @@ ctrec_main (const int argc, char *const argv[])
     im_global = new ImageFile (im_filename, nx, ny);
     im_global->adf.fileCreate();
   }
-  im_local = new ImageFile (nx, ny);
 
+  im_local = new ImageFile (nx, ny);
 #else
   rs_global = raysum_open (rs_name);
   raysum_read (rs_global);
@@ -361,13 +308,13 @@ ctrec_main (const int argc, char *const argv[])
 
   im_global = new ImageFile (im_filename, nx, ny);
   im_global->adf.fileCreate();
-
 #endif
 
 #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);
+
   mpi_t2 = MPI::Wtime();
   mpi_t = mpi_t2 - mpi_t1;
   mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
@@ -385,14 +332,16 @@ ctrec_main (const int argc, char *const argv[])
   int nxLocal = im_local->adf.nx();
   int nyLocal = im_local->adf.ny();
   ImageFileArray vLocal = im_local->getArray();
-  ImageFileArray vGlobal = im_global->getArray();
+  ImageFileArray vGlobal = NULL;
+  if (mpi_ct.my_rank == 0)
+    vGlobal = im_global->getArray();
 
   for (int ix = 0; ix < nxLocal; ix++) {
     void *recvbuf = NULL;
     if (mpi_ct.my_rank == 0)
       recvbuf = vGlobal[ix];
 
-    mpi_ct.comm.Reduce(vLocal[ix], recvbuf, nyLocal, MPI::FLOAT, MPI::SUM, 0);
+    mpi_ct.comm.Reduce(vLocal[ix], recvbuf, nyLocal, im_local->getMPIDataType(), MPI::SUM, 0);
   }
 
   if (opt_verbose) {