22 static const char _function_name[] =
"FieldIO_Binary_Distributed::read_file";
23 const std::string filename
25 filename_base.c_str(),
31 const int nin_field = u->
nin();
32 const int nex_field = u->
nex();
37 if ((nin_file == 0) || (nex_file == 0)) {
44 std::ifstream infile(filename.c_str(), std::ios::in | std::ios::binary);
56 const int block_size = nin_file;
57 char buf[
sizeof(double) * block_size];
59 for (
int j = 0; j < nex_file; ++j) {
60 for (
int isite = 0; isite < nvol; ++isite) {
62 infile.read(buf,
sizeof(
double) * block_size);
75 byte_swap(buf,
sizeof(
double), block_size);
78 double *ptr = (
double *)buf;
80 for (
int i = 0; i < nin_file; ++i) {
84 u->
set(s, isite, t, ptr[i]);
97 static const char _function_name[] =
"FieldIO_Binary_Distributed::write_file";
98 const std::string filename
100 filename_base.c_str(),
106 const int nin_field = u->
nin();
107 const int nex_field = u->
nex();
112 if ((nin_file == 0) || (nex_file == 0)) {
113 nin_file = nin_field;
114 nex_file = nex_field;
125 const int block_size = nin_file;
126 char buf[
sizeof(double) * block_size];
128 std::ofstream outfile(filename.c_str(), std::ios::out | std::ios::binary);
134 for (
int j = 0; j < nex_file; ++j) {
135 for (
int isite = 0; isite < nvol; ++isite) {
136 double *ptr = (
double *)buf;
138 for (
int i = 0; i < nin_file; ++i) {
142 ptr[i] = u->
cmp(s, isite, t);
146 byte_swap(buf,
sizeof(
double), block_size);
149 outfile.write(buf,
sizeof(
double) * block_size);
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)
Container of Field-type object.
double cmp(const int jin, const int site, const int jex) const
static int ipe(const int dir)
logical coordinate of current proc.
static bool is_bigendian()
void read_file(Field *v, const std::string filename)
read data from file.
std::string generate_filename(const char *fmt,...)
const IO_Format::Format * m_format
void crucial(const char *format,...)
void write_file(Field *v, const std::string filename)
write data to file.
static const std::string class_name
Bridge::VerboseLevel m_vl