changed reading hint
[gromacs/adressmacs.git] / src / kernel / mdrun.c
blobdfee1f3a0d35de99382ea5f4567683811fb6f066
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_mdrun_c = "$Id$";
31 #include "typedefs.h"
32 #include "macros.h"
33 #include "copyrite.h"
34 #include "main.h"
35 #include "statutil.h"
36 #include "futil.h"
37 #include "edsam.h"
38 #include "mdrun.h"
39 /* afm stuf */
40 #include "pull.h"
42 int main(int argc,char *argv[])
44 static char *desc[] = {
45 "The mdrun program performs Molecular Dynamics simulations.",
46 "It reads the run input file ([TT]-s[tt]) and distributes the",
47 "topology over processors if needed. The coordinates are passed",
48 "around, so that computations can begin.",
49 "First a neighborlist is made, then the forces are computed.",
50 "The forces are globally summed, and the velocities and",
51 "positions are updated. If necessary shake is performed to constrain",
52 "bond lengths and/or bond angles.",
53 "Temperature and Pressure can be controlled using weak coupling to a",
54 "bath.[PAR]",
55 "mdrun produces at least three output file, plus one log file",
56 "([TT]-g[tt]) per processor.",
57 "The trajectory file ([TT]-o[tt]), contains coordinates, velocities and",
58 "optionally forces.",
59 "The structure file ([TT]-c[tt]) contains the coordinates and",
60 "velocities of the last step.",
61 "The energy file ([TT]-e[tt]) contains energies, the temperature,",
62 "pressure, etc, a lot of these things are also printed in the log file",
63 "of processor 0.",
64 "Optionally coordinates can be written to a compressed trajectory file",
65 "([TT]-x[tt]).[PAR]",
66 "When running in parallel with PVM or an old version of MPI the",
67 "[TT]-np[tt] option must be given to indicate the number of",
68 "processors.[PAR]",
69 "The option [TT]-dgdl[tt] is only used when free energy perturbation is",
70 "turned on.[PAR]",
71 "With [TT]-rerun[tt] an input trajectory can be given for which ",
72 "forces and energies will be (re)calculated.[PAR]",
73 "ED (essential dynamics) sampling is switched on by using the [TT]-ei[tt]",
74 "flag followed by an [TT].edi[tt] file.",
75 "The [TT].edi[tt] file can be produced using options in the essdyn",
76 "menu of the WHAT IF program. mdrun produces a [TT].edo[tt] file that",
77 "contains projections of positions, velocities and forces onto selected",
78 "eigenvectors.[PAR]",
79 "The options [TT]-pi[tt], [TT]-po[tt], [TT]-pd[tt], [TT]-pn[tt] are used",
80 "for potential of mean force calculations and umbrella sampling.",
81 "See manual.[PAR]",
82 "When mdrun receives a TERM signal it will set nsteps to the current",
83 "step plus one, which causes the run to end after one step and write",
84 "all the usual output.",
85 "When running with MPI, a TERM signal to one of the mdrun processes",
86 "is sufficient, this signal should not be sent to mpirun or",
87 "the mdrun process that is the parent of the others."
90 t_commrec *cr;
91 static t_filenm fnm[] = {
92 { efTPX, NULL, NULL, ffREAD },
93 { efTRN, "-o", NULL, ffWRITE },
94 { efXTC, "-x", NULL, ffOPTWR },
95 { efSTO, "-c", "confout", ffWRITE },
96 { efENX, "-e", "ener", ffWRITE },
97 { efLOG, "-g", "md", ffWRITE },
98 { efXVG, "-dgdl", "dgdl", ffOPTWR },
99 { efTRX, "-rerun", "rerun", ffOPTRD },
100 /* function "optRerunMDset" (in runner.c) checks if -rerun is specified */
101 /* { efHAT, "-hat","ghat", ffOPTRD }, currently useless */
102 { efEDI, "-ei", "sam", ffOPTRD },
103 { efEDO, "-eo", "sam", ffOPTWR },
104 { efPPA, "-pi", "pull", ffOPTRD },
105 { efPPA, "-po", "pullout", ffOPTWR },
106 { efPDO, "-pd", "pull", ffOPTWR },
107 { efNDX, "-pn", "pull", ffOPTRD },
109 #define NFILE asize(fnm)
111 /* Command line options ! */
112 static bool bVerbose=FALSE,bCompact=TRUE;
113 #ifdef PARALLEL
114 static int nprocs=1;
115 #endif
116 static int nDLB=0,nstepout=10;
117 static t_pargs pa[] = {
118 #ifdef PARALLEL
119 { "-np", FALSE, etINT, {&nprocs},
120 "Number of processors, must be the same as used for grompp" },
121 #endif
122 { "-v", FALSE, etBOOL,{&bVerbose}, "Be loud and noisy" },
123 { "-compact", FALSE, etBOOL,{&bCompact}, "Write a compact log file" },
124 { "-dlb", FALSE, etINT, {&nDLB},
125 "HIDDENUse dynamic load balancing every ... step. BUGGY do not use" },
126 { "-stepout", FALSE, etINT, {&nstepout},
127 "HIDDENFrequency of writing the remaining runtime" }
129 t_edsamyn edyn;
131 cr = init_par(&argc,&argv);
132 bVerbose = bVerbose && MASTER(cr);
133 edyn.bEdsam=FALSE;
135 if (MASTER(cr))
136 CopyRight(stderr,argv[0]);
138 parse_common_args(&argc,argv,
139 PCA_KEEP_ARGS | PCA_NOEXIT_ON_ARGS | PCA_SET_NPRI |
140 PCA_CAN_SET_DEFFNM | (MASTER(cr) ? 0 : PCA_QUIET),
141 TRUE,NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL);
143 open_log(ftp2fn(efLOG,NFILE,fnm),cr);
145 if (MASTER(cr)) {
146 CopyRight(stdlog,argv[0]);
147 please_cite(stdlog,"Berendsen95a");
150 if (opt2bSet("-ei",NFILE,fnm))
151 ed_open(NFILE,fnm,&edyn);
153 mdrunner(cr,NFILE,fnm,bVerbose,bCompact,nDLB,FALSE,nstepout,&edyn);
155 #ifdef USE_MPI
156 if (gmx_parallel)
157 MPI_Finalize();
158 #endif
160 return 0;