Fix malformed CUDA version macro check
[alexxy/gromacs.git] / include / sim_util.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
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.
16  *
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.
21  *
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.
26  *
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.
34  *
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.
37  */
38
39 #ifndef _sim_util_h
40 #define _sim_util_h
41
42 #include <time.h>
43 #include "visibility.h"
44 #include "typedefs.h"
45 #include "enxio.h"
46 #include "mdebin.h"
47 #include "update.h"
48 #include "vcm.h"
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 typedef struct {
55     t_fileio   *fp_trn;
56     t_fileio   *fp_xtc;
57     int         xtc_prec;
58     ener_file_t fp_ene;
59     const char *fn_cpt;
60     gmx_bool    bKeepAndNumCPT;
61     int         eIntegrator;
62     gmx_bool    bExpanded;
63     int         elamstats;
64     int         simulation_part;
65     FILE       *fp_dhdl;
66     FILE       *fp_field;
67 } gmx_mdoutf_t;
68
69 typedef struct gmx_global_stat *gmx_global_stat_t;
70
71 typedef struct {
72     double          real;
73 #ifdef GMX_CRAY_XT3
74     double          proc;
75 #else
76     clock_t         proc;
77 #endif
78     double          realtime;
79     double          proctime;
80     double          time_per_step;
81     double          last;
82     gmx_large_int_t nsteps_done;
83 } gmx_runtime_t;
84
85
86 GMX_LIBMD_EXPORT
87 void do_pbc_first(FILE *log, matrix box, t_forcerec *fr,
88                   t_graph *graph, rvec x[]);
89
90 GMX_LIBMD_EXPORT
91 void do_pbc_first_mtop(FILE *fplog, int ePBC, matrix box,
92                        gmx_mtop_t *mtop, rvec x[]);
93
94 GMX_LIBMD_EXPORT
95 void do_pbc_mtop(FILE *fplog, int ePBC, matrix box,
96                  gmx_mtop_t *mtop, rvec x[]);
97
98
99
100 /* ROUTINES from stat.c */
101 GMX_LIBMD_EXPORT
102 gmx_global_stat_t global_stat_init(t_inputrec *ir);
103
104 void global_stat_destroy(gmx_global_stat_t gs);
105
106 void global_stat(FILE *log, gmx_global_stat_t gs,
107                  t_commrec *cr, gmx_enerdata_t *enerd,
108                  tensor fvir, tensor svir, rvec mu_tot,
109                  t_inputrec *inputrec,
110                  gmx_ekindata_t *ekind,
111                  gmx_constr_t constr, t_vcm *vcm,
112                  int nsig, real *sig,
113                  gmx_mtop_t *top_global, t_state *state_local,
114                  gmx_bool bSumEkinhOld, int flags);
115 /* Communicate statistics over cr->mpi_comm_mysim */
116
117 gmx_mdoutf_t *init_mdoutf(int nfile, const t_filenm fnm[],
118                           int mdrun_flags,
119                           const t_commrec *cr, const t_inputrec *ir,
120                           const output_env_t oenv);
121 /* Returns a pointer to a data structure with all output file pointers
122  * and names required by mdrun.
123  */
124
125 GMX_LIBMD_EXPORT
126 void done_mdoutf(gmx_mdoutf_t *of);
127 /* Close all open output files and free the of pointer */
128
129 #define MDOF_X   (1<<0)
130 #define MDOF_V   (1<<1)
131 #define MDOF_F   (1<<2)
132 #define MDOF_XTC (1<<3)
133 #define MDOF_CPT (1<<4)
134
135 GMX_LIBMD_EXPORT
136 void write_traj(FILE *fplog, t_commrec *cr,
137                 gmx_mdoutf_t *of,
138                 int mdof_flags,
139                 gmx_mtop_t *top_global,
140                 gmx_large_int_t step, double t,
141                 t_state *state_local, t_state *state_global,
142                 rvec *f_local, rvec *f_global,
143                 int *n_xtc, rvec **x_xtc);
144 /* Routine that writes frames to trn, xtc and/or checkpoint.
145  * What is written is determined by the mdof_flags defined above.
146  * Data is collected to the master node only when necessary.
147  */
148
149 GMX_LIBMD_EXPORT
150 int do_per_step(gmx_large_int_t step, gmx_large_int_t nstep);
151 /* Return TRUE if io should be done */
152
153 /* ROUTINES from sim_util.c */
154
155 GMX_LIBMD_EXPORT
156 double gmx_gettime();
157
158 GMX_LIBMD_EXPORT
159 void print_time(FILE *out, gmx_runtime_t *runtime,
160                 gmx_large_int_t step, t_inputrec *ir, t_commrec *cr);
161
162 GMX_LIBMD_EXPORT
163 void runtime_start(gmx_runtime_t *runtime);
164
165 GMX_LIBMD_EXPORT
166 void runtime_end(gmx_runtime_t *runtime);
167
168 GMX_LIBMD_EXPORT
169 void runtime_upd_proc(gmx_runtime_t *runtime);
170 /* The processor time should be updated every once in a while,
171  * since on 32-bit manchines it loops after 72 minutes.
172  */
173
174 GMX_LIBMD_EXPORT
175 void print_date_and_time(FILE *log, int pid, const char *title,
176                          const gmx_runtime_t *runtime);
177
178 GMX_LIBMD_EXPORT
179 void print_start(FILE *fplog, t_commrec *cr, gmx_runtime_t *runtime,
180                  const char *name);
181
182 GMX_LIBMD_EXPORT
183 void finish_run(FILE *log, t_commrec *cr, const char *confout,
184                 t_inputrec *inputrec,
185                 t_nrnb nrnb[], gmx_wallcycle_t wcycle,
186                 gmx_runtime_t *runtime,
187                 wallclock_gpu_t *gputimes,
188                 int omp_nth_pp,
189                 gmx_bool bWriteStat);
190
191 void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr);
192
193 void calc_dispcorr(FILE *fplog, t_inputrec *ir, t_forcerec *fr,
194                    gmx_large_int_t step, int natoms,
195                    matrix box, real lambda, tensor pres, tensor virial,
196                    real *prescorr, real *enercorr, real *dvdlcorr);
197
198 void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, real *lambda, double *lam0);
199
200 GMX_LIBMD_EXPORT
201 void do_constrain_first(FILE *log, gmx_constr_t constr,
202                         t_inputrec *inputrec, t_mdatoms *md,
203                         t_state *state, rvec *f,
204                         t_graph *graph, t_commrec *cr, t_nrnb *nrnb,
205                         t_forcerec *fr, gmx_localtop_t *top, tensor shake_vir);
206
207 GMX_LIBMD_EXPORT
208 void init_md(FILE *fplog,
209              t_commrec *cr, t_inputrec *ir, const output_env_t oenv,
210              double *t, double *t0,
211              real *lambda, int *fep_state, double *lam0,
212              t_nrnb *nrnb, gmx_mtop_t *mtop,
213              gmx_update_t *upd,
214              int nfile, const t_filenm fnm[],
215              gmx_mdoutf_t **outf, t_mdebin **mdebin,
216              tensor force_vir, tensor shake_vir,
217              rvec mu_tot,
218              gmx_bool *bSimAnn, t_vcm **vcm,
219              t_state *state, unsigned long Flags);
220 /* Routine in sim_util.c */
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif  /* _sim_util_h */