Merge branch 'unit-test-Fortran' into 'development'
Unit test fortran See merge request damask/DAMASK!744
This commit is contained in:
commit
8ce51dc4d8
|
@ -22,6 +22,8 @@ if(DAMASK_SOLVER STREQUAL "GRID")
|
|||
project(damask-grid HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||
elseif(DAMASK_SOLVER STREQUAL "MESH")
|
||||
project(damask-mesh HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||
elseif(DAMASK_SOLVER STREQUAL "TEST")
|
||||
project(damask-test HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid solver: DAMASK_SOLVER=${DAMASK_SOLVER}")
|
||||
endif()
|
||||
|
|
5
Makefile
5
Makefile
|
@ -17,6 +17,11 @@ mesh:
|
|||
@cmake -B build/mesh -DDAMASK_SOLVER=mesh -DCMAKE_INSTALL_PREFIX=${PWD} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDCMD_POST=${BUILDCMD_POST} -DBUILDCMD_PRE=${BUILDCMD_PRE} -DOPTIMIZATION=${OPTIMIZATION} -DOPENMP=${OPENMP}
|
||||
@cmake --build build/mesh --parallel --target install
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
@cmake -B build/test -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${PWD} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDCMD_POST=${BUILDCMD_POST} -DBUILDCMD_PRE=${BUILDCMD_PRE} -DOPTIMIZATION=${OPTIMIZATION} -DOPENMP=${OPENMP}
|
||||
@cmake --build build/test --parallel --target install
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf build
|
||||
|
|
|
@ -13,6 +13,9 @@ if(PROJECT_NAME STREQUAL "damask-grid")
|
|||
elseif(PROJECT_NAME STREQUAL "damask-mesh")
|
||||
set(executable-name "DAMASK_mesh")
|
||||
file(GLOB solver-sources CONFIGURE_DEPENDS mesh/*.f90)
|
||||
elseif(PROJECT_NAME STREQUAL "damask-test")
|
||||
set(executable-name "DAMASK_test")
|
||||
file(GLOB solver-sources CONFIGURE_DEPENDS test/*.f90)
|
||||
endif()
|
||||
|
||||
foreach(solver-source ${solver-sources})
|
||||
|
|
|
@ -41,8 +41,6 @@ module prec
|
|||
real(pReal), dimension(0), parameter :: emptyRealArray = [real(pReal)::]
|
||||
character(len=pStringLen), dimension(0), parameter :: emptyStringArray = [character(len=pStringLen)::]
|
||||
|
||||
private :: &
|
||||
selfTest
|
||||
|
||||
contains
|
||||
|
||||
|
@ -62,7 +60,7 @@ subroutine prec_init()
|
|||
print'( a,e10.3)', ' epsilon value: ',PREAL_EPSILON
|
||||
print'( a,i3)', ' decimal precision: ',precision(0.0_pReal)
|
||||
|
||||
call selfTest()
|
||||
call prec_selfTest()
|
||||
|
||||
end subroutine prec_init
|
||||
|
||||
|
@ -247,7 +245,7 @@ end function prec_bytesToC_INT64_T
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief Check correctness of some prec functions.
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine selfTest()
|
||||
subroutine prec_selfTest()
|
||||
|
||||
integer, allocatable, dimension(:) :: realloc_lhs_test
|
||||
real(pReal), dimension(1) :: f
|
||||
|
@ -281,6 +279,6 @@ subroutine selfTest()
|
|||
i = int(prec_bytesToC_INT64_T(int([+126,+23,+52,+1,0,0,0,0],C_SIGNED_CHAR)),pI64)
|
||||
if (i(1) /= 20191102_pI64) error stop 'prec_bytesToC_INT64_T'
|
||||
|
||||
end subroutine selfTest
|
||||
end subroutine prec_selfTest
|
||||
|
||||
end module prec
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
program DAMASK_test
|
||||
use parallelization
|
||||
use HDF5_utilities
|
||||
|
||||
use test_prec
|
||||
use test_HDF5_utilities
|
||||
|
||||
call prec_test()
|
||||
|
||||
call parallelization_init()
|
||||
call HDF5_utilities_init()
|
||||
|
||||
call HDF5_utilities_test()
|
||||
|
||||
end program DAMASK_test
|
|
@ -0,0 +1,39 @@
|
|||
module test_HDF5_utilities
|
||||
use prec
|
||||
use HDF5
|
||||
use HDF5_utilities
|
||||
|
||||
implicit none(type,external)
|
||||
|
||||
private
|
||||
public :: HDF5_utilities_test
|
||||
|
||||
contains
|
||||
|
||||
subroutine HDF5_utilities_test()
|
||||
|
||||
print*, 'begin test HDF5_utilities'
|
||||
call test_read_write()
|
||||
print*, 'end test HDF5_utilities'
|
||||
|
||||
end subroutine HDF5_utilities_test
|
||||
|
||||
|
||||
subroutine test_read_write()
|
||||
|
||||
integer(HID_T) :: f
|
||||
real(pReal), dimension(3) :: d_in,d_out
|
||||
|
||||
|
||||
call random_number(d_in)
|
||||
|
||||
f = HDF5_openFile('test.hdf5','w')
|
||||
|
||||
call HDF5_write(d_in,f,'test')
|
||||
call HDF5_read(d_out,f,'test')
|
||||
|
||||
if (any(d_in /= d_out)) error stop 'test_read_write'
|
||||
|
||||
end subroutine test_read_write
|
||||
|
||||
end module test_HDF5_utilities
|
|
@ -0,0 +1,19 @@
|
|||
module test_prec
|
||||
use prec
|
||||
|
||||
implicit none(type,external)
|
||||
|
||||
private
|
||||
public :: prec_test
|
||||
|
||||
contains
|
||||
|
||||
subroutine prec_test()
|
||||
|
||||
print*, 'begin test prec'
|
||||
call prec_selfTest()
|
||||
print*, 'end test prec'
|
||||
|
||||
end subroutine prec_test
|
||||
|
||||
end module test_prec
|
Loading…
Reference in New Issue