Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meson: move find/capability logic to cmake/meson.build
- Loading branch information
Showing
22 changed files
with
206 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
ackermann = executable('ackermann', 'ackermann.f90') | ||
test('Ackermann', ackermann, args : ['2','3'], timeout: 10) | ||
test('Ackermann', ackermann, args : ['2','3'], | ||
timeout: 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
f08block = fc.links('block; end block; end', name : 'F2008 block') | ||
|
||
if f08block | ||
block_exe = executable('block', 'block.f90') | ||
test('block', block_exe, timeout: 10) | ||
test('block', block_exe, | ||
timeout: 10) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
ascii = executable('ascii', 'ascii.f90') | ||
test('Ascii Special', ascii) | ||
test('Ascii Special', ascii, | ||
timeout: 10) | ||
|
||
split = executable('split', 'split_string.f90') | ||
test('Split Character', split) | ||
test('Split Character', split, | ||
timeout: 10) | ||
|
||
printorwrite = executable('printorwrite', 'print_vs_write.f90') | ||
test('UTF8', printorwrite) | ||
test('UTF8', printorwrite, | ||
timeout: 10) | ||
|
||
str2int = executable('str2int', 'str2int.f90') | ||
test('Str2Int', str2int) | ||
test('Str2Int', str2int, | ||
timeout: 10) | ||
|
||
special_char = executable('special_char', 'special_characters.f90') | ||
test('Special Characters', special_char) | ||
test('Special Characters', special_char, | ||
timeout: 10) | ||
|
||
charlen = executable('charlen', 'charlen.f90') | ||
test('Character Len', charlen) | ||
test('Character Len', charlen, | ||
timeout: 10) | ||
|
||
if os != 'windows' | ||
overwrite_stdout = executable('overwrite_stdout', 'overwrite_stdout.f90') | ||
test('Overwrite Stdout', overwrite_stdout, timeout: 6) | ||
test('Overwrite Stdout', overwrite_stdout, timeout: 10) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
fc = meson.get_compiler('fortran') | ||
f18flag = fc.first_supported_argument(['-std=f2018', '-stand f18', '/stand:f18']) | ||
impnone = fc.first_supported_argument(['-fimplicit-none', '-warn declarations', '/warn:declarations', '-Mdclchk']) | ||
oldargs = fc.first_supported_argument(['-w', '-nowarn', '/nowarn']) | ||
|
||
if fc.get_id() == 'gcc' | ||
add_global_arguments('-Wextra', '-Wpedantic', f18flag, impnone, language : 'fortran') | ||
oldargs += '-std=legacy' | ||
elif fc.get_id() == 'intel' | ||
add_global_arguments(f18flag, impnone, '-heap-arrays', language: 'fortran') | ||
elif fc.get_id() == 'intel-cl' | ||
# /fpp allows #include etc preprocessor lines | ||
# /heap-arrays necessary to avoid segfault | ||
add_global_arguments(f18flag, impnone, '/fpp', '/heap-arrays', language: 'fortran') | ||
elif fc.get_id() == 'pgi' | ||
add_global_arguments('-C', impnone, language: 'fortran') | ||
elif fc.get_id() == 'flang' | ||
add_global_arguments('-W', language: 'fortran') | ||
endif | ||
|
||
os = host_machine.system() | ||
|
||
# -- compiler capabilities | ||
|
||
f18errorstop = fc.links('character :: b; error stop b; end', name: 'F2018 error stop') | ||
f08block = fc.links('block; end block; end', name : 'F2008 block') | ||
f08contig = fc.links('contig = is_contiguous([1,2,3]); end', name: 'F2008 contiguous') | ||
f08command = fc.links('integer foo; call execute_command_line(" ", exitstat=foo); end', name : 'F2008 execute_command_line') | ||
f18random = fc.links('call random_init(.false., .false.); end', name:'F2018 random_init') | ||
|
||
code = ''' | ||
use, intrinsic:: iso_fortran_env, only: real128 | ||
use, intrinsic:: ieee_arithmetic, only: ieee_is_nan | ||
if (huge(0._real128) /= 1.18973149535723176508575932662800702E+4932_real128) stop 1 | ||
end program''' | ||
f08kind = fc.links(code, name: 'F2008 ieee kinds') | ||
f18prop = fc.links('complex :: z; print *,z%re,z%im,z%kind; end', name: 'F2018 properties') | ||
# -- Fortran coarray | ||
|
||
coarray = dependency('coarray', required : false, disabler: true) | ||
# must be "run" in case of broken MPI library that only shows up on run. | ||
if not (fc.run('sync all; end', dependencies: coarray, name:'Coarray').returncode() == 0) | ||
coarray = disabler() | ||
endif | ||
|
||
f18coarray = fc.run('real :: x[*]; call co_sum(x); sync all; end', dependencies: coarray, name: 'F2018 coarray').returncode() == 0 | ||
|
||
|
||
# -- MPI | ||
|
||
mpi = dependency('mpi', language : 'fortran', required : false, disabler: true) | ||
code = ''' | ||
use mpi | ||
integer :: i | ||
call mpi_init(i) | ||
call mpi_finalize(i) | ||
end program''' | ||
if not fc.links(code, | ||
dependencies : mpi, | ||
name: 'Fortran MPI links') | ||
mpi = disabler() | ||
endif | ||
|
||
mpiexec = find_program('mpiexec', required : false, disabler: true) # MS-MPI has only mpiexec | ||
|
||
# -- HDF5 | ||
|
||
hdf5 = dependency('hdf5', language : 'fortran', required : false, disabler: true) | ||
|
||
if hdf5.found() and not fc.links('use h5lt; end', name: 'HDF5', dependencies : hdf5) | ||
hdf5 = disabler() | ||
endif | ||
|
||
# -- NetCDF | ||
# apt install libnetcdf-dev libnetcdff-dev # need BOTH installed | ||
|
||
# when using CMake, need to capitalize module name like in CMake | ||
netcdf = dependency('NetCDF', required : false, disabler: true, | ||
cmake_module_path : meson.source_root() / 'cmake/Modules') | ||
|
||
if netcdf.found() and not fc.links('use netcdf; end', name: 'NetCDF', dependencies : netcdf) | ||
netcdf = disabler() | ||
endif | ||
|
||
# --- Lapack | ||
lapack = dependency('lapack', required: false, disabler: true) | ||
|
||
# --- Scalapack | ||
# dependency('scalapack') not yet working in Meson | ||
# scalapack = dependency('scalapack', cmake_module_path : 'cmake/Modules', required: false, disabler: true) | ||
scalapack = fc.find_library('scalapack-openmpi', required: false, disabler: true) | ||
if not scalapack.found() | ||
scalapack = fc.find_library('scalapack', required: false, disabler: true) | ||
endif | ||
|
||
# --- MUMPS | ||
# mumps = dependency('mumps', required: false, disabler: true) | ||
if os == 'linux' | ||
mumpsinc = '/usr/include' | ||
else | ||
mumpsinc = '' | ||
endif | ||
mumpslib = fc.find_library('dmumps', required : false, disabler: true) | ||
mumps = declare_dependency(include_directories: mumpsinc, dependencies: mumpslib) | ||
|
||
# -- OpenMP | ||
openmp = dependency('openmp', language : 'fortran', required : false, disabler: true) | ||
|
||
if openmp.found() and not fc.links('use omp_lib; rate = omp_get_wtick(); end', name: 'OpenMP', dependencies : openmp) | ||
openmp = disabler() | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
coarray = dependency('coarray', required : false) | ||
|
||
if not (fc.run('sync all; end', dependencies: coarray, name:'Coarray runs').returncode() == 0) | ||
coarray = disabler() | ||
endif | ||
|
||
# this needs to be "run" to verify no dll runtime issues, particularly on Windows. | ||
f18coarray = fc.run('real :: x[*]; call co_sum(x); sync all; end', dependencies: coarray, name: 'F2018 coarray').returncode() == 0 | ||
|
||
hello = executable('coarray_hello', 'helloworld.f90', | ||
dependencies : coarray) | ||
test('Coarray Hello', hello, timeout: 20, is_parallel : false) | ||
test('Coarray Hello', hello, | ||
timeout: 20, | ||
is_parallel : false) | ||
|
||
pi_src = f18coarray ? 'pi.f90' : 'pi2008.f90' | ||
|
||
# Intel >= 20 supports Fortran 2018 co_sum | ||
if f18coarray | ||
pi = executable('coarray_pi', 'pi.f90', dependencies : coarray) | ||
else | ||
pi = executable('coarray_pi', 'pi2008.f90', dependencies : coarray) | ||
endif | ||
pi = executable('coarray_pi', pi_src, | ||
dependencies : coarray) | ||
|
||
test('Coarray Pi', pi, timeout: 20, is_parallel : false) | ||
test('Coarray Pi', pi, | ||
timeout: 20, | ||
is_parallel : false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
|
||
if fc.get_id() == 'gcc' | ||
boundsargs = '-fcheck=bounds' | ||
xfail = true | ||
else | ||
boundsargs = [] | ||
xfail = false | ||
endif | ||
boundsargs = fc.get_id() == 'gcc' ? '-fcheck=bounds' : [] | ||
|
||
badbounds = executable('badbounds', 'badbounds.f90', | ||
fortran_args : boundsargs) | ||
# Too unreliable to test--that's the point. | ||
|
||
nanmaxmin_exe = executable('nanmaxmin', 'maxmin_nan.f90') | ||
test('debug: NaN min, max', nanmaxmin_exe, timeout: 10) | ||
test('debug: NaN min, max', nanmaxmin_exe, | ||
timeout: 10) | ||
|
||
typecast_exe = executable('typecast', 'typecast.f90', | ||
fortran_args: oldargs) | ||
test('debug: typecase', typecast_exe, timeout: 10) | ||
test('debug: typecase', typecast_exe, | ||
timeout: 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
mpi = dependency('mpi', language : 'fortran', required : false) | ||
|
||
if not fc.links(''' | ||
use mpi | ||
integer :: i | ||
call mpi_init(i) | ||
call mpi_finalize(i) | ||
end''', | ||
dependencies : mpi, | ||
name: 'Fortran MPI links') | ||
mpi = disabler() | ||
endif | ||
|
||
mpiexec = find_program('mpiexec', required : false) # MS-MPI has only mpiexec | ||
|
||
ver = executable('mpivers', 'mpivers.f90', | ||
dependencies : mpi) | ||
test('MPI version check', ver) | ||
|
||
hello = executable('mpi_hello', 'helloworld.f90', | ||
dependencies : mpi) | ||
test('MPI Hello World', mpiexec, timeout: 20, is_parallel : false, | ||
test('MPI Hello World', mpiexec, | ||
timeout: 20, | ||
is_parallel : false, | ||
args: ['-np', '2', hello]) | ||
|
||
|
||
pass = executable('mpi_pass', 'thread_pass.f90', dependencies : mpi) | ||
test('MPI thread pass', mpiexec, timeout: 20, is_parallel : false, | ||
test('MPI thread pass', mpiexec, | ||
timeout: 20, | ||
is_parallel : false, | ||
args: ['-np', '2', pass]) |
Oops, something went wrong.