@@ -198,12 +198,21 @@ namespace libmpdataxx
198198
199199 // T
200200 {
201- const hsize_t
202- nt_out = nt / this ->outfreq + 1 ; // incl. t=0
201+ // incl. t=0 and t=outstart
202+ const hsize_t nt_out = ((nt - this ->outstart ) / this ->outfreq + 1 ) * this ->outwindow
203+ + (this ->outstart == 0 ? 0 : 1 ) // for outstart>0 we still want to store t=0
204+ - std::max (0 , this ->outwindow - int (std::fmod (nt, this ->outfreq )) - 1 ); // timsteps from outwindow that go beyond nt
205+
203206 float dt = this ->dt ;
204207
205208 blitz::Array<typename solver_t ::real_t , 1 > coord (nt_out);
206- coord = (this ->var_dt ? this ->outfreq : this ->outfreq * this ->dt ) * blitz::firstIndex ();
209+ if (this ->outstart == 0 )
210+ 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 ));
211+ else
212+ {
213+ 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 );
214+ coord (0 )=0 ;
215+ }
207216
208217 auto curr_dim = (*hdfp).createDataSet (" T" , flttype_output, H5::DataSpace (1 , &nt_out));
209218
@@ -365,6 +374,22 @@ namespace libmpdataxx
365374 aux.write (data, flttype_solver, H5::DataSpace (parent_t ::n_dims, shape.data ()), space, dxpl_id);
366375 }
367376
377+ // for 1-D arrays
378+ void record_aux_hlpr (const std::string &name, typename solver_t ::real_t *data, hsize_t size, H5::H5File hdf)
379+ {
380+ assert (this ->rank == 0 );
381+
382+ auto aux = hdf.createDataSet (
383+ name,
384+ flttype_output,
385+ H5::DataSpace (1 , &size)
386+ );
387+
388+ auto space = aux.getSpace ();
389+ space.selectHyperslab (H5S_SELECT_SET, &size, &zero);
390+ aux.write (data, flttype_solver, H5::DataSpace (1 , &size), space, dxpl_id);
391+ }
392+
368393 // for discontiguous array with halos
369394 void record_aux_dsc_hlpr (const std::string &name, const typename solver_t ::arr_t &arr, H5::H5File hdf, bool srfc = false )
370395 {
@@ -516,10 +541,24 @@ namespace libmpdataxx
516541 // has to be called after const file was created (i.e. after start())
517542 void record_aux_const (const std::string &name, typename solver_t ::real_t *data)
518543 {
519- H5::H5File hdfcp (const_file, H5F_ACC_RDWR); // reopen the const file
544+ H5::H5File hdfcp (const_file, H5F_ACC_RDWR
545+ #if defined(USE_MPI)
546+ , H5P_DEFAULT, fapl_id
547+ #endif
548+ ); // reopen the const file
520549 record_aux_hlpr (name, data, hdfcp);
521550 }
522551
552+ void record_aux_const (const std::string &name, typename solver_t ::real_t *data, const int &size)
553+ {
554+ H5::H5File hdfcp (const_file, H5F_ACC_RDWR
555+ #if defined(USE_MPI)
556+ , H5P_DEFAULT, fapl_id
557+ #endif
558+ ); // reopen the const file
559+ record_aux_hlpr (name, data, size, hdfcp);
560+ }
561+
523562 void record_aux_const (const std::string &name, const std::string &group_name, typename solver_t ::real_t data)
524563 {
525564 H5::H5File hdfcp (const_file, H5F_ACC_RDWR
0 commit comments