Skip to content
Snippets Groups Projects
Commit e51ced3e authored by Ruonan Wang's avatar Ruonan Wang
Browse files

overloaded printData() in heatTransfer read example to accept both size_t and uint64_t

parent bbdd0841
No related branches found
No related tags found
1 merge request!223fixed a size_t / uint64_t problem for macOS 10.12 and Clang 8.1.0
......@@ -52,3 +52,42 @@ void printData(double *xy, size_t *size, size_t *offset, int rank, int steps)
}
myfile.close();
}
void printData(double *xy, uint64_t *size, uint64_t *offset, int rank,
int steps)
{
std::ofstream myfile;
std::string filename = "data." + std::to_string(rank);
myfile.open(filename);
double *data = xy;
uint64_t nelems = size[0] * size[1];
for (int step = 0; step < steps; step++)
{
myfile << "rank=" << rank << " size=" << size[0] << "x" << size[1]
<< " offsets=" << offset[0] << ":" << offset[1]
<< " step=" << step << std::endl;
myfile << " time row columns " << offset[1] << "..."
<< offset[1] + size[1] - 1 << std::endl;
myfile << " ";
for (int j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << offset[1] + j;
}
myfile << std::endl;
myfile << "------------------------------------------------------------"
"--\n";
for (int i = 0; i < size[0]; i++)
{
myfile << std::setw(5) << step << std::setw(5) << offset[0] + i;
for (int j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << std::setprecision(2)
<< data[i * size[1] + j];
}
myfile << std::endl;
}
data += nelems;
}
myfile.close();
}
......@@ -14,5 +14,7 @@
#include <cstdint>
void printData(double *xy, size_t *size, size_t *offset, int rank, int steps);
void printData(double *xy, uint64_t *size, uint64_t *offset, int rank,
int steps);
#endif /* PRINTDATA_H_ */
......@@ -69,8 +69,6 @@ int main(int argc, char *argv[])
// 1D decomposition of the columns, which is inefficient for reading!
uint64_t readsize[2] = {gndx, gndy / nproc};
uint64_t offset[2] = {0LL, rank * readsize[1]};
size_t readsize_size_t[2] = {gndx, gndy / nproc};
size_t offset_size_t[2] = {0LL, rank * readsize[1]};
if (rank == nproc - 1)
{
// last process should read all the rest of columns
......@@ -92,7 +90,7 @@ int main(int argc, char *argv[])
adios_schedule_read(f, sel, "T", 0, vT->nsteps, T);
adios_perform_reads(f, 1);
printData(T, readsize_size_t, offset_size_t, rank, vT->nsteps);
printData(T, readsize, offset, rank, vT->nsteps);
adios_read_close(f);
adios_free_varinfo(vT);
delete[] T;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment