Skip to content
Snippets Groups Projects
Commit d5f6519d authored by Pradipta Samanta's avatar Pradipta Samanta
Browse files

added the test for the cpp binding of tdma_solver_vec

fixed a bug in testing
parent f6ac8211
No related branches found
No related tags found
1 merge request!37Draft: C++ port of horizontal/mo_lib_gradients.F90
...@@ -43,7 +43,7 @@ if(IM_ENABLE_DIM_SWAP) ...@@ -43,7 +43,7 @@ if(IM_ENABLE_DIM_SWAP)
endif() endif()
if(IM_USE_CPP_BINDINGS) if(IM_USE_CPP_BINDINGS)
target_compile_definitions(iconmath-support PRIVATE __USE_CPP_BINDINGS) target_compile_definitions(iconmath-support PUBLIC __USE_CPP_BINDINGS)
endif() endif()
if(IM_ENABLE_OPENACC) if(IM_ENABLE_OPENACC)
......
...@@ -248,7 +248,9 @@ CONTAINS ...@@ -248,7 +248,9 @@ CONTAINS
INTEGER, PARAMETER :: n = 10 INTEGER, PARAMETER :: n = 10
REAL(wp) :: a(n, n), b(n, n), c(n, n), d(n, n), x(n, n) REAL(wp) :: a(n, n), b(n, n), c(n, n), d(n, n), x(n, n)
INTEGER :: i, j INTEGER :: i, j
REAL(wp) :: sum, sum_ref REAL(wp) :: sum, sum_ref, tol
REAL(wp) :: start_time, end_time, elapsed_time
DO i = 1, n DO i = 1, n
DO j = 1, n DO j = 1, n
a(i, j) = 1.0_wp a(i, j) = 1.0_wp
...@@ -257,14 +259,33 @@ CONTAINS ...@@ -257,14 +259,33 @@ CONTAINS
d(i, j) = 1.0_wp d(i, j) = 1.0_wp
END DO END DO
END DO END DO
CALL CPU_TIME(start_time)
#ifndef __USE_CPP_BINDINGS
CALL tdma_solver_vec(a, b, c, d, 1, n, 1, n, x) CALL tdma_solver_vec(a, b, c, d, 1, n, 1, n, x)
#else
CALL tdma_solver_vec(a, b, c, d, 0, n, 0, n, x, -1)
#endif
CALL CPU_TIME(end_time)
! Compute elapsed time
elapsed_time = end_time - start_time
! Output timing result
write(*,*) "Elapsed time for tdma_solver_vec: ", elapsed_time, " seconds"
sum = 0.0_wp sum = 0.0_wp
DO i = 1, n DO i = 1, n
sum = sum + x(i, 1) DO j = 1, n
sum = sum + x(i, j)
! write(*,"(a,f24.16)") ' x(i, 1): ', x(i, 1)
END DO
END DO END DO
sum_ref = 4.5454545454545467_wp sum_ref = 27.2727272727272769_wp
tol = 1d-15
CALL TAG_TEST("TEST_tdma_solver_vec") CALL TAG_TEST("TEST_tdma_solver_vec")
CALL ASSERT_EQUAL(sum, sum_ref) CALL ASSERT_ALMOST_EQUAL(sum, sum_ref, tol)
END SUBROUTINE TEST_tdma_solver_vec END SUBROUTINE TEST_tdma_solver_vec
END MODULE TEST_mo_math_utilities END MODULE TEST_mo_math_utilities
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment