Skip to content

Commit a0fff40

Browse files
committed
test: use mpi calls
1 parent 353c369 commit a0fff40

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

test/test_string_read.f90

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@ program main
22

33
use hdf5, only: H5T_STR_NULLPAD_F, H5T_STR_NULLTERM_F
44
use h5mpi, only: hdf5_file
5+
use mpi, only : mpi_init, MPI_COMM_WORLD, mpi_comm_rank
56

67
implicit none (type, external)
78

9+
external :: mpi_finalize
10+
811
character(1000) :: pyp, vstr, fstr
912
character(4), parameter :: smiley = "😀", wink = "😉"
1013
character(4) :: u1
1114

1215

13-
integer :: i
16+
integer :: i, mpi_id, ierr
1417

1518
type(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+
1726
call get_command_argument(1, pyp, status=i)
1827
if (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

2231
call h%read("/variable", vstr)
2332
if(vstr /= "Hello World!") error stop "h5py read variable length failed: " // trim(vstr)
@@ -43,9 +52,11 @@ program main
4352
print '(a)', "attribute: wink: " // u1
4453
if(u1 /= wink) error stop "test_utf8:attr: wink failed"
4554

46-
4755
call 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

5162
end program

test/test_write.f90

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,28 @@ program test_scalar
33
use, intrinsic :: iso_fortran_env, only : real32, real64, int32
44

55
use h5mpi, only : hdf5_file
6+
use mpi, only : mpi_init, MPI_COMM_WORLD, mpi_comm_rank
67

78
implicit none (type, external)
89

10+
external :: mpi_finalize
11+
12+
integer :: ierr, mpi_id
13+
14+
call mpi_init(ierr)
15+
if (ierr /= 0) error stop "mpi_init"
16+
17+
call mpi_comm_rank(MPI_COMM_WORLD, mpi_id, ierr)
18+
if (ierr /= 0) error stop "mpi_comm_rank"
19+
920
call test_simple_write('test_write.h5')
10-
print *, "OK: test simple write"
21+
if(mpi_id == 0) print *, "OK: test simple write"
1122

1223
call test_layout_write('test_layout.h5')
13-
print *, "OK: test layout write"
24+
if(mpi_id == 0) print *, "OK: test layout write"
25+
26+
call mpi_finalize(ierr)
27+
if (ierr /= 0) error stop "mpi_finalize"
1428

1529

1630
contains

0 commit comments

Comments
 (0)