From c0d757413560c1d08868903da2ceb502184b74f3 Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de> Date: Tue, 11 Sep 2018 14:00:59 +0200 Subject: [PATCH] fix filtered output --- bfps/cpp/field.cpp | 55 ++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/bfps/cpp/field.cpp b/bfps/cpp/field.cpp index ea0bd7a4..e64a1b95 100644 --- a/bfps/cpp/field.cpp +++ b/bfps/cpp/field.cpp @@ -669,8 +669,8 @@ int field<rnumber, be, fc>::write_filtered( // these are dimensions of dataset, needed // to create dataset //dims[0] = nz; - dims[0] = nz; - dims[1] = ny; + dims[0] = ny; + dims[1] = nz; dims[2] = nx/2+1; /* open/create data set */ @@ -730,35 +730,50 @@ int field<rnumber, be, fc>::write_filtered( /// ny / 2 < this->starts[0] +this->clayout->subsizes[0] < this->sizes[0] - ny/2 /// this->starts[0] >= this->sizes[0] - ny/2 /// we don't care about saving the ny/2 mode, because of symmetry - offset[0] = this->clayout->starts[0]; + hsize_t y0 = this->clayout->starts[0]; + hsize_t y1 = this->clayout->starts[0] + this->clayout->subsizes[0]; memshape[0] = this->clayout->subsizes[0]; - if (this->clayout->starts[0] <= ny/2) + if (y1 <= ny/2) { - if (this->clayout->starts[0] + this->clayout->subsizes[0] <= ny/2) - count[0] = this->clayout->subsizes[0]; - else - count[0] = (ny/2 - (this->clayout->starts[0] + this->clayout->subsizes[0])); - memoffset[0] = 0; - } - else if (ny/2 < this->clayout->starts[0] && - this->clayout->starts[0]+this->clayout->subsizes[0] < this->clayout->sizes[0] - ny/2) - { - count[0] = 0; + count[0] = this->clayout->subsizes[0]; + offset[0] = y0; memoffset[0] = 0; } else { - if (this->clayout->starts[0] < this->clayout->sizes[0] - ny/2) + if (y0 < ny/2) { - count[0] = this->clayout->sizes[0] - ny/2 - this->clayout->starts[0]; - memoffset[0] = this->clayout->sizes[0] - ny/2 - this->clayout->starts[0]; + count[0] = ny/2 - y0; + offset[0] = y0; + memoffset[0] = 0; } else { - memoffset[0] = 0; - count[0] = this->clayout->subsizes[0]; + if (y1 <= this->clayout->sizes[0] - ny/2 + 1) + { // y0 < y1 therefore y0 <= this->clayout->sizes[0] - ny/2 + count[0] = 0; + offset[0] = ny/2; + memoffset[0] = 0; + } + else + { + if (y0 <= this->clayout->sizes[0] - ny/2) + { + count[0] = y1 - (this->clayout->sizes[0] - ny/2); + offset[0] = ny/2; + memoffset[0] = this->clayout->subsizes[0] - count[0]; + } + else + { + count[0] = this->clayout->subsizes[0]; + offset[0] = y0; + memoffset[0] = 0; + } + } } } + DEBUG_MSG("count[0] = %ld, offset[0] = %ld\n", + count[0], offset[0]); /// for z, we need to take into account that there are /// both positive and negative modes for (int cz = 0; cz < 2; cz++) @@ -767,6 +782,8 @@ int field<rnumber, be, fc>::write_filtered( offset[1] = cz*nz/2; memshape [1] = this->clayout->sizes[1]; memoffset[1] = cz*(this->clayout->sizes[1] - nz/2); + DEBUG_MSG("cz = %d, count[1] + offset[1] = %ld\n", + cz, count[1] + offset[1]); //now write data mspace = H5Screate_simple(ndim(fc), memshape, NULL); -- GitLab