From c4a97c0589e749cb4e2e40cd4cd19ea12b573c27 Mon Sep 17 00:00:00 2001 From: James McClure Date: Mon, 16 May 2022 11:17:47 -0400 Subject: [PATCH] support for SWC input format --- common/Domain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/Domain.cpp b/common/Domain.cpp index 42072750..6c6e9c69 100644 --- a/common/Domain.cpp +++ b/common/Domain.cpp @@ -42,6 +42,7 @@ static inline void fgetl(char *str, int num, FILE *stream) { void Domain::read_swc(const std::string &Filename) { //...... READ IN SWC FILE................................... + int count = 0; int number_of_lines = 0; if (rank() == 0){ cout << "Reading SWC file..." << endl; @@ -52,9 +53,11 @@ void Domain::read_swc(const std::string &Filename) { ++number_of_lines; number_of_lines -= 1; } - std::cout << "Number of lines in SWC file: " << number_of_lines; + std::cout << "Number of lines in SWC file: " << number_of_lines << endl; } - Comm.bcast(number_of_lines,0); + count = Comm.sumReduce(number_of_lines); // nonzero only for rank=0 + number_of_lines = count; + printf("***rank=%i , number of lines = %i\n",rank(),number_of_lines); // set up structures to read double *List_cx = new double [number_of_lines]; @@ -73,7 +76,7 @@ void Domain::read_swc(const std::string &Filename) { fgetl(line, 100, fid); //........read the spheres.................. // We will read until a blank like or end-of-file is reached - int count = 0; + count = 0; while (!feof(fid) && fgets(line, 100, fid) != NULL) { char *line2 = line; List_index[count] = int(strtod(line2, &line2)); @@ -104,6 +107,7 @@ void Domain::read_swc(const std::string &Filename) { start_x = rank_info.ix*(Nx-2)*voxel_length; start_y = rank_info.jy*(Ny-2)*voxel_length; start_z = rank_info.kz*(Nz-2)*voxel_length; + printf(" rank = %i: %f %f %f \n",rank(),start_x,start_y,start_z); finish_x = (rank_info.ix+1)*(Nx-2)*voxel_length; finish_y = (rank_info.jy+1)*(Ny-2)*voxel_length; finish_z = (rank_info.kz+1)*(Nz-2)*voxel_length; @@ -125,7 +129,7 @@ void Domain::read_swc(const std::string &Filename) { int cy = int((List_cy[idx] - start_y)/voxel_length) + 1; int cz = int((List_cz[idx] - start_z)/voxel_length) + 1; - if (rank()==0) printf("%i %i %i %i %i\n",label,cx,cy,cz,radius_in_voxels); + if (rank()==1) printf("%i %i %i %i %i\n",label,cx,cy,cz,radius_in_voxels); /* get the little box to loop over*/ int start_idx = int((List_cx[idx] - List_rad[idx] - start_x)/voxel_length) + 1; @@ -148,8 +152,8 @@ void Domain::read_swc(const std::string &Filename) { if (finish_idy > Ny-1 ) finish_idy = Ny; if (finish_idz > Nz-1 ) finish_idz = Nz; - if (rank()==0) printf( "start: %i, %i, %i \n",start_idx,start_idy,start_idz); - if (rank()==0) printf( "finish: %i, %i, %i \n",finish_idx,finish_idy,finish_idz); + if (rank()==1) printf( "start: %i, %i, %i \n",start_idx,start_idy,start_idz); + if (rank()==1) printf( "finish: %i, %i, %i \n",finish_idx,finish_idy,finish_idz); for (int k = start_idz; k