Go to the documentation of this file.
26 const int nin_field = v.
nin();
27 const int nex_field = v.
nex();
32 if ((nin_file == 0) || (nex_file == 0)) {
38 const long_t size = nin_file * Lvol * nex_file;
45 vtmp.
reset(nin_field, Lvol, nex_field);
48 infile.open(filename.c_str(), std::ios::in | std::ios::binary);
54 bool do_byteswap =
false;
62 infile.read((
char *)&flen,
sizeof(uint32_t) * 1);
69 if (flen ==
sizeof(
double) * size) {
73 uint32_t flen_s = flen;
74 byte_swap(&flen_s,
sizeof(uint32_t), 1);
76 if (flen_s ==
sizeof(
double) * size) {
87 const int block_size = nin_file;
88 char buf[
sizeof(double) * block_size];
90 for (
int j = 0; j < nex_file; ++j) {
91 for (long_t isite = 0; isite < Lvol; ++isite) {
93 infile.read(buf,
sizeof(
double) * block_size);
106 byte_swap(buf,
sizeof(
double), block_size);
109 double *ptr = (
double *)buf;
111 for (
int i = 0; i < nin_file; ++i) {
115 vtmp.
set(s, isite, t, ptr[i]);
122 infile.read((
char *)&ftail,
sizeof(uint32_t) * 1);
145 const int nin_field = v.
nin();
146 const int nex_field = v.
nex();
151 if ((nin_file == 0) || (nex_file == 0)) {
152 nin_file = nin_field;
153 nex_file = nex_field;
160 vtmp.
reset(nin_field, Lvol, nex_field);
163 const size_t count = nin_file * Lvol * nex_file;
170 std::ofstream outfile(filename.c_str(), std::ios::out | std::ios::binary);
176 const uint32_t flen =
sizeof(double) * count;
179 outfile.write((
char *)&flen,
sizeof(uint32_t) * 1);
182 vout.
crucial(
m_vl,
"Error at %s: io error. write record header failed.\n", __func__);
187 const int block_size = nin_file;
188 char buf[
sizeof(double) * block_size];
191 for (
int j = 0; j < nex_file; ++j) {
192 for (long_t isite = 0; isite < Lvol; ++isite) {
193 double *ptr = (
double *)buf;
195 for (
int i = 0; i < nin_file; ++i) {
199 ptr[i] = vtmp.
cmp(s, isite, t);
202 outfile.write(buf,
sizeof(
double) * block_size);
212 outfile.write((
char *)&flen,
sizeof(uint32_t) * 1);
215 vout.
crucial(
m_vl,
"Error at %s: write record footer failed.\n", __func__);
void read_file(Field &v, const std::string &filename)
read data from file. (‘const’ is added [18 Mar 2021])
void set(const int jin, const int site, const int jex, double v)
void detailed(const char *format,...)
Bridge::VerboseLevel m_vl
void gather(Field *vglobal, Field *vlocal)
gather data on parallel nodes to primary node.
void deliver(Field *vlocal, Field *vglobal)
distribute data on primary node over parallel nodes.
static void abort()
terminate communicator
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
void write_file(Field &v, const std::string &filename)
write data to file. (‘const’ is added [18 Mar 2021])
double cmp(const int jin, const int site, const int jex) const
static bool is_primary()
check if the present node is primary in small communicator.
void crucial(const char *format,...)
static const std::string class_name
Container of Field-type object.
const IO_Format::Format * m_format