-
Notifications
You must be signed in to change notification settings - Fork 4
/
WI_ud_xspace.c
188 lines (159 loc) · 4.98 KB
/
WI_ud_xspace.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
/*********************************************************************************
* WI_ud_xspace.c
*
* Wed Nov 10 14:12:32 CET 2010
*
* PURPOSE:
* TODO:
* DONE:
* CHANGES:
*********************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#ifdef MPI
# include <mpi.h>
#endif
#include <getopt.h>
#define MAIN_PROGRAM
#include "cvc_complex.h"
#include "cvc_linalg.h"
#include "global.h"
#include "cvc_geometry.h"
#include "cvc_utils.h"
#include "mpi_init.h"
#include "io.h"
#include "propagator_io.h"
#include "contractions_io.h"
#include "Q_phi.h"
#include "read_input_parser.h"
void usage() {
fprintf(stdout, "Code to perform quark-disconnected conserved vector current contractions\n");
fprintf(stdout, "Usage: [options]\n");
fprintf(stdout, "Options: -v verbose\n");
fprintf(stdout, " -g apply a random gauge transformation\n");
fprintf(stdout, " -f input filename [default cvc.input]\n");
#ifdef MPI
MPI_Abort(MPI_COMM_WORLD, 1);
MPI_Finalize();
#endif
exit(0);
}
int main(int argc, char **argv) {
int c, i;
int count = 0;
int filename_set = 0;
int l_LX_at, l_LXstart_at;
int ixm0, ixm1, ixm2, ixm3;
int sid1, status, gid, ix;
double *data=NULL, *work=NULL, *ptr0, *ptr1, *ptr2, *ptr3;
char filename[100];
double ratime, retime;
complex w, w2;
FILE *ofs=NULL;
/****************************************
* initialize the distance vectors
****************************************/
while ((c = getopt(argc, argv, "h?f:")) != -1) {
switch (c) {
case 'f':
strcpy(filename, optarg);
filename_set=1;
break;
case 'h':
case '?':
default:
usage();
break;
}
}
/* set the default values */
if(filename_set==0) strcpy(filename, "cvc.input");
fprintf(stdout, "# Reading input from file %s\n", filename);
read_input_parser(filename);
/* some checks on the input data */
if((T_global == 0) || (LX==0) || (LY==0) || (LZ==0)) {
if(g_proc_id==0) fprintf(stdout, "T and L's must be set\n");
usage();
}
if(g_kappa == 0.) {
if(g_proc_id==0) fprintf(stdout, "kappa should be > 0.n");
usage();
}
fprintf(stdout, "\n**************************************************\n");
fprintf(stdout, "* jc_ud_p\n");
fprintf(stdout, "**************************************************\n\n");
/* initialize */
T = T_global;
Tstart = 0;
l_LX_at = LX;
l_LXstart_at = 0;
fprintf(stdout, "# [%2d] parameters:\n"\
"# T = %3d\n"\
"# Tstart = %3d\n"\
"# l_LX_at = %3d\n"\
"# l_LXstart_at = %3d\n"\
"# FFTW_LOC_VOLUME = %3d\n",
g_cart_id, T, Tstart, l_LX_at, l_LXstart_at, FFTW_LOC_VOLUME);
if(init_geometry() != 0) {
fprintf(stderr, "ERROR from init_geometry\n");
exit(1);
}
geometry();
/****************************************
* allocate memory for the contractions
****************************************/
data = (double*)calloc(8*FFTW_LOC_VOLUME, sizeof(double));
if( data==NULL ) {
fprintf(stderr, "could not allocate memory for data\n");
exit(3);
}
work = (double*)calloc(2*FFTW_LOC_VOLUME, sizeof(double));
if( work == (double*)NULL ) {
fprintf(stderr, "could not allocate memory for work\n");
exit(7);
}
/***********************************************
* start loop on gauge id.s
***********************************************/
for(gid=g_gaugeid; gid<=g_gaugeid2; gid++) {
ratime = (double)clock() / CLOCKS_PER_SEC;
for(sid1=g_sourceid; sid1<=g_sourceid2; sid1+=g_sourceid_step) {
sprintf(filename, "jc_ud_x.%.4d.%.4d", gid, sid1);
if(read_lime_contraction(data, filename, 4, 0) != 0) {
fprintf(stderr, "Error, could not read field no. %d\n", sid1);
exit(15);
}
for(ix=0; ix<2*FFTW_LOC_VOLUME; ix++) work[ix] = 0.;
ptr0 = data;
ptr1 = data + 2*VOLUME;
ptr2 = data + 4*VOLUME;
ptr3 = data + 6*VOLUME;
for(ix=0; ix<VOLUME; ix++) {
ixm0 = g_idn[ix][0];
ixm1 = g_idn[ix][1];
ixm2 = g_idn[ix][2];
ixm3 = g_idn[ix][3];
work[2*ix ] = ptr0[2*ix ] - ptr0[2*ixm0 ]
+ ptr1[2*ix ] - ptr1[2*ixm1 ]
+ ptr2[2*ix ] - ptr2[2*ixm2 ]
+ ptr3[2*ix ] - ptr3[2*ixm3 ];
work[2*ix+1] = ptr0[2*ix+1] - ptr0[2*ixm0+1]
+ ptr1[2*ix+1] - ptr1[2*ixm1+1]
+ ptr2[2*ix+1] - ptr2[2*ixm2+1]
+ ptr3[2*ix+1] - ptr3[2*ixm3+1];
}
}
retime = (double)clock() / CLOCKS_PER_SEC;
if(g_cart_id == 0) fprintf(stdout, "# time for calculating WI: %e seconds\n", retime-ratime);
}
/***********************************************
* free the allocated memory, finalize
***********************************************/
free_geometry();
free(work);
free(data);
return(0);
}