Skip to content

Commit

Permalink
Merge pull request #4 from NCAR/master
Browse files Browse the repository at this point in the history
update with authoritative repo
  • Loading branch information
pjpegion authored Dec 2, 2020
2 parents f60ec02 + d076cc2 commit b934a13
Show file tree
Hide file tree
Showing 299 changed files with 59,400 additions and 19,801 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/basic_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Basic checks for CCPP physics schemes

on: [push, pull_request]

jobs:
build:

runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Init submodules
run: git submodule update --init --recursive
#- name: Update packages
# run: |
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# #brew install autoconf automake coreutils gcc@9 libtool mpich gnu-sed wget
# brew install automake coreutils mpich gnu-sed
- name: Check for ASCII encoding
run: ./tools/check_encoding.py
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "physics/rte-rrtmgp"]
path = physics/rte-rrtmgp
url = https://github.com/RobertPincus/rte-rrtmgp
url = https://github.com/earth-system-radiation/rte-rrtmgp
branch = dtc/ccpp
83 changes: 39 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif (NOT PROJECT)
cmake_minimum_required(VERSION 3.0)

project(ccppphys
VERSION 3.0.0
VERSION 4.0.0
LANGUAGES C CXX Fortran)

# Use rpaths on MacOSX
Expand All @@ -17,6 +17,11 @@ if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)

# CMP0057: Support new IN_LIST if() operator
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif(POLICY CMP0057)

#------------------------------------------------------------------------------
set(PACKAGE "ccpp-physics")
set(AUTHORS "Grant Firl" "Dom Heinzeller" "Man Zhang" "Laurie Carson")
Expand Down Expand Up @@ -131,6 +136,7 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# Set 32-bit floating point precision flags for certain files
# that are executed in the dynamics (fast physics part)
if (DYN32)
if (${CMAKE_CURRENT_SOURCE_DIR}/physics/gfdl_fv_sat_adj.F90 IN_LIST SCHEMES)
# Reduce floating point precision from 64-bit to 32-bit, if necessary
set(CMAKE_Fortran_FLAGS_PREC32 ${CMAKE_Fortran_FLAGS_DEFAULT_PREC})
string(REPLACE "-fdefault-real-8" ""
Expand All @@ -141,7 +147,8 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_PREC32} ")
# Add all of the above files to the list of schemes with special floating point precision flags
list(APPEND SCHEMES_SFX_PREC ${CMAKE_CURRENT_SOURCE_DIR}/physics/gfdl_fv_sat_adj.F90)
endif (DYN32)
endif()
endif()

# Remove files with special floating point precision flags from list
# of files with standard floating point precision flags flags
Expand All @@ -156,57 +163,44 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# Adjust settings for bit-for-bit reproducibility of NEMSfv3gfs
if (PROJECT STREQUAL "CCPP-FV3")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/physics/module_bfmicrophysics.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/sflx.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/sfc_diff.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/sfc_diag.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_nst_model.f90
${CMAKE_CURRENT_SOURCE_DIR}/physics/calpreciptype.f90
${CMAKE_CURRENT_SOURCE_DIR}/physics/mersenne_twister.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_nst_water_prop.f90
${CMAKE_CURRENT_SOURCE_DIR}/physics/aer_cloud.F
${CMAKE_CURRENT_SOURCE_DIR}/physics/wv_saturation.F
${CMAKE_CURRENT_SOURCE_DIR}/physics/cldwat2m_micro.F
${CMAKE_CURRENT_SOURCE_DIR}/physics/surface_perturbation.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f
${CMAKE_CURRENT_SOURCE_DIR}/physics/cu_gf_deep.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/cu_gf_sh.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_bl_mynn.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_MYNNPBL_wrapper.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_sf_mynn.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_MYNNSFC_wrapper.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_MYNNrad_pre.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_MYNNrad_post.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_mp_thompson_make_number_concentrations.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_SF_JSFC.F90
${CMAKE_CURRENT_SOURCE_DIR}/physics/module_BL_MYJPBL.F90
PROPERTIES COMPILE_FLAGS "-r8 -ftz")

