Commit 75a3bcfd authored by Pavel Kus's avatar Pavel Kus Committed by Lorenz Huedepohl
Browse files

separated assert implementation and #defines

and moved the implementation to test_util.F90
parent 6500ebe7
subroutine x_a(condition, condition_string, file, line)
#ifdef HAVE_ISO_FORTRAN_ENV
use iso_fortran_env, only : error_unit
#endif
implicit none
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 0
#endif
logical, intent(in) :: condition
character(len=*), intent(in) :: condition_string
character(len=*), intent(in) :: file
integer, intent(in) :: line
if (.not. condition) then
write(error_unit,'(a,i0)') "Assertion `" // condition_string // "` failed at " // file // ":", line
stop 1
end if
end subroutine
subroutine x_ao(error_code, error_code_string, file, line)
use elpa
#ifdef HAVE_ISO_FORTRAN_ENV
use iso_fortran_env, only : error_unit
#endif
implicit none
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 0
#endif
integer, intent(in) :: error_code
character(len=*), intent(in) :: error_code_string
character(len=*), intent(in) :: file
integer, intent(in) :: line
if (error_code /= ELPA_OK) then
write(error_unit,'(a,i0)') "Assertion failed: `" // error_code_string // &
" is " // elpa_strerr(error_code) // "` at " // file // ":", line
stop 1
end if
end subroutine
#define stringify_(x) "x" #define stringify_(x) "x"
#define stringify(x) stringify_(x) #define stringify(x) stringify_(x)
#define assert(x) call x_a(x, stringify(x), "F", __LINE__) #define assert(x) call x_a(x, stringify(x), "F", __LINE__)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
! any derivatives of ELPA under the same license that we chose for ! any derivatives of ELPA under the same license that we chose for
! the original distribution, the GNU Lesser General Public License. ! the original distribution, the GNU Lesser General Public License.
!#include "assert.h" ! why complains? #include "../Fortran/assert.h"
#include "config-f90.h" #include "config-f90.h"
module test_analytic module test_analytic
......
...@@ -99,4 +99,44 @@ module test_util ...@@ -99,4 +99,44 @@ module test_util
s = real(ticks, kind=c_double) / tick_rate s = real(ticks, kind=c_double) / tick_rate
end function end function
subroutine x_a(condition, condition_string, file, line)
#ifdef HAVE_ISO_FORTRAN_ENV
use iso_fortran_env, only : error_unit
#endif
implicit none
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 0
#endif
logical, intent(in) :: condition
character(len=*), intent(in) :: condition_string
character(len=*), intent(in) :: file
integer, intent(in) :: line
if (.not. condition) then
write(error_unit,'(a,i0)') "Assertion `" // condition_string // "` failed at " // file // ":", line
stop 1
end if
end subroutine
subroutine x_ao(error_code, error_code_string, file, line)
use elpa
#ifdef HAVE_ISO_FORTRAN_ENV
use iso_fortran_env, only : error_unit
#endif
implicit none
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 0
#endif
integer, intent(in) :: error_code
character(len=*), intent(in) :: error_code_string
character(len=*), intent(in) :: file
integer, intent(in) :: line
if (error_code /= ELPA_OK) then
write(error_unit,'(a,i0)') "Assertion failed: `" // error_code_string // &
" is " // elpa_strerr(error_code) // "` at " // file // ":", line
stop 1
end if
end subroutine
end module end module
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