Skip to content

Commit

Permalink
Merge branch 'unit' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryngelson authored Nov 18, 2023
2 parents b3e170e + 0948c85 commit 4a2fbe4
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 23 deletions.
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ option(MFC_OpenACC "Build with OpenACC" OFF)
option(MFC_PRE_PROCESS "Build pre_process" OFF)
option(MFC_SIMULATION "Build simulation" OFF)
option(MFC_POST_PROCESS "Build post_process" OFF)
option(MFC_TEST "Build test" OFF)
option(MFC_SYSCHECK "Build syscheck" OFF)
option(MFC_DOCUMENTATION "Build documentation" OFF)
option(MFC_ALL "Build everything" OFF)
Expand All @@ -30,7 +31,9 @@ if (MFC_BUILD_ALL)
set(MFC_PRE_PROCESS ON FORCE)
set(MFC_SIMULATION ON FORCE)
set(MFC_POST_PROCESS ON FORCE)
set(MFC_TEST ON FORCE)
set(MFC_DOCUMENTATION ON FORCE)
set(MFC_TEST ON FORCE)
endif()


Expand Down Expand Up @@ -225,9 +228,10 @@ endif()
# and generate documentation. Instead, we can simply include the list of .f90
# files that will eventually be used to compile <target>.

macro(HANDLE_SOURCES target useCommon)
set(${target}_DIR "${CMAKE_SOURCE_DIR}/src/${target}")
set(common_DIR "${CMAKE_SOURCE_DIR}/src/common")
macro(HANDLE_SOURCES target useCommon useSimulation)
set(${target}_DIR "${CMAKE_SOURCE_DIR}/src/${target}")
set(common_DIR "${CMAKE_SOURCE_DIR}/src/common")
set(simulation_DIR "${CMAKE_SOURCE_DIR}/src/simulation")

# Gather src/[<target>,common]/*.f90
file(GLOB ${target}_F90s CONFIGURE_DEPENDS "${${target}_DIR}/*.f90")
Expand All @@ -236,13 +240,21 @@ macro(HANDLE_SOURCES target useCommon)
file(GLOB common_F90s CONFIGURE_DEPENDS "${common_DIR}/*.f90")
list(APPEND ${target}_SRCs ${common_F90s})
endif()
if (${useSimulation})
file(GLOB simulation_F90s CONFIGURE_DEPENDS "${simulation_DIR}/*.f90")
list(APPEND ${target}_SRCs ${simulation_F90s})
endif()

# src/[<target>,common]/*.fpp -> src/<target>/autogen/*.f90
file(GLOB ${target}_FPPs CONFIGURE_DEPENDS "${${target}_DIR}/*.fpp")
if (${useCommon})
file(GLOB common_FPPs CONFIGURE_DEPENDS "${common_DIR}/*.fpp")
list(APPEND ${target}_FPPs ${common_FPPs})
endif()
if (${useSimulation})
file(GLOB simulation_FPPs CONFIGURE_DEPENDS "${simulation_DIR}/*.fpp")
list(APPEND ${target}_FPPs ${simulation_FPPs})
endif()

# Locate src/[<target>,common]/include/*.fpp
if (EXISTS "${${target}_DIR}/include")
Expand All @@ -252,6 +264,10 @@ macro(HANDLE_SOURCES target useCommon)
file(GLOB common_incs CONFIGURE_DEPENDS "${common_DIR}/include/*.fpp")
list(APPEND ${target}_incs ${common_incs})
endif()
if (${useSimulation})
file(GLOB simulation_incs CONFIGURE_DEPENDS "${simulation_DIR}/include/*.fpp")
list(APPEND ${target}_incs ${simulation_incs})
endif()

file(MAKE_DIRECTORY "${${target}_DIR}/autogen")
foreach(fpp ${${target}_FPPs})
Expand All @@ -263,6 +279,8 @@ macro(HANDLE_SOURCES target useCommon)
COMMAND ${FYPP_EXE} -m re
-I "${common_DIR}"
-I "${common_DIR}/include"
-I "${simulation_DIR}"
-I "${simulation_DIR}/include"
-I "${${target}_DIR}/include"
-D MFC_${CMAKE_Fortran_COMPILER_ID}
-D MFC_COMPILER="${CMAKE_Fortran_COMPILER_ID}"
Expand All @@ -279,10 +297,11 @@ macro(HANDLE_SOURCES target useCommon)
endmacro()


