From bd7936c77ea19d35e9973c5bd5849977457212ae Mon Sep 17 00:00:00 2001
From: Norbert Podhorszki <pnorbert@ornl.gov>
Date: Tue, 30 May 2017 10:51:51 -0400
Subject: [PATCH] Added XML config file to helloBPWriter example

---
 examples/hello/bpWriter/config.xml        | 41 +++++++++++++++++++++++
 examples/hello/bpWriter/helloBPWriter.cpp | 18 ++++++----
 2 files changed, 52 insertions(+), 7 deletions(-)
 create mode 100644 examples/hello/bpWriter/config.xml

diff --git a/examples/hello/bpWriter/config.xml b/examples/hello/bpWriter/config.xml
new file mode 100644
index 000000000..10dfa830e
--- /dev/null
+++ b/examples/hello/bpWriter/config.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<adios-config>
+
+    <io name="Output">
+        <engine name="BPFileWriter">verbose=4;profile_units=mus</engine>
+        <transport name= "File">
+            profile_units=mus; 
+            abort_on_error;
+            have_metadata_file 
+               =
+                 no;
+        </transport>
+
+        <!-- Create a named transform and add variables to it here. 
+             name is optional, required only if it is used outside the definition
+             options is optional to pass parameters to the transformation
+        -->
+        <transform name="LossyCompression" transform="zfp" options="accuracy=0.001">
+            <var name="myMatrix"/>
+            <var name="ThisVarDoesNotExists"/>
+        </transform>
+
+        <!-- Unnamed transformation -->
+        <transform transform="bzip2">
+            <var name="myMatrix2"/>
+        </transform>
+
+        <!-- A variable can have its own private transform definition. 
+             Also its own ordered chain of transformations.
+             Also can refer to a transform defined previously
+        -->
+        <var name="myDoubles"> 
+            <transform transform="identity">verbose=DEBUG</transform>
+            <transform name="LossyCompression"/>
+        </var>
+
+        <buffer max-size-MB="20"/>
+    </io>
+
+</adios-config>
+
diff --git a/examples/hello/bpWriter/helloBPWriter.cpp b/examples/hello/bpWriter/helloBPWriter.cpp
index 0de89cdd9..61dcf2854 100644
--- a/examples/hello/bpWriter/helloBPWriter.cpp
+++ b/examples/hello/bpWriter/helloBPWriter.cpp
@@ -23,7 +23,8 @@ int main(int argc, char *argv[])
     MPI_Comm_size(MPI_COMM_WORLD, &nproc);
 
     const bool adiosDebug = true;
-    adios::ADIOS adios(MPI_COMM_WORLD, adios::Verbose::INFO, adiosDebug);
+    adios::ADIOS adios("config.xml", MPI_COMM_WORLD, adios::Verbose::INFO,
+                       adiosDebug);
 
     // Application variable
     std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
@@ -60,12 +61,15 @@ int main(int argc, char *argv[])
 
         // Define method for engine creation, it is basically straight-forward
         // parameters
-        adios::Method &bpWriterSettings = adios.DeclareMethod(
-            "SingleFile"); // default method type is BPWriter
-        bpWriterSettings.SetParameters("profile_units=mus");
-        bpWriterSettings.AddTransport(
-            "File", "profile_units=mus",
-            "have_metadata_file=no"); // uses default POSIX library
+        adios::Method &bpWriterSettings =
+            adios.DeclareMethod("Output"); // Output is defined in config.xml
+        if (!bpWriterSettings.IsUserDefined())
+        {
+            bpWriterSettings.SetParameters("profile_units=mus");
+            bpWriterSettings.AddTransport(
+                "File", "profile_units=mus",
+                "have_metadata_file=no"); // uses default POSIX library
+        }
 
         // Create engine smart pointer due to polymorphism,
         // Open returns a smart pointer to Engine containing the Derived class
-- 
GitLab