Skip to content

Commit 62a93b1

Browse files
committed
FEAT: make seconds 00 in output file when not needed
1 parent 67e935c commit 62a93b1

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

include/times.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ class Times {
9494
**/
9595
std::string get_YMD_HMS();
9696

97+
/**************************************************************
98+
\brief Returns the current time as a string (year, month...)
99+
100+
Returns the current time as a string of format YYYYMMDD_HHMM00
101+
**/
102+
std::string get_YMD_HM0();
103+
97104
/**************************************************************
98105
\brief Returns the intermediate time in seconds since ref date
99106
**/
@@ -221,6 +228,9 @@ class Times {
221228
/// represented as YYYYMMDD_HHMMSS
222229
std::string sYMD_HMS;
223230

231+
/// represented as YYYYMMDD_HHMM00
232+
std::string sYMD_HM0;
233+
224234
// -------------------------------------------------------------
225235
// Keeping track of walltime for the run:
226236

src/output.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ bool output(const Neutrals &neutrals,
296296
if (type_output == "therm")
297297
filename = "3DTHR_";
298298

299-
filename = filename + time.get_YMD_HMS();
299+
if ((int64_t(input.get_dt_output(iOutput)) % 60) == 0)
300+
filename = filename + time.get_YMD_HM0();
301+
else
302+
filename = filename + time.get_YMD_HMS();
300303

301304
if (nMembers > 1)
302305
filename = filename + "_" + cMember;

src/time.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ std::string Times::get_YMD_HMS() {
143143
return sYMD_HMS;
144144
}
145145

146+
// -----------------------------------------------------------------------------
147+
// Get the current time as a string, with seconds as 00
148+
// -----------------------------------------------------------------------------
149+
150+
std::string Times::get_YMD_HM0() {
151+
return sYMD_HM0;
152+
}
153+
154+
146155
// -----------------------------------------------------------------------------
147156
// Get the intermediate stopping time
148157
// -----------------------------------------------------------------------------
@@ -222,6 +231,9 @@ void Times::increment_time() {
222231
snprintf(tmp, 100, "%04d%02d%02d_%02d%02d%02d",
223232
year, month, day, hour, minute, second);
224233
sYMD_HMS = std::string(tmp);
234+
snprintf(tmp, 100, "%04d%02d%02d_%02d%02d%02d",
235+
year, month, day, hour, minute, 0);
236+
sYMD_HM0 = std::string(tmp);
225237
snprintf(tmp, 100, "%04d%02d%02d", year, month, day);
226238
sYMD = std::string(tmp);
227239
snprintf(tmp, 100, "%02d%02d%02d", hour, minute, second);

0 commit comments

Comments
 (0)