Skip to content

Commit b124a56

Browse files
committed
Merge remote-tracking branch 'igfuw/master' into aniso_smg
2 parents 8086f50 + bb68ecf commit b124a56

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

CREDITS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The development team consists of (in alphabetic order):
1010
Sylwester Arabas
1111
(core code, library design, OOP-formulae concepts [4],
1212
concurrency, gnuplot output)
13+
Piotr Dziekan
1314
Dorota Jarecka
1415
(shallow-water systems, OOP-formulae concepts [4])
1516
Anna Jaruga

libmpdata++/output/detail/output_common.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace libmpdataxx
2929

3030
int do_record_cnt = 0;
3131
typename parent_t::real_t record_time;
32-
const typename parent_t::advance_arg_t outfreq;
32+
const typename parent_t::advance_arg_t outfreq, outstart;
3333
const int outwindow;
3434
const std::string outdir;
3535

@@ -158,7 +158,7 @@ namespace libmpdataxx
158158
record_time = this->time;
159159
for (int t = 0; t < outwindow; ++t)
160160
{
161-
if ((this->timestep - t) % static_cast<int>(outfreq) == 0) record_all();
161+
if ((this->timestep - t) % static_cast<int>(outfreq) == 0 && (this->timestep - t) >= static_cast<int>(outstart)) record_all();
162162
}
163163
}
164164
}
@@ -170,7 +170,8 @@ namespace libmpdataxx
170170

171171
struct rt_params_t : parent_t::rt_params_t
172172
{
173-
typename parent_t::advance_arg_t outfreq = 1;
173+
typename parent_t::advance_arg_t outfreq = 1,
174+
outstart = 0; // TODO: make it work for var_dt
174175
int outwindow = 1;
175176
std::map<int, info_t> outvars;
176177
std::string outdir;
@@ -184,11 +185,15 @@ namespace libmpdataxx
184185
) :
185186
parent_t(args, p),
186187
outfreq(p.outfreq),
188+
outstart(p.outstart),
187189
outwindow(p.outwindow),
188190
outvars(p.outvars),
189191
outdir(p.outdir),
190192
intrp_vars(args.mem->tmp[__FILE__][0])
191193
{
194+
assert(int(outstart) % int(outfreq) == 0);
195+
assert(int(outstart)==0 || this->var_dt==0);
196+
192197
// default value for outvars
193198
if (this->outvars.size() == 0 && parent_t::n_eqns == 1)
194199
outvars = {{0, {"", ""}}};

libmpdata++/output/gnuplot.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ namespace libmpdataxx
100100

101101
for (int t = 0; t <= nt; t+=p.outfreq)
102102
{
103+
if(t > 0 && t < p.outstart) continue;
103104
for (const auto &v : this->outvars)
104105
{
105106
*gp << ", '-'";

libmpdata++/output/hdf5.hpp

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)