Timer::_timeout should be double and it should be allowed to have fractions.
This commit is contained in:
@ -28,8 +28,8 @@ Timer::Timer(LAMMPS *_lmp) : Pointers(_lmp)
|
||||
{
|
||||
_level = NORMAL;
|
||||
_sync = OFF;
|
||||
_timeout = -1;
|
||||
_s_timeout = -1;
|
||||
_timeout = -1.0;
|
||||
_s_timeout = -1.0;
|
||||
_checkfreq = 10;
|
||||
_nextcheck = -1;
|
||||
this->_stamp(RESET);
|
||||
@ -251,7 +251,7 @@ void Timer::modify_params(int narg, char **arg)
|
||||
|
||||
// format timeout setting
|
||||
std::string timeout = "off";
|
||||
if (_timeout >= 0) {
|
||||
if (_timeout >= 0.0) {
|
||||
std::tm tv = fmt::gmtime((std::time_t) _timeout);
|
||||
timeout = fmt::format("{:02d}:{:%M:%S}", tv.tm_yday * 24 + tv.tm_hour, tv);
|
||||
}
|
||||
|
||||
12
src/timer.h
12
src/timer.h
@ -110,12 +110,12 @@ class Timer : protected Pointers {
|
||||
double previous_cpu;
|
||||
double previous_wall;
|
||||
double timeout_start;
|
||||
int _level; // level of detail: off=0,loop=1,normal=2,full=3
|
||||
int _sync; // if nonzero, synchronize tasks before setting the timer
|
||||
int _timeout; // max allowed wall time in seconds. infinity if negative
|
||||
int _s_timeout; // copy of timeout for restoring after a forced timeout
|
||||
int _checkfreq; // frequency of timeout checking
|
||||
int _nextcheck; // loop number of next timeout check
|
||||
double _timeout; // max allowed wall time in seconds. infinity if negative
|
||||
double _s_timeout; // copy of timeout for restoring after a forced timeout
|
||||
int _level; // level of detail: off=0,loop=1,normal=2,full=3
|
||||
int _sync; // if nonzero, synchronize tasks before setting the timer
|
||||
int _checkfreq; // frequency of timeout checking
|
||||
int _nextcheck; // loop number of next timeout check
|
||||
|
||||
// update one specific timer array
|
||||
void _stamp(enum ttype);
|
||||
|
||||
@ -1677,7 +1677,7 @@ double utils::timespec2seconds(const std::string ×pec)
|
||||
try {
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (!values.has_next()) break;
|
||||
vals[i] = values.next_int();
|
||||
vals[i] = values.next_double();
|
||||
}
|
||||
} catch (TokenizerException &) {
|
||||
return -1.0;
|
||||
|
||||
@ -1061,6 +1061,16 @@ TEST(Utils, timespec2seconds_hhmmss)
|
||||
ASSERT_DOUBLE_EQ(utils::timespec2seconds("2:10:45"), 7845.0);
|
||||
}
|
||||
|
||||
TEST(Utils, timespec2seconds_ssfraction)
|
||||
{
|
||||
ASSERT_DOUBLE_EQ(utils::timespec2seconds("5.2"), 5.2);
|
||||
}
|
||||
|
||||
TEST(Utils, timespec2seconds_mmfraction)
|
||||
{
|
||||
ASSERT_DOUBLE_EQ(utils::timespec2seconds("2.5:10"), 160.0);
|
||||
}
|
||||
|
||||
TEST(Utils, timespec2seconds_invalid)
|
||||
{
|
||||
ASSERT_DOUBLE_EQ(utils::timespec2seconds("2:aa:45"), -1.0);
|
||||
|
||||
Reference in New Issue
Block a user