From d262dffd72d22a5f48e193c5a9a7be5a77a1a948 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 12 Apr 2024 15:31:18 +0200 Subject: [PATCH] fix T in const.h5 for outstart==0 --- libmpdata++/output/hdf5.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libmpdata++/output/hdf5.hpp b/libmpdata++/output/hdf5.hpp index 099b7469..45b4db5c 100644 --- a/libmpdata++/output/hdf5.hpp +++ b/libmpdata++/output/hdf5.hpp @@ -198,13 +198,21 @@ namespace libmpdataxx // T { - const hsize_t - nt_out = (nt - this->outstart) / this->outfreq + 2; // incl. t=0 and t=outstart + // incl. t=0 and t=outstart + const hsize_t nt_out = this->outstart == 0 ? + (nt - this->outstart) / this->outfreq + 1 : + (nt - this->outstart) / this->outfreq + 2; // for outstart>0 we still want to store t=0 + float dt = this->dt; blitz::Array coord(nt_out); - coord(blitz::Range(1,nt_out-1)) = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * (blitz::firstIndex() + this->outstart/this->outfreq); - coord(0)=0; + if(this->outstart == 0) + coord(blitz::Range(0,nt_out-1)) = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * (blitz::firstIndex() + this->outstart/this->outfreq); + else + { + coord(blitz::Range(1,nt_out-1)) = (this->var_dt ? this->outfreq : this->outfreq * this->dt) * (blitz::firstIndex() + this->outstart/this->outfreq); + coord(0)=0; + } auto curr_dim = (*hdfp).createDataSet("T", flttype_output, H5::DataSpace(1, &nt_out));