Skip to content
Snippets Groups Projects
Commit f6477a1a authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Pass a default config file for the experimental XML example

parent 30e6fdc2
No related branches found
No related tags found
2 merge requests!189Memory,!167Point examples to a default XML config
......@@ -9,3 +9,6 @@ else()
endif()
target_link_libraries(helloBPWriterXML adios2)
target_compile_definitions(helloBPWriterXML PRIVATE
-DDEFAULT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/helloBPWriter.xml
)
......@@ -17,6 +17,14 @@
#include <adios2.h>
#define str_helper(X) #X
#define str(X) str_helper(X)
#ifndef DEFAULT_CONFIG
#define DEFAULT_CONFIG helloBPWriter.xml
#endif
#define DEFAULT_CONFIG_STR str(DEFAULT_CONFIG)
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
......@@ -24,6 +32,29 @@ int main(int argc, char *argv[])
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
std::string configFile;
if (argc == 1)
{
configFile = DEFAULT_CONFIG_STR;
}
else if (argc == 2)
{
configFile = argv[1];
}
else
{
if (rank == 0)
{
std::cerr << "Usage: " << argv[0] << " [/path/to/config.xml]"
<< std::endl;
}
return 1;
}
if (rank == 0)
{
std::cout << "Using config file: " << configFile << std::endl;
}
/** Application variable */
std::vector<float> myFloats = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const std::size_t Nx = myFloats.size();
......@@ -31,8 +62,7 @@ int main(int argc, char *argv[])
try
{
/** ADIOS class factory of IO class objects, DebugON is recommended */
adios2::ADIOS adios("helloBPWriter.xml", MPI_COMM_WORLD,
adios2::DebugON);
adios2::ADIOS adios(configFile, MPI_COMM_WORLD, adios2::DebugON);
/*** IO class object: settings and factory of Settings: Variables,
* Parameters, Transports, and Execution: Engines */
......
......@@ -15,8 +15,33 @@
#include <adios2.h>
#define str_helper(X) #X
#define str(X) str_helper(X)
#ifndef DEFAULT_CONFIG
#define DEFAULT_CONFIG helloBPWriter.xml
#endif
#define DEFAULT_CONFIG_STR str(DEFAULT_CONFIG)
int main(int argc, char *argv[])
{
std::string configFile;
if (argc == 1)
{
configFile = DEFAULT_CONFIG_STR;
}
else if (argc == 2)
{
configFile = argv[1];
}
else
{
std::cerr << "Usage: " << argv[0] << " [/path/to/config.xml]"
<< std::endl;
return 1;
}
std::cout << "Using config file: " << configFile << std::endl;
/** Application variable */
std::vector<float> myFloats = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const std::size_t Nx = myFloats.size();
......@@ -24,7 +49,7 @@ int main(int argc, char *argv[])
try
{
/** ADIOS class factory of IO class objects, DebugON is recommended */
adios2::ADIOS adios("helloBPWriter.xml", adios2::DebugON);
adios2::ADIOS adios(configFile, adios2::DebugON);
/*** IO class object: settings and factory of Settings: Variables,
* Parameters, Transports, and Execution: Engines */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment