Skip to content

Commit

Permalink
Add fpp macros to support automatic location info generation
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Oct 3, 2024
1 parent 59ce827 commit 7d9684c
Show file tree
Hide file tree
Showing 57 changed files with 1,215 additions and 29 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ jobs:
run: |
echo "FC=${{ env.FC }}" >> ${GITHUB_ENV}
echo "FPM_FC=${{ env.FC }}" >> ${GITHUB_ENV}
echo "FFLAGS=-ffree-line-length-none" >> ${GITHUB_ENV}
echo "FPM_FFLAGS=-ffree-line-length-none" >> ${GITHUB_ENV}
- name: Setup MPICH on Ubuntu
if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'mpich') }}
Expand Down Expand Up @@ -168,13 +170,14 @@ jobs:
CMAKE_PREFIX_PATH=${INSTALL_DIR} cmake -B ${BUILD_DIR} -G Ninja test/export/${INTERFACE}
cmake --build ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/app/testapp
${RUN_PREFIX} ${BUILD_DIR}/app/testapp_fpp
${RUN_PREFIX} ${BUILD_DIR}/app/testapp_fypp
rm -rf ${BUILD_DIR}
- name: Test fpm export
run: |
./devel/fpm-repo/export-fpm-repo.sh ${INTERFACE} ${FPM_EXPORT_DIR}
fpm run -C ${FPM_EXPORT_DIR}/test/export/${INTERFACE} testapp
fpm run -C ${FPM_EXPORT_DIR}/test/export/${INTERFACE} --runner "${RUN_PREFIX}" testapp testapp_fpp
rm -rf ${FPM_EXPORT_DIR}
- name: Test Meson pkgconfig export
Expand All @@ -186,6 +189,7 @@ jobs:
meson setup ${MESON_OPTIONS_NOFALLBACK} --wrap-mode nofallback ${BUILD_DIR}
ninja -C ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/testapp
${RUN_PREFIX} ${BUILD_DIR}/testapp_fpp
rm -rf ./${BUILD_DIR}
- name: Test Meson subproject export
Expand All @@ -201,6 +205,7 @@ jobs:
meson setup ${MESON_OPTIONS_FALLBACK} --wrap-mode forcefallback ${BUILD_DIR}
ninja -C ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/testapp
${RUN_PREFIX} ${BUILD_DIR}/testapp_fpp
rm -rf subprojects ${BUILD_DIR}
deploy-fpm:
Expand Down
2 changes: 1 addition & 1 deletion cmake/fortuno-coarray.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires: fortuno
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_COA_INSTALL_MODULEDIR@
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_INSTALL_MODULEDIR@ -I@CMAKE_INSTALL_FULL_INCLUDEDIR@
Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lfortuno-coarray
2 changes: 1 addition & 1 deletion cmake/fortuno-mpi.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires: fortuno
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_MPI_INSTALL_MODULEDIR@
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_INSTALL_MODULEDIR@ -I@CMAKE_INSTALL_FULL_INCLUDEDIR@
Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lfortuno-mpi
2 changes: 1 addition & 1 deletion cmake/fortuno-serial.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires: fortuno
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_INSTALL_MODULEDIR@
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_INSTALL_MODULEDIR@ -I@CMAKE_INSTALL_FULL_INCLUDEDIR@
Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lfortuno-serial
2 changes: 1 addition & 1 deletion devel/fpm-repo/coarray/addons/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
- name: Test fpm export
run: |
fpm run -C test/export/${INTERFACE} testapp
fpm run -C test/export/${INTERFACE} testapp testapp_fpp
1 change: 1 addition & 0 deletions devel/fpm-repo/coarray/repo.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
CMakeLists.txt
meson.build
meson.options
*.fypp
2 changes: 2 additions & 0 deletions devel/fpm-repo/coarray/repo.include
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LICENSE
include/
include/fortuno_coarray.fpp
src/
src/fortuno.f90
src/fortuno/
Expand Down
2 changes: 1 addition & 1 deletion devel/fpm-repo/mpi/addons/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
- name: Test fpm export
run: |
fpm run -C test/export/${INTERFACE} --runner 'mpirun -n 2' testapp
fpm run -C test/export/${INTERFACE} --runner 'mpirun -n 2' testapp testapp_fpp
1 change: 1 addition & 0 deletions devel/fpm-repo/mpi/repo.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
CMakeLists.txt
meson.build
meson.options
*.fypp
2 changes: 2 additions & 0 deletions devel/fpm-repo/mpi/repo.include
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LICENSE
include/
include/fortuno_mpi.fpp
src/
src/fortuno.f90
src/fortuno/
Expand Down
2 changes: 1 addition & 1 deletion devel/fpm-repo/serial/addons/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Test fpm export
run: |
fpm run -C test/export/${INTERFACE} testapp
fpm run -C test/export/${INTERFACE} testapp testapp_fpp
1 change: 1 addition & 0 deletions devel/fpm-repo/serial/repo.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
CMakeLists.txt
meson.build
meson.options
*.fypp
2 changes: 2 additions & 0 deletions devel/fpm-repo/serial/repo.include
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LICENSE
include/
include/fortuno_serial.fpp
src/
src/fortuno.f90
src/fortuno/
Expand Down
3 changes: 3 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ list(APPEND CMAKE_MESSAGE_CONTEXT Example)

