Skip to content

Commit

Permalink
fixing indent
Browse files Browse the repository at this point in the history
  • Loading branch information
pengfej committed May 25, 2022
1 parent 76b4ff2 commit 2ae3559
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions source/base/data_out_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7710,22 +7710,22 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
AssertThrowMPI(ierr);

// Define header size so we can broadcast later.
unsigned int header_size;
unsigned int header_size;

// write header
if (myrank == 0)
{
std::stringstream ss;
DataOutBase::write_vtu_header(ss, vtk_flags);
header_size = ss.str().size();
// Write the header on rank 0 at the starting of a file, i.e., offset 0.
// Write the header on rank 0 at the starting of a file, i.e., offset 0.
ierr = MPI_File_write_at(
fh, 0, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}

ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
AssertThrowMPI(ierr);
ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
AssertThrowMPI(ierr);


{
Expand All @@ -7746,30 +7746,32 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
vtk_flags,
ss);

//using prefix sum to find specific offset to write at.
// using prefix sum to find specific offset to write at.
const std::uint64_t size_on_proc = ss.str().size();
std::uint64_t prefix_sum = 0;
ierr = MPI_Exscan(&size_on_proc,
&prefix_sum,
1,
MPI_UINT64_T ,
MPI_SUM,
comm);
std::uint64_t prefix_sum = 0;
ierr =
MPI_Exscan(&size_on_proc, &prefix_sum, 1, MPI_UINT64_T, MPI_SUM, comm);
AssertThrowMPI(ierr);

// Locate specific offset for each processor.
const MPI_Offset offset = static_cast<MPI_Offset>(header_size) + prefix_sum;

ierr = Utilities::MPI::LargeCount::MPI_File_write_at_all_c(
fh, offset, ss.str().c_str(), ss.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
ierr =
Utilities::MPI::LargeCount::MPI_File_write_at_all_c(fh,
offset,
ss.str().c_str(),
ss.str().size(),
MPI_CHAR,
MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);

// Sending the offset for writing the footer to rank 0.
if (myrank == n_ranks-1){
const std::uint64_t footer_offset = size_on_proc + offset;
ierr = MPI_Send(&footer_offset, 1, MPI_UINT64_T , 0, 0, comm);
AssertThrowMPI(ierr);
}
if (myrank == n_ranks - 1)
{
const std::uint64_t footer_offset = size_on_proc + offset;
ierr = MPI_Send(&footer_offset, 1, MPI_UINT64_T, 0, 0, comm);
AssertThrowMPI(ierr);
}
}

// write footer
Expand All @@ -7780,11 +7782,22 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
const unsigned int footer_size = ss.str().size();

std::uint64_t footer_offset;
ierr = MPI_Recv(&footer_offset, 1, MPI_UINT64_T , n_ranks-1, 0, comm, MPI_STATUS_IGNORE);
ierr = MPI_Recv(&footer_offset,
1,
MPI_UINT64_T,
n_ranks - 1,
0,
comm,
MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);

// Writing Footer.
ierr = MPI_File_write_at(fh, footer_offset, ss.str().c_str(), footer_size, MPI_CHAR, MPI_STATUS_IGNORE);
ierr = MPI_File_write_at(fh,
footer_offset,
ss.str().c_str(),
footer_size,
MPI_CHAR,
MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}
ierr = MPI_File_close(&fh);
Expand Down

0 comments on commit 2ae3559

Please sign in to comment.