Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Call WriteJobInfo for openpmd diagnostics #4360

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/Diagnostics/FlushFormats/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ foreach(D IN LISTS WarpX_DIMS)
warpx_set_suffix_dims(SD ${D})
target_sources(lib_${SD}
PRIVATE
FlushFormat.cpp
FlushFormatAscent.cpp
FlushFormatCheckpoint.cpp
FlushFormatPlotfile.cpp
Expand Down
5 changes: 4 additions & 1 deletion Source/Diagnostics/FlushFormats/FlushFormat.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public:
bool isLastBTDFlush = false,
const amrex::Vector<int>& totalParticlesFlushedAlready = amrex::Vector<int>() ) const = 0;

virtual ~FlushFormat() {}
virtual ~FlushFormat() {}

/** Write general info of the run into the plotfile */
void WriteJobInfo(const std::string& dir) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpgrote I wonder if this should be written by full diagnostics at all - or instead rather like the warpx_used_inputs file just in general, when the simulation starts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I like this kind of thing to be written out in the same place as the diagnostics so that it is associated with the output of the simulation. If this is written at the startup, the code would have to figure out where the diagnostics will be written.

};

#endif // WARPX_FLUSHFORMAT_H_
130 changes: 130 additions & 0 deletions Source/Diagnostics/FlushFormats/FlushFormat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#include "FlushFormat.H"

#include "WarpX.H"

#include <AMReX_ParallelDescriptor.H>
#include <AMReX_ParmParse.H>
#include <AMReX_buildInfo.H>


