-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_geometry_indices.c
205 lines (179 loc) · 6.64 KB
/
init_geometry_indices.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
/***********************************************************************
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Carsten Urbach
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#ifdef HAVE_CONFIG_H
# include<config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "global.h"
#include "init_geometry_indices.h"
int *iup = NULL, *idn = NULL, *ipt = NULL, **ipt_ = NULL, ***ipt__ = NULL;
int init_geometry_indices(const int V) {
int i = 0;
g_idn= (int**)calloc(V, sizeof(int*));
if((void*)g_idn == NULL) return(1);
g_iup = (int**)calloc(V, sizeof(int*));
if((void*)g_iup == NULL) return(2);
idn = (int*)calloc(4*V, sizeof(int));
if((void*)idn == NULL ) return(6);
iup = (int*)calloc(4*V, sizeof(int));
if((void*)iup == NULL) return(7);
g_ipt = (int****)calloc(T+4,sizeof(int*));
if((void*)g_ipt == NULL) return(5);
ipt__ = (int***)calloc ((T+4)*(LX+4), sizeof(int*));
if((void*)ipt__ == NULL) return(4);
ipt_ = (int**)calloc((T+4)*(LX+4)*(LY+4), sizeof(int*));
if((void*)ipt_ == NULL) return(3);
ipt = (int*)calloc((T+4)*(LX+4)*(LY+4)*(LZ+4), sizeof(int));
if((void*)ipt == NULL) return(8);
g_lexic2eo = (int*)calloc(V, sizeof(int));
if((void*)g_lexic2eo == NULL) return(9);
/* this +2 is for sanity reasons */
g_lexic2eosub = (int*)calloc(V+2, sizeof(int));
if((void*)g_lexic2eosub == NULL) return(10);
g_eo2lexic = (int*)calloc(V, sizeof(int));
if((void*)g_eo2lexic == NULL) return(11);
#if ( defined PARALLELXYZT || defined PARALLELXYZ )
g_field_z_ipt_even = (int*)calloc(T*LX*LY, sizeof(int));
if((void*)g_field_z_ipt_even == NULL) return(12);
g_field_z_ipt_odd = (int*)calloc(T*LX*LY, sizeof(int));
if((void*)g_field_z_ipt_odd == NULL) return(13);
g_field_z_disp_even_dn = (int*)calloc(T*LX*LY/2, sizeof(int));
if((void*)g_field_z_disp_even_dn == NULL) return(14);
g_field_z_disp_even_up = (int*)calloc(T*LX*LY/2, sizeof(int));
if((void*)g_field_z_disp_even_up == NULL) return(15);
g_field_z_disp_odd_dn = (int*)calloc(T*LX*LY/2, sizeof(int));
if((void*)g_field_z_disp_odd_dn == NULL) return(16);
g_field_z_disp_odd_up = (int*)calloc(T*LX*LY/2, sizeof(int));
if((void*)g_field_z_disp_odd_up == NULL) return(17);
#endif
#ifdef _USE_TSPLITPAR
g_1st_eot= (int**)calloc(T, sizeof(int*));
if((void*)g_1st_eot == NULL) return(18);
for(i=0;i<T;i++){
g_1st_eot[i]= (int *)calloc(2, sizeof(int));
}
g_1st_xt_int_dn = (int*)calloc(T, sizeof(int));
g_1st_xt_int_up = (int*)calloc(T, sizeof(int));
g_1st_xt_ext_dn = (int*)calloc(T, sizeof(int));
g_1st_xt_ext_up = (int*)calloc(T, sizeof(int));
g_1st_yt_int_dn = (int*)calloc(T, sizeof(int));
g_1st_yt_int_up = (int*)calloc(T, sizeof(int));
g_1st_yt_ext_dn = (int*)calloc(T, sizeof(int));
g_1st_yt_ext_up = (int*)calloc(T, sizeof(int));
g_1st_zt_int_dn = (int*)calloc(T, sizeof(int));
g_1st_zt_int_up = (int*)calloc(T, sizeof(int));
g_1st_zt_ext_dn = (int*)calloc(T, sizeof(int));
g_1st_zt_ext_up = (int*)calloc(T, sizeof(int));
g_field_zt_disp_even_dn = (int **)calloc(T, sizeof(int*));
g_field_zt_disp_even_up = (int **)calloc(T, sizeof(int*));
g_field_zt_disp_odd_dn = (int **)calloc(T, sizeof(int*));
g_field_zt_disp_odd_up = (int **)calloc(T, sizeof(int*));
for(i=0;i<T;i++){
g_field_zt_disp_even_dn[i] = (int *)calloc((LX*LY+1)/2, sizeof(int));
g_field_zt_disp_even_up[i] = (int *)calloc((LX*LY+1)/2, sizeof(int));
g_field_zt_disp_odd_dn[i] = (int *)calloc((LX*LY+1)/2, sizeof(int));
g_field_zt_disp_odd_up[i] = (int *)calloc((LX*LY+1)/2, sizeof(int));
}
#endif
g_coord= (int**)calloc(VOLUME, sizeof(int*));
if((void*)g_coord == NULL) return(19);
for(i=0;i<VOLUME;i++){
g_coord[i]= (int*)calloc(4, sizeof(int));
}
g_iup_eo= (int**)calloc(VOLUME+RAND, sizeof(int*)); // NEW GIUPDNEO
if((void*)g_iup_eo == NULL) return(21);
for(i=0;i<VOLUME+RAND;i++){
g_iup_eo[i]= (int*)calloc(4, sizeof(int));
}
g_idn_eo= (int**)calloc(VOLUME+RAND, sizeof(int*));
if((void*)g_idn_eo == NULL) return(22);
for(i=0;i<VOLUME+RAND;i++){
g_idn_eo[i]= (int*)calloc(4, sizeof(int));
}
/* This should only be used for the SFBC. */
/* This should not be used for anything other than the SFBC */
/* because it might eventually vanish. */
g_t = (int*)calloc(V, sizeof(int));
if((void*)g_t == NULL) return(20);
g_idn[0] = idn;
g_iup[0] = iup;
ipt_[0] = ipt;
ipt__[0] = ipt_;
g_ipt[0] = ipt__;
for(i = 1; i < V; i++){
g_idn[i] = g_idn[i-1]+4;
g_iup[i] = g_iup[i-1]+4;
}
for(i = 1; i < (T+4)*(LX+4)*(LY+4); i++){
ipt_[i] = ipt_[i-1]+(LZ+4);
}
for(i = 1; i < (T+4)*(LX+4); i++){
ipt__[i] = ipt__[i-1]+(LY+4);
}
for(i = 1; i < (T+4); i++){
g_ipt[i] = g_ipt[i-1]+(LX+4);
}
/* allocate memory to keep a special index array for the
non-halfspinor hopping matrix */
g_hi = (int*)calloc(16*(VOLUME+RAND)+2,sizeof(int));
if((void*) g_hi == NULL) return(40);
/* body and surface index arrays, they are defined in the spinor initialization */
if( BODY > 0 ) {
g_body = (unsigned int *) malloc(BODY*sizeof(unsigned int));
if((void*) g_body == NULL ) return(50);
}
if( SURFACE > 0 ) {
g_surface = (unsigned int *) malloc(SURFACE*sizeof(unsigned int));
if((void*) g_surface == NULL ) return(51);
}
#ifdef WITHLAPH
g_idn3d = (int**)calloc(SPACEVOLUME, sizeof(int*));
if((void*)g_idn == NULL) return(31);
g_iup3d = (int**)calloc(SPACEVOLUME, sizeof(int*));
if((void*)g_iup == NULL) return(32);
for (i=0;i<SPACEVOLUME;i++){
g_idn3d[i] = (int*)calloc(4, sizeof(int));
g_iup3d[i] = (int*)calloc(4, sizeof(int));
}
#endif
return(0);
}
void free_geometry_indices() {
free(idn);
free(iup);
free(ipt);
free(ipt_);
free(ipt__);
free(g_ipt);
free(g_hi);
free(g_idn);
free(g_iup);
free(g_eo2lexic);
free(g_lexic2eosub);
free(g_lexic2eo);
if(BODY > 0 ) free(g_body);
if(SURFACE > 0 ) free(g_surface);
#if ( defined PARALLELXYZT || defined PARALLELXYZ )
free(g_field_z_ipt_odd);
free(g_field_z_ipt_even);
#endif
free(g_t);
}