Prepare that test programs can write more output

parent 9af253bc
......@@ -171,7 +171,7 @@ else
endif
shared_sources = test/shared_sources/util.F90 test/shared_sources/read_input_parameters.F90 test/shared_sources/check_correctnes.F90 test/shared_sources/setup_mpi.F90 \
test/shared_sources/blacs_infrastructure.F90 test/shared_sources/prepare_matrix.F90
test/shared_sources/blacs_infrastructure.F90 test/shared_sources/prepare_matrix.F90 test/shared_sources/mod_output_types.F90
elpa1_test_real_c_version@SUFFIX@_SOURCES = test/c_test_programs/elpa1_test_real_c_version.c $(shared_sources) $(redirect_sources)
elpa1_test_real_c_version@SUFFIX@_LDADD = $(build_lib)
......
......@@ -143,8 +143,12 @@
endif
#endif /* ELPA1 */
if (write_to_file) then
if (myid .eq. 0) print *,"Writing output files"
if (write_to_file%eigenvectors) then
if (myid .eq. 0) print *,"Writing Eigenvectors to files"
endif
if (write_to_file%eigenvalues) then
if (myid .eq. 0) print *,"Writing Eigenvalues to files"
endif
......@@ -92,6 +92,7 @@ program test_complex
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -120,7 +121,7 @@ program test_complex
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -273,7 +274,7 @@ program test_complex
if(myid == 0) print *,'Time trans_ev_complex :',time_evp_back
if(myid == 0) print *,'Total time (sum above):',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_complex_out.txt",form='formatted',status='new')
do i=1,na
......@@ -282,6 +283,18 @@ program test_complex
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_complex_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -98,6 +98,7 @@ program test_complex2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -129,7 +130,7 @@ program test_complex2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -275,7 +276,7 @@ program test_complex2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_complex2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -284,6 +285,16 @@ program test_complex2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_complex2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -101,6 +101,7 @@ program test_complex2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
......@@ -132,7 +133,7 @@ program test_complex2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -174,10 +175,6 @@ program test_complex2
call timer%start("program")
#endif
if (write_to_file) then
if (myid .eq. 0) print *,"Writing output files"
endif
!-------------------------------------------------------------------------------
! Selection of number of processor rows/columns
! We try to set up the grid square-like, i.e. start the search for possible
......@@ -303,7 +300,7 @@ program test_complex2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_complex2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -312,6 +309,18 @@ program test_complex2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_complex2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -100,6 +100,7 @@ program test_complex2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -131,7 +132,7 @@ program test_complex2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -300,7 +301,7 @@ program test_complex2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_complex2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -309,6 +310,18 @@ program test_complex2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_complex2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -93,6 +93,7 @@ program test_real
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
......@@ -121,7 +122,7 @@ program test_real
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, &
provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
integer :: j
......@@ -279,7 +280,7 @@ program test_real
if(myid == 0) print *,'Time solve_tridi :',time_evp_solve
if(myid == 0) print *,'Time trans_ev_real :',time_evp_back
if(myid == 0) print *,'Total time (sum above):',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_real_out.txt",form='formatted',status='new')
do i=1,na
......@@ -288,6 +289,16 @@ program test_real
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_real_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
......
......@@ -98,6 +98,7 @@ program test_real2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -124,7 +125,7 @@ program test_real2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -273,7 +274,7 @@ program test_real2
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_real2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -282,6 +283,18 @@ program test_real2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_real2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -102,7 +102,7 @@ program test_real2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -129,7 +129,7 @@ program test_real2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -295,7 +295,7 @@ program test_real2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_real2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -304,6 +304,17 @@ program test_real2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_real2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
......
......@@ -101,6 +101,7 @@ program test_real2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -127,7 +128,7 @@ program test_real2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
......@@ -293,7 +294,7 @@ program test_real2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_real2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -302,6 +303,17 @@ program test_real2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="Eigenvalues_real2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -102,6 +102,7 @@ program test_real2
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -128,11 +129,10 @@ program test_real2
#ifdef WITH_OPENMP
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
logical :: success
success = .true.
write_to_file = .false.
if (COMMAND_ARGUMENT_COUNT() /= 0) then
write(error_unit,*) "This program does not support any command-line arguments"
......@@ -305,7 +305,7 @@ program test_real2
if(myid == 0) print *,'Time transform back EVs :',time_evp_back
if(myid == 0) print *,'Total time (sum above) :',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if(write_to_file%eigenvectors) then
if (myid == 0) then
open(17,file="EVs_real2_out.txt",form='formatted',status='new')
do i=1,na
......@@ -314,6 +314,18 @@ program test_real2
close(17)
endif
endif
if(write_to_file%eigenvalues) then
if (myid == 0) then
open(17,file="EVs_real2_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
!-------------------------------------------------------------------------------
! Test correctness of result (using plain scalapack routines)
allocate(tmp1(na_rows,na_cols))
......
......@@ -93,7 +93,7 @@ program test_real
#ifdef HAVE_DETAILED_TIMINGS
use timings
#endif
use output_types
implicit none
!-------------------------------------------------------------------------------
......@@ -125,7 +125,7 @@ program test_real
integer(kind=ik) :: omp_get_max_threads, required_mpi_thread_level, &
provided_mpi_thread_level
#endif
logical :: write_to_file
type(output_t) :: write_to_file
integer(kind=ik) :: checksWrong, checksWrongRecv
logical :: success
......@@ -138,10 +138,6 @@ program test_real
! MPI Initialization
call setup_mpi(myid, nprocs)
if (write_to_file) then
if (myid .eq. 0) print *,"Writing output files"
endif
#ifdef HAVE_DETAILED_TIMINGS
! initialise the timing functionality
......@@ -328,15 +324,6 @@ program test_real
if(myid == 0) print *,'Time solve_tridi :',time_evp_solve
if(myid == 0) print *,'Time trans_ev_real :',time_evp_back
if(myid == 0) print *,'Total time (sum above):',time_evp_back+time_evp_solve+time_evp_fwd
if(write_to_file) then
if (myid == 0) then
open(17,file="EVs_real_out.txt",form='formatted',status='new')
do i=1,na
write(17,*) i,ev(i)
enddo
close(17)
endif
endif
! call the c function
#ifdef WITH_MPI
......
#include "config-f90.h"
module output_types
type :: output_t
logical :: eigenvectors
logical :: eigenvalues
end type
end module
......@@ -49,24 +49,28 @@ module mod_read_input_parameters
use ELPA_utilities, only : error_unit
use precision
use elpa_mpi
use output_types
implicit none
integer(kind=ik), intent(out) :: na, nev, nblk
logical, intent(out) :: write_to_file
type(output_t), intent(out) :: write_to_file
! Command line arguments
character(len=128) :: arg1, arg2, arg3, arg4
character(len=128) :: arg1, arg2, arg3, arg4, arg5
integer(kind=ik) :: mpierr
! default parameters
na = 4000
nev = 1500
nblk = 16
write_to_file = .false.
write_to_file%eigenvectors = .false.
write_to_file%eigenvalues = .false.
if (.not. any(COMMAND_ARGUMENT_COUNT() == [0, 3, 4])) then
if (.not. any(COMMAND_ARGUMENT_COUNT() == [0, 3, 4, 5])) then
write(error_unit, '(a,i0,a)') "Invalid number (", COMMAND_ARGUMENT_COUNT(), ") of command line arguments!"
write(error_unit, *) "Expected: program [ [matrix_size num_eigenvalues block_size] ""output""]"
write(error_unit, *) "Expected: program [ [matrix_size num_eigenvalues block_size] &
""output_eigenvalues"" ""output_eigenvectors""]"
stop 1
endif
......@@ -89,15 +93,40 @@ module mod_read_input_parameters
read(arg2, *) nev
read(arg3, *) nblk
if (arg4 .eq. "output") then
write_to_file = .true.
if (arg4 .eq. "output_eigenvalues") then
write_to_file%eigenvectors = .true.
else
write(error_unit, *) "Invalid value for output flag! Must be ""output"" or omitted"
write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvalues"" or omitted"
stop 1
endif
endif
if (COMMAND_ARGUMENT_COUNT() == 5) then
call GET_COMMAND_ARGUMENT(1, arg1)
call GET_COMMAND_ARGUMENT(2, arg2)
call GET_COMMAND_ARGUMENT(3, arg3)
call GET_COMMAND_ARGUMENT(4, arg4)
call GET_COMMAND_ARGUMENT(5, arg5)
read(arg1, *) na
read(arg2, *) nev
read(arg3, *) nblk
if (arg4 .eq. "output_eigenvalues") then
write_to_file%eigenvalues = .true.
else
write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvalues"" or omitted"
stop 1
endif
if (arg5 .eq. "output_eigenvectors") then
write_to_file%eigenvectors = .true.
else
write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvectors"" or omitted"
stop 1
endif
endif
end subroutine
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