Commit a092b731 authored by Andreas Marek's avatar Andreas Marek Committed by Pavel Kus

Return more expressive error codes

parent 4ffc2622
...@@ -93,7 +93,12 @@ enum ELPA_COMPLEX_KERNELS { ...@@ -93,7 +93,12 @@ enum ELPA_COMPLEX_KERNELS {
X(ELPA_ERROR_ENTRY_INVALID_VALUE, -3) \ X(ELPA_ERROR_ENTRY_INVALID_VALUE, -3) \
X(ELPA_ERROR_ENTRY_ALREADY_SET, -4) \ X(ELPA_ERROR_ENTRY_ALREADY_SET, -4) \
X(ELPA_ERROR_ENTRY_NO_STRING_REPRESENTATION, -5) \ X(ELPA_ERROR_ENTRY_NO_STRING_REPRESENTATION, -5) \
X(ELPA_ERROR_ENTRY_READONLY, -6) X(ELPA_ERROR_SETUP, -6) \
X(ELPA_ERROR_CRITICAL, -7) \
X(ELPA_ERROR_API_VERSION, -8) \
X(ELPA_ERROR_AUTOTUNE_API_VERSION, -9) \
X(ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED, -10) \
X(ELPA_ERROR_ENTRY_READONLY, -11)
enum ELPA_ERRORS { enum ELPA_ERRORS {
ELPA_FOR_ALL_ERRORS(ELPA_ENUM_ENTRY) ELPA_FOR_ALL_ERRORS(ELPA_ENUM_ENTRY)
......
...@@ -188,7 +188,7 @@ module elpa_impl ...@@ -188,7 +188,7 @@ module elpa_impl
if ( elpa_initialized() .ne. ELPA_OK) then if ( elpa_initialized() .ne. ELPA_OK) then
write(error_unit, *) "elpa_allocate(): you must call elpa_init() once before creating instances of ELPA" write(error_unit, *) "elpa_allocate(): you must call elpa_init() once before creating instances of ELPA"
if(present(error)) then if(present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_SETUP
endif endif
return return
endif endif
...@@ -471,7 +471,6 @@ module elpa_impl ...@@ -471,7 +471,6 @@ module elpa_impl
self%communicators_owned = 0 self%communicators_owned = 0
error = ELPA_OK error = ELPA_OK
call self%get("mpi_comm_rows", mpi_comm_rows,error) call self%get("mpi_comm_rows", mpi_comm_rows,error)
if (error .ne. ELPA_OK) then if (error .ne. ELPA_OK) then
print *,"Problem getting option. Aborting..." print *,"Problem getting option. Aborting..."
...@@ -950,10 +949,10 @@ module elpa_impl ...@@ -950,10 +949,10 @@ module elpa_impl
write(error_unit, "(a,i0,a)") "ELPA: Error API version: Autotuning does not support ", elpa_get_api_version() write(error_unit, "(a,i0,a)") "ELPA: Error API version: Autotuning does not support ", elpa_get_api_version()
#ifdef USE_FORTRAN2008 #ifdef USE_FORTRAN2008
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_API_VERSION
endif endif
#else #else
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_API_VERSION
#endif #endif
return return
endif endif
...@@ -1123,16 +1122,16 @@ module elpa_impl ...@@ -1123,16 +1122,16 @@ module elpa_impl
type is (elpa_autotune_impl_t) type is (elpa_autotune_impl_t)
ts_impl => tune_state ts_impl => tune_state
class default class default
print *, "This should not happen" write(error_unit, *) "This should not happen! Critical error"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_CRITICAL
endif endif
end select end select
if (elpa_index_set_autotune_parameters_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc) /= 1) then if (elpa_index_set_autotune_parameters_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc) /= 1) then
print *, "This should not happen (in elpa_autotune_set_best())" write(error_unit, *) "This should not happen (in elpa_autotune_set_best())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED
endif endif
endif endif
end subroutine end subroutine
...@@ -1161,19 +1160,19 @@ module elpa_impl ...@@ -1161,19 +1160,19 @@ module elpa_impl
type is (elpa_autotune_impl_t) type is (elpa_autotune_impl_t)
ts_impl => tune_state ts_impl => tune_state
class default class default
print *, "This should not happen" write(error_unit, *) "This should not happen! Critical error"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_CRITICAL
endif endif
end select end select
print *, "The following settings were found to be best:" !print *, "The following settings were found to be best:"
print *, "Best, i = ", ts_impl%min_loc, "best time = ", ts_impl%min_val !print *, "Best, i = ", ts_impl%min_loc, "best time = ", ts_impl%min_val
flush(output_unit) flush(output_unit)
if (elpa_index_print_autotune_parameters_c(self%index, ts_impl%level, ts_impl%domain) /= 1) then if (elpa_index_print_autotune_parameters_c(self%index, ts_impl%level, ts_impl%domain) /= 1) then
print *, "This should not happen (in elpa_autotune_print_best())" write(error_unit, *) "This should not happen (in elpa_autotune_print_best())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED
endif endif
endif endif
end subroutine end subroutine
...@@ -1195,7 +1194,7 @@ module elpa_impl ...@@ -1195,7 +1194,7 @@ module elpa_impl
error = ELPA_OK error = ELPA_OK
endif endif
if (elpa_index_print_settings_c(self%index, c_null_char) /= 1) then if (elpa_index_print_settings_c(self%index, c_null_char) /= 1) then
print *, "This should not happen (in elpa_print_settings())" write(error_unit, *) "This should not happen (in elpa_print_settings())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR
endif endif
...@@ -1239,7 +1238,7 @@ module elpa_impl ...@@ -1239,7 +1238,7 @@ module elpa_impl
error = ELPA_OK error = ELPA_OK
endif endif
if (elpa_index_print_settings_c(self%index, file_name // c_null_char) /= 1) then if (elpa_index_print_settings_c(self%index, file_name // c_null_char) /= 1) then
print *, "This should not happen (in elpa_store_settings())" write(error_unit, *) "This should not happen (in elpa_store_settings())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR
endif endif
...@@ -1285,7 +1284,7 @@ module elpa_impl ...@@ -1285,7 +1284,7 @@ module elpa_impl
error = ELPA_OK error = ELPA_OK
endif endif
if (elpa_index_load_settings_c(self%index, file_name // c_null_char) /= 1) then if (elpa_index_load_settings_c(self%index, file_name // c_null_char) /= 1) then
print *, "This should not happen (in elpa_load_settings())" write(error_unit, *) "This should not happen (in elpa_load_settings())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR
endif endif
...@@ -1335,17 +1334,17 @@ module elpa_impl ...@@ -1335,17 +1334,17 @@ module elpa_impl
type is (elpa_autotune_impl_t) type is (elpa_autotune_impl_t)
ts_impl => tune_state ts_impl => tune_state
class default class default
print *, "This should not happen" write(error_unit, *) "This should not happen! Critical erro"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_CRITICAL
endif endif
end select end select
if (elpa_index_print_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, & if (elpa_index_print_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, &
ts_impl%min_val, ts_impl%current, ts_impl%cardinality, c_null_char) /= 1) then ts_impl%min_val, ts_impl%current, ts_impl%cardinality, c_null_char) /= 1) then
print *, "This should not happen (in elpa_autotune_print_state())" write(error_unit, *) "This should not happen (in elpa_autotune_print_state())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED
endif endif
endif endif
end subroutine end subroutine
...@@ -1399,17 +1398,17 @@ module elpa_impl ...@@ -1399,17 +1398,17 @@ module elpa_impl
type is (elpa_autotune_impl_t) type is (elpa_autotune_impl_t)
ts_impl => tune_state ts_impl => tune_state
class default class default
print *, "This should not happen" write(error_unit, *) "This should not happen! Critical error"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_CRITICAL
endif endif
end select end select
if (elpa_index_print_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, & if (elpa_index_print_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, &
ts_impl%min_val, ts_impl%current, ts_impl%cardinality, file_name // c_null_char) /= 1) then ts_impl%min_val, ts_impl%current, ts_impl%cardinality, file_name // c_null_char) /= 1) then
print *, "This should not happen (in elpa_autotune_save_state())" write(error_unit, *) "This should not happen (in elpa_autotune_save_state())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED
endif endif
endif endif
end subroutine end subroutine
...@@ -1468,9 +1467,9 @@ module elpa_impl ...@@ -1468,9 +1467,9 @@ module elpa_impl
type is (elpa_autotune_impl_t) type is (elpa_autotune_impl_t)
ts_impl => tune_state ts_impl => tune_state
class default class default
print *, "This should not happen" write(error_unit, *) "This should not happen! Critical error"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_CRITICAL
endif endif
end select end select
...@@ -1478,12 +1477,12 @@ module elpa_impl ...@@ -1478,12 +1477,12 @@ module elpa_impl
if (elpa_index_load_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, & if (elpa_index_load_autotune_state_c(self%index, ts_impl%level, ts_impl%domain, ts_impl%min_loc, &
ts_impl%min_val, ts_impl%current, ts_impl%cardinality, file_name // c_null_char) /= 1) then ts_impl%min_val, ts_impl%current, ts_impl%cardinality, file_name // c_null_char) /= 1) then
!print *, "This should not happen (in elpa_autotune_load_state())" write(error_unit, *) "This should not happen (in elpa_autotune_load_state())"
if (present(error)) then if (present(error)) then
error = ELPA_ERROR error = ELPA_ERROR_AUTOTUNE_OBJECT_CHANGED
endif endif
endif endif
print *, "testing, after C call, ts_impl%current is ", ts_impl%current !print *, "testing, after C call, ts_impl%current is ", ts_impl%current
end subroutine end subroutine
......
...@@ -206,7 +206,7 @@ program test ...@@ -206,7 +206,7 @@ program test
e_ptr => e2 e_ptr => e2
tune_state => e_ptr%autotune_setup(ELPA_AUTOTUNE_MEDIUM, AUTOTUNE_DOMAIN, error) tune_state => e_ptr%autotune_setup(ELPA_AUTOTUNE_FAST, AUTOTUNE_DOMAIN, error)
assert_elpa_ok(error) assert_elpa_ok(error)
......
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