Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 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
92 changes: 76 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ list(APPEND LIBS "ccpp")
include(./CCPP_SCHEMES.cmake)
# Set the sources: physics scheme caps
include(./CCPP_CAPS.cmake)
# Create empty lists for schemes with special compiler flags
set(SCHEMES_SFX "")

# Create empty lists for schemes with special compiler optimization flags
set(SCHEMES_SFX_OPT "")
# Create empty lists for schemes with special floating point precision flags
set(SCHEMES_SFX_PREC "")
# Create a duplicate of the SCHEMES list for handling floating point precision flags
set(SCHEMES2 ${SCHEMES})
#------------------------------------------------------------------------------
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none")
Expand All @@ -112,11 +115,33 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-ffree-line-length-none -fdefault-real-8 -ffree-form")
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F ./physics/surface_perturbation.F90 PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fdefault-double-8")
SET_SOURCE_FILES_PROPERTIES(./physics/module_mp_thompson_make_number_concentrations.F90 PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fdefault-double-8")

if (PROJECT STREQUAL "CCPP-FV3")
# Set 32-bit floating point precision flags for certain files
# that are executed in the dynamics (fast physics part)
if (DYN32)
message (FATAL_ERROR "The current build system does not allow building fast physics with 32-bit precision when the GNU compilers are used")
# 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" ""
CMAKE_Fortran_FLAGS_PREC32 "${CMAKE_Fortran_FLAGS_PREC32}")
string(REPLACE "-fdefault-double-8" ""
CMAKE_Fortran_FLAGS_PREC32 "${CMAKE_Fortran_FLAGS_PREC32}")
SET_PROPERTY(SOURCE ./physics/gfdl_fv_sat_adj.F90
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 ./physics/gfdl_fv_sat_adj.F90)
endif (DYN32)

# Remove files with special floating point precision flags from list
# of files with standard floating point precision flags flags
if (SCHEMES_SFX_PREC)
list(REMOVE_ITEM SCHEMES2 ${SCHEMES_SFX_PREC})
endif (SCHEMES_SFX_PREC)
# Assign standard floating point precision flags to all remaining schemes and caps
SET_PROPERTY(SOURCE ${SCHEMES2} ${CAPS}
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_DEFAULT_PREC} ")
endif (PROJECT STREQUAL "CCPP-FV3")

elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# Adjust settings for bit-for-bit reproducibility of NEMSfv3gfs
if (PROJECT STREQUAL "CCPP-FV3")
Expand Down Expand Up @@ -158,7 +183,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
SET_SOURCE_FILES_PROPERTIES(./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 ./physics/radiation_aerosols.f)
list(APPEND SCHEMES_SFX_OPT ./physics/radiation_aerosols.f)

# Force consistent results of math calculations for MG microphysics;
# in Debug/Bitforbit mode; without this flag, the results of the
Expand Down Expand Up @@ -194,7 +219,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
./physics/gcm_shoc.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_LOPT2}")
# Add all of the above files to the list of schemes with special compiler flags
list(APPEND SCHEMES_SFX ./physics/micro_mg2_0.F90
list(APPEND SCHEMES_SFX_OPT ./physics/micro_mg2_0.F90
./physics/micro_mg3_0.F90
./physics/aer_cloud.F
./physics/cldmacro.F
Expand All @@ -207,17 +232,33 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
endif (TRANSITION)

# Remove files with special compiler flags from list of files with standard compiler flags
list(REMOVE_ITEM SCHEMES ${SCHEMES_SFX})
list(REMOVE_ITEM SCHEMES ${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}")

# This has to come last: append 32-bit dynamics flags to certain files that are executed
# in the dynamics (fast physics part); this will overwrite any preceding -real-size 64
# Set 32-bit floating point precision flags for certain files
# that are executed in the dynamics (fast physics part)
if (DYN32)
SET_PROPERTY(SOURCE ./physics/gfdl_fv_sat_adj.F90 APPEND_STRING PROPERTY COMPILE_FLAGS " -real-size 32 ")
# 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"
CMAKE_Fortran_FLAGS_PREC32 "${CMAKE_Fortran_FLAGS_PREC32}")
SET_PROPERTY(SOURCE ./physics/gfdl_fv_sat_adj.F90
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 ./physics/gfdl_fv_sat_adj.F90)
endif (DYN32)

# Remove files with special floating point precision flags from list
# of files with standard floating point precision flags flags
if (SCHEMES_SFX_PREC)
list(REMOVE_ITEM SCHEMES2 ${SCHEMES_SFX_PREC})
endif (SCHEMES_SFX_PREC)
# Assign standard floating point precision flags to all remaining schemes and caps
SET_PROPERTY(SOURCE ${SCHEMES2} ${CAPS}
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_DEFAULT_PREC} ")

else (PROJECT STREQUAL "CCPP-FV3")
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/sflx.f ./physics/sfc_diff.f ./physics/sfc_diag.f PROPERTIES COMPILE_FLAGS -r8)
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free")
Expand All @@ -233,9 +274,28 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI")
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F ./physics/surface_perturbation.F90 PROPERTIES COMPILE_FLAGS "-r8")
SET_SOURCE_FILES_PROPERTIES(./physics/module_mp_thompson_make_number_concentrations.F90 PROPERTIES COMPILE_FLAGS "-r8")
if (PROJECT STREQUAL "CCPP-FV3")
# Set 32-bit floating point precision flags for certain files
# that are executed in the dynamics (fast physics part)
if (DYN32)
SET_PROPERTY(SOURCE ./physics/gfdl_fv_sat_adj.F90 APPEND_STRING PROPERTY COMPILE_FLAGS " -r4 ")
# Reduce floating point precision from 64-bit to 32-bit, if necessary
set(CMAKE_Fortran_FLAGS_PREC32 ${CMAKE_Fortran_FLAGS_DEFAULT_PREC})
string(REPLACE "-r8" "-r4"
CMAKE_Fortran_FLAGS_PREC32 "${CMAKE_Fortran_FLAGS_PREC32}")
SET_PROPERTY(SOURCE ./physics/gfdl_fv_sat_adj.F90
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 ./physics/gfdl_fv_sat_adj.F90)
endif (DYN32)

# Remove files with special floating point precision flags from list
# of files with standard floating point precision flags flags
if (SCHEMES_SFX_PREC)
list(REMOVE_ITEM SCHEMES2 ${SCHEMES_SFX_PREC})
endif (SCHEMES_SFX_PREC)
# Assign standard floating point precision flags to all remaining schemes and caps
SET_PROPERTY(SOURCE ${SCHEMES2} ${CAPS}
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_DEFAULT_PREC} ")

