2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
7 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
8 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9 * and including many others, as listed in the AUTHORS file in the
10 * top-level source directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
40 #include "printtime.h"
44 #include "gromacs/mdtypes/commrec.h"
45 #include "gromacs/mdtypes/inputrec.h"
46 #include "gromacs/timing/walltime_accounting.h"
47 #include "gromacs/utility/cstringutil.h"
48 #include "gromacs/utility/strconvert.h"
49 #include "gromacs/utility/sysinfo.h"
51 void print_time(FILE* out
,
52 gmx_walltime_accounting_t walltime_accounting
,
58 double dt
, elapsed_seconds
, time_per_step
;
67 fputs(gmx::int64ToString(step
).c_str(), out
);
70 if ((step
>= ir
->nstlist
))
72 double seconds_since_epoch
= gmx_gettime();
74 seconds_since_epoch
- walltime_accounting_get_start_time_stamp(walltime_accounting
);
75 time_per_step
= elapsed_seconds
/ (step
- ir
->init_step
+ 1);
76 dt
= (ir
->nsteps
+ ir
->init_step
- step
) * time_per_step
;
82 finish
= static_cast<time_t>(seconds_since_epoch
+ dt
);
83 auto timebuf
= gmx_ctime_r(&finish
);
84 timebuf
.erase(timebuf
.find_first_of('\n'));
85 fputs(", will finish ", out
);
86 fputs(timebuf
.c_str(), out
);
90 fprintf(out
, ", remaining wall clock time: %5d s ", static_cast<int>(dt
));
95 fprintf(out
, " performance: %.1f ns/day ", ir
->delta_t
/ 1000 * 24 * 60 * 60 / time_per_step
);
104 GMX_UNUSED_VALUE(cr
);
110 void print_date_and_time(FILE* fplog
, int nodeid
, const char* title
, double the_time
)
117 time_t temp_time
= static_cast<time_t>(the_time
);
119 auto timebuf
= gmx_ctime_r(&temp_time
);
121 fprintf(fplog
, "%s on rank %d %s\n", title
, nodeid
, timebuf
.c_str());
124 void print_start(FILE* fplog
, const t_commrec
* cr
, gmx_walltime_accounting_t walltime_accounting
, const char* name
)
128 sprintf(buf
, "Started %s", name
);
129 print_date_and_time(fplog
, cr
->nodeid
, buf
,
130 walltime_accounting_get_start_time_stamp(walltime_accounting
));