-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
95 lines (87 loc) · 2.14 KB
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <parser.h>
#include <defs.h>
#include <spinors.h>
#include <gauge_fields.h>
#include <random_gauge_field.h>
#include <lattice.h>
#include <plaquette.h>
#include <dslash.h>
#define MAX_STRING 256
enum {
CONF_READ,
CONF_RAND
} conf_type;
void
usage(char *argv[])
{
fprintf(stderr, "Usage: %s PARAM_FILE\n", argv[0]);
return;
}
int
main(int argc, char *argv[])
{
/* check and parse command line arguments */
if(argc != 2) {
usage(argv);
exit(1);
}
/* parse parameter (input) file */
parser_init(argv[1]);
int dim[ND];
if(sscanf(parser_parse("Dimensions"), "%d %d %d %d", dim, dim+1, dim+2, dim+3)!=ND) {
fprintf(stderr, "error parsing for %s\n", "Dimensions");
exit(1);
}
char aux_str[MAX_STRING];
if(sscanf(parser_parse("Configuration"), "%s", aux_str)!=1) {
fprintf(stderr, "error parsing for %s\n", "Configuration");
exit(1);
}
if(strcmp(aux_str, "read")==0) {
conf_type = CONF_READ;
} else if(strcmp(aux_str, "random")==0) {
conf_type = CONF_RAND;
} else {
fprintf(stderr, "\"Configuration\" parameter should be one of: ");
fprintf(stderr, "%s, ", "read");
fprintf(stderr, "%s\n", "random");
exit(1);
}
char config_name[MAX_STRING];
switch(conf_type) {
case CONF_RAND:
break;
case CONF_READ:
if(sscanf(parser_parse("Configuration file name"), "%s", config_name)!=1) {
fprintf(stderr, "error parsing for %s\n", "Configuration file name");
exit(1);
}
break;
}
parser_finalize();
lattice *lat = new_lattice(dim);
gauge_field_dp *U = new_gauge_field_dp(lat);
spinor_field_dp *psi0 = new_spinor_field_dp(lat);
spinor_field_dp *psi1 = new_spinor_field_dp(lat);
double mass = 0.01;
switch(conf_type) {
case CONF_RAND:
random_gauge_field_dp(U);
break;
case CONF_READ:
random_gauge_field_dp(U);
break;
}
printf(" Plaquette = %lf\n", plaquette_dp(U));
dslash_init_dp(lat);
dslash_dp(psi1, psi0, U, mass);
dslash_finalize_dp();
del_lattice(lat);
del_spinor_field_dp(psi0);
del_spinor_field_dp(psi1);
del_gauge_field_dp(U);
return 0;
}