From 8a9817c5d6e1e7bce8d941cd9d094d28816a502d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 26 Jul 2013 09:01:30 +0200 Subject: [PATCH] bugfixes and cleanup in the timers command --- src/input.cpp | 1 - src/timer.cpp | 28 ++++++++++++++++++++-------- src/timer.h | 3 ++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 8ad312b29e..9d40c0766f 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1527,7 +1527,6 @@ void Input::timestep() void Input::timers() { - if (narg != 1) error->all(FLERR,"Illegal timers command"); timer->modify_params(narg,arg); } diff --git a/src/timer.cpp b/src/timer.cpp index b3ee15b553..d7e09bf860 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -13,6 +13,7 @@ #include "mpi.h" #include "timer.h" +#include "comm.h" #include "error.h" #include "memory.h" @@ -140,23 +141,34 @@ void Timer::set_wall(enum ttype which, double newtime) /* ---------------------------------------------------------------------- modify parameters of the Timer class ------------------------------------------------------------------------- */ +static const char *timer_style[] = { "off", "loop", "normal", "full" }; +static const char *timer_mode[] = { "nosync", "(dummy)", "sync" }; +static const char timer_fmt[] = "New timer settings: style=%s mode=%s\n"; void Timer::modify_params(int narg, char **arg) { int iarg = 0; while (iarg < narg) { - if (strcmp(arg[iarg],"off") == 0) { + if (strcmp(arg[iarg],timer_style[OFF]) == 0) { _level = OFF; - } else if (strcmp(arg[iarg],"normal") == 0) { + } else if (strcmp(arg[iarg],timer_style[LOOP]) == 0) { + _level = LOOP; + } else if (strcmp(arg[iarg],timer_style[NORMAL]) == 0) { _level = NORMAL; - } else if (strcmp(arg[iarg],"full") == 0) { + } else if (strcmp(arg[iarg],timer_style[FULL]) == 0) { _level = FULL; - } else if (strcmp(arg[iarg],"nosync") == 0) { - _sync = OFF; - } else if (strcmp(arg[iarg],"sync") == 0) { - _sync = NORMAL; + } else if (strcmp(arg[iarg],timer_mode[OFF]) == 0) { + _sync = OFF; + } else if (strcmp(arg[iarg],timer_mode[NORMAL]) == 0) { + _sync = NORMAL; } else error->all(FLERR,"Illegal timers command"); - ++iarg; } + + if (comm->me == 0) { + if (screen) + fprintf(screen,timer_fmt,timer_style[_level],timer_mode[_sync]); + if (logfile) + fprintf(logfile,timer_fmt,timer_style[_level],timer_mode[_sync]); + } } diff --git a/src/timer.h b/src/timer.h index 671cc25ef0..cea8a57a0e 100644 --- a/src/timer.h +++ b/src/timer.h @@ -22,7 +22,8 @@ namespace LAMMPS_NS { class Timer : protected Pointers { public: - enum ttype {TOTAL=0,PAIR,BOND,KSPACE,NEIGHBOR,COMM,MODIFY,OUTPUT,NUM_TIMER}; + enum ttype {RESET=-2,STOP=-1,TOTAL=0,PAIR,BOND,KSPACE, + NEIGH,COMM,MODIFY,OUTPUT,NUM_TIMER}; enum tlevel {OFF=0,LOOP,NORMAL,FULL}; Timer(class LAMMPS *);