endif (PROJECT STREQUAL "CCPP-FV3")
else (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
Expand All @@ -252,14 +312,14 @@ endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# physics schemes, these checks can and should remain enabled. Overwriting
# the pointer check flags explicitly works for Intel and GNU, but not for PGI.
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-fcheck=no-pointer,no-bounds")
set_property(SOURCE ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fcheck=no-pointer,no-bounds ")
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-check nopointers,nobounds")
set_property(SOURCE ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " -check nopointers,nobounds ")
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI")
if (CMAKE_Fortran_FLAGS MATCHES ".*chkptr.*")
message (FATAL_ERROR "PGI compiler option chkptr cannot be used for CCPP physics")
endif (CMAKE_Fortran_FLAGS MATCHES ".*chkptr.*")
set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-Mnobounds")
set_property(SOURCE ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " -Mnobounds ")
endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")

if (PROJECT STREQUAL "CCPP-SCM")
Expand All @@ -269,15 +329,15 @@ endif (PROJECT STREQUAL "CCPP-SCM")
#------------------------------------------------------------------------------

if(STATIC)
add_library(ccppphys STATIC ${SCHEMES} ${SCHEMES_SFX} ${CAPS})
add_library(ccppphys STATIC ${SCHEMES} ${SCHEMES_SFX_OPT} ${CAPS})
# Generate list of Fortran modules from defined sources
foreach(source_f90 ${CAPS})
string(REGEX REPLACE ".F90" ".mod" tmp_module_f90 ${source_f90})
string(TOLOWER ${tmp_module_f90} module_f90)
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/../${module_f90})
endforeach()
else(STATIC)
add_library(ccppphys SHARED ${SCHEMES} ${SCHEMES_SFX} ${CAPS})
add_library(ccppphys SHARED ${SCHEMES} ${SCHEMES_SFX_OPT} ${CAPS})
endif(STATIC)

if (NOT STATIC)
Expand Down
2 changes: 1 addition & 1 deletion physics/GFS_MP_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module GFS_MP_generic_post
subroutine GFS_MP_generic_post_init
end subroutine GFS_MP_generic_post_init

!>\defgroup gfs_calpreciptype GFS/GFDL calpreciptype Main
!>\defgroup gfs_calpreciptype GFS Precipitation Type Diagnostics Module
!! \brief If dominant precip type is requested (i.e., Zhao-Carr MP scheme), 4 more algorithms in calpreciptype()
!! will be called. the tallies are then summed in calwxt_dominant(). For GFDL cloud MP scheme, determine convective
!! rain/snow by surface temperature; and determine explicit rain/snow by rain/snow coming out directly from MP.
Expand Down
20 changes: 11 additions & 9 deletions physics/aer_cloud.F
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ end subroutine aer_cloud_init
!!\param dpre_in mass-weighted diameter of prexisting ice crystals (m)
!!\param ccn_diagr8 array of supersaturations for CCN diagnostics (in-out)
!!\param Ndropr8 Current droplet number concentration (\f$Kg^{-1}\f$)
!!\param qc Liquid water mixing ratio (Kg/Kg)
!!\param use_average_v .false. integrate over the updraft distribution. True: use the mean vertical velocity
!!\param CCN_param CCN activation parameterization. 1- Fountoukis and Nenes (2005), 2-Abdul_Razzak and Ghan (2002) (def = 2)
!!\param IN_param IN activation spectrum (default is 5)
!!\param cdncr8 Activated cloud droplet number concentration (Kg-1)
!!\param smaxliqr8 Maximum supersaturation w.r.t liquid during droplet activation
!!\param incr8 Nucleated ice crystal concentration (Kg-1)
Expand All @@ -172,14 +168,20 @@ end subroutine aer_cloud_init
!!\param Ncdepr8 Nucleated nc by deposition ice nucleation (Kg-1)
!!\param Ncdhfr8 Nucleated nc by immersion in aerosol (Kg -1)
!!\param sc_icer8 Critical saturation ratio in cirrus
!!\param fdust_depr8 Fraction of deposition ice nuclei that are dust
!!\param fdust_immr8 Fraction of immersion mixed-phase ice nuclei that are dust
!!\param fdust_depr8 Fraction of deposition ice nuclei that are dust
!!\param fdust_dhfr8 Fraction of immersion ice nuclei that are dust (not mixed-phase)
!!\param nlimr8 Limiting ice nuclei concentration (m-3)

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


!!\param use_average_v .false. integrate over the updraft distribution. True: use the mean vertical velocity
!!\param CCN_param CCN activation parameterization. 1- Fountoukis and Nenes (2005), 2-Abdul_Razzak and Ghan (2002) (def = 2)
!!\param IN_param IN activation spectrum (default is 5)
!!\param fd_dust
!!\param fd_soot
!!\param pfrz_inc_r8
!!\param sigma_nuc
!!\param rhi_cell
!!\param nccn
!!
subroutine aerosol_activate(tparc_in, pparc_in, sigwparc_in, &
& wparc_ls, Aer_Props, npre_in, dpre_in, ccn_diagr8, Ndropr8, &
& cdncr8, smaxliqr8, incr8, smaxicer8, nheticer8, INimmr8, &
Expand Down
4 changes: 2 additions & 2 deletions physics/cnvc90.f
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module cnvc90
subroutine cnvc90_init()
end subroutine cnvc90_init

!>\defgroup GFS_cnvc90 GFS cnvc90 Main
!>\defgroup GFS_cnvc90 GFS Convective Cloud Diagnostics Module
!> @{
!! This module contains the calculation of fraction of convective cloud,
!! pressure at bottom of convective cloud and at top of convective
Expand All @@ -37,7 +37,7 @@ end subroutine cnvc90_init
!! | errmsg | ccpp_error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | ccpp_error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!!
!>\section gen_cnvc90_run GFS cnvc90_run General Algorithm
! \section gen_cnvc_run GFS cnvc90_run General Algorithm
SUBROUTINE cnvc90_run(CLSTP,IM,IX,RN,KBOT,KTOP,KM,PRSI, &
& ACV,ACVB,ACVT,CV,CVB,CVT,errmsg,errflg)

Expand Down
Loading