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

Add error return values

parent 8850b049
......@@ -263,7 +263,11 @@ module elpa_api
import elpa_t
implicit none
class(elpa_t), intent(inout) :: self
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -280,7 +284,11 @@ module elpa_api
implicit none
class(elpa_t), intent(inout) :: self
character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out):: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -297,7 +305,11 @@ module elpa_api
implicit none
class(elpa_t), intent(inout) :: self
character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -339,7 +351,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(inout), target :: tune_state
logical :: unfinished
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end function
end interface
......@@ -357,7 +373,12 @@ module elpa_api
implicit none
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -375,7 +396,12 @@ module elpa_api
implicit none
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -392,7 +418,11 @@ module elpa_api
implicit none
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -411,7 +441,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......@@ -430,7 +464,11 @@ module elpa_api
class(elpa_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
character(*), intent(in) :: file_name
#ifdef USE_FORTRAN2008
integer, optional, intent(out) :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
#endif
......@@ -698,10 +736,16 @@ module elpa_api
!> Parameters
!> \param self class(elpa_autotune_t): the ELPA autotune object
abstract interface
subroutine elpa_autotune_print_i(self)
subroutine elpa_autotune_print_i(self, error)
import elpa_autotune_t
implicit none
class(elpa_autotune_t), intent(in) :: self
#ifdef USE_FORTRAN2008
integer, intent(out), optional :: error
#else
integer, intent(out) :: error
#endif
end subroutine
end interface
......
......@@ -23,9 +23,14 @@ module elpa_autotune_impl
!> \brief function to print the autotuning
!> Parameters
!> \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
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"
end subroutine
......
......@@ -207,6 +207,7 @@ module elpa_impl
endif
end function
!c> /*! \brief C interface for the implementation of the elpa_allocate method
!c> *
!c> * \param none
......@@ -222,6 +223,7 @@ module elpa_impl
ptr = c_loc(obj)
end function
!c> /*! \brief C interface for the implementation of the elpa_deallocate method
!c> *
!c> * \param elpa_t handle of ELPA object to be deallocated
......@@ -237,6 +239,7 @@ module elpa_impl
deallocate(self)
end subroutine
#ifdef ENABLE_AUTOTUNING
!c> /*! \brief C interface for the implementation of the elpa_autotune_deallocate method
!c> *
......@@ -255,6 +258,7 @@ module elpa_impl
end subroutine
#endif
! 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
! by elpa. If the walues are present already, they are checked for consistency with the communicators.
......@@ -365,6 +369,7 @@ module elpa_impl
end subroutine
!> \brief function to setup an ELPA object and to store the MPI communicators internally
!> Parameters
!> \param self class(elpa_impl_t), the allocated ELPA object
......@@ -460,6 +465,7 @@ module elpa_impl
end function
!c> /*! \brief C interface for the implementation of the elpa_setup method
!c> *
!c> * \param elpa_t handle of the ELPA object which describes the problem to
......@@ -508,6 +514,7 @@ module elpa_impl
error = ELPA_OK
end function
!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> *
......@@ -880,6 +887,7 @@ module elpa_impl
#undef SINGLE_PRECISION
#endif
! function use_cannons_algorithm(self) result(use_cannon, do_print)
! class(elpa_impl_t), intent(inout), target :: self
! logical :: use_cannon
......@@ -986,10 +994,14 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(inout), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl
integer, optional, intent(out) :: error
logical :: unfinished
integer :: i
real(kind=C_DOUBLE) :: time_spent
#ifdef USE_FORTRAN2008
integer(kind=c_int), optional, intent(out) :: error
#else
integer(kind=c_int), intent(out) :: error
#endif
logical :: unfinished
integer :: i
real(kind=C_DOUBLE) :: time_spent
if (present(error)) then
error = ELPA_OK
......@@ -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> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned
......@@ -1071,9 +1055,9 @@ module elpa_impl
!c> * \param error int *error code
!c> * \result int unfinished: describes whether autotuning finished (0) or not (1)
!c> */
!c> int elpa_autotune_step_err(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
function elpa_autotune_step_err_c(handle, autotune_handle, &
error) result(unfinished) bind(C, name="elpa_autotune_step_err")
!c> int elpa_autotune_step(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
function elpa_autotune_step_c(handle, autotune_handle, &
error) result(unfinished) bind(C, name="elpa_autotune_step")
type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self
......@@ -1104,8 +1088,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl
#ifdef USE_FORTRAN2008
integer(kind=ik), optional, intent(out) :: error
#else
integer(kind=ik), intent(out) :: error
#endif
if (present(error)) then
error = ELPA_OK
endif
......@@ -1139,8 +1126,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
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
error = ELPA_OK
endif
......@@ -1173,8 +1163,11 @@ module elpa_impl
subroutine elpa_print_settings(self, error)
implicit none
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
error = ELPA_OK
endif
......@@ -1213,7 +1206,11 @@ module elpa_impl
implicit none
class(elpa_impl_t), intent(inout) :: self
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
error = ELPA_OK
......@@ -1255,8 +1252,11 @@ module elpa_impl
implicit none
class(elpa_impl_t), intent(inout) :: self
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
error = ELPA_OK
endif
......@@ -1296,8 +1296,11 @@ module elpa_impl
class(elpa_impl_t), intent(inout) :: self
class(elpa_autotune_t), intent(in), target :: tune_state
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
error = ELPA_OK
endif
......@@ -1333,8 +1336,11 @@ module elpa_impl
class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl
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
error = ELPA_OK
endif
......@@ -1370,7 +1376,11 @@ module elpa_impl
class(elpa_autotune_t), intent(in), target :: tune_state
type(elpa_autotune_impl_t), pointer :: ts_impl
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
error = ELPA_OK
......@@ -1398,25 +1408,6 @@ module elpa_impl
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> *
......@@ -1425,8 +1416,8 @@ module elpa_impl
!c> * \param error int *
!c> * \result none
!c> */
!c> void elpa_autotune_set_best_err(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")
!c> void elpa_autotune_set_best(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
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 :: autotune_handle
type(elpa_impl_t), pointer :: self
......@@ -1441,26 +1432,6 @@ module elpa_impl
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> *
!c> * \param elpa_t handle: of the ELPA object which should be tuned
......@@ -1468,8 +1439,8 @@ module elpa_impl
!c> * \param error int *
!c> * \result none
!c> */
!c> void elpa_autotune_print_best_err(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")
!c> void elpa_autotune_print_best(elpa_t handle, elpa_autotune_t autotune_handle, int *error);
subroutine elpa_autotune_print_best_c(handle, autotune_handle, error) bind(C, name="elpa_autotune_print_best")
type(c_ptr), intent(in), value :: handle
type(c_ptr), intent(in), value :: autotune_handle
type(elpa_impl_t), pointer :: self
......
......@@ -219,7 +219,7 @@ int main(int argc, char** argv) {
for (i=0; i < 20; i++) {
unfinished = elpa_autotune_step_err(handle, autotune_handle, &error);
unfinished = elpa_autotune_step(handle, autotune_handle, &error);
if (unfinished == 0) {
if (myid == 0) {
......@@ -269,7 +269,7 @@ int main(int argc, char** argv) {
}
}
elpa_autotune_set_best_no_err(handle, autotune_handle);
elpa_autotune_set_best(handle, autotune_handle, &error);
elpa_autotune_deallocate(autotune_handle);
elpa_deallocate(handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment