diff --git a/libmpdata++/output/detail/output_common.hpp b/libmpdata++/output/detail/output_common.hpp index b3258c18..1a7d968d 100644 --- a/libmpdata++/output/detail/output_common.hpp +++ b/libmpdata++/output/detail/output_common.hpp @@ -158,7 +158,7 @@ namespace libmpdataxx record_time = this->time; for (int t = 0; t < outwindow; ++t) { - if ((this->timestep - t) % static_cast(outfreq) == 0 && this->timestep >= static_cast(outstart)) record_all(); + if ((this->timestep - t) % static_cast(outfreq) == 0 && (this->timestep - t) >= static_cast(outstart)) record_all(); } } } diff --git a/libmpdata++/output/hdf5.hpp b/libmpdata++/output/hdf5.hpp index a9e07ae2..a890b45c 100644 --- a/libmpdata++/output/hdf5.hpp +++ b/libmpdata++/output/hdf5.hpp @@ -199,18 +199,18 @@ namespace libmpdataxx // T { // 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 + 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 - int(std::fmod(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) * (blitz::firstIndex() + 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) * (blitz::firstIndex() + 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; }