From de403f4cc40a5dffa2af17421adf3d0229de4319 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 9 Sep 2024 16:53:05 +0200 Subject: [PATCH 1/3] correct output times for window in hdf --- libmpdata++/output/hdf5.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libmpdata++/output/hdf5.hpp b/libmpdata++/output/hdf5.hpp index 7e890916..cbf3a81c 100644 --- a/libmpdata++/output/hdf5.hpp +++ b/libmpdata++/output/hdf5.hpp @@ -199,11 +199,17 @@ namespace libmpdataxx // T { const hsize_t - nt_out = nt / this->outfreq + 1; // incl. t=0 + nt_out = (nt / this->outfreq + 1) * this->outwindow // incl. t=0 + - (this->outwindow - (nt % this->outfreq) - 1); // timsteps from outwindow that go beyond nt float dt = this->dt; blitz::Array coord(nt_out); - coord = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * blitz::firstIndex(); + + for(int i=0; ioutwindow) * this->outfreq + (i % this->outwindow); + coord(i) = timestep * (this->var_dt ? this->outfreq : this->outfreq * this->dt); + } auto curr_dim = (*hdfp).createDataSet("T", flttype_output, H5::DataSpace(1, &nt_out)); From ef5f356b6f1b63b04637d4be7d38949027449c73 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 10 Sep 2024 13:52:37 +0200 Subject: [PATCH 2/3] correct T hdf5.hpp for window and outstart --- libmpdata++/output/hdf5.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libmpdata++/output/hdf5.hpp b/libmpdata++/output/hdf5.hpp index 56766fdc..13672a7a 100644 --- a/libmpdata++/output/hdf5.hpp +++ b/libmpdata++/output/hdf5.hpp @@ -199,17 +199,18 @@ namespace libmpdataxx // T { // incl. t=0 and t=outstart - const hsize_t nt_out = ((nt - this->outstart) / this->outfreq + (this->outstart == 0 ? 1 : 2)) * this->outwindow // for outstart>0 we still want to store t=0 - - (this->outwindow - (nt % this->outfreq) - 1); // timsteps from outwindow that go beyond nt + const hsize_t nt_out = ((nt - this->outstart) / this->outfreq + 1) * this->outwindow + + (this->outstart == 0 ? 0 : 1) // for outstart>0 we still want to store t=0 + - std::max(0, this->outwindow - (nt % this->outfreq) - 1); // timsteps from outwindow that go beyond nt float dt = this->dt; blitz::Array coord(nt_out); if(this->outstart == 0) - coord(blitz::Range(0,nt_out-1)) = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * (floor(blitz::firstIndex() / this->outwindow) * this->outfreq + fmod(blitz::firstIndex(), this->outwindow) + this->outstart/this->outfreq); + coord(blitz::Range(0,nt_out-1)) = (this->var_dt ? 1 : this->dt) * (floor(blitz::firstIndex() / this->outwindow) * this->outfreq + fmod(blitz::firstIndex(), this->outwindow)); else { - coord(blitz::Range(1,nt_out-1)) = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * (floor(blitz::firstIndex() / this->outwindow) * this->outfreq + fmod(blitz::firstIndex(), this->outwindow) + this->outstart/this->outfreq); + coord(blitz::Range(1,nt_out-1)) = (this->var_dt ? 1 : this->dt) * (floor(blitz::firstIndex() / this->outwindow) * this->outfreq + fmod(blitz::firstIndex(), this->outwindow) + this->outstart); coord(0)=0; } From 1582f06cb594045078787159e5e8300ab2161664 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 10 Sep 2024 15:09:24 +0200 Subject: [PATCH 3/3] replace % with fmod --- libmpdata++/output/hdf5.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpdata++/output/hdf5.hpp b/libmpdata++/output/hdf5.hpp index 13672a7a..a890b45c 100644 --- a/libmpdata++/output/hdf5.hpp +++ b/libmpdata++/output/hdf5.hpp @@ -201,7 +201,7 @@ namespace libmpdataxx // incl. t=0 and t=outstart const hsize_t nt_out = ((nt - this->outstart) / this->outfreq + 1) * this->outwindow + (this->outstart == 0 ? 0 : 1) // for outstart>0 we still want to store t=0 - - std::max(0, this->outwindow - (nt % this->outfreq) - 1); // timsteps from outwindow that go beyond nt + - std::max(0, this->outwindow - int(std::fmod(nt, this->outfreq)) - 1); // timsteps from outwindow that go beyond nt float dt = this->dt;