From 350522d8afcab112221953a7d6b0399a4c65f794 Mon Sep 17 00:00:00 2001 From: Stephan Schulz <stephan.schulz-x2q@rub.de> Date: Wed, 25 Nov 2020 15:20:55 +0100 Subject: [PATCH] change Fortran get_gamma to argument call --- README_new.md | 14 +++++++++++++- src/ALL_fortran.cpp | 2 +- src/ALL_module.F90 | 12 ++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README_new.md b/README_new.md index 6cfd91a..92afa7f 100644 --- a/README_new.md +++ b/README_new.md @@ -201,7 +201,7 @@ and then retrieve the new vertices using or new neighbors with - void ALL::ALL<T,W>::getNeighbors ( std::vector<in> &neighbors ) + std::vector<int> &ALL::ALL<T,W>::getNeighbors () ### Special considerations for the Fortran interface The Fortran interface exists in two versions. Either in the form of @@ -227,6 +227,18 @@ and previous interfaces. In previous interfaces all MPI types are the communicator used in the user's application, build the library with enabled Fortran 2008 features and this communicator type is expected. +Retrieving information from the balancer is also different, since most +getter return (a reference to) an object itself. The Fortran subroutines +set the values of its arguments. As an example + + int work = all.getWork(); + +becomes + + integer(c_int) :: work + call ALL_get_work(work) !or + !call all%get_work(work) + ### Details of the balancing methods #### Tensor based diff --git a/src/ALL_fortran.cpp b/src/ALL_fortran.cpp index 38c2d02..da15752 100644 --- a/src/ALL_fortran.cpp +++ b/src/ALL_fortran.cpp @@ -173,7 +173,7 @@ void all_balance_c(ALL_t *all_obj) { ALL_catch } -double all_get_gamma_c(ALL_t *all_obj) { return all_obj->getGamma(); } +double all_get_gamma_c(ALL_t *all_obj, double *gamma) { *gamma = all_obj->getGamma(); } // wrapper to get number of new vertices void all_get_number_of_vertices_c(ALL_t *all_obj, int *n_vertices) { diff --git a/src/ALL_module.F90 b/src/ALL_module.F90 index 3758ee5..94f7eb8 100644 --- a/src/ALL_module.F90 +++ b/src/ALL_module.F90 @@ -138,11 +138,11 @@ module ALL_module use iso_c_binding type(c_ptr), value :: obj end subroutine - function all_get_gamma_c(obj) result(gamma) bind(C) + subroutine all_get_gamma_c(obj, gamma) bind(C) use iso_c_binding type(c_ptr), value :: obj real(c_double) :: gamma - end function + end subroutine subroutine all_get_number_of_vertices_c(obj, n) bind(C) use iso_c_binding type(c_ptr), value :: obj @@ -376,11 +376,11 @@ contains call all_balance_c(this%object) end subroutine !> Retrieve currently set gamma value of balancer - function ALL_get_gamma(this) result(gamma) + subroutine ALL_get_gamma(this, gamma) class(ALL_t), intent(in) :: this - real(c_double) :: gamma - gamma = all_get_gamma_c(this%object) - end function + real(c_double), intent(out) :: gamma + call all_get_gamma_c(this%object, gamma) + end subroutine !> Retrieve number of vertices for current vertices subroutine ALL_get_number_of_vertices(this, n) class(ALL_t), intent(in) :: this -- GitLab