Skip to content

Commit

Permalink
Merge branch '282-setup-for-fortran-unit-testing' into 'development'
Browse files Browse the repository at this point in the history
Resolve "setup for Fortran unit testing"

Closes #282

See merge request damask/DAMASK!783
  • Loading branch information
MarDiehl committed Jul 31, 2023
2 parents dbad2a7 + 289dceb commit 39f4bc4
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 22 deletions.
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions src/crystal.f90
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ module crystal

public :: &
crystal_init, &
crystal_selfTest, &
crystal_isotropic_nu, &
crystal_isotropic_mu, &
crystal_symmetrize_33, &
Expand Down Expand Up @@ -412,7 +413,7 @@ subroutine crystal_init()

print'(/,1x,a)', '<<<+- crystal init -+>>>'; flush(IO_STDOUT)

call selfTest()
call crystal_selfTest()

end subroutine crystal_init

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 5 additions & 4 deletions src/tables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module tables

public :: &
table, &
tables_init
tables_init, &
tables_selfTest

contains

Expand All @@ -37,7 +38,7 @@ subroutine tables_init()

print'(/,1x,a)', '<<<+- tables init -+>>>'; flush(IO_STDOUT)

call selfTest()
call tables_selfTest()

end subroutine tables_init

Expand Down Expand Up @@ -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 :: &
Expand Down Expand Up @@ -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
19 changes: 17 additions & 2 deletions src/test/DAMASK_test.f90
Original file line number Diff line number Diff line change
@@ -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
14 changes: 6 additions & 8 deletions src/test/test_HDF5_utilities.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 17 additions & 0 deletions src/test/test_crystal.f90
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions src/test/test_prec.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 17 additions & 0 deletions src/test/test_tables.f90
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 39f4bc4

Please sign in to comment.