Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* IO_ADIOS1.cpp
*
* Created on: Feb 2017
* Author: Norbert Podhorszki
*/
#include <string>
#include <iostream>
#include <iomanip>
#include "IO.h"
#include "adios.h"
static int64_t group;
static int rank_saved;
IO::IO( std::shared_ptr<Settings> s, MPI_Comm comm )
{
rank_saved = s->rank;
m_outputfilename = s->outputfile + ".bp";
adios_init_noxml( comm );
adios_declare_group( &group, "heat", "", adios_stat_default );
adios_select_method( group, "MPI", "", "" );
adios_define_var( group, "gndx", "", adios_integer, "", "", "");
adios_define_var( group, "gndy", "", adios_integer, "", "", "");
std::string ldims( std::to_string( s->ndx ) + "," + std::to_string( s->ndy ));
std::string gdims( std::to_string( s->gndx ) + "," + std::to_string( s->gndy ));
std::string offs( std::to_string( s->offsx ) + "," + std::to_string( s->offsy ));
uint64_t T_id;
T_id = adios_define_var( group, "T", "", adios_double,
ldims.c_str(), gdims.c_str(), offs.c_str() );
adios_set_transform( T_id, "none");
//adios_set_transform( T_id, "zfp:accuracy=0.001");
}
IO::~IO()
{
adios_finalize(rank_saved);
}
void IO::write( int step, std::shared_ptr<HeatTransfer> ht, std::shared_ptr<Settings> s, MPI_Comm comm )
{
char mode[2] = "w";
if (step > 0)
{
mode[0] = 'a';
}
// for time measurements, let's synchronize the processes
MPI_Barrier( comm );
double time_start = MPI_Wtime();
int64_t f;
adios_open( &f, "heat", m_outputfilename.c_str(), mode, comm);
adios_write( f, "gndx", &s->gndx);
adios_write( f, "gndy", &s->gndy);
adios_write( f, "T", ht->data_noghost().data() );
adios_close( f );
MPI_Barrier( comm );
double total_time = MPI_Wtime() - time_start;
uint64_t adios_totalsize = 2*sizeof(int) + 2*s->ndx*s->ndy*sizeof(double);
uint64_t sizeMB = adios_totalsize * s->nproc/1024/1024/1024; // size in MB
uint64_t mbs = sizeMB/total_time;
if (s->rank==0)
std::cout << "Step " << step << ": " << m_outputfilename
<< " " << sizeMB << " " << total_time << "" << mbs << std::endl;
}