void
FlushFormat::WriteJobInfo(const std::string& dir) const
{

auto & warpx = WarpX::GetInstance();

if (amrex::ParallelDescriptor::IOProcessor())
{
// job_info file with details about the run
std::ofstream jobInfoFile;
std::string FullPathJobInfoFile = dir;

const std::string PrettyLine = std::string(78, '=') + "\n";
// std::string OtherLine = std::string(78, '-') + "\n";
// std::string SkipSpace = std::string(8, ' ') + "\n";
Fixed Show fixed Hide fixed

FullPathJobInfoFile += "/warpx_job_info";
jobInfoFile.open(FullPathJobInfoFile.c_str(), std::ios::out);

// job information
jobInfoFile << PrettyLine;
jobInfoFile << " WarpX Job Information\n";
jobInfoFile << PrettyLine;

jobInfoFile << "number of MPI processes: " << amrex::ParallelDescriptor::NProcs() << "\n";
#ifdef AMREX_USE_OMP
jobInfoFile << "number of threads: " << omp_get_max_threads() << "\n";
#endif

jobInfoFile << "\n\n";

// build information
jobInfoFile << PrettyLine;
jobInfoFile << " Build Information\n";
jobInfoFile << PrettyLine;

jobInfoFile << "build date: " << amrex::buildInfoGetBuildDate() << "\n";
jobInfoFile << "build machine: " << amrex::buildInfoGetBuildMachine() << "\n";
jobInfoFile << "build dir: " << amrex::buildInfoGetBuildDir() << "\n";
jobInfoFile << "AMReX dir: " << amrex::buildInfoGetAMReXDir() << "\n";

jobInfoFile << "\n";

jobInfoFile << "COMP: " << amrex::buildInfoGetComp() << "\n";
jobInfoFile << "COMP version: " << amrex::buildInfoGetCompVersion() << "\n";

jobInfoFile << "\n";

jobInfoFile << "C++ compiler: " << amrex::buildInfoGetCXXName() << "\n";
jobInfoFile << "C++ flags: " << amrex::buildInfoGetCXXFlags() << "\n";

jobInfoFile << "\n";

jobInfoFile << "Fortran comp: " << amrex::buildInfoGetFName() << "\n";
jobInfoFile << "Fortran flags: " << amrex::buildInfoGetFFlags() << "\n";

jobInfoFile << "\n";

jobInfoFile << "Link flags: " << amrex::buildInfoGetLinkFlags() << "\n";
jobInfoFile << "Libraries: " << amrex::buildInfoGetLibraries() << "\n";

jobInfoFile << "\n";

const char* githash1 = amrex::buildInfoGetGitHash(1);
const char* githash2 = amrex::buildInfoGetGitHash(2);
const char* githash3 = amrex::buildInfoGetGitHash(3);
if (strlen(githash1) > 0) {
jobInfoFile << "WarpX git describe: " << githash1 << "\n";
}
if (strlen(githash2) > 0) {
jobInfoFile << "AMReX git describe: " << githash2 << "\n";
}
if (strlen(githash3) > 0) {
jobInfoFile << "PICSAR git describe: " << githash3 << "\n";
}

jobInfoFile << "\n\n";

// grid information
jobInfoFile << PrettyLine;
jobInfoFile << " Grid Information\n";
jobInfoFile << PrettyLine;

for (int i = 0; i <= warpx.finestLevel(); i++)
{
jobInfoFile << " level: " << i << "\n";
jobInfoFile << " number of boxes = " << warpx.boxArray(i).size() << "\n";
jobInfoFile << " maximum zones = ";
for (int n = 0; n < AMREX_SPACEDIM; n++)
{
jobInfoFile << warpx.Geom(i).Domain().length(n) << " ";
}
jobInfoFile << "\n\n";
}

jobInfoFile << " Boundary conditions\n";

jobInfoFile << " -x: " << "interior" << "\n";
jobInfoFile << " +x: " << "interior" << "\n";
if (AMREX_SPACEDIM >= 2) {
jobInfoFile << " -y: " << "interior" << "\n";
jobInfoFile << " +y: " << "interior" << "\n";
}
#if defined(WARPX_DIM_3D)
jobInfoFile << " -z: " << "interior" << "\n";
jobInfoFile << " +z: " << "interior" << "\n";
#endif

jobInfoFile << "\n\n";


// runtime parameters
jobInfoFile << PrettyLine;
jobInfoFile << " Inputs File Parameters\n";
jobInfoFile << PrettyLine;

amrex::ParmParse::dumpTable(jobInfoFile, true);

jobInfoFile.close();
}
}
2 changes: 2 additions & 0 deletions Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@ FlushFormatOpenPMD::WriteToFile (

// signal that no further updates will be written to this iteration
m_OpenPMDPlotWriter->CloseStep(isBTD, isLastBTDFlush);

WriteJobInfo(prefix);
}
2 changes: 0 additions & 2 deletions Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public:
bool isLastBTDFlush = false,
const amrex::Vector<int>& totalParticlesFlushedAlready = amrex::Vector<int>() ) const override;

