Grid 0.7.0
IldgIOtypes.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/parallelIO/IldgIOtypes.h
6
7Copyright (C) 2015
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program; if not, write to the Free Software Foundation, Inc.,
2151 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23See the full license in the file "LICENSE" in the top level distribution
24directory
25*************************************************************************************/
26 /* END LEGAL */
27#ifndef GRID_ILDGTYPES_IO_H
28#define GRID_ILDGTYPES_IO_H
29
30#ifdef HAVE_LIME
31extern "C" { // for linkage
32#include "lime.h"
33}
34
36
38// Data representation of records that enter ILDG and SciDac formats
40
41#define GRID_FORMAT "grid-format"
42#define ILDG_FORMAT "ildg-format"
43#define ILDG_BINARY_DATA "ildg-binary-data"
44#define ILDG_DATA_LFN "ildg-data-lfn"
45#define SCIDAC_CHECKSUM "scidac-checksum"
46#define SCIDAC_PRIVATE_FILE_XML "scidac-private-file-xml"
47#define SCIDAC_FILE_XML "scidac-file-xml"
48#define SCIDAC_PRIVATE_RECORD_XML "scidac-private-record-xml"
49#define SCIDAC_RECORD_XML "scidac-record-xml"
50#define SCIDAC_BINARY_DATA "scidac-binary-data"
51// Unused SCIDAC records names; could move to support this functionality
52#define SCIDAC_SITELIST "scidac-sitelist"
53
55const int GRID_IO_SINGLEFILE = 0; // hardcode lift from QIO compat
56const int GRID_IO_MULTIFILE = 1; // hardcode lift from QIO compat
57const int GRID_IO_FIELD = 0; // hardcode lift from QIO compat
58const int GRID_IO_GLOBAL = 1; // hardcode lift from QIO compat
60
62// QIO uses mandatory "private" records fixed format
63// Private is in principle "opaque" however it can't be changed now because that would break existing
64// file compatability, so should be correct to assume the undocumented but defacto file structure.
66
67struct emptyUserRecord : Serializable {
68 GRID_SERIALIZABLE_CLASS_MEMBERS(emptyUserRecord,int,dummy);
69 emptyUserRecord() { dummy=0; };
70};
71
73// Scidac private file xml
74// <?xml version="1.0" encoding="UTF-8"?><scidacFile><version>1.1</version><spacetime>4</spacetime><dims>16 16 16 32 </dims><volfmt>0</volfmt></scidacFile>
76struct scidacFile : Serializable {
77public:
79 double, version,
80 int, spacetime,
81 std::string, dims, // must convert to int
82 int, volfmt);
83
84 std::vector<int> getDimensions(void) {
85 std::stringstream stream(dims);
86 std::vector<int> dimensions;
87 int n;
88 while(stream >> n){
89 dimensions.push_back(n);
90 }
91 return dimensions;
92 }
93
94 void setDimensions(Coordinate dimensions) {
95 char delimiter = ' ';
96 std::stringstream stream;
97 for(int i=0;i<dimensions.size();i++){
98 stream << dimensions[i];
99 if ( i != dimensions.size()-1) {
100 stream << delimiter <<std::endl;
101 }
102 }
103 dims = stream.str();
104 }
105
106 // Constructor provides Grid
107 scidacFile() =default; // default constructor
108 scidacFile(GridBase * grid){
109 version = 1.0;
110 spacetime = grid->_ndimension;
111 setDimensions(grid->FullDimensions());
112 volfmt = GRID_IO_SINGLEFILE;
113 }
114
115};
116
118// scidac-private-record-xml : example
119// <scidacRecord>
120// <version>1.1</version><date>Tue Jul 26 21:14:44 2011 UTC</date><recordtype>0</recordtype>
121// <datatype>QDP_D3_ColorMatrix</datatype><precision>D</precision><colors>3</colors><spins>4</spins>
122// <typesize>144</typesize><datacount>4</datacount>
123// </scidacRecord>
125
126struct scidacRecord : Serializable {
127public:
129 double, version,
130 std::string, date,
131 int, recordtype,
132 std::string, datatype,
133 std::string, precision,
134 int, colors,
135 int, spins,
136 int, typesize,
137 int, datacount);
138
139 scidacRecord()
140 : version(1.0), recordtype(0), colors(0), spins(0), typesize(0), datacount(0)
141 {}
142};
143
145// ILDG format
147struct ildgFormat : Serializable {
148public:
150 double, version,
151 std::string, field,
152 int, precision,
153 int, rows,
154 int, lx,
155 int, ly,
156 int, lz,
157 int, lt);
158 ildgFormat() { version=1.0; };
159};
161// USQCD info
163struct usqcdInfo : Serializable {
164public:
166 double, version,
167 double, plaq,
168 double, linktr,
169 std::string, info);
170 usqcdInfo() {
171 version=1.0;
172 };
173};
175// Scidac Checksum
177struct scidacChecksum : Serializable {
178public:
179 GRID_SERIALIZABLE_CLASS_MEMBERS(scidacChecksum,
180 double, version,
181 std::string, suma,
182 std::string, sumb);
183 scidacChecksum() {
184 version=1.0;
185 };
186};
188// Type: scidac-file-xml <title>MILC ILDG archival gauge configuration</title>
190
192// Type:
194
196// Scidac private file xml
197// <?xml version="1.0" encoding="UTF-8"?><scidacFile><version>1.1</version><spacetime>4</spacetime><dims>16 16 16 32 </dims><volfmt>0</volfmt></scidacFile>
199
200#if 0
202// From http://www.physics.utah.edu/~detar/scidac/qio_2p3.pdf
204struct usqcdPropFile : Serializable {
205public:
207 double, version,
208 std::string, type,
209 std::string, info);
210 usqcdPropFile() {
211 version=1.0;
212 };
213};
214struct usqcdSourceInfo : Serializable {
215public:
216 GRID_SERIALIZABLE_CLASS_MEMBERS(usqcdSourceInfo,
217 double, version,
218 std::string, info);
219 usqcdSourceInfo() {
220 version=1.0;
221 };
222};
223struct usqcdPropInfo : Serializable {
224public:
226 double, version,
227 int, spin,
228 int, color,
229 std::string, info);
230 usqcdPropInfo() {
231 version=1.0;
232 };
233};
234#endif
235
237#endif
238#endif
AcceleratorVector< int, MaxDims > Coordinate
Definition Coordinate.h:95
#define GRID_SERIALIZABLE_CLASS_MEMBERS(cname,...)
Definition MacroMagic.h:116
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
accelerator_inline size_type size(void) const
Definition Coordinate.h:52
const Coordinate & FullDimensions(void)