Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ endif()

if(CCPP)
add_definitions(-DCCPP)
if(STATIC)
add_definitions(-DSTATIC)
endif()
endif()

add_subdirectory(cpl)
Expand Down Expand Up @@ -113,6 +110,7 @@ add_library(

if(CCPP)
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
add_dependencies(fv3cap ccppdriver ccppphys)
endif()
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics)
target_compile_definitions(fv3cap PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
Expand Down
45 changes: 29 additions & 16 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,18 @@ subroutine update_atmos_radiation_physics (Atmos)
end if

if(IPD_Control%do_ca)then
! DH* The current implementation of cellular_automata assumes that all blocksizes are the
! same, this is tested in the initialization call to cellular_automata, no need to redo *DH
call cellular_automata(IPD_Control%kdt, IPD_Data(:)%Statein, IPD_Data(:)%Coupling, IPD_Data(:)%Intdiag, &
Atm_block%nblks, IPD_Control%levs, IPD_Control%nca, IPD_Control%ncells, &
IPD_Control%nlives, IPD_Control%nfracseed, IPD_Control%nseed, &
IPD_Control%nthresh, IPD_Control%ca_global, IPD_Control%ca_sgs, &
IPD_Control%iseed_ca, IPD_Control%ca_smooth, IPD_Control%nspinup, &
Atm_block%blksz(1))
if(IPD_Control%ca_sgs == .true.)then
call cellular_automata_sgs(IPD_Control%kdt,IPD_Data(:)%Statein,IPD_Data(:)%Coupling,IPD_Data(:)%Intdiag,Atm_block%nblks,IPD_Control%levs, &
IPD_Control%nca,IPD_Control%ncells,IPD_Control%nlives,IPD_Control%nfracseed,&
IPD_Control%nseed,IPD_Control%nthresh,IPD_Control%ca_global,IPD_Control%ca_sgs,IPD_Control%iseed_ca,&
IPD_Control%ca_smooth,IPD_Control%nspinup,Atm_block%blksz(1))
endif
if(IPD_Control%ca_global == .true.)then
call cellular_automata_global(IPD_Control%kdt,IPD_Data(:)%Statein,IPD_Data(:)%Coupling,IPD_Data(:)%Intdiag,Atm_block%nblks,IPD_Control%levs, &
IPD_Control%nca_g,IPD_Control%ncells_g,IPD_Control%nlives_g,IPD_Control%nfracseed,&
IPD_Control%nseed_g,IPD_Control%nthresh,IPD_Control%ca_global,IPD_Control%ca_sgs,IPD_Control%iseed_ca,&
IPD_Control%ca_smooth,IPD_Control%nspinup,Atm_block%blksz(1),IPD_Control%nsmooth,IPD_Control%ca_amplitude)
endif
endif

!--- if coupled, assign coupled fields
Expand Down Expand Up @@ -656,12 +660,21 @@ subroutine atmos_model_init (Atmos, Time_init, Time, Time_step)
call mpp_error(FATAL, 'Logic errror: cellular_automata not compatible with non-uniform blocksizes')
end if
! *DH
call cellular_automata(IPD_Control%kdt, IPD_Data(:)%Statein, IPD_Data(:)%Coupling, IPD_Data(:)%Intdiag, &
Atm_block%nblks, IPD_Control%levs, IPD_Control%nca, IPD_Control%ncells, &
IPD_Control%nlives, IPD_Control%nfracseed, IPD_Control%nseed, &
IPD_Control%nthresh, IPD_Control%ca_global, IPD_Control%ca_sgs, &
IPD_Control%iseed_ca, IPD_Control%ca_smooth, IPD_Control%nspinup, &
Atm_block%blksz(1))
if(IPD_Control%do_ca)then
if(IPD_Control%ca_sgs == .true.)then
call cellular_automata_sgs(IPD_Control%kdt,IPD_Data(:)%Statein,IPD_Data(:)%Coupling,IPD_Data(:)%Intdiag,Atm_block%nblks,IPD_Control%levs, &
IPD_Control%nca,IPD_Control%ncells,IPD_Control%nlives,IPD_Control%nfracseed,&
IPD_Control%nseed,IPD_Control%nthresh,IPD_Control%ca_global,IPD_Control%ca_sgs,IPD_Control%iseed_ca,&
IPD_Control%ca_smooth,IPD_Control%nspinup,Atm_block%blksz(1))
endif
if(IPD_Control%ca_global == .true.)then
call cellular_automata_global(IPD_Control%kdt,IPD_Data(:)%Statein,IPD_Data(:)%Coupling,IPD_Data(:)%Intdiag,Atm_block%nblks,IPD_Control%levs, &
IPD_Control%nca_g,IPD_Control%ncells_g,IPD_Control%nlives_g,IPD_Control%nfracseed,&
IPD_Control%nseed_g,IPD_Control%nthresh,IPD_Control%ca_global,IPD_Control%ca_sgs,IPD_Control%iseed_ca,&
IPD_Control%ca_smooth,IPD_Control%nspinup,Atm_block%blksz(1),IPD_Control%nsmooth,IPD_Control%ca_amplitude)
endif

endif
endif

Atm(mytile)%flagstruct%do_skeb = IPD_Control%do_skeb
Expand Down Expand Up @@ -2044,7 +2057,7 @@ subroutine setup_exportdata (rc)

if (IPD_Control%cplflx) then
! MEAN Zonal compt of momentum flux (N/m**2)
idx = queryfieldlist(exportFieldsList,'mean_zonal_moment_flx')
idx = queryfieldlist(exportFieldsList,'mean_zonal_moment_flx_atm')
if (idx > 0 ) then
!$omp parallel do default(shared) private(i,j,nb,ix)
do j=jsc,jec
Expand All @@ -2057,7 +2070,7 @@ subroutine setup_exportdata (rc)
endif

! MEAN Merid compt of momentum flux (N/m**2)
idx = queryfieldlist(exportFieldsList,'mean_merid_moment_flx')
idx = queryfieldlist(exportFieldsList,'mean_merid_moment_flx_atm')
if (idx > 0 ) then
!$omp parallel do default(shared) private(i,j,nb,ix)
do j=jsc,jec
Expand Down
26 changes: 3 additions & 23 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.0)

