Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if(MPAS_CORES MATCHES " ") #Convert strings separated with spaces to CMake list
set(MPAS_CORES ${MPAS_CORES} CACHE STRING "MPAS cores to build. Options: ${MPAS_ALL_CORES}" FORCE)
endif()
option(DO_PHYSICS "Use built-in physics schemes." TRUE)
option(STOCHASTIC_PHYSICS "Build with stochastic physics support." FALSE)
option(MPAS_DOUBLE_PRECISION "Use double precision 64-bit Floating point." TRUE)
option(MPAS_PROFILE "Enable GPTL profiling" OFF)
option(MPAS_OPENMP "Enable OpenMP" OFF)
Expand Down
9 changes: 7 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ usage() {
echo "Usage: $0 -j <num> -h"
echo
echo " -j number of build jobs DEFAULT: 8"
echo " -s build with stochastic_physics"
Comment thread
guoqing-noaa marked this conversation as resolved.
Outdated
echo " -c additional CMAKE options"
echo " -f force a clean build"
echo " -h display this message and quit"
echo
exit 1
}

while getopts "c:j:hf" opt; do
STOCHASTIC=""
while getopts "c:j:hfs" opt; do
case ${opt} in
c)
CMAKE_OPTS=${OPTARG}
;;
s)
STOCHASTIC="-DSTOCHASTIC_PHYSICS=ON"
;;
j)
BUILD_JOBS=${OPTARG}
;;
Expand Down Expand Up @@ -63,5 +68,5 @@ cd ${BUILD_DIR} || exit 1

