Skip to content

Commit

Permalink
ABLASTR: Move Used Inputs Helper
Browse files Browse the repository at this point in the history
Move the helper to write a file for used inputs to ABLASTR.
  • Loading branch information
ax3l committed Sep 9, 2022
1 parent beab2f3 commit f3630f4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
11 changes: 2 additions & 9 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Utils/WarpXUtil.H"

#include <ablastr/utils/Communication.H>
#include <ablastr/utils/UsedInputsFile.H>
#include <ablastr/warn_manager/WarnManager.H>

#include <AMReX.H>
Expand Down Expand Up @@ -64,7 +65,6 @@
#include <algorithm>
#include <array>
#include <cctype>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
Expand Down Expand Up @@ -350,14 +350,7 @@ WarpX::PrintMainPICparameters ()
void
WarpX::WriteUsedInputsFile (std::string const & filename) const
{
amrex::Print() << "For full input parameters, see the file: " << filename << "\n\n";

if (ParallelDescriptor::IOProcessor()) {
std::ofstream jobInfoFile;
jobInfoFile.open(filename.c_str(), std::ios::out);
ParmParse::dumpTable(jobInfoFile, true);
jobInfoFile.close();
}
ablastr::utils::write_used_inputs_file(filename);
}

void
Expand Down
1 change: 1 addition & 0 deletions Source/ablastr/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target_sources(ablastr
Communication.cpp
TextMsg.cpp
SignalHandling.cpp
UsedInputsFile.cpp
)

add_subdirectory(msg_logger)
27 changes: 27 additions & 0 deletions Source/ablastr/utils/UsedInputsFile.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2022 Axel Huebl
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/

#ifndef ABLASTR_USED_INPUTS_FILE_H
#define ABLASTR_USED_INPUTS_FILE_H

#include <string>


namespace ablastr::utils
{
/** Write a file that record all inputs: inputs file + command line options
*
* This uses the same syntax as amrex::ParmParse inputs files.
* Only the AMReX IOProcessor writes.
*
* @param filename the name of the text file to write
*/
void
write_used_inputs_file (std::string const & filename);
}

#endif // ABLASTR_USED_INPUTS_FILE_H
30 changes: 30 additions & 0 deletions Source/ablastr/utils/UsedInputsFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2022 Axel Huebl
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/

#include "UsedInputsFile.H"

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

#include <fstream>
#include <ios>
#include <string>


void
ablastr::utils::write_used_inputs_file (std::string const & filename)
{
amrex::Print() << "For full input parameters, see the file: " << filename << "\n\n";

if (amrex::ParallelDescriptor::IOProcessor()) {
std::ofstream jobInfoFile;
jobInfoFile.open(filename.c_str(), std::ios::out);
amrex::ParmParse::dumpTable(jobInfoFile, true);
jobInfoFile.close();
}
}

0 comments on commit f3630f4

Please sign in to comment.