# Use rpaths on MacOSX
set(CMAKE_MACOSX_RPATH 1)

if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)

if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)

PROJECT(CCPP-FV3)
project(CCPP-FV3
LANGUAGES C CXX Fortran)
set(PROJECT "CCPP-FV3")

ENABLE_LANGUAGE(Fortran)

include(CMakeForceCompiler)

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -177,27 +171,13 @@ if (MPI)
ADD_DEFINITIONS(-DMPI)
endif (MPI)

#------------------------------------------------------------------------------
# Set flags for static building/linking of CCPP
if (STATIC)
ADD_DEFINITIONS(-DSTATIC)
endif (STATIC)

#------------------------------------------------------------------------------
# Set flag for 32bit dynamics build
if (DYN32)
message(STATUS "Dynamics compiled with 32-bit option, adjust fv_sat_adj types")
ADD_DEFINITIONS(-DOVERLOAD_R4)
endif (DYN32)

#------------------------------------------------------------------------------
# If a dynamic build is requested, set TARGET_SUPPORTS_SHARED_LIBS to TRUE; on
# some systems, cmake doesn't set this even though the system supports shared
# libraries (e.g. Cray systems)
if(NOT STATIC)
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
endif(NOT STATIC)

#------------------------------------------------------------------------------
# Add model-specific flags for C/C++/Fortran preprocessor
ADD_DEFINITIONS(-DMOIST_CAPPA -DUSE_COND -DNEMS_GSM)
Expand Down
60 changes: 9 additions & 51 deletions ccpp/build_ccpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu

# List of valid/tested machines
VALID_MACHINES=( wcoss_cray wcoss_dell_p3 gaea.intel jet.intel \
hera.intel hera.gnu \
hera.intel hera.gnu orion.intel \
cheyenne.intel cheyenne.intel-impi cheyenne.gnu cheyenne.pgi endeavor.intel \
stampede.intel supermuc_phase2.intel macosx.gnu \
linux.intel linux.gnu linux.pgi )
Expand All @@ -25,11 +25,9 @@ function usage {
echo " REPRO=Y/N (default N)"
echo " OPENMP=Y/N (default Y)"
echo " 32BIT=Y/N (default N, affects dynamics/fast physics only)"
echo " STATIC=Y/N (default N, STATIC=Y requires SUITES=...)"
echo " SUITES=ABC,XYZ (comma-separated list of CCPP suites; "
echo " corresponding filenames: suite_ABC.xml. ...)"
echo " MULTI_GASES=Y/N (default N)"
echo " INTEL16=Y/N (default N)"
echo " clean_before [optional] can be 'YES' (default) or 'NO'"
echo " clean_after [optional] can be 'YES' (default) or 'NO'"
exit 1
Expand Down Expand Up @@ -125,31 +123,14 @@ if [[ "${MAKE_OPT}" == *"32BIT=Y"* ]]; then
else
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DDYN32=OFF"
fi
if [[ "${MAKE_OPT}" == *"STATIC=Y"* ]]; then
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DSTATIC=ON"
else
# hera.gnu uses the NCEPLIBS-external/NCEPLIBS umbrella build libraries,
# which cannot be linked dynamically at this point (missing -fPIC flag)
if [[ "${MACHINE_ID}" == "hera.gnu" ]]; then
echo "Dynamic CCPP build not supported on hera.gnu at this time."
exit 1
fi
# Dynamic builds require linking the NCEPlibs, provide path to them
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DSTATIC=OFF -DBACIO_LIB4=${BACIO_LIB4} -DSP_LIBd=${SP_LIBd} -DW3NCO_LIBd=${W3NCO_LIBd}"
fi
if [[ "${MAKE_OPT}" == *"MULTI_GASES=Y"* ]]; then
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DMULTI_GASES=ON"
else
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DMULTI_GASES=OFF"
fi
if [[ "${MAKE_OPT}" == *"INTEL16=Y"* ]]; then
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLEGACY_INTEL=ON"
elif [[ "${MACHINE_ID}" == "wcoss_cray" ]]; then
echo "In ccpp_build.sh: flag to cmake that wcoss_cray uses Intel 16"
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLEGACY_INTEL=ON"
else
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLEGACY_INTEL=OFF"
fi

# Flag to cmake that modern Intel compilers are used
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLEGACY_INTEL=OFF"

# Generate additional CCPP cmake flags depending on machine / compiler
if [[ "${MACHINE_ID}" == "macosx.gnu" ]]; then
Expand All @@ -170,20 +151,6 @@ elif [[ "${MACHINE_ID}" == "gaea.intel" || "${MACHINE_ID}" == "wcoss_cray" ]]; t
if [[ "${MACHINE_ID}" == "gaea.intel" ]]; then
CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLIBXML2_LIB_DIR=${LIBXML2_LIB_DIR} -DLIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}"
fi
# DH* At this time, it is not possible to use the dynamic CCPP
# build on gaea/wcoss_cray. While compiling/linking works, the model
# crashes immediately. This may be related to 64bit/32bit mismatches
# in the MPI libraries (missing "-fPIC" flags when the MPI libraries
# were compiled on the system?) - to be investigated.
if [[ "${MAKE_OPT}" == *"STATIC=Y"* ]]; then
:
else
## FOR DYNAMIC BUILD, SET ENVIRONMENT VARIABLE CRAYPE_LINK_TYPE
#export CRAYPE_LINK_TYPE=dynamic
echo "Dynamic CCPP build not supported on gaea/wcoss_cray at this time."
exit 1
fi
# *DH
fi

CCPP_CMAKE_FLAGS=$(trim "${CCPP_CMAKE_FLAGS}")
Expand Down Expand Up @@ -211,21 +178,12 @@ make ${CCPP_MAKE_FLAGS} install

# Generate ESMF makefile fragment

# Explicitly append libxml2, with or without path
CCPP_XML2_LIB="${LIBXML2_LIB_DIR:+-L${LIBXML2_LIB_DIR} }-lxml2"
set -u
if ( echo "${MAKE_OPT}" | grep STATIC=Y ) ; then
# Set linker flags for static build
CCPP_LINK_OBJS="-L${PATH_CCPP_LIB} -lccpp -lccppphys ${CCPP_XML2_LIB}"
else
# Set link objects
if ( echo "$MACHINE_ID" | grep gaea ) ; then
CCPP_LINK_OBJS="-dynamic -L${PATH_CCPP_LIB} -lccpp ${CCPP_XML2_LIB} ${CRAY_PMI_POST_LINK_OPTS} -lpmi"
else
CCPP_LINK_OBJS="-L${PATH_CCPP_LIB} -lccpp ${CCPP_XML2_LIB}"
fi
fi
echo "ESMF_DEP_INCPATH=${PATH_CCPP_INC}" > ${CCPP_MK}

# Set linker flags
CCPP_LINK_OBJS="-L${PATH_CCPP_LIB} -lccpp -lccppphys"

echo "ESMF_DEP_INCPATH=${PATH_CCPP_INC} ${PATH_CCPP_BUILD}/physics" > ${CCPP_MK}
echo "ESMF_DEP_LINK_OBJS=${CCPP_LINK_OBJS}" >> ${CCPP_MK}

if [ $clean_after = YES ]; then
Expand Down
Loading