HANDLE_SOURCES(pre_process ON)
HANDLE_SOURCES(simulation ON)
HANDLE_SOURCES(post_process ON)
HANDLE_SOURCES(syscheck OFF)
HANDLE_SOURCES(pre_process ON OFF)
HANDLE_SOURCES(simulation ON OFF)
HANDLE_SOURCES(post_process ON OFF)
HANDLE_SOURCES(test ON ON)
HANDLE_SOURCES(syscheck OFF OFF)


# MFC_SETUP_TARGET: Given a target (herein <target>), this macro creates a new
Expand Down Expand Up @@ -310,6 +329,8 @@ function(MFC_SETUP_TARGET)
target_include_directories(${ARGS_TARGET} PRIVATE
"${CMAKE_SOURCE_DIR}/src/common"
"${CMAKE_SOURCE_DIR}/src/common/include"
"${CMAKE_SOURCE_DIR}/src/simulation"
"${CMAKE_SOURCE_DIR}/src/simulation/include"
"${CMAKE_SOURCE_DIR}/src/${ARGS_TARGET}")

if (EXISTS "${CMAKE_SOURCE_DIR}/src/${ARGS_TARGET}/include")
Expand Down Expand Up @@ -429,6 +450,12 @@ if (MFC_SYSCHECK)
MPI OpenACC)
endif()

if (MFC_TEST)
MFC_SETUP_TARGET(TARGET test
SOURCES "${test_SRCs}"
MPI OpenACC FFTW)
endif()

if (MFC_DOCUMENTATION)
# GEN_DOCS: Given a target name (herein <target>), this macro sets up a
# target, <target>_docs, that generates documentation for <target> using
Expand Down
4 changes: 2 additions & 2 deletions src/common/m_mpi_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contains
end if
#endif
#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) | defined(MFC_TEST)
if(qbmm .and. .not. polytropic) then
do i = 1, nb
do j = 1, nnode
Expand Down Expand Up @@ -181,7 +181,7 @@ contains
real(kind(0d0)), intent(OUT) :: Rc_min_glb
#ifdef MFC_MPI
#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) | defined(MFC_TEST)
! Reducing local extrema of ICFL, VCFL, CCFL and Rc numbers to their
! global extrema and bookkeeping the results on the rank 0 processor
Expand Down
26 changes: 13 additions & 13 deletions src/common/m_variables_conversion.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module m_variables_conversion
!$acc declare create(ixb, ixe, iyb, iye, izb, ize)

!! In simulation, gammas and pi_infs is already declared in m_global_variables
#ifndef MFC_SIMULATION
#if !defined(MFC_SIMULATION) && !defined(MFC_TEST)
real(kind(0d0)), allocatable, public, dimension(:) :: gammas, pi_infs
!$acc declare create(gammas, pi_infs)
#endif
Expand Down Expand Up @@ -305,7 +305,7 @@ contains
end if
end if

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
! Computing the shear and bulk Reynolds numbers from species analogs
if (any(Re_size > 0)) then
if (num_fluids == 1) then ! need to consider case with num_fluids >= 2
Expand Down Expand Up @@ -396,7 +396,7 @@ contains
pi_inf = pi_inf + alpha_K(i)*pi_infs(i)
end do

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
! Computing the shear and bulk Reynolds numbers from species analogs
do i = 1, 2

Expand Down Expand Up @@ -449,7 +449,7 @@ contains
integer :: i, j !< Generic loop iterators
real(kind(0d0)) :: alpha_K_sum

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
! Constraining the partial densities and the volume fractions within
! their physical bounds to make sure that any mixture variables that
! are derived from them result within the limits that are set by the
Expand Down Expand Up @@ -521,7 +521,7 @@ contains
integer, intent(IN) :: k, l, r
integer :: i, j !< Generic loop iterators

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
rho_K = 0d0
gamma_K = 0d0
pi_inf_K = 0d0
Expand Down Expand Up @@ -603,7 +603,7 @@ contains
end do
!$acc update device(gammas, pi_infs, Gs)

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)