BUILD_JOBS=${BUILD_JOBS:-8}
CMAKE_OPTS+=' -DMPAS_DOUBLE_PRECISION=OFF'
cmake ${CMAKE_OPTS} -DMPAS_CORES="init_atmosphere;atmosphere" ..
cmake ${CMAKE_OPTS} ${STOCHASTIC} -DMPAS_CORES="init_atmosphere;atmosphere" ..
make -j $BUILD_JOBS
11 changes: 9 additions & 2 deletions src/core_atmosphere/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ list(TRANSFORM ATMOSPHERE_CORE_PHYSICS_SMOKE_SOURCES PREPEND physics/physics_noa

set(ATMOSPHERE_CORE_PHYSICS_MMM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/physics/physics_mmm)

# build stochastic_physics as a library
# build stochastic_physics as a library (optional)
if (${STOCHASTIC_PHYSICS})
set(ATMOSPHERE_CORE_STOCHASTIC_PHYSICS_SOURCES
kinddef.F90
mpi_wrapper.F90
Expand Down Expand Up @@ -174,6 +175,7 @@ target_link_libraries(stochastic_physics PUBLIC MPI::MPI_Fortran framework ${BLA
install(TARGETS stochastic_physics EXPORT ${PROJECT_NAME}ExportsCore
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

if(NOT EXISTS ${ATMOSPHERE_CORE_PHYSICS_MMM_DIR})
set(PHYSICS_MMM_REPO_URL "https://github.com/NCAR/MMM-physics")
Expand Down Expand Up @@ -573,8 +575,13 @@ set(CORE_ATMOSPHERE_COMPILE_DEFINITIONS
if (${DO_PHYSICS})
list(APPEND CORE_ATMOSPHERE_COMPILE_DEFINITIONS DO_PHYSICS)
endif ()
if (${STOCHASTIC_PHYSICS})
list(APPEND CORE_ATMOSPHERE_COMPILE_DEFINITIONS STOCHASTIC_PHYSICS)
endif()
target_compile_definitions(core_atmosphere PRIVATE ${CORE_ATMOSPHERE_COMPILE_DEFINITIONS})
target_link_libraries(core_atmosphere PUBLIC stochastic_physics)
if (${STOCHASTIC_PHYSICS})
target_link_libraries(core_atmosphere PUBLIC stochastic_physics)
endif()
set_MPAS_DEBUG_flag(core_atmosphere)
mpas_core_target(CORE atmosphere TARGET core_atmosphere INCLUDES ${ATMOSPHERE_CORE_INCLUDES})

Expand Down
20 changes: 19 additions & 1 deletion src/core_atmosphere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ifdef CHEMISTRY
CHEM_OBJS = libchem/*.o
endif

ifeq ($(findstring STOCHASTIC_PHYSICS,$(CPPFLAGS)),STOCHASTIC_PHYSICS)
STOCH = true
endif
Comment thread
guoqing-noaa marked this conversation as resolved.
Outdated

OBJS = mpas_atm_core.o \
mpas_atm_core_interface.o \
mpas_atm_dimensions.o \
Expand Down Expand Up @@ -66,8 +70,12 @@ post_build:

physcore: mpas_atm_dimensions.o
( cd physics; $(MAKE) all )
ifdef STOCH
( cd stochastic_physics; $(MAKE) -f Makefile all )
( mkdir libphys; cd libphys; ar -x ../physics/libphys.a; ar -x ../stochastic_physics/libstochphys.a )
( mkdir libphys; cd libphys; ar -x ../physics/libphys.a; ar -x ../stochastic_physics/libstochphys.a )
else
( mkdir libphys; cd libphys; ar -x ../physics/libphys.a )
endif
( cd ../..; ln -sf ./src/core_atmosphere/physics/physics_wrf/files/*TBL .)
( cd ../..; ln -sf ./src/core_atmosphere/physics/physics_wrf/files/*DATA* .)
( cd ../..; ln -sf ./src/core_atmosphere/physics/physics_noahmp/parameters/*TBL .)
Expand Down Expand Up @@ -103,7 +111,9 @@ clean:
@# the latter for MPAS. The default for "make" is to use "makefile", but
@# here, we want to use the one for MPAS (with an upper case "M"). Indicate
@# that using the -f flag.
ifdef STOCH
( cd stochastic_physics; $(MAKE) -f Makefile clean )
endif
Comment thread
guoqing-noaa marked this conversation as resolved.
Outdated
( cd diagnostics; $(MAKE) clean )
( cd utils; $(MAKE) clean )
( cd ../..; rm -f *TBL )
Expand All @@ -120,7 +130,15 @@ clean:
$(RM) $@ $*.mod
ifeq "$(GEN_F90)" "true"
$(CPP) $(CPPFLAGS) $(PHYSICS) $(CHEMISTRY) $(CPPINCLUDES) -I./inc -I../framework $< > $*.f90
ifdef STOCH
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators -I./physics -I./dynamics -I./diagnostics -I./physics/physics_wrf -I./physics/physics_mmm -I./physics/physics_noaa/UGWP $(MPAS_ESMF_INC) -I./chemistry -I./stochastic_physics
else
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators -I./physics -I./dynamics -I./diagnostics -I./physics/physics_wrf -I./physics/physics_mmm -I./physics/physics_noaa/UGWP $(MPAS_ESMF_INC) -I./chemistry
endif
else
ifdef STOCH
$(FC) $(CPPFLAGS) $(PHYSICS) $(CHEMISTRY) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I./inc -I../framework -I../operators -I./physics -I./dynamics -I./diagnostics -I./physics/physics_wrf -I./physics/physics_mmm -I./physics/physics_noaa/UGWP $(MPAS_ESMF_INC) -I./chemistry -I./stochastic_physics
else
$(FC) $(CPPFLAGS) $(PHYSICS) $(CHEMISTRY) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I./inc -I../framework -I../operators -I./physics -I./dynamics -I./diagnostics -I./physics/physics_wrf -I./physics/physics_mmm -I./physics/physics_noaa/UGWP $(MPAS_ESMF_INC) -I./chemistry
endif
endif
6 changes: 6 additions & 0 deletions src/core_atmosphere/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,9 @@
<var name="ke"/>
<var name="uReconstructZonal"/>
<var name="uReconstructMeridional"/>
#ifdef STOCHASTIC_PHYSICS
<var name="stoch_pattern_sppt"/>
#endif

<!-- Begin Ertel PV diagnostics defined in diagnostics/Registry_pv.xml -->
<var name="ertel_pv"/>
Expand Down Expand Up @@ -4415,8 +4417,10 @@
description="Total cell-centered meridional wind tendency from physics"
persistence="scratch" />

#ifdef STOCHASTIC_PHYSICS
<var name="stoch_pattern_sppt" type="real" dimensions="nVertLevels nCells Time" units="unitless"
description="Perturbation pattern for stochastic physics SPPT scheme" />
#endif

#ifdef DO_PHYSICS
<!-- ================================================================================================== -->
Expand Down Expand Up @@ -5135,8 +5139,10 @@
#include "physics/Registry_noahmp.xml"
#include "physics/Registry_tempo.xml"
#include "physics/registry.chemistry.xml"
#ifdef STOCHASTIC_PHYSICS
#include "stochastic_physics/Registry_stoch_physics.xml"
#endif
#endif

#ifdef MPAS_UFS_DYCORE
#include "physics/Registry_noahmp.xml"
Expand Down
4 changes: 4 additions & 0 deletions src/core_atmosphere/build_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ FCINCLUDES += -I$(PWD)/src/core_atmosphere/physics/physics_noahmp/drivers/mpas \
-I$(PWD)/src/core_atmosphere/physics/physics_noahmp/utility \
-I$(PWD)/src/core_atmosphere/physics/physics_noahmp/src

ifeq "$(STOCHASTIC_PHYSICS)" "true"
override CPPFLAGS += -DSTOCHASTIC_PHYSICS
endif

report_builds:
@echo "CORE=atmosphere"
6 changes: 6 additions & 0 deletions src/core_atmosphere/dynamics/mpas_atm_time_integration.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ module atm_time_integration
use mpas_atmphys_interface, only: pre_microphysics, post_microphysics
use mpas_atmphys_todynamics
use mpas_atmphys_utilities
#ifdef STOCHASTIC_PHYSICS
use mpas_stochastic_physics, only : stochastic_physics_pattern_apply, dosppt
#endif
#endif

use mpas_atm_boundaries, only : nSpecZone, nRelaxZone, nBdyZone, mpas_atm_get_bdy_state, mpas_atm_get_bdy_tend ! regional_MPAS addition
Expand Down Expand Up @@ -2145,10 +2147,12 @@ subroutine atm_srk3(domain, dt, itimestep, exchange_halo_group)
rk_step = 1
dynamics_substep = 1

#ifdef STOCHASTIC_PHYSICS
! apply random perturbation pattern to physics process (hydrostatic) tendencies
if (dosppt(domain)) then
call stochastic_physics_pattern_apply(domain, 'phys')
endif
#endif

call physics_get_tend( block, mesh, state, diag, tend, tend_physics, &
block % configs, rk_step, dynamics_substep, &
Expand All @@ -2157,10 +2161,12 @@ subroutine atm_srk3(domain, dt, itimestep, exchange_halo_group)
call mpas_timer_stop('physics_get_tend')
call post_physics_get_tend(block % configs, state, diag, tend)

#ifdef STOCHASTIC_PHYSICS
! apply random perturbation pattern to the accumulated (non-hydrostatic) physics tendencies
if (dosppt(domain)) then
call stochastic_physics_pattern_apply(domain, 'prog')
endif
#endif

#else
#ifndef MPAS_CAM_DYCORE
Expand Down
8 changes: 8 additions & 0 deletions src/core_atmosphere/mpas_atm_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
#ifdef DO_CHEMISTRY
use mpas_atm_chemistry, only: chemistry_init
#endif
#ifdef STOCHASTIC_PHYSICS
use mpas_stochastic_physics, only : stochastic_physics_pattern_init, dosppt
#endif
Comment thread
clark-evans marked this conversation as resolved.

implicit none

Expand Down Expand Up @@ -301,11 +303,13 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
call chemistry_init(domain % blocklist % configs, domain % blocklist % dimensions)
#endif

#ifdef STOCHASTIC_PHYSICS
!
! init stochastic pattern generation
if (dosppt(domain)) then
call stochastic_physics_pattern_init (domain)
endif
#endif

end function atm_core_init

Expand Down Expand Up @@ -1059,7 +1063,9 @@ subroutine atm_do_timestep(domain, dt, itimestep)
use mpas_atm_chemistry, only: chemistry_step
#endif
use mpas_atm_halos, only: exchange_halo_group
#ifdef STOCHASTIC_PHYSICS
use mpas_stochastic_physics, only : stochastic_physics_pattern_adv, dosppt
#endif

implicit none

Expand Down Expand Up @@ -1096,9 +1102,11 @@ subroutine atm_do_timestep(domain, dt, itimestep)
call chemistry_step()
#endif

#ifdef STOCHASTIC_PHYSICS
if (dosppt(domain)) then
call stochastic_physics_pattern_adv(domain, itimestep)
endif
#endif
call atm_timestep(domain, dt, currTime, itimestep, exchange_halo_group)

end subroutine atm_do_timestep
Expand Down
Loading