@@ -2,22 +2,31 @@ program main
22
33use hdf5, only: H5T_STR_NULLPAD_F, H5T_STR_NULLTERM_F
44use h5mpi, only: hdf5_file
5+ use mpi, only : mpi_init, MPI_COMM_WORLD, mpi_comm_rank
56
67implicit none (type, external )
78
9+ external :: mpi_finalize
10+
811character (1000 ) :: pyp, vstr, fstr
912character (4 ), parameter :: smiley = " 😀" , wink = " 😉"
1013character (4 ) :: u1
1114
1215
13- integer :: i
16+ integer :: i, mpi_id, ierr
1417
1518type (hdf5_file) :: h
1619
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+
1726call get_command_argument(1 , pyp, status= i)
1827if (i/= 0 ) error stop " specify file to read"
1928
20- call h% open (pyp, " r" , mpi= .false . )
29+ call h% open (pyp, " r" , mpi= .true . )
2130
2231call h% read (" /variable" , vstr)
2332if (vstr /= " Hello World!" ) error stop " h5py read variable length failed: " // trim (vstr)
@@ -43,9 +52,11 @@ program main
4352print ' (a)' , " attribute: wink: " // u1
4453if (u1 /= wink) error stop " test_utf8:attr: wink failed"
4554
46-
4755call h% close ()
4856
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"
5061
5162end program
0 commit comments