Skip to content
Snippets Groups Projects
Commit 3a2b9c9f authored by Stephan Schulz's avatar Stephan Schulz
Browse files

add initial new interface, temporarily called ALL_module_obj, only external interface for now

parent eb559d04
No related branches found
No related tags found
1 merge request!8Refactor
Pipeline #25943 failed
module ALL_module_obj
use iso_c_binding
implicit none
private
! The different loadbalancing methods. Must be kept in sync with C side.
! TODO reuse those from C side (is that possible?)
integer(c_int), public, parameter :: ALL_STAGGERED = 0
integer(c_int), public, parameter :: ALL_TENSOR = 1
integer(c_int), public, parameter :: ALL_UNSTRUCTURED = 2
integer(c_int), public, parameter :: ALL_VORONOI = 3
integer(c_int), public, parameter :: ALL_HISTOGRAM = 4
! Direct interface with C wrapper
! TODO put this into separate file, and only have the wrappers and convenience functions here
! The interface should not be public! Only this module counts as the public API!
! We do not consider the C functions public! Can we somehow keep them private?
! TODO support optionally mpi_f08 using CMAKE_ALL_USE_F08 / ALL_USE_F08
! TODO add intent() to dummy arguments
interface
function all_init_f(method, dim, gamma) result(this) bind(C)
use iso_c_binding
integer(c_int), value :: method
integer(c_int), value :: dim
integer(c_int), value :: gamma
type(c_ptr) :: this
end function
! TODO separate function to set tag
subroutine all_set_proc_grid_params_f(obj, loc, nloc, size, nsize) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), dimension(nloc) :: loc
integer(c_int), value :: nloc
integer(c_int), dimension(nsize) :: size
integer(c_int), value :: nsize
end subroutine
subroutine all_set_min_domain_size_f(obj, dim, domain_size) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: dim
real(c_double), dimension(dim) :: domain_size
end subroutine
subroutine all_set_work_f(obj, work) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
real(c_double), value :: work
end subroutine
! TODO is dim here really necessary? How should the public API be, just vertices I assume
! check the C++ API
subroutine all_set_vertices_f(obj, n, dim, vertices) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: n
integer(c_int), value :: dim
real(c_double), dimension(n*dim) :: vertices
end subroutine
! TODO Change for mpi_f08!
subroutine all_set_communicator_f(obj, comm) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer, value :: comm
end subroutine
subroutine all_setup_f(obj) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
end subroutine
subroutine all_balance_f(obj) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
end subroutine
subroutine all_get_new_number_of_vertices_f(obj, n) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int) :: n
end subroutine
! TODO is n here needed? may it be inout?
! TODO automatically get number of vertices
! TODO check length of vertices (need dim for that, length is n*dim)
subroutine all_get_vertices_f(obj, n, vertices) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: n
real(c_double), dimension(*) :: vertices
end subroutine
! TODO same as all_get_vertices_f
subroutine all_get_prev_vertices(obj, n, vertices) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: n
real(c_double), dimension(*) :: vertices
end subroutine
subroutine all_print_vtk_outlines_f(obj, step) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: step
end subroutine
end interface
type, public :: ALL_t
type(c_ptr), private :: object = C_NULL_PTR
contains
procedure :: init => ALL_init
end type
contains
!> Initializes the loadbalancing object
subroutine ALL_init(this)
class(ALL_t), intent(out) :: this
end subroutine
end module
......@@ -35,7 +35,7 @@ install(FILES ${ALL_HEADER_FILES}
if (CM_ALL_FORTRAN)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
add_library (ALL_fortran ALL_module.f90)
add_library (ALL_fortran ALL_module.f90 ALL_module_obj.F90)
set_property(TARGET ALL_fortran PROPERTY LINKER_LANGUAGE Fortran)
if(CM_ALL_VTK_OUTPUT)
......@@ -47,7 +47,7 @@ if (CM_ALL_FORTRAN)
# target_link_libraries(ALL_fortran PUBLIC ${CM_ALL_VORO_LIB})
#endif(CM_ALL_VORONOI)
target_include_directories(ALL_fortran PUBLIC ${MPI_CXX_INCLUDE_PATH})
target_include_directories(ALL_fortran PUBLIC ${MPI_Fortran_INCLUDE_PATH})
target_include_directories(ALL_fortran PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ALL_INCLUDE_DIR})
target_link_libraries(ALL_fortran PUBLIC ${MPI_Fortran_LINK_FLAGS} ${MPI_Fortran_LIBRARIES} ALL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment