Skip to content

Commit

Permalink
Merge branch 'master' into mamico-postrefactor-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amartyads committed Oct 29, 2024
2 parents 125c3b6 + be0b01b commit ce1066d
Show file tree
Hide file tree
Showing 110 changed files with 1,482 additions and 1,069 deletions.
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ Please describe the tests that you ran to verify your changes.

- [ ] Test A
- [ ] Test B

## Documentation
(Only relevant if this PR introduces new features)
- [ ] `all-options.xml` documents how to use the feature.
- [ ] The responsible `readXML()` documents how to use the feature.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ MarDyn [options] <inputfile>
```
where `MarDyn` is the executable build in the INSTALLATION section, `[options]` are any "--"-prefixed options as listed by `MarDyn --help` and `<inputfile>` is a input file.

Detailed help can be obtained by running
To get an overview of further command line options run
```sh
MarDyn --help
```

To understand how to write an input file check out [examples/all-options.xml](https://github.com/ls1mardyn/ls1-mardyn/blob/master/examples/all-options.xml), the various examples in the examples folder and the documentation of the various `readXML()` methods, e.g. via our doxygen documentation.

### running examples
ls1-MarDyn comes with a set of examples, which can be found in the examples folder.
```sh
Expand Down
15 changes: 10 additions & 5 deletions src/Domain.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <cstdint>

Expand Down Expand Up @@ -93,7 +94,9 @@ void Domain::readXML(XMLfileUnits& xmlconfig) {
<< _globalLength[2] << std::endl;
}
else {
Log::global_log->error() << "Unsupported volume type " << type << std::endl;
std::ostringstream error_message;
error_message << "Unsupported volume type " << type << std::endl;
MARDYN_EXIT(error_message.str());
}
xmlconfig.changecurrentnode("..");
}
Expand Down Expand Up @@ -552,8 +555,9 @@ void Domain::writeCheckpointHeader(std::string filename,
mixingss << "\t";
}
} else {
Log::global_log->error() << "Only LB mixing rule supported" << std::endl;
mardyn_exit(123);
std::ostringstream error_message;
error_message << "Only LB mixing rule supported" << std::endl;
MARDYN_EXIT(error_message.str());
}
}
}
Expand Down Expand Up @@ -710,8 +714,9 @@ void Domain::enableComponentwiseThermostat()

