changed reading hint
[gromacs/adressmacs.git] / src / gmxlib / rmpbc.c
blobaaff3c33997189f599e8a282ccf20ef0b7550569
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 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_rmpbc_c = "$Id$";
31 #include "sysstuff.h"
32 #include "typedefs.h"
33 #include "smalloc.h"
34 #include "mshift.h"
35 #include "pbc.h"
36 #include "gstat.h"
37 #include "futil.h"
38 #include "vec.h"
40 void rm_pbc(t_idef *idef,int natoms,matrix box,rvec x[],rvec x_s[])
42 typedef struct {
43 int natoms;
44 t_graph *gr;
45 } multi_graph;
47 static int ngraph=0;
48 static multi_graph *mgraph=NULL;
49 static bool bFirst=TRUE;
50 rvec sv[SHIFTS],box_size;
51 int n,i;
52 bool bNeedToCopy;
54 bNeedToCopy = (x != x_s);
56 if (box[0][0]) {
57 if (idef->ntypes!=-1) {
58 n=-1;
59 for(i=0; i<ngraph; i++)
60 if (mgraph[i].natoms==natoms)
61 n=i;
62 if (n==-1) {
63 /* make a new graph if there isn't one with this number of atoms */
64 n=ngraph;
65 ngraph++;
66 srenew(mgraph,ngraph);
67 mgraph[n].natoms=natoms;
68 mgraph[n].gr=mk_graph(idef,natoms,FALSE);
70 mk_mshift(stdout,mgraph[n].gr,box,x);
71 calc_shifts(box,box_size,sv,FALSE);
72 shift_x(mgraph[n].gr,sv,x,x_s);
73 bNeedToCopy=FALSE;
74 } else if (bFirst) {
75 fprintf(stderr,
76 "\nWarning: can not make broken molecules whole without a run input file\n");
77 bFirst=FALSE;
80 if (bNeedToCopy)
81 for (i=0; i<natoms; i++)
82 copy_rvec(x[i],x_s[i]);