forked from milc-qcd/milc_qcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgauge_info.c
118 lines (90 loc) · 3.4 KB
/
gauge_info.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
/*********************** gauge_info.c *************************/
/* MIMD version 7 */
/* For heavy */
/* Application-dependent routine for writing gauge info file */
/* This file is an ASCII companion to the gauge configuration file
and contains information about the action used to generate it.
This information is consistently written in the pattern
keyword value
or
keyword[n] value1 value2 ... valuen
where n is an integer.
To maintain a semblance of consistency, the possible keywords are
listed in io_lat.h. Add more as the need arises, but be sure
to notify the rest of the collaboration.
*/
#include "w_heavy_includes.h"
#include <string.h>
/*---------------------------------------------------------------------------*/
/* This routine writes the ASCII info file. It is called from one of
the lattice output routines in io_lat4.c.*/
void write_appl_gauge_info(FILE *fp, gauge_file *gf)
{
Real gauge_fix_tol = GAUGE_FIX_TOL;
/* Write generic information */
write_generic_gauge_info(fp, gf);
/* The rest are optional */
if(fixflag==COULOMB_GAUGE_FIX)
{
write_w_prop_info_item(fp,"gauge.fix.description","%s",
"\"Coulomb\"",0,0);
write_w_prop_info_item(fp,"gauge.fix.tolerance","%g",
(char *)&gauge_fix_tol,0,0);
}
}
#define INFOSTRING_MAX 2048
/* Follow USQCD style for record XML */
char *create_QCDML(){
size_t bytes = 0;
char *info = (char *)malloc(INFOSTRING_MAX);
size_t max = INFOSTRING_MAX;
char begin[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><usqcdInfo><version>1.0</version>";
char begin_info[] = "<info>";
char end_info[] = "</info>";
char end[] = "</usqcdInfo>";
Real myssplaq = g_ssplaq; /* Precision conversion */
Real mystplaq = g_stplaq; /* Precision conversion */
Real nersc_linktr = linktrsum.real/3.; /* Convention and precision */
Real gauge_fix_tol = GAUGE_FIX_TOL;
char sums[20];
snprintf(info+bytes, max-bytes,"%s",begin);
bytes = strlen(info);
snprintf(info+bytes, max-bytes,"<plaq>%e</plaq>",(myssplaq+mystplaq)/6.);
bytes = strlen(info);
snprintf(info+bytes, max-bytes,"<linktr>%e</linktr>",nersc_linktr);
bytes = strlen(info);
snprintf(info+bytes, max-bytes,"%s",begin_info);
bytes = strlen(info);
/* The rest are optional */
if(startlat_p != NULL)
{
/* To retain some info about the original (or previous)
configuration */
bytes = strlen(info);
sprint_gauge_info_item(info+bytes, max-bytes,"gauge.previous.filename",
"%s", startlat_p->filename,0,0);
bytes = strlen(info);
sprint_gauge_info_item(info+bytes, max-bytes,"gauge.previous.time_stamp",
"%s", startlat_p->header->time_stamp,0,0);
sprintf(sums,"%x %x",startlat_p->check.sum29,startlat_p->check.sum31);
bytes = strlen(info);
sprint_gauge_info_item(info+bytes, max-bytes,"gauge.previous.checksums",
"%s", sums,0,0);
}
if(fixflag==COULOMB_GAUGE_FIX)
{
bytes = strlen(info);
sprint_gauge_info_item(info+bytes, max-bytes,"gauge.fix.description",
"%s", "Coulomb",0,0);
bytes = strlen(info);
sprint_gauge_info_item(info+bytes, max-bytes,"gauge.fix.tolerance",
"%g", (char *)&gauge_fix_tol,0,0);
}
snprintf(info+bytes, max-bytes,"%s",end_info);
bytes = strlen(info);
snprintf(info+bytes, max-bytes,"%s",end);
return info;
}
void free_QCDML(char *info){
if(info != NULL)free(info);
}