/** Write general info of the run into the plotfile */
void WriteJobInfo(const std::string& dir) const;
/** Write WarpX-specific plotfile header */
void WriteWarpXHeader(const std::string& name, amrex::Vector<amrex::Geometry>& geom) const;
void WriteAllRawFields (bool plot_raw_fields, int nlevels,
Expand Down
122 changes: 0 additions & 122 deletions Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,128 +108,6 @@ FlushFormatPlotfile::WriteToFile (
VisMF::SetHeaderVersion(current_version);
}

void
FlushFormatPlotfile::WriteJobInfo(const std::string& dir) const
{

auto & warpx = WarpX::GetInstance();

if (ParallelDescriptor::IOProcessor())
{
// job_info file with details about the run
std::ofstream jobInfoFile;
std::string FullPathJobInfoFile = dir;

const std::string PrettyLine = std::string(78, '=') + "\n";
// std::string OtherLine = std::string(78, '-') + "\n";
// std::string SkipSpace = std::string(8, ' ') + "\n";

FullPathJobInfoFile += "/warpx_job_info";
jobInfoFile.open(FullPathJobInfoFile.c_str(), std::ios::out);

// job information
jobInfoFile << PrettyLine;
jobInfoFile << " WarpX Job Information\n";
jobInfoFile << PrettyLine;

jobInfoFile << "number of MPI processes: " << ParallelDescriptor::NProcs() << "\n";
#ifdef AMREX_USE_OMP
jobInfoFile << "number of threads: " << omp_get_max_threads() << "\n";
#endif

jobInfoFile << "\n\n";

// build information
jobInfoFile << PrettyLine;
jobInfoFile << " Build Information\n";
jobInfoFile << PrettyLine;

jobInfoFile << "build date: " << buildInfoGetBuildDate() << "\n";
jobInfoFile << "build machine: " << buildInfoGetBuildMachine() << "\n";
jobInfoFile << "build dir: " << buildInfoGetBuildDir() << "\n";
jobInfoFile << "AMReX dir: " << buildInfoGetAMReXDir() << "\n";

jobInfoFile << "\n";

jobInfoFile << "COMP: " << buildInfoGetComp() << "\n";
jobInfoFile << "COMP version: " << buildInfoGetCompVersion() << "\n";

jobInfoFile << "\n";

jobInfoFile << "C++ compiler: " << buildInfoGetCXXName() << "\n";
jobInfoFile << "C++ flags: " << buildInfoGetCXXFlags() << "\n";

jobInfoFile << "\n";

jobInfoFile << "Fortran comp: " << buildInfoGetFName() << "\n";
jobInfoFile << "Fortran flags: " << buildInfoGetFFlags() << "\n";

jobInfoFile << "\n";

jobInfoFile << "Link flags: " << buildInfoGetLinkFlags() << "\n";
jobInfoFile << "Libraries: " << buildInfoGetLibraries() << "\n";

jobInfoFile << "\n";

const char* githash1 = buildInfoGetGitHash(1);
const char* githash2 = buildInfoGetGitHash(2);
const char* githash3 = buildInfoGetGitHash(3);
if (strlen(githash1) > 0) {
jobInfoFile << "WarpX git describe: " << githash1 << "\n";
}
if (strlen(githash2) > 0) {
jobInfoFile << "AMReX git describe: " << githash2 << "\n";
}
if (strlen(githash3) > 0) {
jobInfoFile << "PICSAR git describe: " << githash3 << "\n";
}

jobInfoFile << "\n\n";

// grid information
jobInfoFile << PrettyLine;
jobInfoFile << " Grid Information\n";
jobInfoFile << PrettyLine;

for (int i = 0; i <= warpx.finestLevel(); i++)
{
jobInfoFile << " level: " << i << "\n";
jobInfoFile << " number of boxes = " << warpx.boxArray(i).size() << "\n";
jobInfoFile << " maximum zones = ";
for (int n = 0; n < AMREX_SPACEDIM; n++)
{
jobInfoFile << warpx.Geom(i).Domain().length(n) << " ";
}
jobInfoFile << "\n\n";
}

jobInfoFile << " Boundary conditions\n";

jobInfoFile << " -x: " << "interior" << "\n";
jobInfoFile << " +x: " << "interior" << "\n";
if (AMREX_SPACEDIM >= 2) {
jobInfoFile << " -y: " << "interior" << "\n";
jobInfoFile << " +y: " << "interior" << "\n";
}
#if defined(WARPX_DIM_3D)
jobInfoFile << " -z: " << "interior" << "\n";
jobInfoFile << " +z: " << "interior" << "\n";
#endif

jobInfoFile << "\n\n";


// runtime parameters
jobInfoFile << PrettyLine;
jobInfoFile << " Inputs File Parameters\n";
jobInfoFile << PrettyLine;

ParmParse::dumpTable(jobInfoFile, true);

jobInfoFile.close();
}
}

void
FlushFormatPlotfile::WriteWarpXHeader(
const std::string& name,
Expand Down
1 change: 1 addition & 0 deletions Source/Diagnostics/FlushFormats/Make.package
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CEXE_sources += FlushFormat.cpp
CEXE_sources += FlushFormatPlotfile.cpp
CEXE_sources += FlushFormatCheckpoint.cpp
CEXE_sources += FlushFormatAscent.cpp
Expand Down
Loading