Skip to content
Snippets Groups Projects
Commit 9761e6bd authored by wfg's avatar wfg
Browse files

Merge branch 'master' of https://github.com/ornladios/ADIOS2.git

Conflicts:
	examples/heatTransfer/IO_adios2.cpp
	include/core/VariableBase.h
	include/engine/adios1/ADIOS1Reader.h
	source/CMakeLists.txt
	source/engine/adios1/ADIOS1Reader.cpp
	source/functions/adiosFunctions.cpp
parents b13f812b 6bd06b55
No related branches found
No related tags found
2 merge requests!48Utilities,!45Code structure changes and syntax
Showing
with 665 additions and 24 deletions
......@@ -65,7 +65,7 @@ if(ADIOS_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
endif()
option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" ON)
option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" OFF)
if(ADIOS_USE_MPI)
# Workaround for OpenMPI forcing the link of C++ bindings
add_definitions(-DOMPI_SKIP_MPICXX)
......
......@@ -12,34 +12,38 @@ To setup your local repository for development:
1. Fork the main repository on GitHub:
1. Navigate to https://github.com/ornladios/adios2 in your browser.
1. Click the `[Fork]` button in the upper right-hand side of the page.
2. Clone your fork to your local machine:
2. Clone the upstream repository to your local machine:
```
[chuck@hal9000 Code]$ mkdir adios
[chuck@hal9000 Code]$ cd adios
[chuck@hal9000 adios]$ git clone git@github.com:<your-GitHub-username-here>/adios2.git source
$ mkdir adios
$ cd adios
$ git clone https://github.com/ornladios/adios2.git source
Cloning into 'source'...
remote: Counting objects: 4535, done.
remote: Compressing objects: 100% (223/223), done.
remote: Total 4535 (delta 64), reused 0 (delta 0), pack-reused 4301
Receiving objects: 100% (4535/4535), 1.27 MiB | 0 bytes/s, done.
Resolving deltas: 100% (2607/2607), done.
remote: Counting objects: 4632, done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 4632 (delta 33), reused 0 (delta 0), pack-reused 4549
Receiving objects: 100% (4632/4632), 1.23 MiB | 224.00 KiB/s, done.
Resolving deltas: 100% (2738/2738), done.
Checking connectivity... done.
[chuck.atkins@hal9000 adios]$
$
```
3. Run the `scripts/development/setup.sh` script. The script will configure an `upstream` remote and link your local master branch to the upstream.
```
[chuck.atkins@hal9000 adios]$ cd source/
$ ./scripts/developer/setup.sh
Checking GitHub username...
Using GitHub user <your-GitHub-username-here>
Adding upstream remote...
$ cd source/
$ ./scripts/developer/setup.sh
Enter your GitHub username: chuckatkins
Setup SSH push access? [(y)/n] y
Re-configuring local master branch to use upstream
Fetching origin
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/chuckatkins/adios2
Fetching upstream
From https://github.com/ornladios/adios2
* [new branch] master -> upstream/master
* [new branch] dashboard -> upstream/dashboard
* [new branch] hooks -> upstream/hooks
* [new branch] master -> upstream/master
Re-configuring local master branch to use upstream
Setting up git aliases...
Setting up git hooks...
$
......@@ -109,4 +113,5 @@ That will apply the formatting rules used by the ADIOS project.
1. Lines no longer than 80 characters.
1. Always use braces { and }, even for 1 line if blocks.
1. Use 4 spaces for indentation.
There are more formatting rules but these three should at least get you close and prevent any drastic re-writes from the re-formatting tools. More details can be found by looking at the .clang-format config file n the root of the repository and by looking at the clang-format documentation http://releases.llvm.org/3.8.0/tools/clang/docs/ClangFormatStyleOptions.html. While the formatting rules are a bit more involved, the main points are:
# - Find ADIOS 1.x library, routines for scientific, parallel IO
# https://www.olcf.ornl.gov/center-projects/adios/
#
# Use this module by invoking find_package with the form:
# find_package(ADIOS1
# [version] [EXACT] # Minimum or EXACT version, e.g. 1.6.0
# [REQUIRED] # Fail with an error if ADIOS or a required
# # component is not found
# [QUIET] # ...
# [COMPONENTS <...>] # Compiled in components: fortran, readonly,
# sequential (all are case insentative)
# )
#
# Module that finds the includes and libraries for a working ADIOS 1.x install.
# This module invokes the `adios_config` script that should be installed with
# the other ADIOS tools.
#
# To provide a hint to the module where to find the ADIOS installation,
# set the ADIOS1_ROOT or ADIOS1_DIR environment variable.
#
# If this variable is not set, make sure that at least the according `bin/`
# directory of ADIOS 1.x is in your PATH environment variable.
#
# Set the following CMake variables BEFORE calling find_packages to
# influence this module:
# ADIOS1_USE_STATIC_LIBS - Set to ON to force the use of static
# libraries. Default: OFF
#
# This module will define the following variables:
# ADIOS1_INCLUDE_DIRS - Include directories for the ADIOS 1.x headers.
# ADIOS1_LIBRARY_PATH - Full path of the libadios library (.a or .so file)
# ADIOS1_DEPENDENCY_LIBRARIES - ADIOS 1.x dependency libraries.
# ADIOS1_FOUND - TRUE if FindADIOS1 found a working install
# ADIOS1_VERSION - Version in format Major.Minor.Patch
#
# Not used for now:
# ADIOS1_DEFINITIONS - Compiler definitions you should add with
# add_definitions(${ADIOS1_DEFINITIONS})
#
# Example to find ADIOS 1.x (default)
# find_package(ADIOS1)
# if(ADIOS1_FOUND)
# include_directories(${ADIOS1_INCLUDE_DIRS})
# add_executable(foo foo.c)
# target_link_libraries(foo ${ADIOS1_LIBRARY_PATH} ADIOS1_DEPENDENCY_LIBRARIES)
# endif()
# Example to find ADIOS 1.x using component
# find_package(ADIOS1 COMPONENTS fortran)
# if(ADIOS1_FOUND)
# include_directories(${ADIOS1_INCLUDE_DIRS})
# add_executable(foo foo.c)
# target_link_libraries(foo ${ADIOS1_LIBRARY_PATH} ${ADIOS1_DEPENDENCY_LIBRARIES})
# endif()
###############################################################################
#Copyright (c) 2014, Axel Huebl and Felix Schmitt from http://picongpu.hzdr.de
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
#1. Redistributions of source code must retain the above copyright notice, this
#list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright notice,
#this list of conditions and the following disclaimer in the documentation
#and/or other materials provided with the distribution.
#3. Neither the name of the copyright holder nor the names of its contributors
#may be used to endorse or promote products derived from this software without
#specific prior written permission.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
###############################################################################
# Required cmake version
###############################################################################
cmake_minimum_required(VERSION 2.8.5)
###############################################################################
# ADIOS
###############################################################################
# get flags for adios_config, -l is the default
#-f for fortran, -r for readonly, -s for sequential (nompi)
set(OPTLIST "-l")
if(ADIOS1_FIND_COMPONENTS)
foreach(COMP ${ADIOS1_FIND_COMPONENTS})
string(TOLOWER ${COMP} comp)
if(comp STREQUAL "fortran")
set(OPTLIST "${OPTLIST}f")
elseif(comp STREQUAL "readonly")
set(OPTLIST "${OPTLIST}r")
elseif(comp STREQUAL "sequential")
set(OPTLIST "${OPTLIST}s")
else()
message("ADIOS 1.x component ${COMP} is not supported. Please use fortran, readonly, or sequential")
endif()
endforeach()
endif()
# we start by assuming we found ADIOS and falsify it if some
# dependencies are missing (or if we did not find ADIOS at all)
set(ADIOS1_FOUND TRUE)
# find `adios_config` program #################################################
# check the ADIOS1_ROOT and ADIOS1_DIR hint and the normal PATH
find_file(ADIOS1_CONFIG
NAME adios_config
PATHS $ENV{ADIOS1_ROOT}/bin $ENV{ADIOS1_DIR}/bin $ENV{INSTALL_PREFIX}/bin $ENV{PATH})
if(ADIOS1_CONFIG)
message(STATUS "Found 'adios_config': ${ADIOS1_CONFIG}")
else(ADIOS1_CONFIG)
set(ADIOS1_FOUND FALSE)
message(STATUS "Can NOT find 'adios_config' - set ADIOS1_ROOT, ADIOS1_DIR or INSTALL_PREFIX, or check your PATH")
endif(ADIOS1_CONFIG)
# check `adios_config` program ################################################
if(ADIOS1_FOUND)
execute_process(COMMAND ${ADIOS1_CONFIG} ${OPTLIST}
OUTPUT_VARIABLE ADIOS1_LINKFLAGS
RESULT_VARIABLE ADIOS1_CONFIG_RETURN
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ADIOS1_CONFIG_RETURN EQUAL 0)
set(ADIOS1_FOUND FALSE)
message(STATUS "Can NOT execute 'adios_config' - check file permissions")
endif()
# find ADIOS1_ROOT_DIR
execute_process(COMMAND ${ADIOS1_CONFIG} -d
OUTPUT_VARIABLE ADIOS1_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT IS_DIRECTORY "${ADIOS1_ROOT_DIR}")
set(ADIOS1_FOUND FALSE)
message(STATUS "The directory provided by 'adios_config -d' does not exist: ${ADIOS1_ROOT_DIR}")
endif()
endif(ADIOS1_FOUND)
# option: use only static libs ################################################
if(ADIOS1_USE_STATIC_LIBS)
# carfully: we have to restore the original path in the end
set(_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
# we found something in ADIOS1_ROOT_DIR and adios_config works #################
if(ADIOS1_FOUND)
# ADIOS headers
list(APPEND ADIOS1_INCLUDE_DIRS ${ADIOS1_ROOT_DIR}/include)
# check for compiled in dependencies, recomve ";" in ADIOS1_LINKFLAGS (from cmake build)
string(REGEX REPLACE ";" " " ADIOS1_LINKFLAGS "${ADIOS1_LINKFLAGS}")
message(STATUS " ADIOS1 linker flags (unparsed): ${ADIOS1_LINKFLAGS}")
# find all library paths -L
# note: this can cause trouble if some libs are specified twice from
# different sources (quite unlikely)
# http://www.cmake.org/pipermail/cmake/2008-November/025128.html
set(ADIOS1_LIBRARY_DIRS "")
string(REGEX MATCHALL " -L([A-Za-z_0-9/\\.-]+)" _ADIOS1_LIBDIRS " ${ADIOS1_LINKFLAGS}")
foreach(_LIBDIR ${_ADIOS1_LIBDIRS})
string(REPLACE " -L" "" _LIBDIR ${_LIBDIR})
list(APPEND ADIOS1_LIBRARY_DIRS ${_LIBDIR})
endforeach()
# we could append ${CMAKE_PREFIX_PATH} now but that is not really necessary
#message(STATUS "ADIOS1 DIRS to look for libs: ${ADIOS1_LIBRARY_DIRS}")
# parse all -lname libraries and find an absolute path for them
string(REGEX MATCHALL " -l([A-Za-z_0-9\\.-]+)" _ADIOS1_LIBS " ${ADIOS1_LINKFLAGS}")
foreach(_LIB ${_ADIOS1_LIBS})
string(REPLACE " -l" "" _LIB ${_LIB})
# find static lib: absolute path in -L then default
find_library(_LIB_DIR NAMES ${_LIB} PATHS ${ADIOS1_LIBRARY_DIRS} CMAKE_FIND_ROOT_PATH_BOTH)
# found?
if(_LIB_DIR)
if(_LIB STREQUAL "adios")
message(STATUS " Found the main adios library in ${_LIB_DIR}")
set(ADIOS1_LIBRARY_PATH "${_LIB_DIR}")
#message(STATUS " ADIOS1_LIBRARY_PATH set to ${ADIOS1_LIBRARY_PATH}")
else()
message(STATUS " Found ${_LIB} in ${_LIB_DIR}")
list(APPEND ADIOS1_DEPENDENCY_LIBRARIES "${_LIB_DIR}")
endif()
else(_LIB_DIR)
set(ADIOS1_FOUND FALSE)
message(STATUS "ADIOS1: Could NOT find library '${_LIB}'")
endif(_LIB_DIR)
# clean cached var
unset(_LIB_DIR CACHE)
unset(_LIB_DIR)
endforeach()
#add libraries which are already using cmake format
string(REGEX MATCHALL "/([A-Za-z_0-9/\\.-]+)\\.([a|so]+)" _ADIOS1_LIBS_SUB "${ADIOS1_LINKFLAGS}")
list(APPEND ADIOS1_DEPENDENCY_LIBRARIES "${_ADIOS1_LIBS_SUB}")
# add the version string
execute_process(COMMAND ${ADIOS1_CONFIG} -v
OUTPUT_VARIABLE ADIOS1_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(ADIOS1_FOUND)
# unset checked variables if not found
if(NOT ADIOS1_FOUND)
unset(ADIOS1_INCLUDE_DIRS)
unset(ADIOS1_DEPENDENCY_LIBRARIES)
unset(ADIOS1_LIBRARY_PATH)
endif(NOT ADIOS1_FOUND)
# restore CMAKE_FIND_LIBRARY_SUFFIXES if manipulated by this module ###########
if(ADIOS1_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
###############################################################################
# FindPackage Options
###############################################################################
# handles the REQUIRED, QUIET and version-related arguments for find_package
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ADIOS1
REQUIRED_VARS ADIOS1_LIBRARY_PATH ADIOS1_DEPENDENCY_LIBRARIES ADIOS1_INCLUDE_DIRS
VERSION_VAR ADIOS1_VERSION
)
##########################################################################
# Add target and dependencies to ADIOS2
##########################################################################
#message(STATUS "ADIOS1 Find ended with ${ADIOS1_FOUND}")
if(ADIOS1_FOUND AND NOT TARGET adios1::adios)
message(STATUS "Add library ADIOS1 to the build")
add_library(adios1::adios UNKNOWN IMPORTED)
set_target_properties(adios1::adios PROPERTIES
IMPORTED_LOCATION "${ADIOS1_LIBRARY_PATH}"
INTERFACE_LINK_LIBRARIES "${ADIOS1_DEPENDENCY_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${ADIOS1_INCLUDE_DIRS}"
)
endif()
......@@ -4,3 +4,4 @@
#------------------------------------------------------------------------------#
add_subdirectory(hello)
add_subdirectory(heatTransfer)
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
add_subdirectory(write)
add_subdirectory(read)
......@@ -60,6 +60,8 @@ IO::IO(const Settings &s, MPI_Comm comm)
bpWriter = ad->Open(m_outputfilename, "w", comm, bpWriterSettings);
// ad->Open(m_outputfilename, "w", comm, bpWriterSettings);
if (bpWriter == nullptr)
throw std::ios_base::failure("ERROR: failed to open ADIOS bpWriter\n");
}
......
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_USE_ADIOS1)
find_package(ADIOS1 REQUIRED)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(headTransfer_read_adios1 heatRead_adios1.cpp PrintData.cpp)
target_include_directories(headTransfer_read_adios1
PRIVATE ${MPI_C_INCLUDE_PATH}
)
target_link_libraries(headTransfer_read_adios1
adios1::adios ${MPI_C_LIBRARIES}
)
if(ADIOS_BUILD_TESTING)
add_test(
NAME Example::heatTransfer::read::adios1
COMMAND heatRead_adios1
)
endif()
endif()
endif()
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* PrintData.cpp
*
* Created on: Apr 2017
* Author: Norbert Podhorszki
*/
#include "PrintData.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
void printData(double *xy, uint64_t *size, uint64_t *offset, int rank,
int steps)
{
std::ofstream myfile;
std::string filename = "data." + std::to_string(rank);
myfile.open(filename);
double *data = xy;
uint64_t nelems = size[0] * size[1];
for (int step = 0; step < steps; step++)
{
myfile << "rank=" << rank << " size=" << size[0] << "x" << size[1]
<< " offsets=" << offset[0] << ":" << offset[1]
<< " step=" << step << std::endl;
myfile << " time row columns " << offset[1] << "..."
<< offset[1] + size[1] - 1 << std::endl;
myfile << " ";
for (int j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << offset[1] + j;
}
myfile << std::endl;
myfile << "------------------------------------------------------------"
"--\n";
for (int i = 0; i < size[0]; i++)
{
myfile << std::setw(5) << step << std::setw(5) << offset[0] + i;
for (int j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << std::setprecision(2)
<< data[i * size[1] + j];
}
myfile << std::endl;
}
data += nelems;
}
myfile.close();
}
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* PrintData.h
*
* Created on: Apr 2017
* Author: Norbert Podhorszki
*/
#ifndef PRINTDATA_H_
#define PRINTDATA_H_
#include <cstdint>
void printData(double *xy, uint64_t *size, uint64_t *offset, int rank,
int steps);
#endif /* PRINTDATA_H_ */
#include <mpi.h>
#include "adios_read.h"
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <memory>
#include <stdexcept>
#include <string>
#include "PrintData.h"
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
if (argc < 2)
{
std::cout << "Not enough arguments: need an input file\n";
return 1;
}
const char *inputfile = argv[1];
/* World comm spans all applications started with the same aprun command
on a Cray XK6. So we have to split and create the local
'world' communicator for the reader only.
In normal start-up, the communicator will just equal the MPI_COMM_WORLD.
*/
int wrank, wnproc;
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
MPI_Comm_size(MPI_COMM_WORLD, &wnproc);
MPI_Barrier(MPI_COMM_WORLD);
const unsigned int color = 2;
MPI_Comm mpiReaderComm;
MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &mpiReaderComm);
int rank, nproc;
MPI_Comm_rank(mpiReaderComm, &rank);
MPI_Comm_size(mpiReaderComm, &nproc);
adios_read_init_method(ADIOS_READ_METHOD_BP, mpiReaderComm, "verbose=3");
ADIOS_FILE *f;
f = adios_read_open_file(inputfile, ADIOS_READ_METHOD_BP, mpiReaderComm);
if (f == NULL)
{
std::cout << adios_errmsg() << std::endl;
return -1;
}
ADIOS_VARINFO *vgndx = adios_inq_var(f, "gndx");
ADIOS_VARINFO *vgndy = adios_inq_var(f, "gndy");
unsigned int gndx = *(unsigned int *)vgndx->value;
unsigned int gndy = *(unsigned int *)vgndy->value;
if (rank == 0)
{
std::cout << "gndx = " << gndx << std::endl;
std::cout << "gndy = " << gndy << std::endl;
}
adios_free_varinfo(vgndx);
adios_free_varinfo(vgndy);
// 1D decomposition of the columns, which is inefficient for reading!
uint64_t readsize[2] = {gndx, gndy / nproc};
uint64_t offset[2] = {0LL, rank * readsize[1]};
if (rank == nproc - 1)
{
// last process should read all the rest of columns
readsize[1] = gndy - readsize[1] * (nproc - 1);
}
std::cout << "rank " << rank << " reads " << readsize[1]
<< " columns from offset " << offset[1] << std::endl;
ADIOS_VARINFO *vT = adios_inq_var(f, "T");
double *T = new double[vT->nsteps * readsize[0] * readsize[1]];
// Create a 2D selection for the subset
ADIOS_SELECTION *sel = adios_selection_boundingbox(2, offset, readsize);
// Arrays are read by scheduling one or more of them
// and performing the reads at once
adios_schedule_read(f, sel, "T", 0, vT->nsteps, T);
adios_perform_reads(f, 1);
printData(T, readsize, offset, rank, vT->nsteps);
adios_read_close(f);
adios_free_varinfo(vT);
delete[] T;
// Terminate
adios_selection_delete(sel);
adios_read_finalize_method(ADIOS_READ_METHOD_BP);
MPI_Finalize();
return 0;
}
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(heatTransfer_write_adios2
main.cpp
HeatTransfer.cpp
Settings.cpp
IO_adios2.cpp
)
target_include_directories(heatTransfer_write_adios2
PRIVATE ${MPI_C_INCLUDE_PATH}
)
target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES})
if(ADIOS_BUILD_TESTING)
add_test(
NAME Example::heatTransfer::write::adios2
COMMAND heatTransfer_write_adios2
)
endif()
if(ADIOS_USE_ADIOS1)
find_package(ADIOS1 REQUIRED)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(heatTransfer_write_adios1
main.cpp
HeatTransfer.cpp
Settings.cpp
IO_adios1.cpp
)
target_include_directories(heatTransfer_write_adios1
PRIVATE ${MPI_C_INCLUDE_PATH}
)
target_link_libraries(heatTransfer_write_adios1
adios1::adios ${MPI_C_LIBRARIES}
)
if(ADIOS_BUILD_TESTING)
add_test(
NAME Example::heatTransfer::write::adios1
COMMAND heatTransfer_write_adios1
)
endif()
endif()
endif()
......@@ -10,7 +10,6 @@
* Author: Norbert Podhorszki
*
*/
#include <mpi.h>
#include <iomanip>
#include <iostream>
......
......@@ -12,6 +12,7 @@
#define HEATTRANSFER_H_
#include <mpi.h>
#include <vector>
#include "Settings.h"
......
......@@ -13,11 +13,11 @@
#include "HeatTransfer.h"
#include "Settings.h"
#include <mpi.h>
class IO
{
public:
IO(const Settings &s, MPI_Comm comm);
~IO();
......
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* IO_ADIOS2.cpp
*
* Created on: Feb 2017
* Author: Norbert Podhorszki
*/
#include "IO.h"
#include "ADIOS_CPP.h"
#include <string>
static int rank_saved;
adios::ADIOS *ad = nullptr;
std::shared_ptr<adios::Engine> bpWriter;
adios::Variable<double> *varT = nullptr;
IO::IO(const Settings &s, MPI_Comm comm)
{
rank_saved = s.rank;
m_outputfilename = s.outputfile + ".bp";
ad = new adios::ADIOS("adios2.xml", comm, adios::Verbose::INFO);
// Define method for engine creation
// 1. Get method def from config file or define new one
adios::Method &bpWriterSettings = ad->DeclareMethod("output");
if (!bpWriterSettings.isUserDefined())
{
// if not defined by user, we can change the default settings
bpWriterSettings.SetEngine("BPFileWriter"); // BP is the default engine
bpWriterSettings.AllowThreads(
1); // allow 1 extra thread for data processing
bpWriterSettings.AddTransport(
"File", "lucky=yes"); // ISO-POSIX file is the default transport
// Passing parameters to the transport
bpWriterSettings.SetParameters(
"have_metadata_file",
"yes"); // Passing parameters to the engine
bpWriterSettings.SetParameters(
"Aggregation",
std::to_string((s.nproc + 1) / 2)); // number of aggregators
}
// define T as 2D global array
varT = &ad->DefineVariable<double>(
"T",
// Global dimensions
{s.gndx, s.gndy},
// local size, could be defined later using SetSelection()
{s.ndx, s.ndy},
// offset of the local array in the global space
{s.offsx, s.offsy});
// add transform to variable
// adios::Transform tr = adios::transform::BZIP2( );
// varT.AddTransform( tr, "" );
// varT.AddTransform( tr,"accuracy=0.001" ); // for ZFP
bpWriter = ad->Open(m_outputfilename, "w", comm, bpWriterSettings,
adios::IOMode::COLLECTIVE);
if (bpWriter == nullptr)
throw std::ios_base::failure("ERROR: failed to open ADIOS bpWriter\n");
}
IO::~IO()
{
bpWriter->Close();
delete ad;
}
void IO::write(int step, const HeatTransfer &ht, const Settings &s,
MPI_Comm comm)
{
#if 1
/* This selection is redundant and not required, since we defined
* the selection already in DefineVariable(). It is here just as an example.
*/
// Make a selection to describe the local dimensions of the variable we
// write and its offsets in the global spaces. This could have been done in
// adios.DefineVariable()
adios::SelectionBoundingBox sel({s.offsx, s.offsy}, {s.ndx, s.ndy});
varT->SetSelection(sel);
/* Select the area that we want to write from the data pointer we pass to
the
writer.
Think HDF5 memspace, just not hyperslabs, only a bounding box selection.
Engine will copy this bounding box from the data pointer into the output
buffer.
Size of the bounding box should match the "space" selection which was
given
above.
Default memspace is always the full selection.
*/
adios::SelectionBoundingBox memspace =
adios::SelectionBoundingBox({s.ndx, s.ndy}, {1, 1});
varT->SetMemorySelection(memspace);
bpWriter->Write<double>(*varT, ht.data());
bpWriter->Advance();
#else
bpWriter->Write<double>(*varT, ht.data_noghost().data());
bpWriter->Advance();
#endif
}
......@@ -11,6 +11,8 @@
#include <cstdlib>
#include <errno.h>
#include <stdexcept>
#include "Settings.h"
static unsigned int convertToUint(std::string varName, char *arg)
......@@ -80,5 +82,3 @@ Settings::Settings(int argc, char *argv[], int rank, int nproc) : rank{rank}
else
rank_down = rank + npx;
}
Settings::~Settings() {}
......@@ -11,7 +11,7 @@
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <memory>
#include <string>
class Settings
{
......@@ -48,7 +48,6 @@ public:
int rank_down;
Settings(int argc, char *argv[], int rank, int nproc);
~Settings();
};
#endif /* SETTINGS_H_ */
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