/*****************************************************************************
-** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: phm2if.cpp,v 1.4 2000/06/07 10:12:05 kevin Exp $
-** $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.2 2000/06/07 03:50:27 kevin
-** *** empty log message ***
-**
-** Revision 1.1 2000/06/07 02:29:05 kevin
-** Initial C++ versions
-**
-** Revision 1.10 2000/05/24 22:50:04 kevin
-** Added support for new SGP library
-**
-** Revision 1.9 2000/05/16 04:33:59 kevin
-** Improved option processing
-**
-** Revision 1.8 2000/05/11 01:06:30 kevin
-** Changed sprintf to snprintf
-**
-** Revision 1.7 2000/05/08 20:02:32 kevin
-** ANSI C changes
-**
-** Revision 1.6 2000/05/03 08:49:50 kevin
-** Code cleanup
-**
-** Revision 1.5 2000/04/30 19:17:54 kevin
-** *** empty log message ***
+** FILE IDENTIFICATION
**
-** Revision 1.4 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.3 2000/04/28 18:19:01 kevin
-** removed unused files
-**
-** Revision 1.2 2000/04/28 13:50:45 kevin
-** Removed Makefile Makefile.in that are automatically generated by autoconf
-**
-** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
-** Initial CVS import for first public release
+** Name: phm2if.cpp
+** Purpose: Convert an phantom object to an image file
+** Programmer: Kevin Rosenberg
+** Date Started: 1984
**
+** This is part of the CTSim program
+** Copyright (C) 1983-2000 Kevin Rosenberg
**
+** $Id: phm2if.cpp,v 1.5 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
}
#ifdef HAVE_MPI
-void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug);
+void mpi_gather_image (ImageFile* im_global, ImageFile* im_local, const int opt_debug);
#endif
int
if (opt_verbose) {
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);
+ 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);
}
im_global = new ImageFile (opt_outfile, opt_nx, opt_ny);
im_global->adf.fileCreate();
}
-
im_local = new ImageFile (opt_nx, opt_ny);
#else
im_global = new ImageFile (opt_outfile, opt_nx, opt_ny);
}
#endif
- ImageFileArray v = im_global->getArray ();
double calctime = 0;
+ ImageFileArray v;
#ifdef HAVE_MPI
+ if (mpi_ct.my_rank == 0)
+ v = im_global->getArray ();
+
if (phm->type == P_UNIT_PULSE) {
if (mpi_ct.my_rank == 0) {
v[opt_nx/2][opt_ny/2] = 1.;
calctime = 0;
}
} else {
+ mpi_ct.comm.Barrier();
+
if (opt_verbose)
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 (mpi_ct.my_rank == 0)
printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
}
- mpi_gather_image(*im_global, *im_local, opt_debug);
+ mpi_gather_image(im_global, im_local, opt_debug);
}
#else
+ v = im_global->getArray ();
if (phm->type == P_UNIT_PULSE) {
v[opt_nx/2][opt_ny/2] = 1.;
calctime = 0;
im_global->adf.fileClose ();
if (opt_verbose)
fprintf (stdout, "Time to compile image = %.2f sec\n\n", calctime);
- }
- if (opt_trace >= TRACE_PHM) {
- double dmin, dmax;
- int nscale;
-
- printf ("Enter display size scale (nominal = 1): ");
- scanf ("%d", &nscale);
- printf ("Enter minimum and maximum densities (min, max): ");
- scanf ("%lf %lf", &dmin, &dmax);
- image_display_scale (*im_global, nscale, dmin, dmax);
+ if (opt_trace >= TRACE_PHM) {
+ double dmin, dmax;
+ int nscale;
+
+ printf ("Enter display size scale (nominal = 1): ");
+ scanf ("%d", &nscale);
+ printf ("Enter minimum and maximum densities (min, max): ");
+ scanf ("%lf %lf", &dmin, &dmax);
+ image_display_scale (*im_global, nscale, dmin, dmax);
+ }
}
phm_free (phm);
#ifdef HAVE_MPI
-void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug)
+void mpi_gather_image (ImageFile* im_global, ImageFile* im_local, const int opt_debug)
{
- ImageFileArray vLocal = im_local.getArray();
- ImageFileArray vGlobal = im_global.getArray();
- int nyLocal = im_local.ny();
- int nyGlobal = im_global.ny();
+ ImageFileArray vLocal = im_local->getArray();
+ ImageFileArray vGlobal = NULL;
+ if (mpi_ct.my_rank == 0)
+ vGlobal = im_global->getArray();
+ int nyLocal = im_local->ny();
int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
for (int iw = 0; iw <= end_work_unit; iw++) {
- mpi_ct.comm.Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0);
+ mpi_ct.comm.Send(vLocal[iw], nyLocal, im_local->getMPIDataType(), 0, 0);
}
if (mpi_ct.my_rank == 0) {
for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
MPI::Status status;
- mpi_ct.comm.Recv(vGlobal[iw], nyGlobal, MPI::FLOAT, iproc, 0, status);
+ mpi_ct.comm.Recv(vGlobal[iw], nyLocal, im_local->getMPIDataType(), iproc, 0, status);
}
}
}