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 * GROningen Mixture of Alchemy and Childrens' Stories
36 /* This file is completely threadsafe - keep it that way! */
56 void reset_bin(t_bin
*b
)
61 int add_binr(FILE *log
,t_bin
*b
,int nr
,real r
[])
67 if (b
->nreal
+nr
> b
->maxreal
) {
69 fprintf(log
,"Before: maxreal=%d, nr=%d, nreal=%d\n",
70 b
->maxreal
,nr
,b
->nreal
);
72 b
->maxreal
=b
->nreal
+nr
;
73 rest
=b
->maxreal
% MULT
;
75 b
->maxreal
+=MULT
-rest
;
76 srenew(b
->rbuf
,b
->maxreal
);
78 fprintf(log
,"After: maxreal=%d, nr=%d, nreal=%d\n",
79 b
->maxreal
,nr
,b
->nreal
+nr
);
83 rbuf
=b
->rbuf
+b
->nreal
;
93 int add_bind(FILE *log
,t_bin
*b
,int nr
,double r
[])
99 if (b
->nreal
+nr
> b
->maxreal
) {
101 fprintf(log
,"Before: maxreal=%d, nr=%d, nreal=%d\n",
102 b
->maxreal
,nr
,b
->nreal
);
104 b
->maxreal
=b
->nreal
+nr
;
105 rest
=b
->maxreal
% MULT
;
107 b
->maxreal
+=MULT
-rest
;
108 srenew(b
->rbuf
,b
->maxreal
);
110 fprintf(log
,"After: maxreal=%d, nr=%d, nreal=%d\n",
111 b
->maxreal
,nr
,b
->nreal
+nr
);
115 rbuf
=b
->rbuf
+b
->nreal
;
116 for(i
=0; (i
<nr
); i
++)
125 void sum_bin(t_bin
*b
,t_commrec
*cr
)
129 for(i
=b
->nreal
; (i
<b
->maxreal
); i
++)
131 gmx_sumd(b
->maxreal
,b
->rbuf
,cr
);
134 void extract_binr(t_bin
*b
,int index
,int nr
,real r
[])
139 rbuf
= b
->rbuf
+index
;
140 for(i
=0; (i
<nr
); i
++)
144 void extract_bind(t_bin
*b
,int index
,int nr
,double r
[])
149 rbuf
= b
->rbuf
+index
;
150 for(i
=0; (i
<nr
); i
++)
155 int main(int argc
,char *argv
[])
163 cr
=init_par(&argc
,argv
);
166 fprintf(stdlog
,"n=%d\n",n
);
171 for(k
=0; (k
< 3); k
++) {
172 fprintf(stdlog
,"\nk=%d\n",k
);
177 for(i
=0; (i
<m
); i
++) {
183 ni
=add_bind(stdlog
,rb
,n
,r
);
184 mi
=add_binr(stdlog
,rb
,DIM
*m
,v
[0]);
188 extract_bind(rb
,ni
,n
,r
);
189 extract_binr(rb
,mi
,DIM
*m
,v
[0]);
192 fprintf(stdlog
,"r[%d] = %e\n",i
,r
[i
]);
194 fprintf(stdlog
,"v[%d] = (%e,%e,%e)\n",i
,v
[i
][XX
],v
[i
][YY
],v
[i
][ZZ
]);