Merge branch '282-setup-for-fortran-unit-testing' into 'development'

Resolve "setup for Fortran unit testing"

Closes #282

See merge request damask/DAMASK!783
This commit is contained in:
Martin Diehl 2023-07-31 08:51:15 +00:00
commit 39f4bc44e1
8 changed files with 103 additions and 22 deletions

View File

@ -85,6 +85,40 @@ mypy:
###################################################################################################
unittest_GNU_DEBUG:
stage: compile
script:
- module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU}
- TMPDIR=$(mktemp -d)
- cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE -DBUILDCMD_POST=-coverage
- cmake --build ${TMPDIR} --target install
- cd ${TMPDIR}
- ./bin/DAMASK_test
- find -name \*.gcda | xargs gcov
unittest_GNU_RELEASE:
stage: compile
script:
- module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU}
- TMPDIR=$(mktemp -d)
- cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE -DBUILDCMD_POST=-coverage
- cmake --build ${TMPDIR} --target install
- cd ${TMPDIR}
- ./bin/DAMASK_test
- find -name \*.gcda | xargs gcov
unittest_GNU_PERFORMANCE:
stage: compile
script:
- module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU}
- TMPDIR=$(mktemp -d)
- cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=PERFORMANCE -DBUILDCMD_POST=-coverage
- cmake --build ${TMPDIR} --target install
- cd ${TMPDIR}
- ./bin/DAMASK_test
- find -name \*.gcda | xargs gcov
grid_GNU:
stage: compile
script:

View File

@ -377,6 +377,7 @@ module crystal
public :: &
crystal_init, &
crystal_selfTest, &
crystal_isotropic_nu, &
crystal_isotropic_mu, &
crystal_symmetrize_33, &
@ -412,7 +413,7 @@ subroutine crystal_init()
print'(/,1x,a)', '<<<+- crystal init -+>>>'; flush(IO_STDOUT)
call selfTest()
call crystal_selfTest()
end subroutine crystal_init
@ -2226,7 +2227,7 @@ end function crystal_isotropic_mu
!--------------------------------------------------------------------------------------------------
!> @brief Check correctness of some crystal functions.
!--------------------------------------------------------------------------------------------------
subroutine selfTest
subroutine crystal_selfTest
real(pREAL), dimension(:,:,:), allocatable :: CoSy
real(pREAL), dimension(:,:), allocatable :: system
@ -2333,6 +2334,6 @@ subroutine selfTest
if (dNeq(crystal_isotropic_nu(C,'isostress','cF'), crystal_isotropic_nu(C,'isostress'), 1.0e-12_pREAL)) &
error stop 'isotropic_nu/isostress/cF-tI'
end subroutine selfTest
end subroutine crystal_selfTest
end module crystal

View File

@ -25,7 +25,8 @@ module tables
public :: &
table, &
tables_init
tables_init, &
tables_selfTest
contains
@ -37,7 +38,7 @@ subroutine tables_init()
print'(/,1x,a)', '<<<+- tables init -+>>>'; flush(IO_STDOUT)
call selfTest()
call tables_selfTest()
end subroutine tables_init
@ -106,7 +107,7 @@ end function eval
!--------------------------------------------------------------------------------------------------
!> @brief Check correctness of table functionality.
!--------------------------------------------------------------------------------------------------
subroutine selfTest()
subroutine tables_selfTest()
type(tTable) :: t
real(pREAL), dimension(*), parameter :: &
@ -140,6 +141,6 @@ subroutine selfTest()
if (dNeq(y_true(i),t%at(x_eval(i)))) error stop 'table eval/dict'
end do
end subroutine selfTest
end subroutine tables_selfTest
end module tables

View File

@ -1,15 +1,30 @@
program DAMASK_test
use parallelization
use HDF5_utilities
use test_prec
use test_tables
use test_crystal
use test_HDF5_utilities
call prec_test()
print('(/,a)'), 'begin test prec'
call test_prec_run()
print('(a)'), 'begin test prec'
print('(/,a)'), 'begin test tables'
call test_tables_run()
print('(a)'), 'end test tables'
print('(/,a)'), 'begin test crystal'
call test_crystal_run()
print('(a)'), 'end test crystal'
call parallelization_init()
call HDF5_utilities_init()
call HDF5_utilities_test()
print('(/,a)'), 'begin test HDF5_utilities'
call test_HDF5_utilities_run()
print('(a)'), 'begin test HDF5_utilities'
end program DAMASK_test

View File

@ -6,20 +6,18 @@ module test_HDF5_utilities
implicit none(type,external)
private
public :: HDF5_utilities_test
public :: test_HDF5_utilities_run
contains
subroutine HDF5_utilities_test()
subroutine test_HDF5_utilities_run()
print*, 'begin test HDF5_utilities'
call test_read_write()
print*, 'end test HDF5_utilities'
call read_write()
end subroutine HDF5_utilities_test
end subroutine test_HDF5_utilities_run
subroutine test_read_write()
subroutine read_write()
integer(HID_T) :: f
real(pREAL), dimension(3) :: d_in,d_out
@ -34,6 +32,6 @@ subroutine test_read_write()
if (any(d_in /= d_out)) error stop 'test_read_write'
end subroutine test_read_write
end subroutine read_write
end module test_HDF5_utilities

17
src/test/test_crystal.f90 Normal file
View File

@ -0,0 +1,17 @@
module test_crystal
use crystal
implicit none(type,external)
private
public :: test_crystal_run
contains
subroutine test_crystal_run()
call crystal_selfTest()
end subroutine test_crystal_run
end module test_crystal

View File

@ -4,16 +4,14 @@ module test_prec
implicit none(type,external)
private
public :: prec_test
public :: test_prec_run
contains
subroutine prec_test()
subroutine test_prec_run()
print*, 'begin test prec'
call prec_selfTest()
print*, 'end test prec'
end subroutine prec_test
end subroutine test_prec_run
end module test_prec

17
src/test/test_tables.f90 Normal file
View File

@ -0,0 +1,17 @@
module test_tables
use tables
implicit none(type,external)
private
public :: test_tables_run
contains
subroutine test_tables_run()
call tables_selfTest()
end subroutine test_tables_run
end module test_tables