fermisurfer Git
Revision | 205e7cdf584b86951dbd592c3b733e67f804f264 (tree) |
---|---|
Zeit | 2018-01-06 00:10:06 |
Autor | mitsuaki1987 <kawamitsuaki@gmai...> |
Commiter | mitsuaki1987 |
Add batch mode
@@ -63,6 +63,7 @@ with a color-plot of the arbitraly matrix element | ||
63 | 63 | |
64 | 64 | #include <stdlib.h> |
65 | 65 | #include <stdio.h> |
66 | +#include <string.h> | |
66 | 67 | #include "variable.h" |
67 | 68 | #include "read_file.h" |
68 | 69 | #include "menu.h" |
@@ -101,6 +102,27 @@ void init(void) | ||
101 | 102 | FS_CreateMenu(); |
102 | 103 | } /* init */ |
103 | 104 | /** |
105 | + @brief Glut Display function | |
106 | + called by glutDisplayFunc | |
107 | +*/ | |
108 | +void timer(int it) | |
109 | +{ | |
110 | + int ibatch, ierr; | |
111 | + char command_name[256]; | |
112 | + | |
113 | + printf("\n Batch mode.\n"); | |
114 | + for (ibatch = 0; ibatch < nbatch; ibatch++) { | |
115 | + read_batch(batch_file[ibatch]); | |
116 | + refresh_patch_segment(); | |
117 | + //glutPostRedisplay(); | |
118 | + display(); | |
119 | + glFlush(); | |
120 | + sprintf(command_name, "import -window \"%s\" %s%d.png", window_name, window_name, ibatch); | |
121 | + ierr = system(command_name); | |
122 | + }/*for (ibatch = 0; ibatch < nbatch; ibatch++)*/ | |
123 | + exit(0); | |
124 | +} | |
125 | +/** | |
104 | 126 | @brief Main routine of FermiSurfer |
105 | 127 | |
106 | 128 | Refer: ::query |
@@ -112,6 +134,8 @@ int main( | ||
112 | 134 | char *argv[] //!< [in] Input file name |
113 | 135 | ) |
114 | 136 | { |
137 | + int ibatch; | |
138 | + | |
115 | 139 | printf("\n"); |
116 | 140 | printf("###########################################\n"); |
117 | 141 | printf("## ##\n"); |
@@ -119,6 +143,7 @@ int main( | ||
119 | 143 | printf("## ##\n"); |
120 | 144 | printf("###########################################\n"); |
121 | 145 | printf("\n"); |
146 | + nbatch = argc - 4; | |
122 | 147 | if (argc < 2) { |
123 | 148 | printf("\n"); |
124 | 149 | printf(" Input file is not specified !\n"); |
@@ -126,6 +151,14 @@ int main( | ||
126 | 151 | getchar(); |
127 | 152 | exit(-1); |
128 | 153 | } |
154 | + if (nbatch > 0) { | |
155 | + strcpy(window_name, argv[1]); | |
156 | + batch_file = (char**)malloc(sizeof(char*) * nbatch); | |
157 | + for (ibatch = 0; ibatch < nbatch; ibatch++) { | |
158 | + batch_file[ibatch] = (char*)malloc(sizeof(char) * 256); | |
159 | + strcpy(batch_file[ibatch], argv[4 + ibatch]); | |
160 | + } | |
161 | + } | |
129 | 162 | /**/ |
130 | 163 | #if defined(_OPENMP) |
131 | 164 | #pragma omp parallel |
@@ -166,6 +199,7 @@ int main( | ||
166 | 199 | printf("\n"); |
167 | 200 | /**/ |
168 | 201 | glutInit(&argc, argv); |
202 | + if (argc >= 4)glutInitWindowSize(atoi(argv[2]), atoi(argv[3])); | |
169 | 203 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); |
170 | 204 | glutCreateWindow(argv[1]); |
171 | 205 | glutDisplayFunc(display); |
@@ -175,6 +209,7 @@ int main( | ||
175 | 209 | glutKeyboardFunc(keyboard); |
176 | 210 | glutSpecialFunc(special_key); |
177 | 211 | glutMenuStateFunc(FS_ModifyMenu); |
212 | + if (nbatch > 0) glutTimerFunc(10, timer, 0); | |
178 | 213 | init(); |
179 | 214 | glutMainLoop(); |
180 | 215 | return 0; |
@@ -57,7 +57,7 @@ void compute_patch_segment() { | ||
57 | 57 | query = 0; equator(); |
58 | 58 | } |
59 | 59 | |
60 | -static void refresh_patch_segment() { | |
60 | +void refresh_patch_segment() { | |
61 | 61 | free_patch(); |
62 | 62 | compute_patch_segment(); |
63 | 63 | } |
@@ -25,3 +25,4 @@ THE SOFTWARE. | ||
25 | 25 | void compute_patch_segment(); |
26 | 26 | void FS_CreateMenu(); |
27 | 27 | void FS_ModifyMenu(int status); |
28 | +void refresh_patch_segment(); |
@@ -26,8 +26,17 @@ THE SOFTWARE. | ||
26 | 26 | */ |
27 | 27 | #include <stdlib.h> |
28 | 28 | #include <stdio.h> |
29 | +#include <math.h> | |
29 | 30 | #include "variable.h" |
30 | 31 | #include "basic_math.h" |
32 | +#if defined(HAVE_CONFIG_H) | |
33 | +#include <config.h> | |
34 | +#endif | |
35 | +#if defined(HAVE_GL_GLUT_H) | |
36 | +#include <GL/glut.h> | |
37 | +#elif defined(HAVE_GLUT_GLUT_H) | |
38 | +#include <GLUT/glut.h> | |
39 | +#endif | |
31 | 40 | /** |
32 | 41 | @brief Input from Fermi surface file |
33 | 42 | */ |
@@ -183,3 +192,58 @@ void read_file( | ||
183 | 192 | } |
184 | 193 | fclose(fp); |
185 | 194 | } /* read_file */ |
195 | + | |
196 | +void read_batch( | |
197 | + char *fname//!<[in] Input file name | |
198 | +) | |
199 | +{ | |
200 | + FILE *fp; | |
201 | + int ierr, ib; | |
202 | + | |
203 | + printf(" Openning batch file %s ...\n", fname); | |
204 | + if ((fp = fopen(fname, "r")) == NULL) { | |
205 | + printf("file open error!!\n"); | |
206 | + printf(" Press any key to exit.\n"); | |
207 | + getchar(); | |
208 | + exit(EXIT_FAILURE); | |
209 | + } | |
210 | + ierr = fscanf(fp, "%d", &blackback); | |
211 | + for (ib = 0; ib < nb; ib++) | |
212 | + ierr = fscanf(fp, "%d", &draw_band[ib]); | |
213 | + ierr = fscanf(fp, "%d", &lcolorbar); | |
214 | + ierr = fscanf(fp, "%d", &fcscl); | |
215 | + ierr = fscanf(fp, "%d", &lequator); | |
216 | + if (lequator == 1) | |
217 | + ierr = fscanf(fp, "%f %f %f", &eqvec[0], &eqvec[1], &eqvec[2]); | |
218 | + ierr = fscanf(fp, "%d", &interpol); | |
219 | + ierr = fscanf(fp, "%d", &lside); | |
220 | + ierr = fscanf(fp, "%f", &linewidth); | |
221 | + ierr = fscanf(fp, "%d", &nodeline); | |
222 | + ierr = fscanf(fp, "%d", &lsection); | |
223 | + if (lsection == 1) { | |
224 | + ierr = fscanf(fp, "%f", &secscale); | |
225 | + ierr = fscanf(fp, "%f %f %f", &secvec[0], &secvec[1], &secvec[2]); | |
226 | + } | |
227 | + ierr = fscanf(fp, "%f", &EF); | |
228 | + ierr = fscanf(fp, "%d", &lstereo); | |
229 | + ierr = fscanf(fp, "%f", &scl); | |
230 | + ierr = fscanf(fp, "%f %f %f", &trans[0], &trans[1], &trans[2]); | |
231 | + ierr = fscanf(fp, "%f %f %f", &thetax, &thetay, &thetaz); | |
232 | + fclose(fp); | |
233 | + if (blackback == 1) glClearColor(0.0, 0.0, 0.0, 0.0); | |
234 | + else glClearColor(1.0, 1.0, 1.0, 0.0); | |
235 | + | |
236 | + thetax = 3.14159265f / 180.0f * thetax; | |
237 | + thetay = 3.14159265f / 180.0f * thetay; | |
238 | + thetaz = 3.14159265f / 180.0f * thetaz; | |
239 | + | |
240 | + rot[0][0] = cosf(thetay)* cosf(thetaz); | |
241 | + rot[0][1] = -cosf(thetay)* sinf(thetaz); | |
242 | + rot[0][2] = sinf(thetay); | |
243 | + rot[1][0] = cosf(thetaz)* sinf(thetax)* sinf(thetay) + cosf(thetax)* sinf(thetaz); | |
244 | + rot[1][1] = cosf(thetax) * cosf(thetaz) - sinf(thetax)* sinf(thetay)* sinf(thetaz); | |
245 | + rot[1][2] = -cosf(thetay)* sinf(thetax); | |
246 | + rot[2][0] = -cosf(thetax)* cosf(thetaz)* sinf(thetay) + sinf(thetax)* sinf(thetaz); | |
247 | + rot[2][1] = cosf(thetaz)* sinf(thetax) + cosf(thetax)* sinf(thetay)* sinf(thetaz); | |
248 | + rot[2][2] = cosf(thetax)* cosf(thetay); | |
249 | +} |
@@ -23,3 +23,4 @@ THE SOFTWARE. | ||
23 | 23 | */ |
24 | 24 | |
25 | 25 | void read_file(char *fname/**<[in] fname Input file name*/); |
26 | +void read_batch(char *fname/**<[in] fname Input file name*/); |
@@ -170,3 +170,9 @@ enum | ||
170 | 170 | MOUSE_SCROLL_DOWN = 4 //!< Mouse wheel down |
171 | 171 | }; |
172 | 172 | int nthreads;//!< Number of OpenMP threads |
173 | +/* | |
174 | + Batch mode | |
175 | +*/ | |
176 | +int nbatch; | |
177 | +char **batch_file; | |
178 | +char window_name[256]; |