Skip to content

Commit d62974c

Browse files
committed
more rigourously handle compiler checks, especially for MPI
1 parent 8fec166 commit d62974c

File tree

7 files changed

+36
-20
lines changed

7 files changed

+36
-20
lines changed

.appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
image:
2-
# - Visual Studio 2017 CMake < 3.13
2+
- Visual Studio 2017
33
- ubuntu1804
44

55
environment:
66
MINGW_DIR: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin
7+
CMAKE_GENERATOR: "MinGW Makefiles"
78

89
clone_depth: 3
910

@@ -14,8 +15,7 @@ init:
1415
- sh: sudo apt install -yq --no-install-recommends libscalapack-openmpi-dev libopenmpi-dev openmpi-bin
1516

1617
install:
17-
- cmd: cmake -B build -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..
18-
- sh: cmake -B build
18+
- cmake -B build
1919

2020
- cmake --build build --parallel
2121

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.14)
22
if(NOT CMAKE_BUILD_TYPE)
33
set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug or Release")
44
endif()

coarray/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ if(NOT Coarray_FOUND)
1010
return()
1111
endif()
1212

13-
include(CheckFortranSourceCompiles)
13+
include(CheckFortranSourceRuns)
1414
set(CMAKE_REQUIRED_FLAGS ${Coarray_COMPILE_OPTIONS})
1515
set(CMAKE_REQUIRED_LIBRARIES ${Coarray_LIBRARY})
16-
check_fortran_source_compiles("real :: x[*]; call co_sum(x); end"
16+
check_fortran_source_runs("real :: x[*]; end"
17+
f08coarray SRC_EXT f90)
18+
if(NOT f08coarray)
19+
return()
20+
endif()
21+
check_fortran_source_runs("real :: x[*]; call co_sum(x); end"
1722
f18coarray SRC_EXT f90)
1823

1924

coarray/meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ if not coarray.found()
33
subdir_done()
44
endif
55

6-
f18coarray = fc.run('real :: x[*]; call co_sum(x); end', name: 'F2018 coarray').returncode() == 0
6+
# this needs to be "run" to verify no dll runtime issues, particularly on Windows.
7+
f18coarray = fc.run('real :: x[*]; call co_sum(x); end', dependencies: coarray, name: 'F2018 coarray').returncode() == 0
78

8-
hello = executable('coarray_hello', 'helloworld.f90', dependencies : coarray)
9+
hello = executable('coarray_hello', 'helloworld.f90',
10+
dependencies : coarray)
911
test('Coarray Hello', hello)
1012

1113

contiguous/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if fc.links('contig = is_contiguous(x); end', name: 'F2008 contiguous')
1+
if fc.links('contig = is_contiguous([1,2,3]); end', name: 'F2008 contiguous')
22
f08contig='-DISCONTIG'
33
else
44
f08contig=''

mpi/meson.build

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,29 @@ if not mpi.found()
44
subdir_done()
55
endif
66

7-
if not (fc.run('use mpi; end', name: 'MPI', dependencies : mpi).returncode() == 0)
7+
if fc.links('''
8+
use mpi
9+
integer :: i
10+
call mpi_init(i)
11+
call mpi_finalize(i)
12+
end''',
13+
dependencies : mpi,
14+
name: 'Fortran MPI links')
815
subdir_done()
916
endif
1017

11-
ver = executable('mpivers', 'mpivers.f90', dependencies : mpi)
18+
mpiexec = find_program('mpiexec') # MS-MPI has only mpiexec
19+
20+
ver = executable('mpivers', 'mpivers.f90',
21+
dependencies : mpi)
1222
test('MPI version check', ver)
1323

14-
hello = executable('mpi_hello', 'helloworld.f90', dependencies : mpi)
15-
test('MPI Hello World', hello)
24+
hello = executable('mpi_hello', 'helloworld.f90',
25+
dependencies : mpi)
26+
test('MPI Hello World', mpiexec,
27+
args: ['-np', '2', hello])
28+
1629

17-
mpirun = find_program('mpiexec') # MS-MPI has only mpiexec
1830
pass = executable('mpi_pass', 'thread_pass.f90', dependencies : mpi)
19-
test('MPI thread pass', mpirun, args: ['-np', '2', pass])
31+
test('MPI thread pass', mpiexec,
32+
args: ['-np', '2', pass])

mpi/thread_pass.f90

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
! Find out the number of processes available.
2323
call MPI_Comm_size ( MPI_COMM_WORLD, num_procs, ierr)
2424
if (ierr /= 0) error stop 'mpi size error'
25-
if (num_procs < 2) then
26-
write(stderr,*) 'ERROR: two threads are required, use:'
27-
write(stderr,*) 'mpiexec -np 2 ./mpi_pass'
28-
stop 1
29-
endif
25+
if (num_procs < 2) error stop 'two threads are required, use: mpiexec -np 2 ./mpi_pass'
3026

3127
! Have Process 0 say hello.
3228
if ( rank == 0 ) then

0 commit comments

Comments
 (0)