Skip to content

Commit

Permalink
Addressing reviews and fixing github tests
Browse files Browse the repository at this point in the history
  • Loading branch information
V. Raffuzzi committed Dec 23, 2024
1 parent 6a1eb86 commit 7b36bcc
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 252 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
build-and-test:
strategy:
matrix:
compiler: [gfortran8, gfortran9, gfortran10]
compiler: [gfortran10, gfortran11, gfortran12]
runs-on: ubuntu-20.04
container:
image: mikolajkowalski/scone-test:${{matrix.compiler}}_pfu4
options: --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
steps:
- uses: actions/checkout@v3
- name: CompileAndTest
Expand All @@ -22,12 +23,13 @@ jobs:
cd build
cmake ..
make -j
make test
ctest --output-on-faliure
cd -
build-and-test-debug:
runs-on: ubuntu-20.04
container:
image: mikolajkowalski/scone-test:gfortran10_pfu4
image: mikolajkowalski/scone-test:gfortran12_pfu4
options: --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
steps:
- uses: actions/checkout@v3
- name: CompileAndTest
Expand All @@ -36,12 +38,13 @@ jobs:
cd build
cmake -DDEBUG=ON ..
make -j
make test
ctest --output-on-faliure
cd -
build-and-test-no-openmp:
runs-on: ubuntu-20.04
container:
image: mikolajkowalski/scone-test:gfortran10_pfu4
image: mikolajkowalski/scone-test:gfortran12_pfu4
options: --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
steps:
- uses: actions/checkout@v3
- name: CompileAndTest
Expand All @@ -50,5 +53,19 @@ jobs:
cd build
cmake -DOPENMP=OFF ..
make -j
make test
ctest --output-on-faliure
cd -
build-and-test-no-mpi:
runs-on: ubuntu-20.04
container:
image: mikolajkowalski/scone-test:gfortran12_pfu4
steps:
- uses: actions/checkout@v3
- name: CompileAndTest
run : |
mkdir build
cd build
cmake -DMPI=OFF ..
make -j
ctest --output-on-faliure
cd -
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cream.egg-info/
Build
build

# Ignore all hidden files (except gitignore)
# Ignore all hidden files (except gitignore and the github folder)
.*
!/.gitignore
!/.github/*
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ endif()
# Add environmental variable to default search directories
list(APPEND CMAKE_PREFIX_PATH $ENV{LAPACK_INSTALL})

find_package(LAPACK REQUIRED )
find_package(LAPACK REQUIRED)
message(STATUS ${LAPACK_LIBRARIES})

# Dependencies for BUILD_TESTS
Expand Down Expand Up @@ -144,9 +144,10 @@ get_property(SRCS GLOBAL PROPERTY SRCS_LIST)

# Compile library
add_library(scone STATIC ${SRCS})
target_compile_options(scone PRIVATE ${scone_extra_flags} )
target_link_libraries(scone PUBLIC ${LAPACK_LIBRARIES} )
target_compile_options(scone PRIVATE ${scone_extra_flags})
target_link_libraries(scone PUBLIC ${LAPACK_LIBRARIES})
if(MPI)
add_compile_definitions(MPI)
target_link_libraries(scone PUBLIC MPI::MPI_Fortran)
endif()

Expand All @@ -156,8 +157,8 @@ endif()

####################################################################################################
# COMPILE SOLVERS
add_executable(scone.out ./Apps/scone.f90 )
target_link_libraries(scone.out scone )
add_executable(scone.out ./Apps/scone.f90)
target_link_libraries(scone.out scone)

####################################################################################################
# COMPILE UNIT TESTS
Expand All @@ -172,16 +173,22 @@ if(BUILD_TESTS)
list(APPEND UNIT_TESTS_RELATIVE ${_testPath})
endforeach()

if(MPI)
set(MAX_PES_OPTION MAX_PES 1)
else()
set(MAX_PES_OPTION "")
endif()

add_pfunit_ctest(unitTests
TEST_SOURCES ${UNIT_TESTS_RELATIVE}
LINK_LIBRARIES scone
MAX_PES 1
${MAX_PES_OPTION}
)

# pFUnit may have a bug which causes a unused variable `class(Test), allocatable :: t` be
# present if the suite contains only a TestCase and its methods
# We need to suppress this warning for clarity
target_compile_options(unitTests PRIVATE "-Wno-unused-variable" )
target_compile_options(unitTests PRIVATE "-Wno-unused-variable")

####################################################################################################
# COMPILE INTEGRATION TESTS
Expand All @@ -203,7 +210,7 @@ if(BUILD_TESTS)
# pFUnit may have a bug which causes a unused variable `class(Test), allocatable :: t` be
# present if the suite contains only a TestCase and its methods
# We need to suppress this warning for clarity
target_compile_options(integrationTests PRIVATE "-Wno-unused-variable" )
target_compile_options(integrationTests PRIVATE "-Wno-unused-variable")

endif()

Expand Down
9 changes: 8 additions & 1 deletion DataStructures/heapQueue_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,21 @@ subroutine push(self, val)
self % size = self % size + 1
self % heap(self % size) = val

! If the heap is of size 1 there is no need to order it
! Also, avoid test fail in debug mode, since parent would be 0 and the
! code is looking for self % heap(parent) inside the while condition
if (self % size == 1) return

! Shift the new value up the heap to restore the heap property
child = self % size
parent = child / 2

do while (child > 1 .and. self % heap(parent) < self % heap(child))
do while (self % heap(parent) < self % heap(child))
call swap(self % heap(parent), self % heap(child))
child = parent
parent = child / 2
! As above: avoid error in debug mode, caused by trying to access self % heap(0)
if (parent == 0) return
end do

end subroutine push
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module baseMgNeutronDatabase_iTest
use dictionary_class, only : dictionary
use dictParser_func, only : charToDict
use particle_class, only : particle
use RNG_class, only : RNG

! Nuclear Data Objects & Interfaces
use baseMgNeutronDatabase_class, only : baseMgNeutronDatabase, baseMgNeutronDatabase_CptrCast, &
Expand Down Expand Up @@ -59,12 +60,12 @@ subroutine testBaseMgNeutronDatabaseWithP0()
type(dictionary) :: matMenuDict
type(particle) :: p
type(neutronMacroXSs) :: xss
type(RNG), target :: pRNG
type(baseMgNeutronMaterial),pointer :: mat
class(baseMgNeutronMaterial),pointer :: matClass
class(reactionHandle), pointer :: reac
real(defReal),parameter :: TOL = 1.0E-6_defReal


data_ptr => database

! Load materialMenu
Expand All @@ -81,6 +82,8 @@ subroutine testBaseMgNeutronDatabaseWithP0()
@assertEqual(4, database % nGroups())

! Test getting Transport XS
! Associate pointer to pass tests in debug mode
p % pRNG => pRNG
p % G = 1
@assertEqual(2.1_defReal, database % getTrackingXS(p, 1, MATERIAL_XS), TOL)

Expand Down Expand Up @@ -185,12 +188,12 @@ subroutine testBaseMgNeutronDatabaseWithP1()
type(dictionary) :: matMenuDict
type(particle) :: p
type(neutronMacroXSs) :: xss
type(RNG), target :: pRNG
type(baseMgNeutronMaterial),pointer :: mat
class(baseMgNeutronMaterial),pointer :: matClass
class(reactionHandle), pointer :: reac
real(defReal),parameter :: TOL = 1.0E-6_defReal


data_ptr => database

! Load materialMenu
Expand All @@ -207,6 +210,8 @@ subroutine testBaseMgNeutronDatabaseWithP1()
@assertEqual(4, database % nGroups())

! Test getting Transport XS
! Associate pointer to pass tests in debug mode
p % pRNG => pRNG
p % G = 1
@assertEqual(2.1_defReal, database % getTrackingXS(p, 1, MATERIAL_XS), TOL)

Expand Down
6 changes: 5 additions & 1 deletion NuclearData/mgNeutronData/mgNeutronMaterial_inter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ subroutine getMacroXSs_byP(self, xss, p)
class(mgNeutronMaterial), intent(in) :: self
type(neutronMacroXSs), intent(out) :: xss
class(particle), intent(in) :: p
integer(shortInt) :: matIdx
character(100), parameter :: Here = 'getMacroXSs_byP (mgNeutronMateerial_inter.f90)'

if (.not. p % isMG) call fatalError(Here, 'CE particle was given to MG data')

associate (matCache => cache_materialCache(p % matIdx()))
! Store p % matIdx() in a dedicated variable to avoid compilation errors with gfortran >= 13.2
matIdx = p % matIdx()

associate (matCache => cache_materialCache(matIdx))

if (matCache % G_tail /= p % G) then
! Get cross sections
Expand Down
9 changes: 9 additions & 0 deletions ParticleObjects/Tests/particleDungeon_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module particleDungeon_test
use RNG_class, only : RNG
use particle_class, only : particle, particleState
use particleDungeon_class, only : particleDungeon
#ifdef MPI
use mpi_func, only : mpiInitTypes, MPI_COMM_WORLD
#endif
use funit

implicit none
Expand Down Expand Up @@ -213,13 +215,18 @@ subroutine testNormPopDown()
real(defReal), parameter :: TOL = 1.0E-9
character(100),parameter :: Here = 'testNormPopDown (particleDungeon_test.f90)'

#ifdef MPI
call mpi_comm_size(MPI_COMM_WORLD, worldSize, ierr)

if (worldSize > 1) &
call fatalError(Here, 'This test cannot be run with multiple MPI processes')

! Initialise MPI types needed for this procedure
! NOTE: This is necessary because the normalisation uses some mpi procedure
! with data types manually defined inside mpiInitTypes. During the tests,
! mpiInit and mpiInitTypes aren't called, so this is done manually here
call mpiInitTypes()
#endif

! Initialise
call dungeon % init(10)
Expand Down Expand Up @@ -260,10 +267,12 @@ subroutine testNormPopUp()
real(defReal), parameter :: TOL = 1.0E-9
character(100),parameter :: Here = 'testNormPopUp (particleDungeon_test.f90)'

#ifdef MPI
call mpi_comm_size(MPI_COMM_WORLD, worldSize, ierr)

if (worldSize > 1) &
call fatalError(Here, 'This test cannot be run with multiple MPI processes')
#endif

! Initialise
call dungeon % init(20)
Expand Down
Loading

0 comments on commit 7b36bcc

Please sign in to comment.