Skip to content

Commit

Permalink
Adapt to interface changes in Fortuno
Browse files Browse the repository at this point in the history
Note: currently uses a personal fork, not the official Fortuno repo.
  • Loading branch information
aradi committed Sep 22, 2024
1 parent 2387be0 commit dea2bb3
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 48 deletions.
30 changes: 22 additions & 8 deletions templates/testapp-coarray.f90
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
36 changes: 25 additions & 11 deletions templates/testapp-mpi.f90
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
34 changes: 23 additions & 11 deletions templates/testapp-serial.f90
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
2 changes: 2 additions & 0 deletions test/runners/init.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/runners/test.cmake-coarray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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\
Expand Down
2 changes: 1 addition & 1 deletion test/runners/test.cmake-mpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
8 changes: 7 additions & 1 deletion test/runners/test.cmake-serial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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\
Expand Down
9 changes: 6 additions & 3 deletions {{ cookiecutter.project_slug }}/fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ 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.git" }
fortuno = { git = "https://github.com/aradi/fortuno.git", branch = "testlist" }
{%- 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-mpi.git" }
fortuno-mpi = { git = "https://github.com/aradi/fortuno-mpi.git", branch = "testlist" }
{%- 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-coarray.git" }
fortuno-coarray = { git = "https://github.com/aradi/fortuno-coarray.git", branch = "testlist" }
{%- endif %}
6 changes: 4 additions & 2 deletions {{ cookiecutter.project_slug }}/subprojects/Fortuno.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ option(
# Make subproject available
FetchContent_Declare(
Fortuno
GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno.git"
GIT_TAG "main"
# GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno.git"
# GIT_TAG "main"
GIT_REPOSITORY "https://github.com/aradi/fortuno.git"
GIT_TAG "testlist"
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(Fortuno)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ option(
# Make subproject available
FetchContent_Declare(
FortunoCoarray
GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-coarray.git"
GIT_TAG "main"
# GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-coarray.git"
# GIT_TAG "main"
GIT_REPOSITORY "https://github.com/aradi/fortuno-coarray.git"
GIT_TAG "testlist"
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(FortunoCoarray)
Expand Down
6 changes: 4 additions & 2 deletions {{ cookiecutter.project_slug }}/subprojects/FortunoMpi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ option(
# Make subproject available
FetchContent_Declare(
FortunoMpi
GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-mpi.git"
GIT_TAG "main"
# GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno-mpi.git"
# GIT_TAG "main"
GIT_REPOSITORY "https://github.com/aradi/fortuno-mpi.git"
GIT_TAG "testlist"
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(FortunoMpi)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[wrap-git]
directory=fortuno-coarray
url=https://github.com/fortuno-repos/fortuno-coarray
revision=main
# url=https://github.com/fortuno-repos/fortuno-coarray
# revision=main
url=https://github.com/aradi/fortuno-coarray
revision=testlist
6 changes: 4 additions & 2 deletions {{ cookiecutter.project_slug }}/subprojects/fortuno-mpi.wrap
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[wrap-git]
directory=fortuno-mpi
url=https://github.com/fortuno-repos/fortuno-mpi
revision=main
# url=https://github.com/fortuno-repos/fortuno-mpi
# revision=main
url=https://github.com/aradi/fortuno-mpi
revision=testlist
6 changes: 4 additions & 2 deletions {{ cookiecutter.project_slug }}/subprojects/fortuno.wrap
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[wrap-git]
directory=fortuno
url=https://github.com/fortuno-repos/fortuno
revision=main
# url=https://github.com/fortuno-repos/fortuno
# revision=main
url=https://github.com/aradi/fortuno
revision=testlist

0 comments on commit dea2bb3

Please sign in to comment.