r102: fixed mpi bug
[ctsim.git] / src / phm2if.cpp
index 573cb7c697525de4790f1143c8fd8b5d72b4adff..0eb5c9e1ebc544c765b6788db92e2cccf4b5ce5e 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.10 2000/06/18 10:27:11 kevin Exp $
+**  $Id: phm2if.cpp,v 1.11 2000/06/19 17:58:13 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
@@ -270,7 +270,7 @@ phm2if_main (int argc, char* argv[])
 #endif
 
 #ifdef HAVE_MPI
-  TimerMPI timerBcast (mpiWorld.getComm());
+  TimerCollectiveMPI timerBcast (mpiWorld.getComm());
   mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
@@ -305,7 +305,7 @@ phm2if_main (int argc, char* argv[])
   else {
     if (mpiWorld.getRank() == 0)
       cerr << "phmnum < 0" << endl;
-    exit(1);
+    return (1);
   }
 #endif
 
@@ -323,12 +323,12 @@ phm2if_main (int argc, char* argv[])
       image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
     }
   } else {
-    TimerMPI timerRasterize (mpiWorld.getComm());
+    TimerCollectiveMPI timerRasterize (mpiWorld.getComm());
     phm_to_imagefile (phm, *imLocal, mpiWorld.getMyStartWorkUnit(),  mpiWorld.getMyLocalWorkUnits(), opt_nsample, opt_trace);
     if (opt_verbose)
       timerRasterize.timerEndAndReport ("Time to rasterize phantom");
 
-    TimerMPI timerGather (mpiWorld.getComm());
+    TimerCollectiveMPI timerGather (mpiWorld.getComm());
     mpi_gather_image (mpiWorld, imGlobal, imLocal, opt_debug);
     if (opt_verbose)
       timerGather.timerEndAndReport ("Time to gather image");
@@ -405,6 +405,16 @@ void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* imGlobal, ImageFile* imLoc
 int 
 main (int argc, char* argv[])
 {
-  return (phm2if_main(argc, argv));
+  int retval = 1;
+
+  try {
+    retval = phm2if_main(argc, argv);
+  } catch (exception e) {
+    cerr << "Exception: " << e.what() << endl;
+  } catch (...) {
+    cerr << "Unknown exception" << endl;
+  }
+
+  return (retval);
 }
 #endif