Skip to content

Commit

Permalink
Add "also_previous"-parameter to gridtools frontend for Serializer::r…
Browse files Browse the repository at this point in the history
…ead (#150)
  • Loading branch information
lukasm91 authored and havogt committed Apr 25, 2018
1 parent 3a8dba3 commit 0c90e8d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/serialbox/core/frontend/gridtools/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,13 @@ class serializer {
/// \see
/// SerializerImpl::read
template <class StorageType>
void read(const std::string& name, const savepoint& sp, StorageType& storage) {
void read(const std::string& name, const savepoint& sp, StorageType& storage,
const bool also_previous = false) {
StorageView storageView(
internal::get_origin_ptr(storage, 0), ToTypeID<typename StorageType::data_t>::value,
std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));

serializerImpl_->read(name, *sp.impl(), storageView);
serializerImpl_->read(name, *sp.impl(), storageView, also_previous);
}

/// \brief Deserialize sliced field `name` (given as `storageView` and `slice`) at `savepoint`
Expand All @@ -358,12 +359,13 @@ class serializer {
/// serializer::read
///
template <class StorageType>
void read_slice(const std::string& name, const savepoint& sp, StorageType& storage, Slice slice) {
void read_slice(const std::string& name, const savepoint& sp, StorageType& storage, Slice slice,
const bool also_previous = false) {
StorageView storageView(
internal::get_origin_ptr(storage, 0), ToTypeID<typename StorageType::data_t>::value,
std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
storageView.setSlice(slice);
serializerImpl_->read(name, *sp.impl(), storageView);
serializerImpl_->read(name, *sp.impl(), storageView, also_previous);
}

/// \brief Deserialize field `name` given as `origin_ptr` and `strides` at `savepoint` to disk
Expand All @@ -379,10 +381,10 @@ class serializer {
/// SerializerImpl::write
template <class T>
void read(const std::string& name, const savepoint& sp, T* origin_ptr,
const std::vector<int>& strides) {
const std::vector<int>& strides, const bool also_previous = false) {
const auto& dims = get_field_meta_info(name).dims();
StorageView storageView(origin_ptr, ToTypeID<T>::value, dims, strides);
serializerImpl_->read(name, *sp.impl(), storageView);
serializerImpl_->read(name, *sp.impl(), storageView, also_previous);
}

/// \brief Directly read a gridools field, given by `storage`, from `file`
Expand Down

0 comments on commit 0c90e8d

Please sign in to comment.