Skip to content

Commit

Permalink
Merge pull request #339 from germasch/pr/outp
Browse files Browse the repository at this point in the history
OutputParticles work
  • Loading branch information
germasch authored Aug 30, 2024
2 parents 3c1210c + 51224ff commit 62b350c
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 389 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,4 @@ spack-build-out.txt
spack-configure-args.txt
.vscode/
**/psc*params.txt
.venv/
2 changes: 1 addition & 1 deletion src/include/binary_collision.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct RngC
{
real_t ran;
do {
ran = real_t(random()) / RAND_MAX;
ran = real_t(random()) / real_t(RAND_MAX);
} while (ran == real_t(0.f));

return ran;
Expand Down
4 changes: 2 additions & 2 deletions src/include/ddc_particles.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ inline ddc_particles<MP>::ddc_particles(const Grid_t& grid)
n_recv_ranks = 0;
for (int r = 0; r < size; r++) {
if (info[r].n_recv_entries) {
MPI_Irecv(info[r].recv_entry.data(),
MPI_Irecv((int*)info[r].recv_entry.data(),
sizeof(drecv_entry) / sizeof(int) * info[r].n_recv_entries,
MPI_INT, r, 111, comm, &recv_reqs_[n_recv_ranks++]);
}
Expand All @@ -255,7 +255,7 @@ inline ddc_particles<MP>::ddc_particles(const Grid_t& grid)
n_send_ranks = 0;
for (int r = 0; r < size; r++) {
if (info[r].n_send_entries) {
MPI_Isend(info[r].send_entry.data(),
MPI_Isend((int*)info[r].send_entry.data(),
sizeof(dsend_entry) / sizeof(int) * info[r].n_send_entries,
MPI_INT, r, 111, comm, &send_reqs_[n_send_ranks++]);
}
Expand Down
15 changes: 9 additions & 6 deletions src/include/writer_adios2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public:
int step = grid.timestep();
double time = grid.timestep() * grid.dt;

char filename[dir_.size() + pfx_.size() + 20];
sprintf(filename, "%s/%s.%09d.bp", dir_.c_str(), pfx_.c_str(), step);
int len = dir_.size() + pfx_.size() + 20;
char filename[len];
snprintf(filename, len, "%s/%s.%09d.bp", dir_.c_str(), pfx_.c_str(), step);
file_ = io_.open(filename, kg::io::Mode::Write, comm_, pfx_);
file_.beginStep(kg::io::StepMode::Append);
file_.put("step", step);
Expand Down Expand Up @@ -157,9 +158,9 @@ public:
Double3 length = grid.domain.length;
Double3 corner = grid.domain.corner;

auto write_func = [this, step, time, h_expr = move(h_expr), name,
auto write_func = [this, step, time, h_expr = std::move(h_expr), name,
comp_names, ldims, gdims, length, corner,
patch_off = move(patch_off)]() {
patch_off = std::move(patch_off)]() {
// std::this_thread::sleep_for(std::chrono::milliseconds(1000));

prof_start(pr_thread);
Expand All @@ -170,8 +171,10 @@ public:
Int3 ib = {-(im[0] - ldims[0]) / 2, -(im[1] - ldims[1]) / 2,
-(im[2] - ldims[2]) / 2};

char filename[dir_.size() + pfx_.size() + 20];
sprintf(filename, "%s/%s.%09d.bp", dir_.c_str(), pfx_.c_str(), step);
int len = dir_.size() + pfx_.size() + 20;
char filename[len];
snprintf(filename, len, "%s/%s.%09d.bp", dir_.c_str(), pfx_.c_str(),
step);
{
auto launch = kg::io::Mode::Blocking;

Expand Down
2 changes: 1 addition & 1 deletion src/libpsc/psc_balance/psc_balance_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ inline void write_loads(const input& input,
int timestep)
{
char s[20];
sprintf(s, "loads2-%06d.asc", timestep);
snprintf(s, 20, "loads2-%06d.asc", timestep);
FILE* f = fopen(s, "w");

int gp = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ struct OutputParticlesAscii

int rank;
MPI_Comm_rank(comm_, &rank);
char filename[strlen(data_dir) + strlen(basename) + 21];
sprintf(filename, "%s/%s.%06d_p%06d.asc", data_dir, basename,
grid.timestep(), rank);
int slen = strlen(data_dir) + strlen(basename) + 21;
char filename[slen];
snprintf(filename, slen, "%s/%s.%06d_p%06d.asc", data_dir, basename,
grid.timestep(), rank);

FILE* file = fopen(filename, "w");
auto accessor = mprts.accessor();
Expand Down
Loading

0 comments on commit 62b350c

Please sign in to comment.