-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.c
57 lines (43 loc) · 1.29 KB
/
Main.c
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
import LXJ_HDF5;
#include "mpi.h"
#include "hdf5.h"
import <cstdlib>;
import <iostream>;
using namespace std;
int main(int argc, char **argv)
{
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Init(&argc, &argv);
int mpi_rank,mpi_size;
MPI_Comm_rank(comm, &mpi_rank);
MPI_Comm_size(comm, &mpi_size);
double* data = new double[10];
for (int i=0; i < 10; i++) {
data[i] = mpi_rank + i;
};
char* file = "SDS_row.h5";
char* dset = "IntArray";
char* group_name = "TestGroup";
int size[2] {8,5};
int rank {2};
hid_t file_id = H5CPPopen(file,'w',comm);
hid_t group_id = H5Gcreate(file_id,group_name,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
H5CPPsave(group_id,dset,data,size,rank,comm);
H5Gclose(group_id);
H5CPPclose(file_id);
double* data_out = new double[10];
for (int i=0; i < 10; i++) {
data[i] = mpi_rank + i;
};
file_id = H5CPPopen(file,'r',comm);
group_id = H5Gopen(file_id,group_name,H5P_DEFAULT);
H5CPPload(group_id,dset,data_out,comm);
H5Gclose(group_id);
H5CPPclose(file_id);
for (int i=0; i<10; i++) {cout<<data[i]<<" ";};
cout<<"\t>> IN "<<endl;
for (int i=0; i<10; i++) {cout<<data_out[i]<<" ";};
cout<<"\t<< OUT "<<endl;
delete(data);
MPI_Finalize();
}