From 47b90d504c6f4df7fa54309c9abcaa491f7af5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Sat, 28 Sep 2024 20:41:53 +0200 Subject: [PATCH] Adapt to interface changes in Fortuno --- README.rst | 12 +++---- hooks/post_gen_project.py | 8 ++--- templates/testapp-coarray.f90 | 30 +++++++++++----- templates/testapp-mpi.f90 | 36 +++++++++++++------ templates/testapp-serial.f90 | 34 ++++++++++++------ test/runners/init.sh | 2 ++ test/runners/test.cmake-coarray.sh | 14 ++++---- test/runners/test.cmake-mpi.sh | 2 +- test/runners/test.cmake-serial.sh | 8 ++++- test/runners/test.meson-coarray.sh | 8 ++--- .../export_test.coarray/CMakeLists.txt | 16 ++++----- .../export_test.coarray/app/CMakeLists.txt | 4 +-- .../export_test.coarray/app/meson.build | 4 +-- test/testers/export_test.coarray/meson.build | 4 +-- .../testers/export_test.coarray/meson.options | 4 +-- .../CMakeLists.txt | 10 ++---- .../app/meson.build | 4 +-- ... cookiecutter.project_name }}Helpers.cmake | 4 +-- .../example/meson.build | 4 +-- {{ cookiecutter.project_slug }}/fpm.toml | 6 ++-- {{ cookiecutter.project_slug }}/meson.build | 19 +++++++--- {{ cookiecutter.project_slug }}/meson.options | 4 +-- .../src/meson.build | 4 +-- .../subprojects/Fortuno.cmake | 6 ++++ .../subprojects/FortunoCoarray.cmake | 24 ------------- .../subprojects/FortunoMpi.cmake | 24 ------------- .../subprojects/fortuno-coarray.wrap | 4 --- .../subprojects/fortuno-mpi.wrap | 4 --- .../subprojects/fortuno.wrap | 2 +- .../test/meson.build | 4 +-- 30 files changed, 153 insertions(+), 156 deletions(-) delete mode 100644 {{ cookiecutter.project_slug }}/subprojects/FortunoCoarray.cmake delete mode 100644 {{ cookiecutter.project_slug }}/subprojects/FortunoMpi.cmake delete mode 100644 {{ cookiecutter.project_slug }}/subprojects/fortuno-coarray.wrap delete mode 100644 {{ cookiecutter.project_slug }}/subprojects/fortuno-mpi.wrap diff --git a/README.rst b/README.rst index 46675ea..7d73637 100644 --- a/README.rst +++ b/README.rst @@ -121,11 +121,11 @@ with the uppercase version of your project's slug.) Name of the subdirectory to put the installed module files into. Default: ``modules``. -``_COARRAY_COMPILE_FLAGS`` - Compiler flags to use when compiling coarray source code (only available if - the coarray template was chosen). Default: ``-coarray``. +``_FFLAGS_COARRAY`` + Fortran compiler flags to use when compiling coarray source code (only + available if the coarray template was chosen). Default: ``-coarray``. -``_COARRAY_LINK_FLAGS`` +``_LDFLAGS_COARRAY`` Linker flags to use when linking coarray object files (only available if the coarray template was chosen). Default: ``-coarray``. @@ -263,11 +263,11 @@ during the configuration step. the include folder. Therefore, the specified directory will be relative to that folder. Default: ``modules``. -``coarray_compile_flags`` +``fflags_coarray`` Compiler flags to use when compiling coarray source code (only available if the coarray template was chosen). Default: ``-coarray``. -``coarray_link_flags`` +``ldflags_coarray`` Linker flags to use when linking coarray object files (only available if the coarray template was chosen). Default: ``-coarray``. diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 12eac3d..e1964f0 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -26,12 +26,8 @@ (r"./meson$", MESON_BUILD), (r"./example$", WITH_EXAMPLE), (r"./subprojects$", CMAKE_BUILD or MESON_BUILD), - (r"./subprojects/Fortuno.cmake$", CMAKE_BUILD and SERIAL_CODE), - (r"./subprojects/FortunoMpi.cmake$", CMAKE_BUILD and MPI_CODE), - (r"./subprojects/FortunoCoarray.cmake$", CMAKE_BUILD and COARRAY_CODE), - (r"./subprojects/fortuno.wrap$", MESON_BUILD and SERIAL_CODE), - (r"./subprojects/fortuno-mpi.wrap$", MESON_BUILD and MPI_CODE), - (r"./subprojects/fortuno-coarray.wrap$", MESON_BUILD and COARRAY_CODE), + (r"./subprojects/Fortuno.cmake$", CMAKE_BUILD), + (r"./subprojects/fortuno.wrap$", MESON_BUILD), (r".*/CMakeLists.txt$", CMAKE_BUILD), (r".*/fpm.toml$", FPM_BUILD), (r".*/meson.build$", MESON_BUILD), diff --git a/templates/testapp-coarray.f90 b/templates/testapp-coarray.f90 index a7dd40c..4349c8a 100644 --- a/templates/testapp-coarray.f90 +++ b/templates/testapp-coarray.f90 @@ -1,17 +1,21 @@ -program testapp +module test_{{cookiecutter.project_slug}} use {{cookiecutter.project_slug}}, only : broadcast use fortuno_coarray, only : as_char, test => coa_pure_case_item, context => coa_context,& - & execute_coa_cmd_app, is_equal, test_item + & is_equal, test_list implicit none - call execute_coa_cmd_app(& - testitems=[& - test("broadcast", test_broadcast)& - ]& - ) - contains + function tests() + type(test_list) :: tests + + tests = test_list([& + test("broadcast", test_broadcast)& + ]) + + end function tests + + subroutine test_broadcast(ctx) class(context), intent(inout) :: ctx @@ -33,4 +37,14 @@ subroutine test_broadcast(ctx) end subroutine test_broadcast +end module test_{{cookiecutter.project_slug}} + + +program testapp + use fortuno_coarray, only : execute_coa_cmd_app + use test_{{cookiecutter.project_slug}}, only : tests + implicit none + + call execute_coa_cmd_app(tests()) + end program testapp diff --git a/templates/testapp-mpi.f90 b/templates/testapp-mpi.f90 index 5a7cda8..708ae36 100644 --- a/templates/testapp-mpi.f90 +++ b/templates/testapp-mpi.f90 @@ -1,20 +1,24 @@ -program testapp +module test_{{cookiecutter.project_slug}} use {{cookiecutter.project_slug}}, only : broadcast - use fortuno_mpi, only : execute_mpi_cmd_app, global_comm, is_equal, test => mpi_case_item,& - & check => mpi_check, test_item, this_rank + use fortuno_mpi, only : global_comm, is_equal, test => mpi_case_item, check => mpi_check,& + & test_list, this_rank implicit none - call execute_mpi_cmd_app(& - testitems=[& - test("broadcast", test_broadcast)& - ]& - ) - contains + function tests() + type(test_list) :: tests + + tests = test_list([& + test("broadcast", test_broadcast)& + &]) + + end function tests + + subroutine test_broadcast() - integer, parameter :: sourcerank = 0, sourceval = 1, otherval = -1 - integer :: buffer + integer, parameter :: sourcerank = 0, sourceval = 1, otherval = -1 + integer :: buffer ! GIVEN source rank contains a different integer value as all other ranks if (this_rank() == sourcerank) then @@ -31,4 +35,14 @@ subroutine test_broadcast() end subroutine test_broadcast +end module test_{{cookiecutter.project_slug}} + + +program testapp + use fortuno_mpi, only : execute_mpi_cmd_app + use test_{{cookiecutter.project_slug}}, only : tests + implicit none + + call execute_mpi_cmd_app(tests()) + end program testapp diff --git a/templates/testapp-serial.f90 b/templates/testapp-serial.f90 index db8032b..91bec3d 100644 --- a/templates/testapp-serial.f90 +++ b/templates/testapp-serial.f90 @@ -1,19 +1,21 @@ -program testapp +module test_{{cookiecutter.project_slug}} use {{cookiecutter.project_slug}}, only : factorial - use fortuno_serial, only : execute_serial_cmd_app, is_equal, test => serial_case_item,& - & check => serial_check + use fortuno_serial, only : is_equal, test => serial_case_item, check => serial_check, test_list implicit none - call execute_serial_cmd_app(& - testitems=[& - test("factorial_0", test_factorial_0),& - test("factorial_1", test_factorial_1),& - test("factorial_2", test_factorial_2)& - ]& - ) - contains + function tests() + type(test_list) :: tests + + tests = test_list([& + test("factorial_0", test_factorial_0),& + test("factorial_1", test_factorial_1),& + test("factorial_2", test_factorial_2)& + ]) + + end function tests + ! Test: 0! = 1 subroutine test_factorial_0() call check(factorial(0) == 1) @@ -30,4 +32,14 @@ subroutine test_factorial_2() call check(is_equal(factorial(2), 2)) end subroutine test_factorial_2 +end module test_{{cookiecutter.project_slug}} + + +program testapp + use fortuno_serial, only : execute_serial_cmd_app + use test_{{cookiecutter.project_slug}}, only : tests + implicit none + + call execute_serial_cmd_app(tests()) + end program testapp diff --git a/test/runners/init.sh b/test/runners/init.sh index 050bee2..130cbaf 100644 --- a/test/runners/init.sh +++ b/test/runners/init.sh @@ -1,5 +1,7 @@ TEST_DIR="$(readlink -f $SCRIPT_DIR/..)" COOKIECUTTER_ROOT_DIR="$(readlink -f $SCRIPT_DIR/../..)" +DISTRO_ID=$(python3 -c "import platform; print(platform.freedesktop_os_release()['ID'])") +LIB_DIR=$([[ "${DISTRO_ID}" =~ ^(ubuntu|debian)$ ]] && echo "lib" || echo "lib64") build_dir=$1 if [[ -z ${build_dir} ]]; then diff --git a/test/runners/test.cmake-coarray.sh b/test/runners/test.cmake-coarray.sh index c0f1965..bcd9d09 100755 --- a/test/runners/test.cmake-coarray.sh +++ b/test/runners/test.cmake-coarray.sh @@ -13,8 +13,8 @@ cmake\ -GNinja\ -B _build\ -DCMAKE_INSTALL_PREFIX=$PWD/_install\ - -DTESTPROJECT_COARRAY_COMPILE_FLAGS=${FFLAGS_COARRAY}\ - -DTESTPROJECT_COARRAY_LINK_FLAGS=${LDFLAGS_COARRAY}\ + -DTESTPROJECT_FFLAGS_COARRAY=${FFLAGS_COARRAY}\ + -DTESTPROJECT_LDFLAGS_COARRAY=${LDFLAGS_COARRAY}\ testproject/ cmake --build _build ctest --test-dir _build @@ -27,19 +27,19 @@ CMAKE_PREFIX_PATH=$PWD/_install\ -B _build_export_cmake\ -GNinja\ -DFIND_BY_CMAKE=ON\ - -DCOARRAY_COMPILE_FLAGS=${FFLAGS_COARRAY}\ - -DCOARRAY_LINK_FLAGS=${LDFLAGS_COARRAY}\ + -DFFLAGS_COARRAY=${FFLAGS_COARRAY}\ + -DLDFLAGS_COARRAY=${LDFLAGS_COARRAY}\ ${TEST_DIR}/testers/export_test.coarray cmake --build _build_export_cmake ./_build_export_cmake/app/export_test -PKG_CONFIG_PATH=$PWD/_install/lib/pkgconfig\ +PKG_CONFIG_PATH=$PWD/_install/${LIB_DIR}/pkgconfig\ cmake\ -B _build_export_pkgconf\ -GNinja\ -DFIND_BY_CMAKE=OFF\ - -DCOARRAY_COMPILE_FLAGS=${FFLAGS_COARRAY}\ - -DCOARRAY_LINK_FLAGS=${LDFLAGS_COARRAY}\ + -DFFLAGS_COARRAY=${FFLAGS_COARRAY}\ + -DLDFLAGS_COARRAY=${LDFLAGS_COARRAY}\ ${TEST_DIR}/testers/export_test.coarray cmake --build _build_export_pkgconf ./_build_export_pkgconf/app/export_test \ No newline at end of file diff --git a/test/runners/test.cmake-mpi.sh b/test/runners/test.cmake-mpi.sh index 937a93b..50b224a 100755 --- a/test/runners/test.cmake-mpi.sh +++ b/test/runners/test.cmake-mpi.sh @@ -29,7 +29,7 @@ CMAKE_PREFIX_PATH=$PWD/_install\ cmake --build _build_export_cmake mpirun -n 2 ./_build_export_cmake/app/export_test -PKG_CONFIG_PATH=$PWD/_install/lib/pkgconfig\ +PKG_CONFIG_PATH=$PWD/_install/${LIB_DIR}/pkgconfig\ cmake\ -B _build_export_pkgconf\ -GNinja\ diff --git a/test/runners/test.cmake-serial.sh b/test/runners/test.cmake-serial.sh index 86ef89a..c98037c 100755 --- a/test/runners/test.cmake-serial.sh +++ b/test/runners/test.cmake-serial.sh @@ -2,6 +2,12 @@ set -e -v -x SCRIPT_DIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))" +DISTRO_ID=$(python3 -c "import platform; print(platform.freedesktop_os_release()['ID'])") +if [[ "${DISTRO_ID}" =~ ^(ubuntu|debian)$ ]]; then + LIB_DIR="lib" +else + LIB_DIR="lib64" +fi source ${SCRIPT_DIR}/init.sh @@ -29,7 +35,7 @@ CMAKE_PREFIX_PATH=$PWD/_install\ cmake --build _build_export_cmake ./_build_export_cmake/app/export_test -PKG_CONFIG_PATH=$PWD/_install/lib/pkgconfig\ +PKG_CONFIG_PATH=$PWD/_install/${LIB_DIR}/pkgconfig\ cmake\ -B _build_export_pkgconf\ -GNinja\ diff --git a/test/runners/test.meson-coarray.sh b/test/runners/test.meson-coarray.sh index e13135c..97cc292 100755 --- a/test/runners/test.meson-coarray.sh +++ b/test/runners/test.meson-coarray.sh @@ -12,8 +12,8 @@ cookiecutter \ meson setup\ --prefix $PWD/_install\ --libdir $PWD/_install/lib\ - -Dcoarray_compile_flags=${FFLAGS_COARRAY}\ - -Dcoarray_link_flags=${LDFLAGS_COARRAY}\ + -Dfflags_coarray=${FFLAGS_COARRAY}\ + -Dldflags_coarray=${LDFLAGS_COARRAY}\ _build testproject meson compile -C _build meson test -C _build --verbose @@ -24,8 +24,8 @@ LD_LIBRARY_PATH="${PWD}/_install/lib:${LD_LIBRARY_PATH}"\ PKG_CONFIG_PATH=$PWD/_install/lib/pkgconfig\ meson setup\ - -Dcoarray_compile_flags=${FFLAGS_COARRAY}\ - -Dcoarray_link_flags=${LDFLAGS_COARRAY}\ + -Dfflags_coarray=${FFLAGS_COARRAY}\ + -Dldflags_coarray=${LDFLAGS_COARRAY}\ _build_export\ ${TEST_DIR}/testers/export_test.coarray meson compile -C _build_export diff --git a/test/testers/export_test.coarray/CMakeLists.txt b/test/testers/export_test.coarray/CMakeLists.txt index 4e3e380..9a8626a 100644 --- a/test/testers/export_test.coarray/CMakeLists.txt +++ b/test/testers/export_test.coarray/CMakeLists.txt @@ -4,19 +4,19 @@ project(export_test LANGUAGES Fortran) option(FIND_BY_CMAKE "Use find_package() to find installed project (otherwise pkg-config)" ON) -set(COARRAY_COMPILE_FLAGS "" CACHE STRING "Extra flags to use for compiling coarray source files") +set(FFLAGS_COARRAY "" CACHE STRING "Extra flags to use for compiling coarray source files") -set(COARRAY_LINK_FLAGS "" CACHE STRING "Extra flags to use for linking coarray object files") +set(LDFFLAGS_COARRAY "" CACHE STRING "Extra flags to use for linking coarray object files") -if (COARRAY_COMPILE_FLAGS) - set(_coarray_compile_flags "${COARRAY_COMPILE_FLAGS}") +if (FFLAGS_COARRAY) + set(_fflags_coarray "${FFLAGS_COARRAY}") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") - set(_coarray_compile_flags "-coarray") + set(_fflags_coarray "-coarray") endif () -if (COARRAY_LINK_FLAGS) - set(_coarray_link_flags "${COARRAY_LINK_FLAGS}") +if (LDFLAGS_COARRAY) + set(_ldflags_coarray "${LDFLAGS_COARRAY}") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") - set(_coarray_link_flags "-coarray") + set(_ldflags_coarray "-coarray") endif () if (FIND_BY_CMAKE) diff --git a/test/testers/export_test.coarray/app/CMakeLists.txt b/test/testers/export_test.coarray/app/CMakeLists.txt index 47c05b6..41964f8 100644 --- a/test/testers/export_test.coarray/app/CMakeLists.txt +++ b/test/testers/export_test.coarray/app/CMakeLists.txt @@ -1,4 +1,4 @@ add_executable(export_test export_test.f90) target_link_libraries(export_test PRIVATE TestProject::testproject) -target_compile_options(export_test PRIVATE ${_coarray_compile_flags}) -target_link_options(export_test PRIVATE ${_coarray_link_flags}) +target_compile_options(export_test PRIVATE ${_fflags_coarray}) +target_link_options(export_test PRIVATE ${_ldflags_coarray}) diff --git a/test/testers/export_test.coarray/app/meson.build b/test/testers/export_test.coarray/app/meson.build index e61e033..74ce7d2 100644 --- a/test/testers/export_test.coarray/app/meson.build +++ b/test/testers/export_test.coarray/app/meson.build @@ -8,6 +8,6 @@ export_test_exe = executable( 'export_test_app', sources: export_test_sources, dependencies: export_test_deps, - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, ) diff --git a/test/testers/export_test.coarray/meson.build b/test/testers/export_test.coarray/meson.build index 943b122..d585a98 100644 --- a/test/testers/export_test.coarray/meson.build +++ b/test/testers/export_test.coarray/meson.build @@ -4,8 +4,8 @@ project( version: '0.0.0' ) -coarray_compile_flags = get_option('coarray_compile_flags') -coarray_link_flags = get_option('coarray_link_flags') +fflags_coarray = get_option('fflags_coarray') +ldflags_coarray = get_option('ldflags_coarray') testproject_dep = dependency('testproject', required: true) diff --git a/test/testers/export_test.coarray/meson.options b/test/testers/export_test.coarray/meson.options index c1be7ff..18ac375 100644 --- a/test/testers/export_test.coarray/meson.options +++ b/test/testers/export_test.coarray/meson.options @@ -1,9 +1,9 @@ option( - 'coarray_compile_flags', type: 'array', value: [], + 'fflags_coarray', type: 'array', value: [], description: 'Fortran compiler arguments to use when compiling coarray sources' ) option( - 'coarray_link_flags', type: 'array', value: [], + 'ldflags_coarray', type: 'array', value: [], description: 'Fortran linker arguments to use when linking coarray sources' ) diff --git a/{{ cookiecutter.project_slug }}/CMakeLists.txt b/{{ cookiecutter.project_slug }}/CMakeLists.txt index 32a7ae3..5ebc71f 100644 --- a/{{ cookiecutter.project_slug }}/CMakeLists.txt +++ b/{{ cookiecutter.project_slug }}/CMakeLists.txt @@ -54,13 +54,13 @@ set( ) {% if cookiecutter.parallelization == "coarray" -%} set( - {{cookiecutter.__project_slug_upper}}_COARRAY_COMPILE_FLAGS + {{cookiecutter.__project_slug_upper}}_FFLAGS_COARRAY "-coarray" CACHE STRING "{{cookiecutter.project_name}}: Extra flags to use for compiling coarray source files" ) set( - {{cookiecutter.__project_slug_upper}}_COARRAY_LINK_FLAGS + {{cookiecutter.__project_slug_upper}}_LDFLAGS_COARRAY "-coarray" CACHE STRING "{{cookiecutter.project_name}}: Extra flags to use for linking coarray object files" @@ -112,13 +112,7 @@ if ({{cookiecutter.__project_slug_upper}}_BUILD_EXAMPLES) endif () {%- endif %} if ({{cookiecutter.__project_slug_upper}}_BUILD_TESTS) - {% if cookiecutter.parallelization == "serial" -%} include(subprojects/Fortuno.cmake) - {%- elif cookiecutter.parallelization == "mpi" -%} - include(subprojects/FortunoMpi.cmake) - {%- elif cookiecutter.parallelization == "coarray" -%} - include(subprojects/FortunoCoarray.cmake) - {%- endif %} enable_testing() add_subdirectory(test) endif () diff --git a/{{ cookiecutter.project_slug }}/app/meson.build b/{{ cookiecutter.project_slug }}/app/meson.build index 33aeb6e..783390a 100644 --- a/{{ cookiecutter.project_slug }}/app/meson.build +++ b/{{ cookiecutter.project_slug }}/app/meson.build @@ -13,8 +13,8 @@ sources: {{cookiecutter.project_slug}}_app_sources, dependencies: {{cookiecutter.project_slug}}_app_deps, {% if cookiecutter.__coarray_code == "True" -%} - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, {% endif %} install: true, ) diff --git a/{{ cookiecutter.project_slug }}/cmake/{{ cookiecutter.project_name }}Helpers.cmake b/{{ cookiecutter.project_slug }}/cmake/{{ cookiecutter.project_name }}Helpers.cmake index a4701ef..803f338 100644 --- a/{{ cookiecutter.project_slug }}/cmake/{{ cookiecutter.project_name }}Helpers.cmake +++ b/{{ cookiecutter.project_slug }}/cmake/{{ cookiecutter.project_name }}Helpers.cmake @@ -28,11 +28,11 @@ function ({{cookiecutter.project_slug}}_create_coarray_build_target) add_library(CoarrayBuildInterface INTERFACE) target_compile_options( CoarrayBuildInterface INTERFACE - ${{'{'}}{{cookiecutter.__project_slug_upper}}_COARRAY_COMPILE_FLAGS} + ${{'{'}}{{cookiecutter.__project_slug_upper}}_FFLAGS_COARRAY} ) target_link_options( CoarrayBuildInterface INTERFACE - ${{'{'}}{{cookiecutter.__project_slug_upper}}_COARRAY_LINK_FLAGS} + ${{'{'}}{{cookiecutter.__project_slug_upper}}_LDFLAGS_COARRAY} ) endif () diff --git a/{{ cookiecutter.project_slug }}/example/meson.build b/{{ cookiecutter.project_slug }}/example/meson.build index 21cb9a9..3a86262 100644 --- a/{{ cookiecutter.project_slug }}/example/meson.build +++ b/{{ cookiecutter.project_slug }}/example/meson.build @@ -13,8 +13,8 @@ sources: {{cookiecutter.project_slug}}_example_sources, dependencies: {{cookiecutter.project_slug}}_example_deps, {% if cookiecutter.__coarray_code == "True" -%} - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, {% endif %} install: false, ) diff --git a/{{ cookiecutter.project_slug }}/fpm.toml b/{{ cookiecutter.project_slug }}/fpm.toml index 0cac738..abd6f62 100644 --- a/{{ cookiecutter.project_slug }}/fpm.toml +++ b/{{ cookiecutter.project_slug }}/fpm.toml @@ -37,9 +37,9 @@ mpi = "*" [dev-dependencies] {% if cookiecutter.__serial_code == "True" -%} -fortuno = { git = "https://github.com/fortuno-repos/fortuno.git" } +fortuno = { git = "https://github.com/fortuno-repos/fortuno-fpm-serial.git" } {%- elif cookiecutter.__mpi_code == "True" -%} -fortuno-mpi = { git = "https://github.com/fortuno-repos/fortuno-mpi.git" } +fortuno-mpi = { git = "https://github.com/fortuno-repos/fortuno-fpm-mpi.git" } {%- elif cookiecutter.__coarray_code == "True" -%} -fortuno-coarray = { git = "https://github.com/fortuno-repos/fortuno-coarray.git" } +fortuno-coarray = { git = "https://github.com/fortuno-repos/fortuno-fpm-coarray.git" } {%- endif %} diff --git a/{{ cookiecutter.project_slug }}/meson.build b/{{ cookiecutter.project_slug }}/meson.build index 7db223f..c426430 100644 --- a/{{ cookiecutter.project_slug }}/meson.build +++ b/{{ cookiecutter.project_slug }}/meson.build @@ -13,19 +13,28 @@ install_modules_dir = join_paths(get_option('includedir'), module_dir_name) install_modules_script = find_program(files(join_paths('meson', 'install-modules.py'))) {% if cookiecutter.__coarray_code == "True" -%} -coarray_compile_flags = get_option('coarray_compile_flags') -coarray_link_flags = get_option('coarray_link_flags') +fflags_coarray = get_option('fflags_coarray') +ldflags_coarray = get_option('ldflags_coarray') {% endif %} {% if cookiecutter.__serial_code == "True" -%} fortuno_serial_dep = dependency('fortuno-serial', fallback: ['fortuno', 'fortuno_serial_dep']) {%- elif cookiecutter.__mpi_code == "True" -%} mpi_fortran_dep = dependency('mpi', language: 'fortran', required: true) -fortuno_mpi_dep = dependency('fortuno-mpi', fallback: ['fortuno-mpi', 'fortuno_mpi_dep']) +fortuno_mpi_dep = dependency( + 'fortuno-mpi', + fallback: ['fortuno', 'fortuno_mpi_dep'], + default_options: {'with_mpi': true} +) {%- elif cookiecutter.__coarray_code == "True" -%} fortuno_coarray_dep = dependency( - 'fortuno-coarray', fallback: ['fortuno-coarray', 'fortuno_coarray_dep'], - default_options: {'coarray_compile_flags': coarray_compile_flags, 'coarray_link_flags': coarray_link_flags}, + 'fortuno-coarray', + fallback: ['fortuno', 'fortuno_coarray_dep'], + default_options: { + 'with_coarray': true, + 'fflags_coarray': fflags_coarray, + 'ldflags_coarray': ldflags_coarray, + }, ) {%- endif %} diff --git a/{{ cookiecutter.project_slug }}/meson.options b/{{ cookiecutter.project_slug }}/meson.options index 9b2d837..9af8761 100644 --- a/{{ cookiecutter.project_slug }}/meson.options +++ b/{{ cookiecutter.project_slug }}/meson.options @@ -17,12 +17,12 @@ option( {% if cookiecutter.__coarray_code == "True" -%} option( - 'coarray_compile_flags', type: 'array', value: [], + 'fflags_coarray', type: 'array', value: [], description: 'Fortran compiler arguments to use when compiling coarray sources' ) option( - 'coarray_link_flags', type: 'array', value: [], + 'ldflags_coarray', type: 'array', value: [], description: 'Fortran linker arguments to use when linking coarray sources' ) {% endif %} diff --git a/{{ cookiecutter.project_slug }}/src/meson.build b/{{ cookiecutter.project_slug }}/src/meson.build index 829308b..25b6cff 100644 --- a/{{ cookiecutter.project_slug }}/src/meson.build +++ b/{{ cookiecutter.project_slug }}/src/meson.build @@ -14,8 +14,8 @@ sources: {{cookiecutter.project_slug}}_sources, dependencies: {{cookiecutter.project_slug}}_deps, {% if cookiecutter.__coarray_code == "True" -%} - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, {% endif %} install: true, ) diff --git a/{{ cookiecutter.project_slug }}/subprojects/Fortuno.cmake b/{{ cookiecutter.project_slug }}/subprojects/Fortuno.cmake index 67fe407..60b9dbc 100644 --- a/{{ cookiecutter.project_slug }}/subprojects/Fortuno.cmake +++ b/{{ cookiecutter.project_slug }}/subprojects/Fortuno.cmake @@ -8,6 +8,12 @@ option( FORTUNO_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${{'{'}}{{cookiecutter.__project_slug_upper}}_BUILD_SHARED_LIBS} ) +{% if cookiecutter.__mpi_code == "True" -%} +option(FORTUNO_WITH_MPI "Fortuno: whether to build the MPI interface" ON) +{%- elif cookiecutter.__coarray_code == "True" -%} +option(FORTUNO_WITH_COARRAY "Fortuno: whether to build the coarray interface" ON) +{%- endif %} + # Make subproject available FetchContent_Declare( Fortuno diff --git a/{{ cookiecutter.project_slug }}/subprojects/FortunoCoarray.cmake b/{{ cookiecutter.project_slug }}/subprojects/FortunoCoarray.cmake deleted file mode 100644 index 9f0827f..0000000 --- a/{{ cookiecutter.project_slug }}/subprojects/FortunoCoarray.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Variables influencing how subproject is obtained -set(CMAKE_REQUIRE_FIND_PACKAGE_FortunoCoarray ${{'{'}}{{cookiecutter.__project_slug_upper}}_SUBPROJECT_REQUIRE_FIND}) -set(CMAKE_DISABLE_FIND_PACKAGE_FortunoCoarray ${{'{'}}{{cookiecutter.__project_slug_upper}}_SUBPROJECT_DISABLE_FIND}) -# set FETCHCONTENT_SOURCE_DIR_FORTUNO to use a local source of the subproject - -# Subproject related variables -option( - FORTUNO_COARRAY_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${{'{'}}{{cookiecutter.__project_slug_upper}}_BUILD_SHARED_LIBS} -) - -# Make subproject available -FetchContent_Declare( - FortunoCoarray - GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-coarray.git" - GIT_TAG "main" - FIND_PACKAGE_ARGS -) -FetchContent_MakeAvailable(FortunoCoarray) - -if (FortunoCoarray_FOUND) - message(STATUS "Subproject FortunoCoarray: using installed version") -else () - message(STATUS "Subproject FortunoCoarray: building from source in ${fortunocoarray_SOURCE_DIR}") -endif () diff --git a/{{ cookiecutter.project_slug }}/subprojects/FortunoMpi.cmake b/{{ cookiecutter.project_slug }}/subprojects/FortunoMpi.cmake deleted file mode 100644 index 1f1ffd1..0000000 --- a/{{ cookiecutter.project_slug }}/subprojects/FortunoMpi.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Variables influencing how subproject is obtained -set(CMAKE_REQUIRE_FIND_PACKAGE_FortunoMpi ${{'{'}}{{cookiecutter.__project_slug_upper}}_SUBPROJECT_REQUIRE_FIND}) -set(CMAKE_DISABLE_FIND_PACKAGE_FortunoMpi ${{'{'}}{{cookiecutter.__project_slug_upper}}_SUBPROJECT_DISABLE_FIND}) -# set FETCHCONTENT_SOURCE_DIR_FORTUNO to use a local source of the subproject - -# Subproject related variables -option( - FORTUNO_MPI_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${{'{'}}{{cookiecutter.__project_slug_upper}}_BUILD_SHARED_LIBS} -) - -# Make subproject available -FetchContent_Declare( - FortunoMpi - GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-mpi.git" - GIT_TAG "main" - FIND_PACKAGE_ARGS -) -FetchContent_MakeAvailable(FortunoMpi) - -if (FortunoMpi_FOUND) - message(STATUS "Subproject FortunoMpi: using installed version") -else () - message(STATUS "Subproject FortunoMpi: building from source in ${fortunompi_SOURCE_DIR}") -endif () diff --git a/{{ cookiecutter.project_slug }}/subprojects/fortuno-coarray.wrap b/{{ cookiecutter.project_slug }}/subprojects/fortuno-coarray.wrap deleted file mode 100644 index 6129b0a..0000000 --- a/{{ cookiecutter.project_slug }}/subprojects/fortuno-coarray.wrap +++ /dev/null @@ -1,4 +0,0 @@ -[wrap-git] -directory=fortuno-coarray -url=https://github.com/fortuno-repos/fortuno-coarray -revision=main diff --git a/{{ cookiecutter.project_slug }}/subprojects/fortuno-mpi.wrap b/{{ cookiecutter.project_slug }}/subprojects/fortuno-mpi.wrap deleted file mode 100644 index 0d3ed03..0000000 --- a/{{ cookiecutter.project_slug }}/subprojects/fortuno-mpi.wrap +++ /dev/null @@ -1,4 +0,0 @@ -[wrap-git] -directory=fortuno-mpi -url=https://github.com/fortuno-repos/fortuno-mpi -revision=main diff --git a/{{ cookiecutter.project_slug }}/subprojects/fortuno.wrap b/{{ cookiecutter.project_slug }}/subprojects/fortuno.wrap index 330f1f4..da63ac2 100644 --- a/{{ cookiecutter.project_slug }}/subprojects/fortuno.wrap +++ b/{{ cookiecutter.project_slug }}/subprojects/fortuno.wrap @@ -1,4 +1,4 @@ [wrap-git] directory=fortuno -url=https://github.com/fortuno-repos/fortuno +url=https://github.com/fortuno-repos/fortuno.git revision=main diff --git a/{{ cookiecutter.project_slug }}/test/meson.build b/{{ cookiecutter.project_slug }}/test/meson.build index 2d68078..af420ff 100644 --- a/{{ cookiecutter.project_slug }}/test/meson.build +++ b/{{ cookiecutter.project_slug }}/test/meson.build @@ -13,8 +13,8 @@ testapp_exe = executable( sources: testapp_sources, dependencies: testapp_deps, {% if cookiecutter.__coarray_code == "True" -%} - fortran_args: coarray_compile_flags, - link_args: coarray_link_flags, + fortran_args: fflags_coarray, + link_args: ldflags_coarray, {% endif %} ) test('testapp', testapp_exe) \ No newline at end of file