4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Gnomes, ROck Monsters And Chili Sauce
33 /* This file is completely threadsafe - keep it that way! */
50 void reset_bin(t_bin
*b
)
55 int add_binr(FILE *log
,t_bin
*b
,int nr
,real r
[])
61 if (b
->nreal
+nr
> b
->maxreal
) {
63 fprintf(log
,"Before: maxreal=%d, nr=%d, nreal=%d\n",
64 b
->maxreal
,nr
,b
->nreal
);
66 b
->maxreal
=b
->nreal
+nr
;
67 rest
=b
->maxreal
% MULT
;
69 b
->maxreal
+=MULT
-rest
;
70 srenew(b
->rbuf
,b
->maxreal
);
72 fprintf(log
,"After: maxreal=%d, nr=%d, nreal=%d\n",
73 b
->maxreal
,nr
,b
->nreal
+nr
);
77 rbuf
=b
->rbuf
+b
->nreal
;
87 int add_bind(FILE *log
,t_bin
*b
,int nr
,double r
[])
93 if (b
->nreal
+nr
> b
->maxreal
) {
95 fprintf(log
,"Before: maxreal=%d, nr=%d, nreal=%d\n",
96 b
->maxreal
,nr
,b
->nreal
);
98 b
->maxreal
=b
->nreal
+nr
;
99 rest
=b
->maxreal
% MULT
;
101 b
->maxreal
+=MULT
-rest
;
102 srenew(b
->rbuf
,b
->maxreal
);
104 fprintf(log
,"After: maxreal=%d, nr=%d, nreal=%d\n",
105 b
->maxreal
,nr
,b
->nreal
+nr
);
109 rbuf
=b
->rbuf
+b
->nreal
;
110 for(i
=0; (i
<nr
); i
++)
119 void sum_bin(t_bin
*b
,t_commrec
*cr
)
123 for(i
=b
->nreal
; (i
<b
->maxreal
); i
++)
125 gmx_sumd(b
->maxreal
,b
->rbuf
,cr
);
128 void extract_binr(t_bin
*b
,int index
,int nr
,real r
[])
133 rbuf
= b
->rbuf
+index
;
134 for(i
=0; (i
<nr
); i
++)
138 void extract_bind(t_bin
*b
,int index
,int nr
,double r
[])
143 rbuf
= b
->rbuf
+index
;
144 for(i
=0; (i
<nr
); i
++)
149 int main(int argc
,char *argv
[])
157 cr
=init_par(&argc
,argv
);
160 fprintf(stdlog
,"n=%d\n",n
);
165 for(k
=0; (k
< 3); k
++) {
166 fprintf(stdlog
,"\nk=%d\n",k
);
171 for(i
=0; (i
<m
); i
++) {
177 ni
=add_bind(stdlog
,rb
,n
,r
);
178 mi
=add_binr(stdlog
,rb
,DIM
*m
,v
[0]);
182 extract_bind(rb
,ni
,n
,r
);
183 extract_binr(rb
,mi
,DIM
*m
,v
[0]);
186 fprintf(stdlog
,"r[%d] = %e\n",i
,r
[i
]);
188 fprintf(stdlog
,"v[%d] = (%e,%e,%e)\n",i
,v
[i
][XX
],v
[i
][YY
],v
[i
][ZZ
]);