if (FORTUNO_WITH_SERIAL)
add_subdirectory(serial)
add_subdirectory(serial-fpp)
if (FYPP)
add_subdirectory(serial-fypp)
endif ()
endif ()

if (FORTUNO_WITH_MPI)
add_subdirectory(mpi)
add_subdirectory(mpi-fpp)
if (FYPP)
add_subdirectory(mpi-fypp)
endif ()
endif ()

if (FORTUNO_WITH_COARRAY)
add_subdirectory(coarray)
add_subdirectory(coarray-fpp)
if (FYPP)
add_subdirectory(coarray-fypp)
endif ()
Expand Down
33 changes: 33 additions & 0 deletions example/coarray-fpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

list(APPEND CMAKE_MESSAGE_CONTEXT CoarrayFpp)

add_library(fortuno_example_coarray_fpp_mylib)
set_target_properties(
fortuno_example_coarray_fpp_mylib PROPERTIES
OUTPUT_NAME mylib
)
target_sources(
fortuno_example_coarray_fpp_mylib PRIVATE
mylib.f90
)
fortuno_add_coarray_build_flags(fortuno_example_coarray_fpp_mylib)

add_executable(fortuno_example_coarray_fpp_testapp)
set_target_properties(
fortuno_example_coarray_fpp_testapp PROPERTIES
OUTPUT_NAME testapp
)
target_sources(
fortuno_example_coarray_fpp_testapp PRIVATE
test_simple_fpp.F90
testapp.f90
)
target_link_libraries(
fortuno_example_coarray_fpp_testapp PRIVATE
fortuno_example_coarray_fpp_mylib
Fortuno::fortuno_coarray
)
fortuno_add_coarray_build_flags(fortuno_example_coarray_fpp_testapp)
26 changes: 26 additions & 0 deletions example/coarray-fpp/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

example_mylib_fpp_lib = library(
'mylib',
sources: ['mylib.f90'],
install: false,
fortran_args: fflags_coarray,
link_args: ldflags_coarray,
)
example_mylib_fpp_dep = declare_dependency(
link_with: example_mylib_fpp_lib,
)

example_testapp_exe = executable(
'testapp',
sources: [
'test_simple_fpp.F90',
'testapp.f90',
],
dependencies: [example_mylib_fpp_dep, fortuno_coarray_dep],
install: false,
fortran_args: fflags_coarray,
link_args: ldflags_coarray,
)
30 changes: 30 additions & 0 deletions example/coarray-fpp/mylib.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
! This file is part of Fortuno.
! Licensed under the BSD-2-Clause Plus Patent license.
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Demo module/library to be tested
module mylib
implicit none

private
public :: broadcast

contains


!> Broadcasts a scalar integer.
subroutine broadcast(buffer, source)

!> Buffer to broadcast
integer, intent(inout) :: buffer