void Domain::setComponentThermostat(int cid, int thermostat) {
if ((0 > cid) || (0 >= thermostat)) {
Log::global_log->error() << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl;
mardyn_exit(787);
std::ostringstream error_message;
error_message << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl;
MARDYN_EXIT(error_message.str());
}
this->_componentToThermostatIdMap[cid] = thermostat;
this->_universalThermostatN[thermostat] = 0;
Expand Down
78 changes: 44 additions & 34 deletions src/MarDyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iostream>
#include <string>
#include <vector>
#include <memory>

#include "WrapOpenMP.h"

Expand Down Expand Up @@ -58,42 +59,42 @@ void initOptions(optparse::OptionParser *op) {
/**
* @brief Helper function outputting program build information to given logger
*/
void program_build_info(Log::Logger *log) {
log->info() << "Compilation info:" << std::endl;
void log_program_build_info() {
Log::global_log->info() << "Compilation info:" << std::endl;

char info_str[MAX_INFO_STRING_LENGTH];
get_compiler_info(info_str);
log->info() << " Compiler: " << info_str << std::endl;
Log::global_log->info() << " Compiler: " << info_str << std::endl;
get_compile_time(info_str);
log->info() << " Compiled on: " << info_str << std::endl;
Log::global_log->info() << " Compiled on: " << info_str << std::endl;
get_precision_info(info_str);
log->info() << " Precision: " << info_str << std::endl;
Log::global_log->info() << " Precision: " << info_str << std::endl;
get_intrinsics_info(info_str);
log->info() << " Intrinsics: " << info_str << std::endl;
Log::global_log->info() << " Intrinsics: " << info_str << std::endl;
get_rmm_normal_info(info_str);
log->info() << " RMM/normal: " << info_str << std::endl;
Log::global_log->info() << " RMM/normal: " << info_str << std::endl;
get_openmp_info(info_str);
log->info() << " OpenMP: " << info_str << std::endl;
Log::global_log->info() << " OpenMP: " << info_str << std::endl;
get_mpi_info(info_str);
log->info() << " MPI: " << info_str << std::endl;
Log::global_log->info() << " MPI: " << info_str << std::endl;
}

/**
* @brief Helper function outputting program invocation information to given logger
*/
void program_execution_info(int argc, char **argv, Log::Logger *log) {
log->info() << "Execution info:" << std::endl;
void log_program_execution_info(int argc, char **argv) {
Log::global_log->info() << "Execution info:" << std::endl;

char info_str[MAX_INFO_STRING_LENGTH];
get_timestamp(info_str);
log->info() << " Started: " << info_str << std::endl;
Log::global_log->info() << " Started: " << info_str << std::endl;
get_host(info_str);
log->info() << " Execution host: " << info_str << std::endl;
Log::global_log->info() << " Execution host: " << info_str << std::endl;
std::stringstream arguments;
for (int i = 0; i < argc; i++) {
arguments << " " << argv[i];
}
log->info() << " Started with arguments: " << arguments.str() << std::endl;
Log::global_log->info() << " Started with arguments: " << arguments.str() << std::endl;

#if defined(_OPENMP)
int num_threads = mardyn_get_max_threads();
Expand Down Expand Up @@ -135,18 +136,31 @@ int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
#endif

/* Initialize the global log file */
Log::global_log = new Log::Logger(Log::Info);
#ifdef ENABLE_MPI
Log::global_log->set_mpi_output_root(0);
//global_log->set_mpi_output_all();
#endif
// Open scope to exclude MPI_Init() and MPI_Finalize().
// This way, all simulation objects are cleaned up before MPI finalizes.
{

optparse::OptionParser op;
initOptions(&op);
optparse::Values options = op.parse_args(argc, argv);
std::vector<std::string> args = op.args();

/* Initialize the global log file */
if( options.is_set_by_user("logfile") ) {
// Print to file
std::string logfileNamePrefix(options.get("logfile"));
std::cout << "Using logfile with prefix " << logfileNamePrefix << std::endl;
Log::global_log = std::make_unique<Log::Logger>(Log::Info, logfileNamePrefix);
} else {
// Print to stream (default: std::cout)
Log::global_log = std::make_unique<Log::Logger>(Log::Info);
}

#ifdef ENABLE_MPI
Log::global_log->set_mpi_output_root(0);
//global_log->set_mpi_output_all();
#endif

Log::global_log->info() << "Running ls1-MarDyn version " << MARDYN_VERSION << std::endl;

#ifdef MARDYN_AUTOPAS
Expand All @@ -157,12 +171,6 @@ int main(int argc, char** argv) {
Log::global_log->warning() << "This ls1-MarDyn binary is a DEBUG build!" << std::endl;
#endif

if( options.is_set_by_user("logfile") ) {
std::string logfileNamePrefix(options.get("logfile"));
Log::global_log->info() << "Using logfile with prefix " << logfileNamePrefix << std::endl;
delete Log::global_log;
Log::global_log = new Log::Logger(Log::Info, logfileNamePrefix);
}
if( options.is_set_by_user("verbose") ) {
Log::global_log->info() << "Enabling verbose log output." << std::endl;
Log::global_log->set_log_level(Log::All);
Expand All @@ -173,8 +181,8 @@ int main(int argc, char** argv) {
registerSigsegvHandler(); // from SigsegvHandler.h
}
#endif
program_build_info(Log::global_log);
program_execution_info(argc, argv, Log::global_log);
log_program_build_info();
log_program_execution_info(argc, argv);


/* Run built in tests and exit */
Expand All @@ -183,7 +191,7 @@ int main(int argc, char** argv) {
#ifdef ENABLE_MPI
MPI_Finalize();
#endif
exit(testresult); // using exit here should be OK
std::exit(testresult); // using exit here should be OK
}


Expand All @@ -192,18 +200,20 @@ int main(int argc, char** argv) {

auto numArgs = args.size();
if(numArgs != 1) {
Log::global_log->error() << "Incorrect number of arguments provided." << std::endl;
op.print_usage();
mardyn_exit(-1);
std::ostringstream error_message;
error_message << "Incorrect number of arguments provided." << std::endl;
MARDYN_EXIT(error_message.str());
}
/* First read the given config file if it exists, then overwrite parameters with command line arguments. */
std::string configFileName(args[0]);
if( fileExists(configFileName.c_str()) ) {
Log::global_log->info() << "Config file: " << configFileName << std::endl;
simulation.readConfigFile(configFileName);
} else {
Log::global_log->error() << "Cannot open config file '" << configFileName << "'" << std::endl;
mardyn_exit(-2);
std::ostringstream error_message;
error_message << "Cannot open config file '" << configFileName << "'" << std::endl;
MARDYN_EXIT(error_message.str());
}

/* processing command line arguments */
Expand Down Expand Up @@ -281,7 +291,7 @@ int main(int argc, char** argv) {

simulation.finalize();

delete Log::global_log;
} // End of scope to exclude MPI_Init() and MPI_Finalize()

#ifdef ENABLE_MPI
MPI_Finalize();
Expand Down
Loading

0 comments on commit ce1066d

Please sign in to comment.