Commit 316be4bf authored by Andreas Marek's avatar Andreas Marek
Browse files

Add error return values

parent 8850b049
...@@ -263,7 +263,11 @@ module elpa_api ...@@ -263,7 +263,11 @@ module elpa_api
import elpa_t import elpa_t
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -280,7 +284,11 @@ module elpa_api ...@@ -280,7 +284,11 @@ module elpa_api
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out):: error integer, optional, intent(out):: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -297,7 +305,11 @@ module elpa_api ...@@ -297,7 +305,11 @@ module elpa_api
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -339,7 +351,11 @@ module elpa_api ...@@ -339,7 +351,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(inout), target :: tune_state class(elpa_autotune_t), intent(inout), target :: tune_state
logical :: unfinished logical :: unfinished
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end function end function
end interface end interface
...@@ -357,7 +373,12 @@ module elpa_api ...@@ -357,7 +373,12 @@ module elpa_api
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -375,7 +396,12 @@ module elpa_api ...@@ -375,7 +396,12 @@ module elpa_api
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -392,7 +418,11 @@ module elpa_api ...@@ -392,7 +418,11 @@ module elpa_api
implicit none implicit none
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -411,7 +441,11 @@ module elpa_api ...@@ -411,7 +441,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
...@@ -430,7 +464,11 @@ module elpa_api ...@@ -430,7 +464,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
#endif #endif
...@@ -698,10 +736,16 @@ module elpa_api ...@@ -698,10 +736,16 @@ module elpa_api
!> Parameters !> Parameters
!> \param self class(elpa_autotune_t): the ELPA autotune object !> \param self class(elpa_autotune_t): the ELPA autotune object
abstract interface abstract interface
subroutine elpa_autotune_print_i(self) subroutine elpa_autotune_print_i(self, error)
import elpa_autotune_t import elpa_autotune_t
implicit none implicit none
class(elpa_autotune_t), intent(in) :: self class(elpa_autotune_t), intent(in) :: self
#ifdef USE_FORTRAN2008
integer, intent(out), optional :: error
#else
integer, intent(out) :: error
#endif
end subroutine end subroutine
end interface end interface
......
...@@ -23,9 +23,14 @@ module elpa_autotune_impl ...@@ -23,9 +23,14 @@ module elpa_autotune_impl
!> \brief function to print the autotuning !> \brief function to print the autotuning
!> Parameters !> Parameters
!> \param self class(elpa_autotune_impl_t) the allocated ELPA autotune object !> \param self class(elpa_autotune_impl_t) the allocated ELPA autotune object
subroutine elpa_autotune_print(self) subroutine elpa_autotune_print(self, error)
implicit none implicit none
class(elpa_autotune_impl_t), intent(in) :: self class(elpa_autotune_impl_t), intent(in) :: self
#ifdef USE_FORTRAN2008
integer, intent(out), optional :: error
#else
integer, intent(out) :: error
#endif
!print *, "Print me" !print *, "Print me"
end subroutine end subroutine
......
...@@ -207,6 +207,7 @@ module elpa_impl ...@@ -207,6 +207,7 @@ module elpa_impl
endif endif
end function end function
!c> /*! \brief C interface for the implementation of the elpa_allocate method !c> /*! \brief C interface for the implementation of the elpa_allocate method
!c> * !c> *
!c> * \param none !c> * \param none
...@@ -222,6 +223,7 @@ module elpa_impl ...@@ -222,6 +223,7 @@ module elpa_impl
ptr = c_loc(obj) ptr = c_loc(obj)
end function end function
!c> /*! \brief C interface for the implementation of the elpa_deallocate method !c> /*! \brief C interface for the implementation of the elpa_deallocate method
!c> * !c> *
!c> * \param elpa_t handle of ELPA object to be deallocated !c> * \param elpa_t handle of ELPA object to be deallocated
...@@ -237,6 +239,7 @@ module elpa_impl ...@@ -237,6 +239,7 @@ module elpa_impl
deallocate(self) deallocate(self)
end subroutine end subroutine
#ifdef ENABLE_AUTOTUNING #ifdef ENABLE_AUTOTUNING
!c> /*! \brief C interface for the implementation of the elpa_autotune_deallocate method !c> /*! \brief C interface for the implementation of the elpa_autotune_deallocate method
!c> * !c> *
...@@ -255,6 +258,7 @@ module elpa_impl ...@@ -255,6 +258,7 @@ module elpa_impl
end subroutine end subroutine
#endif #endif
! we want to ensure, that my_prow(col) and np_rows(cols) values are allways accessible trhough ! we want to ensure, that my_prow(col) and np_rows(cols) values are allways accessible trhough
! the elpa object, no matter whether the user provides communicators or communicators are created ! the elpa object, no matter whether the user provides communicators or communicators are created
! by elpa. If the walues are present already, they are checked for consistency with the communicators. ! by elpa. If the walues are present already, they are checked for consistency with the communicators.
...@@ -365,6 +369,7 @@ module elpa_impl ...@@ -365,6 +369,7 @@ module elpa_impl
end subroutine end subroutine
!> \brief function to setup an ELPA object and to store the MPI communicators internally !> \brief function to setup an ELPA object and to store the MPI communicators internally
!> Parameters !> Parameters
!> \param self class(elpa_impl_t), the allocated ELPA object !> \param self class(elpa_impl_t), the allocated ELPA object
...@@ -460,6 +465,7 @@ module elpa_impl ...@@ -460,6 +465,7 @@ module elpa_impl
end function end function
!c> /*! \brief C interface for the implementation of the elpa_setup method !c> /*! \brief C interface for the implementation of the elpa_setup method
!c> * !c> *
!c> * \param elpa_t handle of the ELPA object which describes the problem to !c> * \param elpa_t handle of the ELPA object which describes the problem to
...@@ -508,6 +514,7 @@ module elpa_impl ...@@ -508,6 +514,7 @@ module elpa_impl
error = ELPA_OK error = ELPA_OK
end function end function
!c> /*! \brief C interface for the implementation of the elpa_set_integer method !c> /*! \brief C interface for the implementation of the elpa_set_integer method
!c> * This method is available to the user as C generic elpa_set method !c> * This method is available to the user as C generic elpa_set method
!c> * !c> *
...@@ -880,6 +887,7 @@ module elpa_impl ...@@ -880,6 +887,7 @@ module elpa_impl
#undef SINGLE_PRECISION #undef SINGLE_PRECISION
#endif #endif
! function use_cannons_algorithm(self) result(use_cannon, do_print) ! function use_cannons_algorithm(self) result(use_cannon, do_print)
! class(elpa_impl_t), intent(inout), target :: self ! class(elpa_impl_t), intent(inout), target :: self
! logical :: use_cannon ! logical :: use_cannon
...@@ -986,10 +994,14 @@ module elpa_impl ...@@ -986,10 +994,14 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(inout), target :: tune_state class(elpa_autotune_t), intent(inout), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
logical :: unfinished integer(kind=c_int), optional, intent(out) :: error
integer :: i #else
real(kind=C_DOUBLE) :: time_spent integer(kind=c_int), intent(out) :: error
#endif
logical :: unfinished
integer :: i
real(kind=C_DOUBLE) :: time_spent
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
...@@ -1036,34 +1048,6 @@ module elpa_impl ...@@ -1036,34 +1048,6 @@ module elpa_impl
!c> /*! \brief C interface for the implementation of the elpa_autotune_step method
!c> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned
!c> * \param elpa_autotune_t autotune_handle: the autotuning object
!c> * \result int unfinished: describes whether autotuning finished (0) or not (1)
!c> */
!c> int elpa_autotune_step_no_err(elpa_t handle, elpa_autotune_t autotune_handle);
function elpa_autotune_step_no_err_c(handle, autotune_handle) result(unfinished) bind(C, name="elpa_autotune_step_no_err")
type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self
type(elpa_autotune_impl_t), pointer :: tune_state
logical :: unfinished_f
integer(kind=c_int) :: unfinished
call c_f_pointer(handle, self)
call c_f_pointer(autotune_handle, tune_state)
unfinished_f = self%autotune_step(tune_state)
if (unfinished_f) then
unfinished = 1
else
unfinished = 0
endif
end function
!c> /*! \brief C interface for the implementation of the elpa_autotune_step method !c> /*! \brief C interface for the implementation of the elpa_autotune_step method
!c> * !c> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned !c> * \param elpa_t handle: of the ELPA object which should be tuned
...@@ -1071,9 +1055,9 @@ module elpa_impl ...@@ -1071,9 +1055,9 @@ module elpa_impl
!c> * \param error int *error code !c> * \param error int *error code
!c> * \result int unfinished: describes whether autotuning finished (0) or not (1) !c> * \result int unfinished: describes whether autotuning finished (0) or not (1)
!c> */ !c> */
!c> int elpa_autotune_step_err(elpa_t handle, elpa_autotune_t autotune_handle, int *error); !c> int elpa_autotune_step(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
function elpa_autotune_step_err_c(handle, autotune_handle, & function elpa_autotune_step_c(handle, autotune_handle, &
error) result(unfinished) bind(C, name="elpa_autotune_step_err") error) result(unfinished) bind(C, name="elpa_autotune_step")
type(c_ptr), intent(in), value :: handle type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self type(elpa_impl_t), pointer :: self
...@@ -1104,8 +1088,11 @@ module elpa_impl ...@@ -1104,8 +1088,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
#ifdef USE_FORTRAN2008
integer(kind=ik), optional, intent(out) :: error integer(kind=ik), optional, intent(out) :: error
#else
integer(kind=ik), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1139,8 +1126,11 @@ module elpa_impl ...@@ -1139,8 +1126,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1173,8 +1163,11 @@ module elpa_impl ...@@ -1173,8 +1163,11 @@ module elpa_impl
subroutine elpa_print_settings(self, error) subroutine elpa_print_settings(self, error)
implicit none implicit none
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1213,7 +1206,11 @@ module elpa_impl ...@@ -1213,7 +1206,11 @@ module elpa_impl
implicit none implicit none
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
...@@ -1255,8 +1252,11 @@ module elpa_impl ...@@ -1255,8 +1252,11 @@ module elpa_impl
implicit none implicit none
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1296,8 +1296,11 @@ module elpa_impl ...@@ -1296,8 +1296,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1333,8 +1336,11 @@ module elpa_impl ...@@ -1333,8 +1336,11 @@ module elpa_impl
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
endif endif
...@@ -1370,7 +1376,11 @@ module elpa_impl ...@@ -1370,7 +1376,11 @@ module elpa_impl
class(elpa_autotune_t), intent(in), target :: tune_state class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl type(elpa_autotune_impl_t), pointer :: ts_impl
character(*), intent(in) :: file_name character(*), intent(in) :: file_name
integer, optional, intent(out) :: error #ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
if (present(error)) then if (present(error)) then
error = ELPA_OK error = ELPA_OK
...@@ -1398,25 +1408,6 @@ module elpa_impl ...@@ -1398,25 +1408,6 @@ module elpa_impl
end subroutine end subroutine
!c> /*! \brief C interface for the implementation of the elpa_autotune_set_best method
!c> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned
!c> * \param elpa_autotune_t autotune_handle: the autotuning object
!c> * \result none
!c> */
!c> void elpa_autotune_set_best_no_err(elpa_t handle, elpa_autotune_t autotune_handle);
subroutine elpa_autotune_set_best_no_err_c(handle, autotune_handle) bind(C, name="elpa_autotune_set_best_no_err")
type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self
type(elpa_autotune_impl_t), pointer :: tune_state
call c_f_pointer(handle, self)
call c_f_pointer(autotune_handle, tune_state)
call self%autotune_set_best(tune_state)
end subroutine
!c> /*! \brief C interface for the implementation of the elpa_autotune_set_best method !c> /*! \brief C interface for the implementation of the elpa_autotune_set_best method
!c> * !c> *
...@@ -1425,8 +1416,8 @@ module elpa_impl ...@@ -1425,8 +1416,8 @@ module elpa_impl
!c> * \param error int * !c> * \param error int *
!c> * \result none !c> * \result none
!c> */ !c> */
!c> void elpa_autotune_set_best_err(elpa_t handle, elpa_autotune_t autotune_handle, int *error); !c> void elpa_autotune_set_best(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
subroutine elpa_autotune_set_best_err_c(handle, autotune_handle, error) bind(C, name="elpa_autotune_set_best_err") subroutine elpa_autotune_set_best_c(handle, autotune_handle, error) bind(C, name="elpa_autotune_set_best")
type(c_ptr), intent(in), value :: handle type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self type(elpa_impl_t), pointer :: self
...@@ -1441,26 +1432,6 @@ module elpa_impl ...@@ -1441,26 +1432,6 @@ module elpa_impl
end subroutine end subroutine
!c> /*! \brief C interface for the implementation of the elpa_autotune_print_best method
!c> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned
!c> * \param elpa_autotune_t autotune_handle: the autotuning object
!c> * \result none
!c> */
!c> void elpa_autotune_print_best_no_err(elpa_t handle, elpa_autotune_t autotune_handle);
subroutine elpa_autotune_print_best_no_err_c(handle, autotune_handle) bind(C, name="elpa_autotune_print_best_no_err")
type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self
type(elpa_autotune_impl_t), pointer :: tune_state
call c_f_pointer(handle, self)
call c_f_pointer(autotune_handle, tune_state)
call self%autotune_print_best(tune_state)
end subroutine
!c> /*! \brief C interface for the implementation of the elpa_autotune_print_best method !c> /*! \brief C interface for the implementation of the elpa_autotune_print_best method
!c> * !c> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned !c> * \param elpa_t handle: of the ELPA object which should be tuned
...@@ -1468,8 +1439,8 @@ module elpa_impl ...@@ -1468,8 +1439,8 @@ module elpa_impl
!c> * \param error int * !c> * \param error int *
!c> * \result none !c> * \result none
!c> */ !c> */
!c> void elpa_autotune_print_best_err(elpa_t handle, elpa_autotune_t autotune_handle, int *error); !c> void elpa_autotune_print_best(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
subroutine elpa_autotune_print_best_err_c(handle, autotune_handle, error) bind(C, name="elpa_autotune_print_best_err")