From 762daa33061a50709b2cc5ceed0da1d7629d8b6c Mon Sep 17 00:00:00 2001 From: James McClung Date: Mon, 31 Mar 2025 16:13:03 -0400 Subject: [PATCH 1/2] output_particles_hdf5_impl: add 3 more digits and a warning --- .../output_particles_hdf5_impl.hxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx index 54825b6fa..86073f9e6 100644 --- a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx +++ b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx @@ -150,9 +150,20 @@ public: abort(); #endif - int slen = strlen(params_.data_dir) + strlen(params_.basename) + 20; + // FIXME there must be a safer way to do this. + + // Currently, if timestep has too many digits, the filename string gets + // truncated to e.g. prt.1234567890_p000000.h (with .h instead of .h5) + + // This is probably a problem with other outputs, too + int slen = strlen(params_.data_dir) + strlen(params_.basename) + 23; char filename[slen]; - snprintf(filename, slen, "%s/%s.%06d_p%06d.h5", params_.data_dir, + if (timestep > 999999999) { + LOG_WARN("%s step index exceeds digit limit in file name. Data still " + "written, but file name is truncated.\n", + params_.basename); + } + snprintf(filename, slen, "%s/%s.%09d_p%06d.h5", params_.data_dir, params_.basename, timestep, 0); hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); From 86a50731be6f27497794d8ef1af0bacce5bb4032 Mon Sep 17 00:00:00 2001 From: James McClung Date: Tue, 1 Apr 2025 12:28:53 -0400 Subject: [PATCH 2/2] output_particles_hdf5_impl: drop the _p000000 Since we're breaking the API anyways... --- .../psc_output_particles/output_particles_hdf5_impl.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx index 86073f9e6..710e2210a 100644 --- a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx +++ b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx @@ -153,18 +153,18 @@ public: // FIXME there must be a safer way to do this. // Currently, if timestep has too many digits, the filename string gets - // truncated to e.g. prt.1234567890_p000000.h (with .h instead of .h5) + // truncated to e.g. prt.1234567890.h (with .h instead of .h5) // This is probably a problem with other outputs, too - int slen = strlen(params_.data_dir) + strlen(params_.basename) + 23; + int slen = strlen(params_.data_dir) + strlen(params_.basename) + 15; char filename[slen]; if (timestep > 999999999) { LOG_WARN("%s step index exceeds digit limit in file name. Data still " "written, but file name is truncated.\n", params_.basename); } - snprintf(filename, slen, "%s/%s.%09d_p%06d.h5", params_.data_dir, - params_.basename, timestep, 0); + snprintf(filename, slen, "%s/%s.%09d.h5", params_.data_dir, + params_.basename, timestep); hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); H5_CHK(file);