Skip to content

Commit

Permalink
Merge branch 'lax-unit-tests' into 'develop'
Browse files Browse the repository at this point in the history
Add a unit test for LAPACK zdotc.

See merge request QEF/q-e!1506
  • Loading branch information
ye-luo committed Jul 17, 2021
2 parents 38720dc + cae2e0f commit 0511df0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions LAXlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ if(QE_ENABLE_TEST)
add_unit_test(test_qe_lax-r1-t3 1 3 $<TARGET_FILE:qe_lax_test>)
add_unit_test(test_qe_lax-r4-t1 4 1 $<TARGET_FILE:qe_lax_test>)
add_unit_test(test_qe_lax-r9-t2 9 2 $<TARGET_FILE:qe_lax_test>)

add_subdirectory(tests)
endif(QE_ENABLE_TEST)
12 changes: 12 additions & 0 deletions LAXlib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
qe_add_executable(test_qe_lax_lapack_zdotc test_lapack_zdotc.f90)
set_target_properties(test_qe_lax_lapack_zdotc
PROPERTIES
OUTPUT_NAME test_qe_lax_lapack_zdotc.x
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../bin)
target_link_libraries(test_qe_lax_lapack_zdotc
PRIVATE
qe_openmp_fortran
qe_mpi_fortran
qe_lapack)

add_unit_test(test_qe_lapack_zdotc 1 1 $<TARGET_FILE:test_qe_lax_lapack_zdotc>)
18 changes: 18 additions & 0 deletions LAXlib/tests/test_lapack_zdotc.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
program test
implicit none
complex*16 :: a(2), b(2)
complex*16 res
complex*16, external :: ZDOTC

a(1) = (-9.6224246089610388d-2, 3.2442340359108593d-3)
a(2) = (-0.9037769140058165, 3.2441868631152768d-3)

b(1) = (-0.9999890875238262, -5.3357405582201908d-7)
b(2) = (-0.9999998761616069, 4.3341267956954060d-8)

res = ZDOTC(2, a, 1, b, 1)
if (ABS(res - (1.0000000308637980,6.48839729724212839E-003)) >= 1.d-6) then
write(*,*) "zdotc check failed. Expected (1.0000000308637980,6.48839729724212839E-003) but got ", res
stop 1
endif
end program

0 comments on commit 0511df0

Please sign in to comment.