From b50f048604de63a91dede66c89dae06332dfbd89 Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Wed, 15 Nov 2017 10:42:37 +0100
Subject: [PATCH] bugfix: use proper syntax to call operator=

code runs without segfaults. I still need to test the correctness.
---
 bfps/cpp/field.cpp            | 4 +++-
 bfps/cpp/full_code/resize.cpp | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bfps/cpp/field.cpp b/bfps/cpp/field.cpp
index ba0656f8..b18706da 100644
--- a/bfps/cpp/field.cpp
+++ b/bfps/cpp/field.cpp
@@ -1385,13 +1385,15 @@ field<rnumber, be, fc> &field<rnumber, be, fc>::operator=(
             this->get_ny() == src.get_ny() &&
             this->get_nz() == src.get_nz())
         {
+            DEBUG_MSG("in operator=, doing simple copy\n");
             std::copy(src.data,
-                      src.data + 2*this->clayout->local_size,
+                      src.data + this->rmemlayout->local_size,
                       this->data);
         }
         // complicated resize
         else
         {
+            DEBUG_MSG("in operator=, doing complicated resize\n");
             int64_t slice_size = src.clayout->local_size / src.clayout->subsizes[0];
             // clean up
             std::fill_n(this->data,
diff --git a/bfps/cpp/full_code/resize.cpp b/bfps/cpp/full_code/resize.cpp
index 87a45c03..41d68ef7 100644
--- a/bfps/cpp/full_code/resize.cpp
+++ b/bfps/cpp/full_code/resize.cpp
@@ -52,7 +52,7 @@ int resize<rnumber>::work_on_current_iteration(void)
     std::string fname = (
             this->new_simname +
             std::string("_fields.h5"));
-    this->new_field = this->vorticity;
+    *this->new_field = *this->vorticity;
     this->new_field->io(
             fname,
             "vorticity",
-- 
GitLab