Skip to content

Commit

Permalink
Make PrintToFile() and AllPrintToFile() work with ParallelContext (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers authored Jun 9, 2020
1 parent 1eff033 commit 399917f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Src/Base/AMReX_Print.H
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ namespace amrex

explicit PrintToFile (const std::string& file_name_)
: file_name(file_name_)
, rank(ParallelDescriptor::IOProcessorNumber())
, comm(ParallelDescriptor::Communicator())
, rank(ParallelContext::IOProcessorNumberSub())
, comm(ParallelContext::CommunicatorSub())
{ Initialize(); }

PrintToFile (const std::string& file_name_, int rank_ )
: file_name(file_name_)
, rank(rank_)
, comm(ParallelDescriptor::Communicator())
, comm(ParallelContext::CommunicatorSub())
{ Initialize(); }

PrintToFile (const std::string& file_name_, int rank_, MPI_Comm comm_)
Expand All @@ -133,7 +133,7 @@ namespace amrex
{ Initialize(); }

~PrintToFile () {
if (rank == AllProcs || rank == ParallelDescriptor::MyProc(comm)) {
if (rank == AllProcs || rank == ParallelContext::MyProcSub()) {
ofs.flush();
ofs << ss.str();
ofs.flush();
Expand Down Expand Up @@ -161,9 +161,10 @@ namespace amrex
private:

void Initialize() {
int my_proc = ParallelDescriptor::MyProc(comm);
int my_proc = ParallelContext::MyProcSub();
if (rank == AllProcs || rank == my_proc) {
std::string proc_file_name = file_name + "." + std::to_string(my_proc);
int my_proc_global = ParallelDescriptor::MyProc();
std::string proc_file_name = file_name + "." + std::to_string(my_proc_global);
#ifdef _OPENMP
proc_file_name += "." + std::to_string(omp_get_thread_num());
#endif
Expand Down

0 comments on commit 399917f

Please sign in to comment.