fermisurfer Git
Revision | c6746334c11b5fa2de91edb5f843d41d45b4560d (tree) |
---|---|
Zeit | 2017-04-16 01:14:12 |
Autor | ![]() |
Commiter | mitsuaki1987 |
More tuning of OpenMP and appearance
@@ -1,7 +1,7 @@ | ||
1 | 1 | |
2 | 2 | CC = gcc |
3 | 3 | |
4 | -CFLAGS=-O3 -lglut -lGLU -lGL -lm -g -fopenmp | |
4 | +CFLAGS=-g -O0 -lglut -lGLU -lGL -lm -fopenmp -g | |
5 | 5 | # for mac |
6 | 6 | #CFLAGS=-D MAC -O3 -framework OpenGL -framework GLUT -lm |
7 | 7 |
@@ -29,6 +29,10 @@ THE SOFTWARE. | ||
29 | 29 | #include <GL/glut.h> |
30 | 30 | #endif |
31 | 31 | |
32 | +#if defined(_OPENMP) | |
33 | +#include <omp.h> | |
34 | +#endif | |
35 | + | |
32 | 36 | /** |
33 | 37 | *Work as Modulo function of fortran |
34 | 38 | */ |
@@ -122,3 +126,13 @@ void normal_vec( | ||
122 | 126 | norm = sqrtf(out[0] * out[0] + out[1] * out[1] + out[2] * out[2]); |
123 | 127 | for (i = 0; i<3; i++) out[i] = out[i] / norm; |
124 | 128 | } /* normal_vec */ |
129 | + | |
130 | +int get_thread() { | |
131 | + int ithread; | |
132 | +#if defined(_OPENMP) | |
133 | + ithread = omp_get_thread_num(); | |
134 | +#else | |
135 | + ithread = 0; | |
136 | +#endif | |
137 | + return ithread; | |
138 | +} |
@@ -41,4 +41,5 @@ void normal_vec( | ||
41 | 41 | GLfloat in1[3] /**< [in] Corner 1*/, |
42 | 42 | GLfloat in2[3] /**< [in] Corner 2*/, |
43 | 43 | GLfloat in3[3] /**< [in] Corner 3*/, |
44 | - GLfloat out[3] /**< [out] The normal vector*/); | |
\ No newline at end of file | ||
44 | + GLfloat out[3] /**< [out] The normal vector*/); | |
45 | +int get_thread(); |
@@ -131,7 +131,7 @@ void bz_lines() { | ||
131 | 131 | } |
132 | 132 | /**/ |
133 | 133 | if (query == 1) { |
134 | - printf("# of lines for BZ : %d \n", nbzl); | |
134 | + printf(" # of lines for BZ : %d\n", nbzl); | |
135 | 135 | /**/ |
136 | 136 | bzl = (GLfloat***)malloc(nbzl * sizeof(GLfloat*)); |
137 | 137 | for (ibzl = 0; ibzl < nbzl; ++ibzl) { |
@@ -25,6 +25,7 @@ THE SOFTWARE. | ||
25 | 25 | #include <stdio.h> |
26 | 26 | #include <math.h> |
27 | 27 | #include "variable.h" |
28 | +#include "basic_math.h" | |
28 | 29 | |
29 | 30 | #if defined(MAC) |
30 | 31 | #include <GLUT/glut.h> |
@@ -32,10 +33,6 @@ THE SOFTWARE. | ||
32 | 33 | #include <GL/glut.h> |
33 | 34 | #endif |
34 | 35 | |
35 | -#if defined(_OPENMP) | |
36 | -#include <omp.h> | |
37 | -#endif | |
38 | - | |
39 | 36 | /** |
40 | 37 | * Node line |
41 | 38 | */ |
@@ -49,11 +46,7 @@ void calc_nodeline() { | ||
49 | 46 | shared(nb,nnl,matp,ntri,ntri_th) \ |
50 | 47 | private(ib,itri,mprod,nnl0,ithread) |
51 | 48 | { |
52 | -#if defined(_OPENMP) | |
53 | - ithread = omp_get_thread_num(); | |
54 | -#else | |
55 | - ithread = 0; | |
56 | -#endif | |
49 | + ithread = get_thread(); | |
57 | 50 | for (ib = 0; ib < nb; ib++) { |
58 | 51 | nnl0 = 0; |
59 | 52 | #pragma omp for |
@@ -99,11 +92,10 @@ void calc_nodeline() { | ||
99 | 92 | } |
100 | 93 | ntri_th[ib][0] = 0; |
101 | 94 | } |
102 | - printf("band # of nodeline \n"); | |
95 | + printf(" band # of nodeline\n"); | |
103 | 96 | for (ib = 0; ib < nb; ib++) { |
104 | - printf("%d %d \n", ib + 1, nnl[ib]); | |
97 | + printf(" %d %d\n", ib + 1, nnl[ib]); | |
105 | 98 | } |
106 | - printf("\n"); | |
107 | 99 | /** |
108 | 100 | * Allocation of nodeline |
109 | 101 | */ |
@@ -126,11 +118,7 @@ void calc_nodeline() { | ||
126 | 118 | shared(nb,nnl,matp,kvnl,kvp,ntri,ntri_th) \ |
127 | 119 | private(ib,itri,mprod,i,nnl0,ithread) |
128 | 120 | { |
129 | -#if defined(_OPENMP) | |
130 | - ithread = omp_get_thread_num(); | |
131 | -#else | |
132 | - ithread = 0; | |
133 | -#endif | |
121 | + ithread = get_thread(); | |
134 | 122 | for (ib = 0; ib < nb; ib++) { |
135 | 123 | nnl0 = ntri_th[ib][ithread]; |
136 | 124 | #pragma omp for |
@@ -33,10 +33,6 @@ THE SOFTWARE. | ||
33 | 33 | #include <GL/glut.h> |
34 | 34 | #endif |
35 | 35 | |
36 | -#if defined(_OPENMP) | |
37 | -#include <omp.h> | |
38 | -#endif | |
39 | - | |
40 | 36 | /** |
41 | 37 | * Store triangle patch |
42 | 38 | */ |
@@ -216,9 +212,19 @@ void fermi_patch() | ||
216 | 212 | GLfloat kvec1[8][3], eig1[8], mat1[8]; |
217 | 213 | /**/ |
218 | 214 | if (fbz == 1) { |
215 | + if (query == 1) { | |
216 | + printf("\n"); | |
217 | + printf(" ## First Brillouin zone mode #######\n"); | |
218 | + printf("\n"); | |
219 | + } | |
219 | 220 | for (i0 = 0; i0 < 3; ++i0) start[i0] = - ng[i0]; |
220 | 221 | } |
221 | 222 | else { |
223 | + if (query == 1) { | |
224 | + printf("\n"); | |
225 | + printf(" ## Premitive Brillouin zone mode #######\n"); | |
226 | + printf("\n"); | |
227 | + } | |
222 | 228 | for (i0 = 0; i0 < 3; ++i0) start[i0] = 0; |
223 | 229 | } |
224 | 230 | /**/ |
@@ -226,11 +232,7 @@ void fermi_patch() | ||
226 | 232 | shared(nb,ntri,ntri_th,start,ng,ng0,eig,EF,mat,shiftk,query) \ |
227 | 233 | private(ib,j0,j1,j2,i0,i1,i2,ii0,ii1,ii2,kvec1,eig1,mat1,i,j,ntri0,ithread) |
228 | 234 | { |
229 | -#if defined(_OPENMP) | |
230 | - ithread = omp_get_thread_num(); | |
231 | -#else | |
232 | - ithread = 0; | |
233 | -#endif | |
235 | + ithread = get_thread(); | |
234 | 236 | for (ib = 0; ib < nb; ++ib) { |
235 | 237 | |
236 | 238 | if(query == 1) ntri0 = 0; |
@@ -329,9 +331,9 @@ void fermi_patch() | ||
329 | 331 | ntri_th[ib][0] = 0; |
330 | 332 | } |
331 | 333 | /**/ |
332 | - printf("band # of patchs \n"); | |
334 | + printf(" band # of patchs\n"); | |
333 | 335 | for (ib = 0; ib < nb; ib++) { |
334 | - printf("%d %d \n", ib + 1, ntri[ib]); | |
336 | + printf(" %d %d\n", ib + 1, ntri[ib]); | |
335 | 337 | } |
336 | 338 | printf("\n"); |
337 | 339 | /** |
@@ -80,12 +80,16 @@ int main( | ||
80 | 80 | char *argv[] /**< [in] */) |
81 | 81 | { |
82 | 82 | printf("\n"); |
83 | - printf(" Welocome to FermiSurfer ver. 1.8\n"); | |
83 | + printf("########################################\n"); | |
84 | + printf("## ##\n"); | |
85 | + printf("## Welocome to FermiSurfer ver. 1.8 ##\n"); | |
86 | + printf("## ##\n"); | |
87 | + printf("########################################\n"); | |
84 | 88 | printf("\n"); |
85 | 89 | if (argc < 2) { |
86 | 90 | printf("\n"); |
87 | - printf(" Input file is not specified !\n"); | |
88 | - printf(" Press any key to exit.\n"); | |
91 | + printf(" Input file is not specified !\n"); | |
92 | + printf(" Press any key to exit.\n"); | |
89 | 93 | getchar(); |
90 | 94 | exit(-1); |
91 | 95 | } |
@@ -97,9 +101,9 @@ int main( | ||
97 | 101 | #else |
98 | 102 | nthreads = 1; |
99 | 103 | #endif |
100 | - printf(" Number of threads : %d\n", nthreads); | |
104 | + printf(" Number of threads : %d\n", nthreads); | |
101 | 105 | printf("\n"); |
102 | - printf(" Initialize variables ...\n"); | |
106 | + printf(" Initialize variables ...\n"); | |
103 | 107 | printf("\n"); |
104 | 108 | initialize_val(); |
105 | 109 | /**/ |
@@ -114,23 +118,23 @@ int main( | ||
114 | 118 | /**/ |
115 | 119 | max_and_min_bz(); |
116 | 120 | /**/ |
117 | - printf("\n##### First Brillouin zone mode ##### \n\n"); | |
118 | 121 | query = 1; |
119 | 122 | fermi_patch(); |
120 | 123 | query = 0; |
121 | 124 | fermi_patch(); |
122 | 125 | calc_nodeline(); |
123 | 126 | /**/ |
124 | - printf("\n##### Full color scale ##### \n\n"); | |
125 | 127 | max_and_min(); |
126 | 128 | /* |
127 | 129 | Description |
128 | 130 | */ |
129 | - printf("\n##### How to handle ##### \n\n"); | |
130 | - printf(" mouse drag : Rotate objects \n"); | |
131 | - printf(" mousewheel : Resize objects \n"); | |
132 | - printf(" cursorkey : Move objects \n"); | |
133 | - printf(" mouse right button : Menu \n"); | |
131 | + printf("\n"); | |
132 | + printf(" ## How to handle ###################\n"); | |
133 | + printf("\n"); | |
134 | + printf(" mouse drag : Rotate objects\n"); | |
135 | + printf(" mousewheel : Resize objects\n"); | |
136 | + printf(" cursorkey : Move objects\n"); | |
137 | + printf(" mouse right button : Menu\n"); | |
134 | 138 | printf("\n"); |
135 | 139 | /**/ |
136 | 140 | glutInit(&argc, argv); |
@@ -26,6 +26,7 @@ THE SOFTWARE. | ||
26 | 26 | #include <math.h> |
27 | 27 | #include <stdio.h> |
28 | 28 | #include "variable.h" |
29 | +#include "basic_math.h" | |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * Free variables for patch |
@@ -80,133 +81,177 @@ void free_patch() { | ||
80 | 81 | * Max. & Min. of matrix elements. |
81 | 82 | */ |
82 | 83 | void max_and_min() { |
83 | - int ib, itri, i, j, ierr; | |
84 | - GLfloat matmax, matmin, mat2; | |
85 | - /**/ | |
86 | - matmax = -100000000.0000; | |
87 | - matmin = 100000000.0000; | |
84 | + int ib, itri, i, j, ierr, ithread; | |
85 | + GLfloat matmax, matmin, mat2, *max_th, *min_th; | |
86 | + | |
87 | + max_th = (GLfloat*)malloc(nthreads * sizeof(GLfloat)); | |
88 | + min_th = (GLfloat*)malloc(nthreads * sizeof(GLfloat)); | |
89 | + | |
90 | + printf("\n"); | |
91 | + if (fcscl == 1) printf(" ## Full color scale mode #############\n"); | |
92 | + else if (fcscl == 2) printf(" ## Manual color scale mode #############\n"); | |
93 | + else if (fcscl == 3) printf(" ## Uni-color mode #############\n"); | |
94 | + else printf(" ## Periodic color scale mode #############\n"); | |
95 | + printf("\n"); | |
96 | + | |
97 | +#pragma omp parallel default(none) \ | |
98 | + shared(nb,ntri,matp,max_th,min_th) private(ib,itri,i,ithread) | |
99 | + { | |
100 | + ithread = get_thread(); | |
101 | + max_th[ithread] = -100000000.0000; | |
102 | + min_th[ithread] = 100000000.0000; | |
103 | + | |
104 | + for (ib = 0; ib < nb; ib++) { | |
105 | +#pragma omp for | |
106 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
107 | + for (i = 0; i < 3; ++i) { | |
108 | + if (matp[ib][itri][i] > max_th[ithread]) max_th[ithread] = matp[ib][itri][i]; | |
109 | + if (matp[ib][itri][i] < min_th[ithread]) min_th[ithread] = matp[ib][itri][i]; | |
110 | + } | |
111 | + }/*for (itri = 0; itri < ntri[ib]; ++itri)*/ | |
112 | + }/*for (ib = 0; ib < nb; ib++)*/ | |
113 | + }/*End of parallel region*/ | |
88 | 114 | /**/ |
89 | - for (ib = 0; ib < nb; ib++) { | |
90 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
91 | - for (i = 0; i < 3; ++i) { | |
92 | - if (matp[ib][itri][i] > matmax) matmax = matp[ib][itri][i]; | |
93 | - if (matp[ib][itri][i] < matmin) matmin = matp[ib][itri][i]; | |
94 | - } | |
95 | - } | |
115 | + matmax = max_th[0]; | |
116 | + matmin = min_th[0]; | |
117 | + for (ithread = 1; ithread < nthreads; ithread++) { | |
118 | + if (max_th[ithread] > matmax) matmax = max_th[ithread]; | |
119 | + if (min_th[ithread] > matmin) matmin = min_th[ithread]; | |
96 | 120 | } |
97 | - /**/ | |
98 | - printf("Max. value : %f \n", matmax); | |
99 | - printf("Min. value : %f \n \n", matmin); | |
121 | + printf(" Max. value : %f\n", matmax); | |
122 | + printf(" Min. value : %f\n\n", matmin); | |
100 | 123 | /**/ |
101 | 124 | if (fcscl == 2) { |
102 | - printf("Set min. value : "); | |
125 | + printf(" Set min. value : "); | |
103 | 126 | ierr = scanf("%f", &matmin); |
104 | 127 | if (ierr == 0) printf("error ! reading min"); |
105 | - printf("Set max. value : "); | |
128 | + printf(" Set max. value : "); | |
106 | 129 | ierr = scanf("%f", &matmax); |
107 | 130 | if (ierr == 0) printf("error ! reading max"); |
108 | 131 | } |
109 | 132 | /**/ |
110 | 133 | if (fcscl == 1 || fcscl == 2) { |
111 | - for (ib = 0; ib < nb; ib++) { | |
112 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
113 | - for (i = 0; i < 3; ++i) { | |
114 | - /**/ | |
115 | - mat2 = (matp[ib][itri][i] - matmin) / (matmax - matmin); | |
116 | - mat2 = mat2 * 4.0; | |
117 | - /**/ | |
118 | - if (mat2 <= 1.0) { | |
119 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + blue[j] * (1.0 - mat2); | |
120 | - } | |
121 | - else if (mat2 <= 2.0) { | |
122 | - mat2 = mat2 - 1.0; | |
123 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + cyan[j] * (1.0 - mat2); | |
124 | - } | |
125 | - else if (mat2 <= 3.0) { | |
126 | - mat2 = mat2 - 2.0; | |
127 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + green[j] * (1.0 - mat2); | |
128 | - } | |
129 | - else { | |
130 | - mat2 = mat2 - 3.0; | |
131 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + yellow[j] * (1.0 - mat2); | |
132 | - } | |
133 | - } | |
134 | - } | |
135 | - } | |
134 | +#pragma omp parallel default(none) \ | |
135 | +shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,matmax,matmin) \ | |
136 | +private(ib,itri,i,mat2,j) | |
137 | + { | |
138 | + for (ib = 0; ib < nb; ib++) { | |
139 | +#pragma omp for nowait | |
140 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
141 | + for (i = 0; i < 3; ++i) { | |
142 | + /**/ | |
143 | + mat2 = (matp[ib][itri][i] - matmin) / (matmax - matmin); | |
144 | + mat2 = mat2 * 4.0; | |
145 | + /**/ | |
146 | + if (mat2 <= 1.0) { | |
147 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + blue[j] * (1.0 - mat2); | |
148 | + } | |
149 | + else if (mat2 <= 2.0) { | |
150 | + mat2 = mat2 - 1.0; | |
151 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + cyan[j] * (1.0 - mat2); | |
152 | + } | |
153 | + else if (mat2 <= 3.0) { | |
154 | + mat2 = mat2 - 2.0; | |
155 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + green[j] * (1.0 - mat2); | |
156 | + } | |
157 | + else { | |
158 | + mat2 = mat2 - 3.0; | |
159 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + yellow[j] * (1.0 - mat2); | |
160 | + } | |
161 | + }/*for (i = 0; i < 3; ++i)*/ | |
162 | + }/*for (itri = 0; itri < ntri[ib]; ++itri)*/ | |
163 | + }/*for (ib = 0; ib < nb; ib++)*/ | |
164 | + }/*End of parallel region*/ | |
136 | 165 | } |
137 | 166 | else if (fcscl == 4) { |
138 | - for (ib = 0; ib < nb; ib++) { | |
139 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
140 | - for (i = 0; i < 3; ++i) { | |
141 | - /**/ | |
142 | - mat2 = matp[ib][itri][i] / 6.283185307; | |
143 | - mat2 = mat2 - floorf(mat2); | |
144 | - mat2 = mat2 * 6.0; | |
145 | - /**/ | |
146 | - if (mat2 <= 1.0) { | |
147 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + red[j] * (1.0 - mat2); | |
148 | - } | |
149 | - else if (mat2 <= 2.0) { | |
150 | - mat2 = mat2 - 1.0; | |
151 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + yellow[j] * (1.0 - mat2); | |
152 | - } | |
153 | - else if (mat2 <= 3.0) { | |
154 | - mat2 = mat2 - 2.0; | |
155 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + green[j] * (1.0 - mat2); | |
156 | - } | |
157 | - else if (mat2 <= 4.0) { | |
158 | - mat2 = mat2 - 3.0; | |
159 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = blue[j] * mat2 + cyan[j] * (1.0 - mat2); | |
160 | - } | |
161 | - else if (mat2 <= 5.0) { | |
162 | - mat2 = mat2 - 4.0; | |
163 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = magenta[j] * mat2 + blue[j] * (1.0 - mat2); | |
164 | - } | |
165 | - else { | |
166 | - mat2 = mat2 - 5.0; | |
167 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + magenta[j] * (1.0 - mat2); | |
168 | - } | |
169 | - } | |
170 | - } | |
171 | - } | |
172 | - } | |
173 | - else { | |
174 | - for (ib = 0; ib < nb; ib++) { | |
175 | - /**/ | |
176 | - mat2 = 1.0 / (GLfloat)(nb - 1) * (GLfloat)ib; | |
177 | - mat2 = mat2 * 4.0; | |
178 | - /**/ | |
179 | - if (mat2 <= 1.0) { | |
167 | +#pragma omp parallel default(none) \ | |
168 | +shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,magenta) \ | |
169 | +private(ib,itri,i,mat2,j) | |
170 | + { | |
171 | + for (ib = 0; ib < nb; ib++) { | |
180 | 172 | for (itri = 0; itri < ntri[ib]; ++itri) { |
181 | 173 | for (i = 0; i < 3; ++i) { |
182 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + blue[j] * (1.0 - mat2); | |
174 | + /**/ | |
175 | + mat2 = matp[ib][itri][i] / 6.283185307; | |
176 | + mat2 = mat2 - floorf(mat2); | |
177 | + mat2 = mat2 * 6.0; | |
178 | + /**/ | |
179 | + if (mat2 <= 1.0) { | |
180 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + red[j] * (1.0 - mat2); | |
181 | + } | |
182 | + else if (mat2 <= 2.0) { | |
183 | + mat2 = mat2 - 1.0; | |
184 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + yellow[j] * (1.0 - mat2); | |
185 | + } | |
186 | + else if (mat2 <= 3.0) { | |
187 | + mat2 = mat2 - 2.0; | |
188 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + green[j] * (1.0 - mat2); | |
189 | + } | |
190 | + else if (mat2 <= 4.0) { | |
191 | + mat2 = mat2 - 3.0; | |
192 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = blue[j] * mat2 + cyan[j] * (1.0 - mat2); | |
193 | + } | |
194 | + else if (mat2 <= 5.0) { | |
195 | + mat2 = mat2 - 4.0; | |
196 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = magenta[j] * mat2 + blue[j] * (1.0 - mat2); | |
197 | + } | |
198 | + else { | |
199 | + mat2 = mat2 - 5.0; | |
200 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + magenta[j] * (1.0 - mat2); | |
201 | + } | |
202 | + }/*for (i = 0; i < 3; ++i)*/ | |
203 | + }/*for (itri = 0; itri < ntri[ib]; ++itri)*/ | |
204 | + }/*for (ib = 0; ib < nb; ib++)*/ | |
205 | + }/*End of parallel region*/ | |
206 | + } | |
207 | + else { | |
208 | +#pragma omp parallel default(none) \ | |
209 | +shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red) \ | |
210 | +private(ib,itri,i,mat2,j) | |
211 | + { | |
212 | + for (ib = 0; ib < nb; ib++) { | |
213 | + /**/ | |
214 | + mat2 = 1.0 / (GLfloat)(nb - 1) * (GLfloat)ib; | |
215 | + mat2 = mat2 * 4.0; | |
216 | + /**/ | |
217 | + if (mat2 <= 1.0) { | |
218 | +#pragma omp for nowait | |
219 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
220 | + for (i = 0; i < 3; ++i) { | |
221 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = cyan[j] * mat2 + blue[j] * (1.0 - mat2); | |
222 | + } | |
183 | 223 | } |
184 | 224 | } |
185 | - } | |
186 | - else if (mat2 <= 2.0) { | |
187 | - mat2 = mat2 - 1.0; | |
188 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
189 | - for (i = 0; i < 3; ++i) { | |
190 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + cyan[j] * (1.0 - mat2); | |
225 | + else if (mat2 <= 2.0) { | |
226 | + mat2 = mat2 - 1.0; | |
227 | +#pragma omp for nowait | |
228 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
229 | + for (i = 0; i < 3; ++i) { | |
230 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = green[j] * mat2 + cyan[j] * (1.0 - mat2); | |
231 | + } | |
191 | 232 | } |
192 | 233 | } |
193 | - } | |
194 | - else if (mat2 <= 3.0) { | |
195 | - mat2 = mat2 - 2.0; | |
196 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
197 | - for (i = 0; i < 3; ++i) { | |
198 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + green[j] * (1.0 - mat2); | |
234 | + else if (mat2 <= 3.0) { | |
235 | + mat2 = mat2 - 2.0; | |
236 | +#pragma omp for nowait | |
237 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
238 | + for (i = 0; i < 3; ++i) { | |
239 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = yellow[j] * mat2 + green[j] * (1.0 - mat2); | |
240 | + } | |
199 | 241 | } |
200 | 242 | } |
201 | - } | |
202 | - else { | |
203 | - mat2 = mat2 - 3.0; | |
204 | - for (itri = 0; itri < ntri[ib]; ++itri) { | |
205 | - for (i = 0; i < 3; ++i) { | |
206 | - for (j = 0; j<4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + yellow[j] * (1.0 - mat2); | |
243 | + else { | |
244 | + mat2 = mat2 - 3.0; | |
245 | +#pragma omp for nowait | |
246 | + for (itri = 0; itri < ntri[ib]; ++itri) { | |
247 | + for (i = 0; i < 3; ++i) { | |
248 | + for (j = 0; j < 4; ++j) clr[ib][itri][i][j] = red[j] * mat2 + yellow[j] * (1.0 - mat2); | |
249 | + } | |
207 | 250 | } |
208 | 251 | } |
209 | 252 | } |
210 | - } | |
253 | + }/*End of parallel region*/ | |
211 | 254 | } |
255 | + free(max_th); | |
256 | + free(min_th); | |
212 | 257 | } /* max_and_min */ |
@@ -220,8 +220,10 @@ void max_and_min_bz() { | ||
220 | 220 | int ib, i0, i1, i2; |
221 | 221 | GLfloat eigmin, eigmax, matmin, matmax; |
222 | 222 | /**/ |
223 | - printf("\n##### Max. and Min. of each bands ##### \n\n"); | |
224 | - printf("Band Eig_Min. Eig_Max Mat_Min Mat_Max \n"); | |
223 | + printf("\n"); | |
224 | + printf(" ## Max. and Min. of each bands #######################\n"); | |
225 | + printf("\n"); | |
226 | + printf(" Band Eig_Min. Eig_Max Mat_Min Mat_Max\n"); | |
225 | 227 | for (ib = 0; ib < nb; ib++) { |
226 | 228 | eigmax = -100000000.0000; |
227 | 229 | eigmin = 100000000.0000; |
@@ -237,7 +239,7 @@ void max_and_min_bz() { | ||
237 | 239 | } |
238 | 240 | } |
239 | 241 | } |
240 | - printf("%d %f %f %f %f \n", ib + 1, eigmin, eigmax, matmin, matmax); | |
242 | + printf(" %d %f %f %f %f\n", ib + 1, eigmin, eigmax, matmin, matmax); | |
241 | 243 | } |
242 | 244 | /**/ |
243 | 245 | }/* max_and_min_bz */ |
@@ -84,12 +84,13 @@ void interpol_energy() { | ||
84 | 84 | * 3rd order - three dimensional Kumo interpolation |
85 | 85 | */ |
86 | 86 | #pragma omp parallel default(none) \ |
87 | - shared(ib,nb,ng0,ng,eig,eig0,mat,mat0,interpol) \ | |
88 | - private (i0,i1,ii,i2,j0,j1,j2,coef,eig1,mat1,eig2,mat2,eig3,mat3) | |
87 | + shared(nb,ng0,ng,eig,eig0,mat,mat0,interpol) \ | |
88 | + private (ib,i0,i1,ii,i2,j0,j1,j2,coef,eig1,mat1,eig2,mat2,eig3,mat3) | |
89 | 89 | { |
90 | 90 | for (ib = 0; ib < nb; ib++) { |
91 | 91 | # pragma omp for nowait |
92 | 92 | for (i0 = 0; i0 < ng0[0]; i0++) { |
93 | + //if (ith == 1) continue; | |
93 | 94 | for (i1 = 0; i1 < ng0[1]; i1++) { |
94 | 95 | for (i2 = 0; i2 < ng0[2]; i2++) { |
95 | 96 | for (j0 = 0; j0 < 4; j0++) { |
@@ -104,7 +105,6 @@ void interpol_energy() { | ||
104 | 105 | }/*for (j2 = 0; j2 < 4; j2++)*/ |
105 | 106 | }/*for (j1 = 0; j1 < 4; j1++)*/ |
106 | 107 | }/*for (i2 = 0; i2 < ng0[2]; i2++)*/ |
107 | - | |
108 | 108 | for (j0 = 0; j0 < interpol; j0++) { |
109 | 109 | kumo_coef(j0, &coef[0]); |
110 | 110 | for (j1 = 0; j1 < 4; j1++) { |
@@ -97,9 +97,9 @@ void menu_shiftEF(int value /**< [in] Selected menu*/) | ||
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | - printf("Min Max E_F \n"); | |
101 | - printf("%f %f %f \n", emin, emax, EF); | |
102 | - printf("New Fermi energy : "); | |
100 | + printf(" Min Max E_F \n"); | |
101 | + printf(" %f %f %f \n", emin, emax, EF); | |
102 | + printf(" New Fermi energy : "); | |
103 | 103 | // |
104 | 104 | ierr = scanf("%f", &EF); |
105 | 105 | if (ierr != 1) printf("error ! reading ef"); |
@@ -125,8 +125,8 @@ void menu_interpol(int value /**< [in] Selected menu*/) | ||
125 | 125 | GLfloat emin, emax; |
126 | 126 | |
127 | 127 | if (value == 1) { |
128 | - printf("Old interpolation ratio : %d\n", interpol); | |
129 | - printf("New interpolation ratio : "); | |
128 | + printf(" Old interpolation ratio : %d\n", interpol); | |
129 | + printf(" New interpolation ratio : "); | |
130 | 130 | // |
131 | 131 | ierr = scanf("%d", &interpol); |
132 | 132 | if (ierr != 1) printf("error ! reading interpol"); |
@@ -153,15 +153,15 @@ void menu_view(int value /**< [in] Selected menu*/) | ||
153 | 153 | |
154 | 154 | if (value == 1) { |
155 | 155 | |
156 | - printf(" Current Scale : %f\n", scl); | |
157 | - printf(" New Scale : "); | |
156 | + printf(" Current Scale : %f\n", scl); | |
157 | + printf(" New Scale : "); | |
158 | 158 | ierr = scanf("%f", &scl); |
159 | 159 | |
160 | 160 | } |
161 | 161 | else if (value == 2) { |
162 | 162 | |
163 | - printf(" Current Position(x y) : %f %f\n", trans[0], trans[1]); | |
164 | - printf(" New Position(x y) : "); | |
163 | + printf(" Current Position(x y) : %f %f\n", trans[0], trans[1]); | |
164 | + printf(" New Position(x y) : "); | |
165 | 165 | ierr = scanf("%f %f", &trans[0], &trans[1]); |
166 | 166 | |
167 | 167 | } |
@@ -183,8 +183,8 @@ void menu_view(int value /**< [in] Selected menu*/) | ||
183 | 183 | thetax = 180.0 / 3.14159265 * thetax; |
184 | 184 | thetay = 180.0 / 3.14159265 * thetay; |
185 | 185 | thetaz = 180.0 / 3.14159265 * thetaz; |
186 | - printf(" Current Rotation (theta_x theta_y teta_z) in degree : %f %f %f\n", thetax, thetay, thetaz); | |
187 | - printf(" New Rotation (theta_x theta_y teta_z) in degree : "); | |
186 | + printf(" Current Rotation (theta_x theta_y teta_z) in degree : %f %f %f\n", thetax, thetay, thetaz); | |
187 | + printf(" New Rotation (theta_x theta_y teta_z) in degree : "); | |
188 | 188 | ierr = scanf("%f %f %f", &thetax, &thetay, &thetaz); |
189 | 189 | thetax = 3.14159265 / 180.0 * thetax; |
190 | 190 | thetay = 3.14159265 / 180.0 * thetay; |
@@ -364,7 +364,7 @@ void menu_colorbar(int value /**<[in] Selected menu*/) { | ||
364 | 364 | void menu_tetra(int value) /**<[in] Selected menu*/ { |
365 | 365 | /**/ |
366 | 366 | if (value != itet) { |
367 | - printf("Tetra patern %d \n", value + 1); | |
367 | + printf(" Tetra patern %d \n", value + 1); | |
368 | 368 | itet = value; |
369 | 369 | init_corner(); |
370 | 370 | free_patch(); |
@@ -43,13 +43,15 @@ void read_file(char *fname/**<[in] fname Input file name*/) | ||
43 | 43 | getchar(); |
44 | 44 | exit(EXIT_FAILURE); |
45 | 45 | } |
46 | - printf("\n##### Brillouin zone informations ##### \n\n"); | |
46 | + printf("\n"); | |
47 | + printf(" ## Brillouin zone informations ###########\n"); | |
48 | + printf("\n"); | |
47 | 49 | /* |
48 | 50 | k-point grid |
49 | 51 | */ |
50 | 52 | ierr = fscanf(fp, "%d%d%d", &ng0[0], &ng0[1], &ng0[2]); |
51 | 53 | if (ierr == 0) printf("error ! reading ng"); |
52 | - printf("k point grid : %d %d %d \n", ng0[0], ng0[1], ng0[2]); | |
54 | + printf(" k point grid : %d %d %d \n", ng0[0], ng0[1], ng0[2]); | |
53 | 55 | for (i = 0; i < 3; i++) ng[i] = ng0[i]; |
54 | 56 | /* |
55 | 57 | Shift of k-point grid |
@@ -58,15 +60,15 @@ void read_file(char *fname/**<[in] fname Input file name*/) | ||
58 | 60 | if (ierr == 0) printf("error ! reading lshift"); |
59 | 61 | |
60 | 62 | if (lshift == 0) { |
61 | - printf("k point grid is the Monkhorst-Pack grid. \n"); | |
63 | + printf(" k point grid is the Monkhorst-Pack grid. \n"); | |
62 | 64 | for (i = 0; i < 3; i++) shiftk[i] = (ng0[i] + 1) % 2; |
63 | 65 | } |
64 | 66 | else if (lshift == 1) { |
65 | - printf("k point grid starts from Gamma. \n"); | |
67 | + printf(" k point grid starts from Gamma. \n"); | |
66 | 68 | for (i = 0; i < 3; i++) shiftk[i] = 0; |
67 | 69 | } |
68 | 70 | else if (lshift == 2) { |
69 | - printf("k point grid starts from Gamma + a half grid. \n"); | |
71 | + printf(" k point grid starts from Gamma + a half grid. \n"); | |
70 | 72 | for (i = 0; i < 3; i++) shiftk[i] = 1; |
71 | 73 | } |
72 | 74 | else { |
@@ -77,7 +79,7 @@ void read_file(char *fname/**<[in] fname Input file name*/) | ||
77 | 79 | */ |
78 | 80 | ierr = fscanf(fp, "%d", &nb); |
79 | 81 | if (ierr == 0) printf("error ! reading nb"); |
80 | - printf("# of bands : %d \n", nb); | |
82 | + printf(" # of bands : %d\n", nb); | |
81 | 83 | ntri = (int*)malloc(nb * sizeof(int)); |
82 | 84 | ntri_th = (int**)malloc(nb * sizeof(int*)); |
83 | 85 | for (ib = 0; ib < nb; ib++) ntri_th[ib] = (int*)malloc(nthreads * sizeof(int)); |
@@ -90,7 +92,7 @@ void read_file(char *fname/**<[in] fname Input file name*/) | ||
90 | 92 | for (i = 0; i < 3; ++i) { |
91 | 93 | ierr = fscanf(fp, "%e%e%e", &bvec[i][0], &bvec[i][1], &bvec[i][2]); |
92 | 94 | if (ierr == 0) printf("error ! reading bvec"); |
93 | - printf("bvec %d : %f %f %f \n", i + 1, bvec[i][0], bvec[i][1], bvec[i][2]); | |
95 | + printf(" bvec %d : %f %f %f \n", i + 1, bvec[i][0], bvec[i][1], bvec[i][2]); | |
94 | 96 | } |
95 | 97 | /* |
96 | 98 | Allocation of Kohn-Sham energies $ matrix elements |