forked from milc-qcd/milc_qcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol_mr.c
333 lines (242 loc) · 7.45 KB
/
control_mr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/***************** control_mr.c *****************************************/
/* MIMD version 7 */
/*
* Main procedure for quenched heavy-light SU3 Wilson fermions --- hopping
* param expansion for heavies
*/
/* MIMD version 7 */
/*
* Background gauge field is supplied, assumed to be in coulomb gauge
*/
#define CONTROL
#include "w_heavy_includes.h"
int main(int argc, char **argv)
{
int meascount[MAX_NKAP];
int prompt, count1, count2;
Real avm_iters[MAX_NKAP];
double starttime, endtime;
int MaxMR, restart_flag;
Real RsdMR; /******/
int spin, color, nk; /******/
int max_prop;
double ssplaq, stplaq;
FILE *fp_m_out; /*** meson IO stuff **/
int fb_m_out; /*** meson IO stuff **/
w_prop_file *fp_in_w[MAX_NKAP]; /* For propagator files */
w_prop_file *fp_out_w[MAX_NKAP]; /* For propagator files */
field_offset rv;
double g_time ;
int cl_cg = CL_CG;
/************************************************************/
initialize_machine(&argc, &argv);
/* Remap standard I/O */
if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
g_sync();
/* set up */
prompt = setup_h();
/* loop over input sets */
while (readin(prompt) == 0)
{
starttime = dclock();
if( fixflag == COULOMB_GAUGE_FIX)
{
if(this_node == 0)
printf("Fixing to Coulomb gauge\n");
g_time = -dclock();
gaugefix(TUP,(Real)1.5,500,GAUGE_FIX_TOL);
g_time += dclock();
if(this_node==0)printf("Time to gauge fix = %e\n",g_time);
invalidate_this_clov(gen_clov);
}
else
if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
/* save lattice if requested */
if( saveflag != FORGET )
{
/* Note: beta, kappa are kept only for save_old_binary */
save_lattice( saveflag, savefile, stringLFN );
}
/* call plaquette measuring process */
d_plaquette(&ssplaq, &stplaq);
if (this_node == 0)
printf("START %e %e\n",(double) ssplaq, (double) stplaq);
MaxMR = niter;
RsdMR = (Real) sqrt((double) rsqprop);
if (this_node == 0)
printf("Residue=%e\n",(double) RsdMR);
for (nk = 0; nk < nkap; nk++)
{
avm_iters[nk] = 0.0;
meascount[nk] = 0;
}
max_prop = 12;
count1 = 0;
count2 = 0;
for (spin = start_spin; spin < 4; spin++)
{
for (color = 0; color < 3; color++)
{
count1++;
if (count1 == 1)
color += start_color;
for (nk = 0; nk < nkap; nk++)
{
count2++;
if (count2 == 1)
nk += start_kap;
kappa = cappa[nk];
meascount[nk]++;
/* open file for wilson propagators */
fp_in_w[nk] = r_open_wprop(startflag_w[nk], startfile_w[nk]);
if ((spin + color) == 0)
{
/*** first pass of the code **/
fp_out_w[nk] = w_open_wprop(saveflag_w[nk], savefile_w[nk],
wqs.type);
/* open file for meson output and writet he header */
if (saveflag_m == SAVE_MESON_ASCII)
{
fp_m_out = w_ascii_m_i(savefile_m[nk], max_prop);
fb_m_out = -1; /* i.e. file is NOT binary */
}
else if (saveflag_m == SAVE_MESON_BINARY)
{
fb_m_out = w_binary_m_i(savefile_m[nk], max_prop);
fp_m_out = NULL; /* i.e. file is NOT ascii */
}
else
{
if( this_node == 0 )
printf("ERROR in main saveflag_m = %d is out of range in initial opening\n",saveflag_m) ;
terminate(1);
}
} /*** end of spin =0 && color == 0 **/
else
{
fp_out_w[nk] = w_open_wprop(saveflag_w[nk], savefile_w[nk],
wqs.type);
/* open file for meson output for appending output*/
if (saveflag_m == SAVE_MESON_ASCII)
{
fp_m_out = a_ascii_m_i(savefile_m[nk], max_prop);
fb_m_out = -1; /* i.e. file is NOT binary */
}
if (saveflag_m == SAVE_MESON_BINARY)
{
fb_m_out = a_binary_m_i(savefile_m[nk], max_prop);
fp_m_out = NULL; /* i.e. file is NOT ascii */
}
else
{
if( this_node == 0 )
printf("ERROR in main saveflag_m = %d is out of range in appending opening\n",saveflag_m) ;
terminate(1);
}
} /*** end of spin && color not equal to zero ***/
if (this_node == 0)
printf("color=%d spin=%d kappa=%f nk=%d\n", color, spin, (double) kappa, nk);
/* load psi if requested */
init_qs(&wqstmp2);
reload_wprop_sc_to_site(startflag_w[nk], fp_in_w[nk], &wqstmp2,
spin, color, F_OFFSET(psi),1);
if (nk == 0 || count2 == 1)
restart_flag = flag;
else
restart_flag = 1;
/* Conjugate gradient inversion uses site structure
temporary"chi" */
/* (Used only for bicg inverters, where rv is an extra wilson_vector
work space.) */
rv = 2000000000; /* Force seg fault if we try to use it here */
/* Complete the source structure */
wqs.color = color;
wqs.spin = spin;
wqs.parity = EVENANDODD;
/* For wilson_info */
wqstmp = wqs;
/* If we are starting fresh, we want to set a mininum number of
iterations */
/* Load inversion control structure */
qic.prec = MILC_PRECISION;
qic.min = 0;
qic.max = MaxMR;
qic.nrestart = nrestart;
qic.parity = EVENANDODD;
qic.start_flag = restart_flag;
qic.nsrc = 1;
qic.resid = RsdMR;
qic.relresid = 0;
/* Load Dirac matrix parameters */
dwp.Kappa = kappa;
switch (cl_cg) {
case CG:
/* compute the propagator. Result in psi. */
avm_iters[nk] +=
(Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
w_source_h,&wqs,
cgilu_w_site,&qic,(void *)&dwp);
break;
case MR:
/* compute the propagator. Result in psi. */
avm_iters[nk] +=
(Real)wilson_invert_site_wqs(F_OFFSET(chi),F_OFFSET(psi),
w_source_h,&wqs,
mrilu_w_site,&qic,(void *)&dwp);
break;
default:
node0_printf("main(%d): Inverter choice %d not supported\n",
this_node,cl_cg);
}
/* save psi if requested */
save_wprop_sc_from_site( saveflag_w[nk],fp_out_w[nk],&wqstmp2,
spin,color,F_OFFSET(psi),1);
light_meson(F_OFFSET(psi), color, spin, wqs.type, fp_m_out, fb_m_out);
if (this_node == 0)
printf("Light mesons found\n");
/*
* find source again since mrilu overwrites it; for hopping
* expansion
*/
/* source must be of definite parity */
wqs.parity = source_parity;
w_source_h(F_OFFSET(chi), &wqs);
hopping(F_OFFSET(chi), F_OFFSET(mp), F_OFFSET(psi), nhop,
kappa_c, wqs.parity, color, spin, wqs.type,
fp_m_out, fb_m_out);
/* close files */
r_close_wprop(startflag_w[nk], fp_in_w[nk]);
w_close_wprop(saveflag_w[nk],fp_out_w[nk]);
if (saveflag_m == SAVE_MESON_ASCII)
w_ascii_m_f(fp_m_out, savefile_m[nk]);
else if (saveflag_m == SAVE_MESON_BINARY)
w_binary_m_f(fb_m_out, savefile_m[nk]);
if (spin == end_spin && color == end_color && nk == end_kap)
goto end_of_loops;
}
}
} /* end of loop over spin, color, kappa */
end_of_loops:
if (this_node == 0)
printf("RUNNING COMPLETED\n");
for (nk = 0; nk < nkap; nk++)
{
if (meascount[nk] > 0)
{
if (this_node == 0)
printf("total mr iters for measurement= %e\n",
(double) avm_iters[nk]);
if (this_node == 0)
printf("average mr iters per spin-color= %e\n",
(double) avm_iters[nk] / (double) meascount[nk]);
}
}
endtime = dclock();
if (this_node == 0)
{
printf("Time = %e seconds\n", (double) (endtime - starttime));
}
fflush(stdout);
} /* while(prompt) */
return 0;
} /* main() */