!> Source image
integer, intent(in) :: source

integer :: stat

call co_broadcast(buffer, source)

end subroutine broadcast

end module mylib
57 changes: 57 additions & 0 deletions example/coarray-fpp/test_simple_fpp.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
! This file is part of Fortuno.
! Licensed under the BSD-2-Clause Plus Patent license.
! SPDX-License-Identifier: BSD-2-Clause-Patent

#include "fortuno_coarray.fpp"

module test_simple_fpp
use mylib, only : broadcast
use fortuno_coarray, only : as_char, test => coa_pure_case_item, context => coa_context,&
& is_equal, test_list
implicit none

contains


!> Returns the tests from this module
function tests()
type(test_list) :: tests

tests = test_list([&
test("broadcast", test_broadcast)&
])

end function tests


!> Broadcast test with collective communication
subroutine test_broadcast(ctx)
class(context), intent(inout) :: ctx

integer, parameter :: sourceimg = 1, sourceval = 100, otherval = -1
integer :: buffer

character(:), allocatable :: msg

! GIVEN source rank contains a different integer value as all other ranks
if (this_image() == sourceimg) then
buffer = sourceval
else
buffer = otherval
end if

! WHEN source rank broadcasts its value
call broadcast(buffer, sourceimg)

! Make every third rank fail for demonstration purposes
if (mod(this_image() - 1, 3) == 2) then
buffer = sourceval + 1
msg = "Failing on image " // as_char(this_image()) // " on purpose"
end if

! THEN each rank must contain source rank's value
CHECK_MSG(ctx, is_equal(buffer, sourceval), msg)

end subroutine test_broadcast

end module test_simple_fpp
13 changes: 13 additions & 0 deletions example/coarray-fpp/testapp.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
! This file is part of Fortuno.
! Licensed under the BSD-2-Clause Plus Patent license.
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Test app, collecting and executing the tests
program testapp
use fortuno_coarray, only : execute_coa_cmd_app
use test_simple_fpp, only : tests
implicit none

call execute_coa_cmd_app(tests())

end program testapp
3 changes: 3 additions & 0 deletions example/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

if with_serial
subdir('serial')
subdir('serial-fpp')
endif

if with_mpi
subdir('mpi')
subdir('mpi-fpp')
endif

if with_coarray
subdir('coarray')
subdir('coarray-fpp')
endif
34 changes: 34 additions & 0 deletions example/mpi-fpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

list(APPEND CMAKE_MESSAGE_CONTEXT MpiFpp)

add_library(fortuno_example_mpi_fpp_mylib)
set_target_properties(
fortuno_example_mpi_fpp_mylib PROPERTIES
OUTPUT_NAME mylib
)
target_sources(
fortuno_example_mpi_fpp_mylib PRIVATE
mylib.f90
)
target_link_libraries(fortuno_example_mpi_fpp_mylib PRIVATE MPI::MPI_Fortran)

add_executable(fortuno_example_mpi_fpp_testapp)
set_target_properties(
fortuno_example_mpi_fpp_testapp PROPERTIES
OUTPUT_NAME testapp
)
target_sources(
fortuno_example_mpi_fpp_testapp PRIVATE
test_simple_fpp.F90
testapp.f90
)
target_link_libraries(
fortuno_example_mpi_fpp_testapp
PRIVATE
fortuno_example_mpi_fpp_mylib
Fortuno::fortuno_mpi
MPI::MPI_Fortran
)
23 changes: 23 additions & 0 deletions example/mpi-fpp/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

example_mylib_fpp_lib = library(
'mylib',
sources: ['mylib.f90'],
dependencies: [mpi_fortran_dep],
install: false,
)
example_mylib_fpp_dep = declare_dependency(
link_with: example_mylib_fpp_lib,
)

example_testapp_exe = executable(
'testapp',
sources: [
'test_simple_fpp.F90',
'testapp.f90',
],
dependencies: [example_mylib_fpp_dep, fortuno_mpi_dep],
install: false,
)
Loading

0 comments on commit 7d9684c

Please sign in to comment.