Commit 0913a668 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Factor-out the command-line handling of the tests

parent adae127f
......@@ -45,19 +45,32 @@ module mod_read_input_parameters
contains
subroutine read_input_parameters(na, nev, nblk, write_to_file)
#ifdef HAVE_ISO_FORTRAN_ENV
use iso_fortran_env, only : stderr => error_unit
#else
#define stderr 0
#endif
implicit none
include 'mpif.h'
integer, intent(out) :: na, nev, nblk
logical, intent(out) :: write_to_file
integer, intent(inout) :: na, nev, nblk
logical, intent(inout) :: write_to_file
! Command line arguments
character(len=128) :: arg1, arg2, arg3, arg4
integer :: mpierr
!-------------------------------------------------------------------------------
! Parse command line argumnents, if given
character*16 arg1
character*16 arg2
character*16 arg3
character*16 arg4
! default parameters
na = 4000
nev = 1500
nblk = 16
write_to_file = .false.
if (.not. any(COMMAND_ARGUMENT_COUNT() == [0, 3, 4])) then
write(stderr, '(a,i0,a)') "Invalid number (", COMMAND_ARGUMENT_COUNT(), ") of command line arguments!"
write(stderr, *) "Expected: program [ [matrix_size num_eigenvalues block_size] ""output""]"
stop 1
endif
if (COMMAND_ARGUMENT_COUNT() == 3) then
call GET_COMMAND_ARGUMENT(1, arg1)
......@@ -77,10 +90,14 @@ module mod_read_input_parameters
read(arg1, *) na
read(arg2, *) nev
read(arg3, *) nblk
endif
if (arg4 .eq. "output") then
write_to_file = .true.
if (arg4 .eq. "output") then
write_to_file = .true.
else
write(stderr, *) "Invalid value for output flag! Must be ""output"" or omitted"
stop 1
endif
endif
end subroutine
......
......@@ -126,16 +126,11 @@ program test_complex
#endif
logical :: write_to_file
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
success = .true.
write_to_file = .false.
nblk = 16
na = 4000
nev = 1500
success = .true.
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
......
......@@ -128,7 +128,6 @@ program test_complex2
complex*16, allocatable :: a(:,:), z(:,:), tmp1(:,:), tmp2(:,:), as(:,:)
integer :: iseed(4096) ! Random seed, size should be sufficient for every generator
integer :: STATUS
......@@ -140,19 +139,13 @@ program test_complex2
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
! MPI Initialization
......
......@@ -142,19 +142,13 @@ program test_complex2
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
......
......@@ -140,19 +140,13 @@ program test_complex2
logical :: write_to_file
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
! MPI Initialization
......
......@@ -131,20 +131,13 @@ program test_real
!-------------------------------------------------------------------------------
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
success = .true.
write_to_file = .false.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
......
......@@ -133,19 +133,13 @@ program test_real2
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
......
......@@ -136,21 +136,14 @@ program test_real2
#endif
logical :: write_to_file
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
......
......@@ -135,19 +135,13 @@ program test_real2
logical :: write_to_file
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
logical :: success
success = .true.
write_to_file = .false.
success = .true.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
! MPI Initialization
......
......@@ -136,25 +136,16 @@ program test_real
integer :: checksWrong, checksWrongRecv
#ifndef HAVE_ISO_FORTRAN_ENV
integer, parameter :: error_unit = 6
integer, parameter :: error_unit = 6
#endif
logical :: success
success = .true.
write_to_file = .false.
nblk = 16
na = 4000
nev = 1500
! read input parameters if they are provided
call read_input_parameters(na, nev, nblk, write_to_file)
!-------------------------------------------------------------------------------
! MPI Initialization
call setup_mpi(myid, nprocs)
......
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