Skip to content

Commit 5f70070

Browse files
committed
correct example linking MPI
1 parent 8925424 commit 5f70070

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Examples/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
cmake_minimum_required(VERSION 3.20...3.22)
22

33
project(h5mpiExample
4-
LANGUAGES Fortran
4+
LANGUAGES C Fortran
55
)
66

77
enable_testing()
88

9+
find_package(MPI COMPONENTS C Fortran REQUIRED)
910
find_package(h5mpi CONFIG REQUIRED)
1011

1112
# --- example 1
1213
add_executable(example1 example1.f90)
13-
target_link_libraries(example1 h5mpi::h5mpi)
14+
target_link_libraries(example1 h5mpi::h5mpi MPI::MPI_Fortran MPI::MPI_C)
1415

1516
add_test(NAME Example1
1617
COMMAND $<TARGET_FILE:example1>

Examples/example1.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
program example2
22

3-
use, intrinsic :: iso_fortran_env, only : real32
3+
use, intrinsic :: iso_fortran_env, only : real32, int32
44

5-
use mpi, only : mpi_init, mpi_finalize
5+
use mpi, only : mpi_init, MPI_COMM_WORLD, mpi_comm_rank, mpi_comm_size
66

77
use h5mpi, only : hdf5_file, HSIZE_T
88

99
implicit none (type, external)
1010

11+
external :: mpi_finalize
12+
1113
character(*), parameter :: filename = 'example1.h5'
12-
integer :: ierr, mpi_id, Nmpi
14+
integer(int32) :: ierr, mpi_id, Nmpi, i32
1315

1416
type(hdf5_file) :: h5f
1517

0 commit comments

Comments
 (0)