1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * For more info, check our website at http://www.gromacs.org
34 * GROwing Monsters And Cloning Shrimps
47 #include "gmx_fatal.h"
55 #include "gmx_random.h"
61 #define NOT_FINISHED(l1,l2) \
62 printf("not finished yet: lines %d .. %d in %s\n",l1,l2,__FILE__)
64 void set_state_entries(t_state *state,const t_inputrec *ir,int nnodes)
68 /* The entries in the state in the tpx file might not correspond
69 * with what is needed, so we correct this here.
72 if (ir->efep != efepNO)
73 state->flags |= (1<<estLAMBDA);
74 state->flags |= (1<<estX);
76 snew(state->x,state->nalloc);
77 if (EI_DYNAMICS(ir->eI)) {
78 state->flags |= (1<<estV);
80 snew(state->v,state->nalloc);
82 if (ir->eI == eiSD2) {
83 state->flags |= (1<<estSDX);
84 if (state->sd_X == NULL) {
85 /* sd_X is not stored in the tpx file, so we need to allocate it */
86 snew(state->sd_X,state->nalloc);
91 state->flags |= (1<<estCGP);
92 if (state->cg_p == NULL)
94 /* cg_p is not stored in the tpx file, so we need to allocate it */
95 snew(state->cg_p,state->nalloc);
98 if (EI_SD(ir->eI) || ir->eI == eiBD || ir->etc == etcVRESCALE) {
99 state->nrng = gmx_rng_n();
101 if (EI_SD(ir->eI) || ir->eI == eiBD) {
102 /* This will be correct later with DD */
103 state->nrng *= nnodes;
104 state->nrngi *= nnodes;
106 state->flags |= ((1<<estLD_RNG) | (1<<estLD_RNGI));
107 snew(state->ld_rng, state->nrng);
108 snew(state->ld_rngi,state->nrngi);
113 if (ir->ePBC != epbcNONE) {
114 state->flags |= (1<<estBOX);
115 if (PRESERVE_SHAPE(*ir)) {
116 state->flags |= (1<<estBOX_REL);
118 if ((ir->epc == epcPARRINELLORAHMAN) || (ir->epc == epcMTTK)) {
119 state->flags |= (1<<estBOXV);
121 if (ir->epc != epcNO) {
122 if (IR_NPT_TROTTER(ir)) {
124 state->flags |= (1<<estNHPRES_XI);
125 state->flags |= (1<<estNHPRES_VXI);
126 state->flags |= (1<<estSVIR_PREV);
127 state->flags |= (1<<estFVIR_PREV);
128 state->flags |= (1<<estVETA);
129 state->flags |= (1<<estVOL0);
131 state->flags |= (1<<estPRES_PREV);
136 if (ir->etc == etcNOSEHOOVER) {
137 state->flags |= (1<<estNH_XI);
138 state->flags |= (1<<estNH_VXI);
141 if (ir->etc == etcVRESCALE) {
142 state->flags |= (1<<estTC_INT);
145 init_gtc_state(state,state->ngtc,state->nnhpres,ir->opts.nhchainlength); /* allocate the space for nose-hoover chains */
146 init_ekinstate(&state->ekinstate,ir);
148 init_energyhistory(&state->enerhist);
152 void init_parallel(FILE *log, t_commrec *cr, t_inputrec *inputrec,
155 bcast_ir_mtop(cr,inputrec,mtop);
158 if (inputrec->eI == eiBD || EI_SD(inputrec->eI)) {
159 /* Make sure the random seeds are different on each node */
160 inputrec->ld_seed += cr->nodeid;