X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fctrec.c;h=8015376fff4d3b40507276b68131f560df48181c;hb=853b74083affe617d84ed790a4705dc1d1ed52c2;hp=f8c58ef1282ccea9b53fc1b76cca99497ff4609c;hpb=ff95dd83503e99e50b32140a073c0a742c414cb1;p=ctsim.git diff --git a/src/ctrec.c b/src/ctrec.c index f8c58ef..8015376 100644 --- a/src/ctrec.c +++ b/src/ctrec.c @@ -2,8 +2,23 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctrec.c,v 1.4 2000/04/30 10:13:27 kevin Exp $ +** $Id: ctrec.c,v 1.9 2000/05/08 20:02:32 kevin Exp $ ** $Log: ctrec.c,v $ +** 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 +** +** 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 ** @@ -44,15 +59,7 @@ #include "ct.h" -#define O_INTERP 1 -#define O_FILTER 2 -#define O_FILTER_PARAM 3 -#define O_BACKPROJ 4 -#define O_VERBOSE 5 -#define O_TRACE 6 -#define O_HELP 7 -#define O_DEBUG 8 -#define O_VERSION 9 +enum {O_INTERP, O_FILTER, O_FILTER_PARAM, O_BACKPROJ, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION}; static struct option my_options[] = { @@ -103,7 +110,7 @@ usage (const char *program) fprintf(stdout," --trace Set tracing to level\n"); fprintf(stdout," none No tracing (default)\n"); fprintf(stdout," status Status tracing\n"); - fprintf(stdout," pic Trace picture\n"); + fprintf(stdout," phm Trace phantom\n"); fprintf(stdout," rays Trace allrays\n"); fprintf(stdout," plot Trace plotting\n"); fprintf(stdout," clipping Trace clipping\n"); @@ -135,17 +142,17 @@ main (const int argc, char *const argv[]) int opt_debug = 0; int opt_trace = TRACE_NONE; double opt_filter_param = 1; - int opt_filter = W_A_BANDLIMIT; + int opt_filter = FILTER_ABS_BANDLIMIT; int opt_interp = I_LINEAR; int opt_interp_param = 1; - int opt_backproj = O_BPROJ_DIFF2; + BackprojType opt_backproj = O_BPROJ_DIFF2; #ifdef MPI_CT IMAGE *im_local; RAYSUM *rs_local; int mpi_argc = argc; char **mpi_argv = (char **) argv; int mpi_nview, mpi_ndet; - double mpi_detinc, mpi_rotinc, mpi_piclen; + double mpi_detinc, mpi_rotinc, mpi_phmlen; double mpi_t1, mpi_t2, mpi_t, mpi_t_g; int ix; @@ -233,15 +240,14 @@ main (const int argc, char *const argv[]) nx = strtol(argv[optind + 2], &endptr, 10); ny = strtol(argv[optind + 3], &endptr, 10); - if (opt_filter == W_G_HAMMING || opt_filter == W_AG_HAMMING) + if (opt_filter == FILTER_G_HAMMING || opt_filter == FILTER_ABS_G_HAMMING) sprintf (filt_name, "%s: alpha = %.2f", - filter_name_of (opt_filter), opt_filter_param); + name_of_filter (opt_filter), opt_filter_param); else - sprintf (filt_name, "%s", filter_name_of (opt_filter)); + sprintf (filt_name, "%s", name_of_filter (opt_filter)); - sprintf (remark, - "Reconstruct: %dx%d, %s, %s, %s", - nx, ny, filt_name, interp_name_of (opt_interp), name_of_backproj(opt_backproj)); + sprintf (remark, "Reconstruct: %dx%d, %s, %s, %s", + nx, ny, filt_name, name_of_interpolation (opt_interp), name_of_backproj(opt_backproj)); if (opt_verbose) fprintf (stdout, "%s\n", remark); @@ -253,14 +259,13 @@ main (const int argc, char *const argv[]) if (mpi_ct.my_rank == 0) { rs_global = raysum_open (rs_name); raysum_read (rs_global); - if (opt_verbose) { + if (opt_verbose) print_raysum_info(rs_global); - } mpi_ndet = rs_global->ndet; mpi_nview = rs_global->nview; mpi_detinc = rs_global->det_inc; - mpi_piclen = rs_global->piclen; + mpi_phmlen = rs_global->phmlen; mpi_rotinc = rs_global->rot_inc; } @@ -276,7 +281,7 @@ main (const int argc, char *const argv[]) 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_piclen, 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); @@ -290,21 +295,12 @@ main (const int argc, char *const argv[]) mpi_ct_calc_work_units(mpi_nview); - if (opt_debug) { - fprintf(stdout, "Calc'd local work units process %d: nviews=%d, local_work_units=%d, start_work_units=%d\n", - mpi_ct.my_rank, mpi_nview, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ct.start_work_unit[mpi_ct.my_rank]); - MPI_Barrier(mpi_ct.comm); - } - rs_local = raysum_create (NULL, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ndet); - if (opt_debug) { - fprintf(stdout, "Created rs_local %lx for process %d: local views=%4d, local dets=%4d\n", (unsigned long int) rs_local, mpi_ct.my_rank, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ndet); - } rs_local->ndet = mpi_ndet; rs_local->nview = mpi_nview; rs_local->det_inc = mpi_detinc; - rs_local->piclen = mpi_piclen; + rs_local->phmlen = mpi_phmlen; rs_local->rot_inc = mpi_rotinc; if (opt_verbose) @@ -328,7 +324,7 @@ main (const int argc, char *const argv[]) #else rs_global = raysum_open (rs_name); raysum_read (rs_global); - if (opt_debug) + if (opt_verbose) print_raysum_info(rs_global); im_global = image_create (im_filename, nx, ny); @@ -340,14 +336,11 @@ main (const int argc, char *const argv[]) mpi_t1 = MPI_Wtime(); image_reconst (im_local, rs_local, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); - if (opt_debug) - printf("Back from image_reconst in process %d\n", mpi_ct.my_rank); mpi_t2 = MPI_Wtime(); mpi_t = mpi_t2 - mpi_t1; MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); - if (mpi_ct.my_rank == 0) { + if (mpi_ct.my_rank == 0 && opt_verbose) printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g); - } #else image_reconst (im_global, rs_global, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); @@ -360,16 +353,15 @@ main (const int argc, char *const argv[]) if (opt_verbose) mpi_t1 = MPI_Wtime(); + for (ix = 0; ix < im_local->nx; ix++) { void *recvbuf = NULL; if (mpi_ct.my_rank == 0) recvbuf = im_global->v[ix]; - if (opt_debug) - printf("Calling MPI_Reduce in process %2d for ix=%d\n", mpi_ct.my_rank, ix); - MPI_Reduce(im_local->v[ix], recvbuf, im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm); } + if (opt_verbose) { mpi_t2 = MPI_Wtime(); mpi_t = mpi_t2 - mpi_t1; @@ -378,20 +370,19 @@ main (const int argc, char *const argv[]) printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g); } if (mpi_ct.my_rank == 0) { - strncpy (im_global->remark, remark, MAXREMARK); - image_save (im_global); + strncpy (im_global->remark, remark, sizeof(im_global->remark)); time_end = MPI_Wtime(); im_global->calctime = time_end - time_start; + image_save (im_global); if (opt_verbose) fprintf (stdout, "Time active = %.2f\n", im_global->calctime); } #else raysum_close (rs_global); - strncpy (im_global->remark, remark, MAXREMARK); - image_save (im_global); - + strncpy (im_global->remark, remark, sizeof(im_global->remark)); time_end = td_current_sec(); im_global->calctime = time_end - time_start; + image_save (im_global); if (opt_verbose) fprintf (stdout, "Time active = %.2f secs\n", im_global->calctime); #endif @@ -448,7 +439,7 @@ static void print_raysum_info(const RAYSUM *rs) printf ("Number of detectors: %d\n", rs->ndet); printf (" Number of views: %d\n", rs->nview); printf (" Remark: %s\n", rs->remark); - printf (" Piclen: %f\n", rs->piclen); + printf (" phmlen: %f\n", rs->phmlen); printf (" det_start: %f\n", rs->det_start); printf (" det_inc: %f\n", rs->det_inc); printf (" rot_start: %f\n", rs->rot_start);