From 9e46e5e7aaf8eba19cc3b911364493df2b50ac3a Mon Sep 17 00:00:00 2001 From: climbfuji Date: Wed, 27 Feb 2019 13:42:12 -0700 Subject: [PATCH 1/3] CMakeLists.txt: reduce optimization for gcm_shoc.F90; force-remove bounds-check for auto-generated physics caps (similar to the existing force-removal of pointer association checks) --- CMakeLists.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8143a32ec..9e59ca1ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") ./physics/sflx.f ./physics/satmedmfvdif.F ./physics/cs_conv.F90 + ./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 @@ -214,6 +215,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") ./physics/sflx.f ./physics/satmedmfvdif.F ./physics/cs_conv.F90 + ./physics/gcm_shoc.F90 ./physics/gfdl_fv_sat_adj.F90) endif (${CMAKE_BUILD_TYPE} MATCHES "Debug") @@ -254,21 +256,22 @@ else (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") # The auto-generated caps can contain calls to physics schemes in -# which some of the arguments (pointers) are not associated. This is -# on purpose to avoid allocating fields that are not used inside the +# which some of the arguments (pointers, arrays) are not associated/allocated. +# This is on purpose to avoid allocating fields that are not used inside the # scheme if, for example, certain conditions are not met. To avoid # Fortran runtime errors, it is necessary to remove checks for pointers -# that are not associated from the caps ONLY. For the physics schemes, -# these checks can and should remain enabled. Overwriting the check flags -# explicitly works for Intel and GNU, but not for PGI. +# that are not associated and for array bounds from the caps ONLY. For the +# 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") + set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-fcheck=no-pointer,no-bounds") elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") - set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-check nopointers") + set_property(SOURCE ${CAPS} 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") endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") if (PROJECT STREQUAL "CCPP-FV3") From 6b8634d1a6205e59e0dc469de6b147c70db0aaa6 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Wed, 27 Feb 2019 13:43:27 -0700 Subject: [PATCH 2/3] physics/cs_conv.F90, physics/GFS_suite_interstitial.F90: remove hard-coded dimensions for arrays that may not be allocated, depending on the choice of microphysics --- physics/GFS_suite_interstitial.F90 | 8 ++++++-- physics/cs_conv.F90 | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/physics/GFS_suite_interstitial.F90 b/physics/GFS_suite_interstitial.F90 index 8abe472b2..5606ed1f1 100644 --- a/physics/GFS_suite_interstitial.F90 +++ b/physics/GFS_suite_interstitial.F90 @@ -615,7 +615,9 @@ subroutine GFS_suite_interstitial_3_run (im, levs, nn, cscnv, satmedmf, trans_tr real(kind=kind_phys), dimension(im), intent(in) :: xlat real(kind=kind_phys), dimension(im, levs, ntrac), intent(in) :: gq0 - real(kind=kind_phys), dimension(im, levs), intent(inout) :: rhc, save_qc, save_qi + real(kind=kind_phys), dimension(im, levs), intent(inout) :: rhc, save_qc + ! save_qi is not allocated for Zhao-Carr MP + real(kind=kind_phys), dimension(:, :), intent(inout) :: save_qi real(kind=kind_phys), dimension(im, levs, nn), intent(inout) :: clw character(len=*), intent(out) :: errmsg @@ -829,7 +831,9 @@ subroutine GFS_suite_interstitial_4_run (im, levs, ltaerosol, lgocart, tracers_t logical, intent(in) :: ltaerosol, lgocart real(kind=kind_phys), intent(in) :: con_pi, dtf - real(kind=kind_phys), dimension(im,levs), intent(in) :: save_qc, save_qi + real(kind=kind_phys), dimension(im,levs), intent(in) :: save_qc + ! save_qi is not allocated for Zhao-Carr MP + real(kind=kind_phys), dimension(:, :), intent(in) :: save_qi real(kind=kind_phys), dimension(im,levs,ntrac), intent(inout) :: gq0 real(kind=kind_phys), dimension(im,levs,nn), intent(inout) :: clw diff --git a/physics/cs_conv.F90 b/physics/cs_conv.F90 index 6a4ad57ba..0562acdf4 100644 --- a/physics/cs_conv.F90 +++ b/physics/cs_conv.F90 @@ -59,7 +59,9 @@ subroutine cs_conv_pre_run(im, levs, ntrac, ncld, q, clw1, clw2, & ! --- input/output real(r8), dimension(ntrac-ncld+2), intent(out) :: fswtr, fscav real(r8), dimension(im), intent(out) :: wcbmax - real(r8), dimension(im,levs), intent(out) :: save_q1,save_q2,save_q3 + real(r8), dimension(im,levs), intent(out) :: save_q1,save_q2 + ! save_q3 is not allocated for Zhao-Carr MP + real(r8), dimension(:,:), intent(out) :: save_q3 character(len=*), intent(out) :: errmsg integer, intent(out) :: errflg From e2652e85238016acd55c5f2bcdad36eee6f68809 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Wed, 27 Feb 2019 16:13:40 -0700 Subject: [PATCH 3/3] physics/module_bl_mynn.F90: remove trailing whitespaces --- physics/module_bl_mynn.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/module_bl_mynn.F90 b/physics/module_bl_mynn.F90 index 661bde35e..81d9e1089 100644 --- a/physics/module_bl_mynn.F90 +++ b/physics/module_bl_mynn.F90 @@ -113,7 +113,7 @@ MODULE module_bl_mynn & p_qnc= 0, & & p_qni= 0 -!END FV3 CONSTANTS +!END FV3 CONSTANTS !==================================================================== !WRF CONSTANTS ! USE module_model_constants, only: &