31 int nin_field = v->
nin();
32 int nex_field = v->
nex();
37 if ((nin_file == 0) || (nex_file == 0)) {
44 int size = nin_file * Lvol * nex_file;
51 vtmp.
reset(nin_field, Lvol, nex_field);
54 infile.open(filename.c_str(), std::ios::in | std::ios::binary);
56 vout.
crucial(
m_vl,
"file open failure: %s may not exist.\n", filename.c_str());
60 bool do_byteswap =
false;
68 infile.read((
char *)&flen,
sizeof(uint32_t) * 1);
75 if (flen ==
sizeof(
double) * size) {
79 uint32_t flen_s = flen;
82 if (flen_s ==
sizeof(
double) * size) {
93 const int block_size = nin_file;
94 char buf[
sizeof(double) * block_size];
96 for (
int j = 0; j < nex_file; ++j) {
97 for (
int isite = 0; isite < Lvol; ++isite) {
99 infile.read(buf,
sizeof(
double) * block_size);
111 byte_swap(buf,
sizeof(
double), block_size);
114 double *ptr = (
double *)buf;
116 for (
int i = 0; i < nin_file; ++i) {
120 vtmp.
set(s, isite, t, ptr[i]);
127 infile.read((
char *)&ftail,
sizeof(uint32_t) * 1);
150 int nin_field = v->
nin();
151 int nex_field = v->
nex();
156 if ((nin_file == 0) || (nex_file == 0)) {
157 nin_file = nin_field;
158 nex_file = nex_field;
165 vtmp.
reset(nin_field, Lvol, nex_field);
168 size_t count = nin_file * Lvol * nex_file;
175 std::ofstream outfile(filename.c_str(), std::ios::out | std::ios::binary);
181 uint32_t flen =
sizeof(double) * count;
184 outfile.write((
char *)&flen,
sizeof(uint32_t) * 1);
187 vout.
crucial(
m_vl,
"%s: io error. write record header failed.\n", __func__);
192 const int block_size = nin_file;
193 char buf[
sizeof(double) * block_size];
196 for (
int j = 0; j < nex_file; ++j) {
197 for (
int isite = 0; isite < Lvol; ++isite) {
198 double *ptr = (
double *)buf;
200 for (
int i = 0; i < nin_file; ++i) {
204 ptr[i] = vtmp.
cmp(s, isite, t);
207 outfile.write(buf,
sizeof(
double) * block_size);
217 outfile.write((
char *)&flen,
sizeof(uint32_t) * 1);
220 vout.
crucial(
m_vl,
"%s: io error. write record footer failed.\n", __func__);
static void byte_swap(void *buf, size_t size, size_t nmemb)
< convert byte order. alternative interface.
void detailed(const char *format,...)
void set(const int jin, const int site, const int jex, double v)
void deliver(Field *vlocal, Field *vglobal)
distribute data on primary node over parallel nodes.
Container of Field-type object.
double cmp(const int jin, const int site, const int jex) const
void read_file(Field *v, std::string filename)
read data from file.
static const std::string class_name
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
const IO_Format::Format * m_format
void crucial(const char *format,...)
void write_file(Field *v, std::string filename)
write data to file.
static bool is_primary()
check if the present node is primary in small communicator.
void gather(Field *vglobal, Field *vlocal)
gather data on parallel nodes to primary node.
Bridge::VerboseLevel m_vl