# Replace -xHost or -xCORE-AVX2 with -xCORE-AVX-I for certain files
set(CMAKE_Fortran_FLAGS_LOPT1 ${CMAKE_Fortran_FLAGS_OPT})
string(REPLACE "-xHOST" "-xCORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
string(REPLACE "-xCORE-AVX2" "-xCORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
string(REPLACE "-axSSE4.2,AVX,CORE-AVX2,CORE-AVX512" "-axSSE4.2,AVX,CORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_LOPT1}")
# Add all of the above files to the list of schemes with special compiler flags
list(APPEND SCHEMES_SFX_OPT ${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f)
if (${CMAKE_CURRENT_SOURCE_DIR}/physics/module_sf_mynn.F90 IN_LIST SCHEMES)
# Reduce optimization for module_sf_mynn.F90 (to avoid an apparent compiler bug with Intel 18 on Hera)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/physics/module_sf_mynn.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT} -O1")
list(APPEND SCHEMES_SFX_OPT ${CMAKE_CURRENT_SOURCE_DIR}/physics/module_sf_mynn.F90)
endif()

if (${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f IN_LIST SCHEMES)
# Replace -xHost or -xCORE-AVX2 with -xCORE-AVX-I for certain files
set(CMAKE_Fortran_FLAGS_LOPT1 ${CMAKE_Fortran_FLAGS_OPT})
string(REPLACE "-xHOST" "-xCORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
string(REPLACE "-xCORE-AVX2" "-xCORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
string(REPLACE "-axSSE4.2,AVX,CORE-AVX2,CORE-AVX512" "-axSSE4.2,AVX,CORE-AVX-I"
CMAKE_Fortran_FLAGS_LOPT1
"${CMAKE_Fortran_FLAGS_LOPT1}")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_LOPT1}")
# Add all of the above files to the list of schemes with special compiler flags
list(APPEND SCHEMES_SFX_OPT ${CMAKE_CURRENT_SOURCE_DIR}/physics/radiation_aerosols.f)
endif()

# Remove files with special compiler flags from list of files with standard compiler flags
list(REMOVE_ITEM SCHEMES ${SCHEMES_SFX_OPT})
if (SCHEMES_SFX_OPT)
list(REMOVE_ITEM SCHEMES ${SCHEMES_SFX_OPT})
endif(SCHEMES_SFX_OPT)
# Assign standard compiler flags to all remaining schemes and caps
SET_SOURCE_FILES_PROPERTIES(${SCHEMES} ${CAPS}
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT}")

# Set 32-bit floating point precision flags for certain files
# that are executed in the dynamics (fast physics part)
if (DYN32)
if (${CMAKE_CURRENT_SOURCE_DIR}/physics/gfdl_fv_sat_adj.F90 IN_LIST SCHEMES)
# Reduce floating point precision from 64-bit to 32-bit, if necessary
set(CMAKE_Fortran_FLAGS_PREC32 ${CMAKE_Fortran_FLAGS_DEFAULT_PREC})
string(REPLACE "-real-size 64" "-real-size 32"
Expand All @@ -215,7 +209,8 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_PREC32} ")
# Add all of the above files to the list of schemes with special floating point precision flags
list(APPEND SCHEMES_SFX_PREC ${CMAKE_CURRENT_SOURCE_DIR}/physics/gfdl_fv_sat_adj.F90)
endif (DYN32)
endif()
endif()

# Remove files with special floating point precision flags from list
# of files with standard floating point precision flags flags
Expand Down
40 changes: 22 additions & 18 deletions physics/GFS_DCNV_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ end subroutine GFS_DCNV_generic_pre_init
subroutine GFS_DCNV_generic_pre_finalize()
end subroutine GFS_DCNV_generic_pre_finalize

#if 0
!> \brief Interstitial scheme called prior to any deep convective scheme to save state variables for calculating tendencies after the deep convective scheme is executed
!! \section arg_table_GFS_DCNV_generic_pre_run Argument Table
!! \htmlinclude GFS_DCNV_generic_pre_run.html
!!
#endif
subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, cplchm, &
gu0, gv0, gt0, gq0_water_vapor, &
save_u, save_v, save_t, save_qv, ca_deep, &
dqdti, errmsg, errflg)
subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, qdiag3d, do_cnvgwd, cplchm,&
gu0, gv0, gt0, gq0_water_vapor, &
save_u, save_v, save_t, save_qv, dqdti, &
errmsg, errflg)

use machine, only: kind_phys

implicit none

integer, intent(in) :: im, levs
logical, intent(in) :: ldiag3d, do_cnvgwd, cplchm
logical, intent(in) :: ldiag3d, qdiag3d, do_cnvgwd, cplchm
real(kind=kind_phys), dimension(im,levs), intent(in) :: gu0
real(kind=kind_phys), dimension(im,levs), intent(in) :: gv0
real(kind=kind_phys), dimension(im,levs), intent(in) :: gt0
Expand All @@ -36,7 +34,6 @@ subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, cplchm,
real(kind=kind_phys), dimension(im,levs), intent(inout) :: save_v
real(kind=kind_phys), dimension(im,levs), intent(inout) :: save_t
real(kind=kind_phys), dimension(im,levs), intent(inout) :: save_qv
real(kind=kind_phys), dimension(im), intent(in) :: ca_deep
! dqdti only allocated if cplchm is .true.
real(kind=kind_phys), dimension(:,:), intent(inout) :: dqdti
character(len=*), intent(out) :: errmsg
Expand Down Expand Up @@ -65,7 +62,7 @@ subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, cplchm,
enddo
endif

if (ldiag3d .or. cplchm) then
if ((ldiag3d.and.qdiag3d) .or. cplchm) then
do k=1,levs
do i=1,im
save_qv(i,k) = gq0_water_vapor(i,k)
Expand Down Expand Up @@ -94,19 +91,20 @@ end subroutine GFS_DCNV_generic_post_finalize
!> \section arg_table_GFS_DCNV_generic_post_run Argument Table
!! \htmlinclude GFS_DCNV_generic_post_run.html
!!
subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv, &
frain, rain1, dtf, cld1d, save_u, save_v, save_t, save_qv, gu0, gv0, gt0, &
gq0_water_vapor, ud_mf, dd_mf, dt_mf, con_g, npdf3d, num_p3d, ncnvcld3d, &
rainc, cldwrk, dt3dt, dq3dt, du3dt, dv3dt, upd_mf, dwn_mf, det_mf, &
cnvw, cnvc, cnvw_phy_f3d, cnvc_phy_f3d, &
errmsg, errflg)
subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, qdiag3d, ras, cscnv, &
frain, rain1, dtf, cld1d, save_u, save_v, save_t, save_qv, gu0, gv0, gt0, &
gq0_water_vapor, ud_mf, dd_mf, dt_mf, con_g, npdf3d, num_p3d, ncnvcld3d, &
rainc, cldwrk, dt3dt, dq3dt, du3dt, dv3dt, upd_mf, dwn_mf, det_mf, &
cnvw, cnvc, cnvw_phy_f3d, cnvc_phy_f3d, flag_for_dcnv_generic_tend, errmsg, errflg)


use machine, only: kind_phys

implicit none

integer, intent(in) :: im, levs
logical, intent(in) :: lssav, ldiag3d, ras, cscnv
logical, intent(in) :: lssav, ldiag3d, qdiag3d, ras, cscnv
logical, intent(in) :: flag_for_dcnv_generic_tend

real(kind=kind_phys), intent(in) :: frain, dtf
real(kind=kind_phys), dimension(im), intent(in) :: rain1, cld1d
Expand Down Expand Up @@ -165,11 +163,10 @@ subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv,
cldwrk (i) = cldwrk (i) + cld1d(i) * dtf
enddo

if (ldiag3d) then
if (ldiag3d .and. flag_for_dcnv_generic_tend) then
do k=1,levs
do i=1,im
dt3dt(i,k) = dt3dt(i,k) + (gt0(i,k)-save_t(i,k)) * frain
! dq3dt(i,k) = dq3dt(i,k) + (gq0_water_vapor(i,k)-save_qv(i,k)) * frain
du3dt(i,k) = du3dt(i,k) + (gu0(i,k)-save_u(i,k)) * frain
dv3dt(i,k) = dv3dt(i,k) + (gv0(i,k)-save_v(i,k)) * frain

Expand All @@ -178,6 +175,13 @@ subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv,
! det_mf(i,k) = det_mf(i,k) + dt_mf(i,k) * (con_g*frain)
enddo
enddo
if(qdiag3d) then
do k=1,levs
do i=1,im
dq3dt(i,k) = dq3dt(i,k) + (gq0_water_vapor(i,k)-save_qv(i,k)) * frain
enddo
enddo
endif
endif ! if (ldiag3d)

endif ! if (lssav)
Expand Down
Loading

0 comments on commit b934a13

Please sign in to comment.