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

ABLASTR: Move Used Inputs Helper #3376

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
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
3 changes: 2 additions & 1 deletion Source/ablastr/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
target_sources(ablastr
PRIVATE
Communication.cpp
TextMsg.cpp
SignalHandling.cpp
TextMsg.cpp
UsedInputsFile.cpp
)

add_subdirectory(msg_logger)
5 changes: 3 additions & 2 deletions Source/ablastr/utils/Make.package
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CEXE_sources += TextMsg.cpp
CEXE_sources += SignalHandling.cpp
CEXE_sources += Communication.cpp
CEXE_sources += SignalHandling.cpp
CEXE_sources += TextMsg.cpp
CEXE_sources += UsedInputsFile.cpp

VPATH_LOCATIONS += $(WARPX_HOME)/Source/ablastr/utils

Expand Down
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();
}
}