@@ -2,22 +2,31 @@ program main
2
2
3
3
use hdf5, only: H5T_STR_NULLPAD_F, H5T_STR_NULLTERM_F
4
4
use h5mpi, only: hdf5_file
5
+ use mpi, only : mpi_init, MPI_COMM_WORLD, mpi_comm_rank
5
6
6
7
implicit none (type, external )
7
8
9
+ external :: mpi_finalize
10
+
8
11
character (1000 ) :: pyp, vstr, fstr
9
12
character (4 ), parameter :: smiley = " 😀" , wink = " 😉"
10
13
character (4 ) :: u1
11
14
12
15
13
- integer :: i
16
+ integer :: i, mpi_id, ierr
14
17
15
18
type (hdf5_file) :: h
16
19
20
+ call mpi_init(ierr)
21
+ if (ierr /= 0 ) error stop " mpi_init"
22
+
23
+ call mpi_comm_rank(MPI_COMM_WORLD, mpi_id, ierr)
24
+ if (ierr/= 0 ) error stop " mpi_comm_rank"
25
+
17
26
call get_command_argument(1 , pyp, status= i)
18
27
if (i/= 0 ) error stop " specify file to read"
19
28
20
- call h% open (pyp, " r" , mpi= .false . )
29
+ call h% open (pyp, " r" , mpi= .true . )
21
30
22
31
call h% read (" /variable" , vstr)
23
32
if (vstr /= " Hello World!" ) error stop " h5py read variable length failed: " // trim (vstr)
@@ -43,9 +52,11 @@ program main
43
52
print ' (a)' , " attribute: wink: " // u1
44
53
if (u1 /= wink) error stop " test_utf8:attr: wink failed"
45
54
46
-
47
55
call h% close ()
48
56
49
- print * , " OK: variable/nullpad length string read"
57
+ if (mpi_id == 0 ) print * , " OK: variable/nullpad length string read"
58
+
59
+ call mpi_finalize(ierr)
60
+ if (ierr /= 0 ) error stop " mpi_finalize"
50
61
51
62
end program
0 commit comments