diff --git a/array/meson.build b/array/meson.build index dcadbd4..0d057bf 100644 --- a/array/meson.build +++ b/array/meson.build @@ -2,4 +2,5 @@ rotflip = library('rotflip', 'rot90.f90') rotflip_test = executable('rotflip_test', 'test_rot90.f90', link_with : rotflip) -test('Rotate Flip', rotflip_test) +test('Rotate Flip', rotflip_test, + timeout: 10) diff --git a/benchmarks/meson.build b/benchmarks/meson.build index 16f28ab..832bce4 100644 --- a/benchmarks/meson.build +++ b/benchmarks/meson.build @@ -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) diff --git a/block/meson.build b/block/meson.build index 3594e4a..813fec2 100644 --- a/block/meson.build +++ b/block/meson.build @@ -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 \ No newline at end of file diff --git a/character/meson.build b/character/meson.build index 6fe03af..1aaf21d 100644 --- a/character/meson.build +++ b/character/meson.build @@ -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 \ No newline at end of file diff --git a/cmake/meson.build b/cmake/meson.build new file mode 100644 index 0000000..51d81f7 --- /dev/null +++ b/cmake/meson.build @@ -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 \ No newline at end of file diff --git a/coarray/meson.build b/coarray/meson.build index b050c0f..1079046 100644 --- a/coarray/meson.build +++ b/coarray/meson.build @@ -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) diff --git a/contiguous/meson.build b/contiguous/meson.build index 7115001..45ef470 100644 --- a/contiguous/meson.build +++ b/contiguous/meson.build @@ -1,17 +1,9 @@ -if fc.get_id() == 'intel-cl' - message('Intel Fortran on Windows has a continuous bug') - subdir_done() -endif -if fc.links('contig = is_contiguous([1,2,3]); end', name: 'F2008 contiguous') - f08contig='-DISCONTIG' -else - f08contig='' -endif +args = f08contig ? '-DISCONTIG' : '' if fc.get_id() != 'gcc' contig_exe = executable('contig', 'contiguous.F90', - fortran_args : f08contig) + fortran_args : args) test('Contiguous', contig_exe) else message('contiguous: Meson bug with gfortran') diff --git a/cxx/meson.build b/cxx/meson.build index c3f5475..e974b16 100644 --- a/cxx/meson.build +++ b/cxx/meson.build @@ -4,7 +4,7 @@ if not add_languages('cpp', required: false) endif if os == 'darwin' - message('cxx: Meson build on Mac') + message('cxx: SKIP Meson build on Mac') subdir_done() endif diff --git a/debug/CMakeLists.txt b/debug/CMakeLists.txt index 417a8b7..0617267 100644 --- a/debug/CMakeLists.txt +++ b/debug/CMakeLists.txt @@ -1,16 +1,8 @@ add_executable(badbounds badbounds.f90) if(CMAKE_Fortran_COMPILER_ID STREQUAL GCC) target_compile_options(badbounds PRIVATE -fcheck=bounds) - set(xfail true) -elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - set(xfail true) -else() - set(xfail false) endif() -# falsely trips with segfault -# add_test(NAME BoundsFail COMMAND badbounds WILL_FAIL ${xfail}) - if(WIN32 AND CMAKE_Fortran_COMPILER_ID STREQUAL PGI) message(STATUS "CMake bug with PGI on Windows -- pgfortran.exe itself works") else() diff --git a/debug/meson.build b/debug/meson.build index 443046c..edf80ff 100644 --- a/debug/meson.build +++ b/debug/meson.build @@ -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) \ No newline at end of file +test('debug: typecase', typecast_exe, + timeout: 10) \ No newline at end of file diff --git a/hdf5/meson.build b/hdf5/meson.build index 2001918..fa274f5 100644 --- a/hdf5/meson.build +++ b/hdf5/meson.build @@ -1,9 +1,3 @@ -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 - h5mod = library('h5mod', 'h5mod.f90', dependencies : hdf5) h5simple = executable('h5simple', 'hdf5simple.f90', diff --git a/io/meson.build b/io/meson.build index 6118956..517aa69 100644 --- a/io/meson.build +++ b/io/meson.build @@ -5,7 +5,8 @@ append_exe = executable('test_logging', 'append_file.f90', termio = executable('termio', 'terminal_io.f90') leading_zeros = executable('leading_zeros', 'leading_zeros.f90') -test('LeadingZeros', leading_zeros) +test('LeadingZeros', leading_zeros, + timeout: 10) expanduser = executable('expanduser', 'expanduser.f90') diff --git a/meson.build b/meson.build index 09013e4..4060835 100644 --- a/meson.build +++ b/meson.build @@ -4,27 +4,7 @@ project('Fortran2018examples', 'fortran', 'c', realbits = get_option('realbits') -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, language: 'fortran') -elif fc.get_id() == 'intel-cl' - # /fpp allows #include etc preprocessor lines - add_global_arguments(f18flag, impnone, '/fpp', 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() - -f18errorstop = fc.links('character :: b; error stop b; end', name: 'F2018 error stop') +subdir('cmake') # must be before other subdirs to get compiler capabilities and libraries subdir('array') subdir('benchmarks') diff --git a/mpi/meson.build b/mpi/meson.build index 966c415..263c143 100644 --- a/mpi/meson.build +++ b/mpi/meson.build @@ -1,17 +1,3 @@ -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) @@ -19,10 +5,14 @@ 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]) diff --git a/mumps/meson.build b/mumps/meson.build index 2b374c6..28ace13 100644 --- a/mumps/meson.build +++ b/mumps/meson.build @@ -1,22 +1,4 @@ -mpi = dependency('MPI', language: 'fortran', required: false, disabler: true) -if mpi.found() and not fc.links('use mpi; end', dependencies: mpi, name: 'MPI') - mpi = disabler() -endif -mpiexec = find_program('mpiexec', required: false, disabler: true) - -# --- Lapack -# Lapack must work correctly for Scalapack to work -lapack = dependency('lapack', required: false, disabler: true) - -# --- Scalapack -# dependency('scalapack') not yet working in Meson--cmake->meson bug within Meson, yielding long meson-log.txt -# scalapack = dependency('scalapack', cmake_module_path : 'cmake/Modules') -scalapack = fc.find_library('scalapack-openmpi', required: false, disabler: true) -if not scalapack.found() - scalapack = fc.find_library('scalapack', required: false, disabler: true) -endif - blacs1_exe = executable('blacs1', 'blacs.f', dependencies: [mpi, lapack, scalapack]) test('BLACS', mpiexec, args: ['-np', '1', blacs1_exe], @@ -30,16 +12,6 @@ test('Scalapack', mpiexec, workdir: meson.current_source_dir(), timeout: 15) -# --- MUMPS -# mumps = dependency('mumps', required: false) -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) - testmumps_exe = executable('testmumps', 'test_mumps.f90', dependencies: [mpi, mumps]) test('MUMPS', mpiexec, args: ['-np', '1', testmumps_exe], diff --git a/netcdf/meson.build b/netcdf/meson.build index 35ab18d..7b4cc43 100644 --- a/netcdf/meson.build +++ b/netcdf/meson.build @@ -1,12 +1,4 @@ -# 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 netcdf_rw = executable('netcdf_rw', 'simple_xy_wr.f90', dependencies : netcdf) -test('NetCDF', netcdf_rw) +test('NetCDF', netcdf_rw, + timeout: 20) diff --git a/openmp/meson.build b/openmp/meson.build index e818d7c..b96f792 100644 --- a/openmp/meson.build +++ b/openmp/meson.build @@ -1,8 +1,4 @@ -openmp = dependency('openmp', language : 'fortran', required : false) - -if not fc.links('use omp_lib; rate = omp_get_wtick(); end', name: 'OpenMP', dependencies : openmp) -openmp = disabler() -endif timeprec = executable('timeprec', 'timeprec.f90', dependencies : openmp) -test('OpenMP:TimeMeasure', timeprec) +test('OpenMP:TimeMeasure', timeprec, + timeout: 30) diff --git a/overloading/meson.build b/overloading/meson.build index e1ce19d..fced594 100644 --- a/overloading/meson.build +++ b/overloading/meson.build @@ -1,6 +1,6 @@ proc = executable('proc', 'pragma.f90') - -test('Pragma', proc) +test('Pragma', proc, + timeout: 10) if f18errorstop f18es_exe = executable('f18es', 'f2018errorstop.f90') diff --git a/random/meson.build b/random/meson.build index 09d7714..5dda171 100644 --- a/random/meson.build +++ b/random/meson.build @@ -1,11 +1,8 @@ -f18random = fc.links('call random_init(.false., .false.); end', name:'F2018 random_init') +src = f18random ? files('random_init_f2018.f90') : files('random_init.f90') -if f18random - src = files('random_init_f2018.f90') -else - src = files('random_init.f90') -endif +random = executable('random', + sources: ['random.f90', 'random_demo.f90', src]) -random = executable('random', 'random.f90', 'random_demo.f90', src) -test('RandomInit', random) +test('RandomInit', random, + timeout: 10) diff --git a/real/meson.build b/real/meson.build index 499d4a7..5d50228 100644 --- a/real/meson.build +++ b/real/meson.build @@ -1,54 +1,43 @@ -f08kind = fc.links(''' -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''', name: 'F2008 ieee kinds') - -f18prop = fc.links('complex :: z; print *,z%re,z%im,z%kind; end', - name: 'F2018 properties') - -if f08kind - r128 = '-DREAL128' -else - r128 = '' -endif +r128 = f08kind ? '-DREAL128' : '' polymorph = executable('polymorph', 'polymorphic.F90', fortran_args: '-DREALBITS='+realbits) -test('real:Polymorphic', polymorph) +test('real:Polymorphic', polymorph, + timeout: 10) divprec = executable('divprec', 'div_precision.F90', fortran_args: r128) -test('real:DivisionPrecision', divprec) +test('real:DivisionPrecision', divprec, + timeout: 10) floatprec = executable('floatprec', 'floating_precision.F90', fortran_args: r128) -test('real:FloatPrecision', floatprec) +test('real:FloatPrecision', floatprec, + timeout: 10) hugeprec = executable('hugeprec', 'huge_precision.F90', fortran_args: r128) -test('real:HugePrecision', hugeprec) +test('real:HugePrecision', hugeprec, + timeout: 10) if f08kind precprob = executable('precprob', 'precision_problems.f90') - test('real:PrecisionProblems', precprob) + test('real:PrecisionProblems', precprob, + timeout: 15) endif if f18prop properties = executable('properties', 'properties.f90') - test('real:Fortran2018 Properties', properties) + test('real:Fortran2018 Properties', properties, + timeout: 10) endif -if f08kind - nanargs = [r128, '-DIEEENAN'] -else - nanargs = [] -endif +nanargs = f08kind ? [r128, '-DIEEENAN'] : [] nan = executable('nan', 'nans.F90', fortran_args: nanargs) -test('NaN', nan) +test('NaN', nan, + timeout: 10) assert_lib = library('assert', 'assert.F90', fortran_args: '-DREALBITS='+realbits) @@ -56,5 +45,6 @@ assert_lib = library('assert', 'assert.F90', if f08kind testassert_exe = executable('testassert', 'not-finite.f90', 'fib3.f90', link_with: assert_lib) - test('real:Assert', testassert_exe) + test('real:Assert', testassert_exe, + timeout: 10) endif diff --git a/standard/meson.build b/standard/meson.build index 840dac1..d8d16fc 100644 --- a/standard/meson.build +++ b/standard/meson.build @@ -2,26 +2,24 @@ short_circuit = executable('shortcircuit', 'short_circuit.f90') # test is too unreliable--sometimes pass sometimes fail, that's the point. bitpat= executable('bitpat', 'bitpat.f90') -test('standard:Bit Pattern', bitpat) +test('standard:Bit Pattern', bitpat, + timeout: 10) justwait_exe = executable('justwait', 'pause.f90') -if os == 'windows' and ['pgi', 'intel-cl'].contains(fc.get_id()) - message('mkdir: PGI and Intel Windows bug') -else - if fc.get_id()=='intel' - mkdir_src = files('isdir_intel.f90') - else - mkdir_src = files('isdir.f90') - endif - mkdirstd = executable('mkdirstd', 'mkdir.f90', mkdir_src) - test('standard:mkdir', mkdirstd, args: 'testdir/hello') -endif +mkdir_src = fc.get_id() == 'intel' or fc.get_id() == 'intel-cl' ? files('isdir_intel.f90') : files('isdir.f90') +mkdirstd = executable('mkdirstd', + sources: ['mkdir.f90', mkdir_src]) +test('standard:mkdir', mkdirstd, args: 'testdir/hello', + timeout: 20) -if os != 'windows' +if os != 'windows' or fc.get_id() == 'gcc' + # gcc has unistd.h on Windows via MinGW sleepstd = executable('sleepstd', 'sleep.f90') - test('standard:Micro sleep', sleepstd, timeout : 1) + test('standard:Micro sleep', sleepstd, + timeout : 5) endif statement = executable('statement', 'statement_function.f90') -test('standard:Statement', statement) +test('standard:Statement', statement, + timeout: 10) diff --git a/system/meson.build b/system/meson.build index 5f17ab7..db7da97 100644 --- a/system/meson.build +++ b/system/meson.build @@ -1,19 +1,20 @@ color_exe = executable('color', 'color_text.f90') +test('system: color', color_exe, + timeout: 10) osdet = library('osdet', 'os_detect.f90') -f08command = fc.links('integer foo; call execute_command_line(" ", exitstat=foo); end', - name : 'F2008 execute_command_line') - if not f08command subdir_done() endif gitrev = executable('gitrev', 'gitrev.f90') -test('Git revision log', gitrev) +test('Git revision log', gitrev, + timeout: 15) complog = executable('complog', 'compiler_log.f90') -test('Compiler version logging', complog) +test('Compiler version logging', complog, + timeout: 15) playsound_exe = executable('playsound', 'play_sound.f90')