Encapsulate gmx_wallclock_accounting_t into new timing module
[alexxy/gromacs.git] / src / gromacs / legacyheaders / sim_util.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  *
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  *
30  * For more info, check our website at http://www.gromacs.org
31  *
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _sim_util_h
37 #define _sim_util_h
38
39 #include "typedefs.h"
40 #include "enxio.h"
41 #include "mdebin.h"
42 #include "update.h"
43 #include "vcm.h"
44 #include "gromacs/timing/walltime_accounting.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 typedef struct {
51     t_fileio   *fp_trn;
52     t_fileio   *fp_xtc;
53     int         xtc_prec;
54     ener_file_t fp_ene;
55     const char *fn_cpt;
56     gmx_bool    bKeepAndNumCPT;
57     int         eIntegrator;
58     gmx_bool    bExpanded;
59     int         elamstats;
60     int         simulation_part;
61     FILE       *fp_dhdl;
62     FILE       *fp_field;
63 } gmx_mdoutf_t;
64
65 typedef struct gmx_global_stat *gmx_global_stat_t;
66
67 void do_pbc_first(FILE *log, matrix box, t_forcerec *fr,
68                   t_graph *graph, rvec x[]);
69
70 void do_pbc_first_mtop(FILE *fplog, int ePBC, matrix box,
71                        gmx_mtop_t *mtop, rvec x[]);
72
73 void do_pbc_mtop(FILE *fplog, int ePBC, matrix box,
74                  gmx_mtop_t *mtop, rvec x[]);
75
76
77
78 /* ROUTINES from stat.c */
79 gmx_global_stat_t global_stat_init(t_inputrec *ir);
80
81 void global_stat_destroy(gmx_global_stat_t gs);
82
83 void global_stat(FILE *log, gmx_global_stat_t gs,
84                  t_commrec *cr, gmx_enerdata_t *enerd,
85                  tensor fvir, tensor svir, rvec mu_tot,
86                  t_inputrec *inputrec,
87                  gmx_ekindata_t *ekind,
88                  gmx_constr_t constr, t_vcm *vcm,
89                  int nsig, real *sig,
90                  gmx_mtop_t *top_global, t_state *state_local,
91                  gmx_bool bSumEkinhOld, int flags);
92 /* Communicate statistics over cr->mpi_comm_mysim */
93
94 gmx_mdoutf_t *init_mdoutf(int nfile, const t_filenm fnm[],
95                           int mdrun_flags,
96                           const t_commrec *cr, const t_inputrec *ir,
97                           const output_env_t oenv);
98 /* Returns a pointer to a data structure with all output file pointers
99  * and names required by mdrun.
100  */
101
102 void done_mdoutf(gmx_mdoutf_t *of);
103 /* Close all open output files and free the of pointer */
104
105 #define MDOF_X   (1<<0)
106 #define MDOF_V   (1<<1)
107 #define MDOF_F   (1<<2)
108 #define MDOF_XTC (1<<3)
109 #define MDOF_CPT (1<<4)
110
111 void write_traj(FILE *fplog, t_commrec *cr,
112                 gmx_mdoutf_t *of,
113                 int mdof_flags,
114                 gmx_mtop_t *top_global,
115                 gmx_large_int_t step, double t,
116                 t_state *state_local, t_state *state_global,
117                 rvec *f_local, rvec *f_global,
118                 int *n_xtc, rvec **x_xtc);
119 /* Routine that writes frames to trn, xtc and/or checkpoint.
120  * What is written is determined by the mdof_flags defined above.
121  * Data is collected to the master node only when necessary.
122  */
123
124 int do_per_step(gmx_large_int_t step, gmx_large_int_t nstep);
125 /* Return TRUE if io should be done */
126
127 /* ROUTINES from sim_util.c */
128
129 void print_time(FILE *out, gmx_walltime_accounting_t walltime_accounting,
130                 gmx_large_int_t step, t_inputrec *ir, t_commrec *cr);
131
132 void print_date_and_time(FILE *log, int pid, const char *title,
133                          const gmx_walltime_accounting_t walltime_accounting);
134
135 void finish_run(FILE *log, t_commrec *cr,
136                 t_inputrec *inputrec,
137                 t_nrnb nrnb[], gmx_wallcycle_t wcycle,
138                 gmx_walltime_accounting_t walltime_accounting,
139                 wallclock_gpu_t *gputimes,
140                 gmx_bool bWriteStat);
141
142 void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr);
143
144 void calc_dispcorr(FILE *fplog, t_inputrec *ir, t_forcerec *fr,
145                    gmx_large_int_t step, int natoms,
146                    matrix box, real lambda, tensor pres, tensor virial,
147                    real *prescorr, real *enercorr, real *dvdlcorr);
148
149 void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, real *lambda, double *lam0);
150
151 void do_constrain_first(FILE *log, gmx_constr_t constr,
152                         t_inputrec *inputrec, t_mdatoms *md,
153                         t_state *state, t_commrec *cr, t_nrnb *nrnb,
154                         t_forcerec *fr, gmx_localtop_t *top);
155
156 void init_md(FILE *fplog,
157              t_commrec *cr, t_inputrec *ir, const output_env_t oenv,
158              double *t, double *t0,
159              real *lambda, int *fep_state, double *lam0,
160              t_nrnb *nrnb, gmx_mtop_t *mtop,
161              gmx_update_t *upd,
162              int nfile, const t_filenm fnm[],
163              gmx_mdoutf_t **outf, t_mdebin **mdebin,
164              tensor force_vir, tensor shake_vir,
165              rvec mu_tot,
166              gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags);
167 /* Routine in sim_util.c */
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif  /* _sim_util_h */