Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fortran tests #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR}/src/C-interface)
include_directories(
${CMAKE_SOURCE_DIR}/src/C-interface
${CMAKE_BINARY_DIR}/src/Fortran-interface)

set(SOURCES_TYPED
add_matrix_typed.c
Expand Down Expand Up @@ -76,6 +78,27 @@ if(MPI_C_FOUND AND MPI_C_COMPILE_FLAGS)
LINK_FLAGS ${MPI_C_LINK_FLAGS})
endif()

add_executable(bml-test-fortran
test_m.F90
allocate_matrix.F90
bml_test.F90)
target_link_libraries(bml-test-fortran bml ${LINK_LIBRARIES})
set_target_properties(bml-test-fortran
PROPERTIES
LINK_FLAGS "--coverage")
if(OPENMP_FOUND)
set_target_properties(bml-test-fortran
PROPERTIES
COMPILE_FLAGS ${OpenMP_Fortran_FLAGS}
LINK_FLAGS ${OpenMP_Fortran_FLAGS})
endif()
if(MPI_Fortran_FOUND AND MPI_Fortran_COMPILE_FLAGS)
set_target_properties(bml-test-fortran
PROPERTIES
COMPILE_FLAGS ${MPI_Fortran_COMPILE_FLAGS}
LINK_FLAGS ${MPI_Fortran_LINK_FLAGS})
endif()

foreach(N add adjacency adjungate_triangle allocate convert copy diagonalize
get_element get_sparsity inverse multiply norm normalize scale
get_set_diagonal set_row submatrix threshold trace transpose)
Expand All @@ -85,6 +108,7 @@ foreach(N add adjacency adjungate_triangle allocate convert copy diagonalize
#add_test(${N}-${T}-${P} mpirun -np 1 bml-test -n ${N} -t ${T} -p ${P})
#else()
add_test(${N}-${T}-${P} bml-test -n ${N} -t ${T} -p ${P})
add_test(${N}-${T}-${P}-Fortran bml-test-fortran ${N} ${T} ${P})
#endif()
if(NOT BML_MPI AND NOT BML_OPENMP AND VALGRIND)
add_test(${N}-${T}-${P}-valgrind ${VALGRIND} --error-exitcode=1
Expand Down
35 changes: 35 additions & 0 deletions tests/bml_test.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
program bml_test

use bml_types_m

integer :: N = 11
integer :: M = -1
character(1000) :: test = ""
character(1000) :: matrix_type = BML_MATRIX_DENSE
character(1000) :: matrix_precision = BML_ELEMENT_REAL

integer :: n_args

! Arguments are interpreted as
!
! testname
! matrix_type
! precision

n_args = command_argument_count()
if(n_args /= 3) then
print *, "incorrect number of command line arguments"
error stop
end if

call get_command_argument(1, test)
call get_command_argument(2, matrix_type)
call get_command_argument(3, matrix_precision)

select case(test)
case default
print *, "unknown test name "//trim(test)
error stop
end select

end program bml_test
20 changes: 0 additions & 20 deletions tests/test_driver.F90

This file was deleted.

24 changes: 0 additions & 24 deletions tests/test_driver.c

This file was deleted.

1 change: 1 addition & 0 deletions tests/test_m.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module test_m

! All tests need the Fortran kinds corresponding to the C floating types.
use, intrinsic :: iso_c_binding, only : C_FLOAT, C_DOUBLE, C_FLOAT_COMPLEX, &
& C_DOUBLE_COMPLEX
Expand Down