if (any(Re_size > 0)) then
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
Expand Down Expand Up @@ -788,7 +788,7 @@ contains
real(kind(0d0)) :: rho_K, gamma_K, pi_inf_K, dyn_pres_K

#:if MFC_CASE_OPTIMIZATION
#ifndef MFC_SIMULATION
#if !defined(MFC_SIMULATION) && !defined(MFC_TEST)
real(kind(0d0)), dimension(:), allocatable :: nRtmp
#else
real(kind(0d0)), dimension(nb) :: nRtmp
Expand All @@ -808,7 +808,7 @@ contains
real(kind(0.d0)) :: ntmp

#:if MFC_CASE_OPTIMIZATION
#ifndef MFC_SIMULATION
#if !defined(MFC_SIMULATION) && !defined(MFC_TEST)
if (bubbles) then
allocate(nRtmp(nb))
else
Expand Down Expand Up @@ -843,7 +843,7 @@ contains


if (model_eqns /= 4) then
#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
! If in simulation, use acc mixture subroutines
if (hypoelasticity) then
call s_convert_species_to_mixture_variables_acc(rho_K, gamma_K, pi_inf_K, alpha_K, &
Expand All @@ -867,7 +867,7 @@ contains
#endif
end if

#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
rho_K = max(rho_K, sgm_eps)
#endif

Expand Down Expand Up @@ -908,7 +908,7 @@ contains
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l)/nbub_sc
end do
!Need to keep track of nb in the primitive variable list (converted back to true value before output)
#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
qK_prim_vf(bubxb)%sf(j, k, l) = qK_cons_vf(bubxb)%sf(j, k, l)
#endif

Expand Down Expand Up @@ -986,7 +986,7 @@ contains

integer :: i, j, k, l, q !< Generic loop iterators

#ifndef MFC_SIMULATION
#if !defined(MFC_SIMULATION) && !defined(MFC_TEST)
! Converting the primitive variables to the conservative variables
do l = 0, p
do k = 0, n
Expand Down Expand Up @@ -1148,7 +1148,7 @@ contains

! Computing the flux variables from the primitive variables, without
! accounting for the contribution of either viscosity or capillarity
#ifdef MFC_SIMULATION
#if defined(MFC_SIMULATION) || defined(MFC_TEST)
!$acc parallel loop collapse(3) gang vector default(present) private(alpha_rho_K, vel_K, alpha_K, Re_K)
do l = is3b, is3e
do k = is2b, is2e
Expand Down
14 changes: 14 additions & 0 deletions src/test/p_main.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
program p_main

! Dependencies =============================================================

use m_global_parameters !< Definitions of the global parameters
use m_mpi_proxy !< Definitions of the global parameters

! ==========================================================================

implicit none

stop

end program p_main
3 changes: 2 additions & 1 deletion toolchain/mfc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ def clean(self):
PRE_PROCESS = MFCTarget('pre_process', ['-DMFC_PRE_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([], [], []))
SIMULATION = MFCTarget('simulation', ['-DMFC_SIMULATION=ON'], False, True, False, MFCTarget.Dependencies([], [FFTW], []))
POST_PROCESS = MFCTarget('post_process', ['-DMFC_POST_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([FFTW, SILO], [], []))
TEST = MFCTarget('test', ['-DMFC_TEST=ON'], False, True, False, MFCTarget.Dependencies([], [FFTW], []))
SYSCHECK = MFCTarget('syscheck', ['-DMFC_SYSCHECK=ON'], False, False, True, MFCTarget.Dependencies([], [], []))
DOCUMENTATION = MFCTarget('documentation', ['-DMFC_DOCUMENTATION=ON'], False, False, False, MFCTarget.Dependencies([], [], []))

TARGETS = { FFTW, HDF5, SILO, PRE_PROCESS, SIMULATION, POST_PROCESS, SYSCHECK, DOCUMENTATION }
TARGETS = { FFTW, HDF5, SILO, PRE_PROCESS, SIMULATION, POST_PROCESS, SYSCHECK, TEST, DOCUMENTATION }

DEFAULT_TARGETS = { target for target in TARGETS if target.isDefault }
REQUIRED_TARGETS = { target for target in TARGETS if target.isRequired }
Expand Down

0 comments on commit 4a2fbe4

Please sign in to comment.