diff --git a/CMakeLists.txt b/CMakeLists.txt index e8f39f745e..adf5d9b263 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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() @@ -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 . -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/[,common]/*.f90 file(GLOB ${target}_F90s CONFIGURE_DEPENDS "${${target}_DIR}/*.f90") @@ -236,6 +240,10 @@ 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/[,common]/*.fpp -> src//autogen/*.f90 file(GLOB ${target}_FPPs CONFIGURE_DEPENDS "${${target}_DIR}/*.fpp") @@ -243,6 +251,10 @@ macro(HANDLE_SOURCES target 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/[,common]/include/*.fpp if (EXISTS "${${target}_DIR}/include") @@ -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}) @@ -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}" @@ -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 ), this macro creates a new @@ -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") @@ -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 ), this macro sets up a # target, _docs, that generates documentation for using diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index 4f235c0a9e..4d3064d901 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -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 @@ -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 diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index c6be345f0a..f77d0ea39d 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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))) @@ -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 @@ -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 @@ -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, & @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/test/p_main.fpp b/src/test/p_main.fpp new file mode 100644 index 0000000000..cc8c8f2c59 --- /dev/null +++ b/src/test/p_main.fpp @@ -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 diff --git a/toolchain/mfc/build.py b/toolchain/mfc/build.py index 7505b03a9d..a078ba1f4d 100644 --- a/toolchain/mfc/build.py +++ b/toolchain/mfc/build.py @@ -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 }