From 29de6e94226e48e339d2b0e5b3dae75cc63af3f4 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Tue, 12 Mar 2019 21:21:08 -0400 Subject: [PATCH 1/6] CMakeLists.txt: explicitly define that a shared library is to be built for the dynamic build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16864dde8..431cff855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,7 @@ if(STATIC) list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/../${module_f90}) endforeach() else(STATIC) - add_library(ccppphys ${SCHEMES} ${CAPS}) + add_library(ccppphys SHARED ${SCHEMES} ${CAPS}) endif(STATIC) if (PROJECT STREQUAL "CCPP-FV3") From ed1cb7b7a1ea8ff2ec47604cb8984601389eeb26 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Thu, 14 Mar 2019 20:11:51 -0400 Subject: [PATCH 2/6] Update comment in CMakeLists.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 431cff855..700ba144b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,8 +179,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}") endif (DYN32) - # For CCPP acceptance: selective reduction of optimization flags, hopefully - # to be removed once established that this is not a reasonable approach. + # For CCPP acceptance: selective reduction of optimization flags if (TRANSITION) # Replace "-no-prec-div -no-prec-sqrt" with "-prec-div -prec-sqrt", # replace "CORE-AVX2" with "CORE-AVX-I" From 81d2046faa47906f69869022bf6723307c872423 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Fri, 15 Mar 2019 15:59:09 -0400 Subject: [PATCH 3/6] Remove linking to NCEPlibs --- CMakeLists.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd790f147..e92d1913a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,9 +274,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI") set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-Mnobounds") endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") -if (PROJECT STREQUAL "CCPP-FV3") - link_directories(${NCEPLIBS_DIR}/lib) -elseif (PROJECT STREQUAL "CCPP-SCM") +if (PROJECT STREQUAL "CCPP-SCM") SET(W3LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/w3nco/v2.0.6/src) SET(BACIOLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/bacio/v2.0.1/src) SET(SPLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/sp/v2.0.2/src) @@ -291,7 +289,7 @@ elseif (PROJECT STREQUAL "CCPP-SCM") INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/ccpp/framework/src) -endif (PROJECT STREQUAL "CCPP-FV3") +endif (PROJECT STREQUAL "CCPP-SCM") #------------------------------------------------------------------------------ @@ -307,11 +305,10 @@ else(STATIC) add_library(ccppphys SHARED ${SCHEMES} ${SCHEMES_SFX} ${CAPS}) endif(STATIC) -if (PROJECT STREQUAL "CCPP-FV3") - target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} sp_v2.0.2_d bacio_4 w3nco_d) -elseif (PROJECT STREQUAL "CCPP-SCM") +if (PROJECT STREQUAL "CCPP-SCM") target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio) -endif (PROJECT STREQUAL "CCPP-FV3") +endif (PROJECT STREQUAL "CCPP-SCM") + set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) From dc83fc4d04fdb1b806d254c64ee7b492b270fe11 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Fri, 15 Mar 2019 16:45:51 -0400 Subject: [PATCH 4/6] Remove all code related to the memcheck utility --- physics/memcheck.F90 | 88 -------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 physics/memcheck.F90 diff --git a/physics/memcheck.F90 b/physics/memcheck.F90 deleted file mode 100644 index 3d8e5df68..000000000 --- a/physics/memcheck.F90 +++ /dev/null @@ -1,88 +0,0 @@ -!> \file memcheck.F90 -!! Contains code to check memory usage with/without CCPP. - - module memcheck - - implicit none - - private - - public memcheck_init, memcheck_run, memcheck_finalize - - contains - - subroutine memcheck_init () - end subroutine memcheck_init - - subroutine memcheck_finalize () - end subroutine memcheck_finalize - -!> \section arg_table_memcheck_run Argument Table -!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional | -!! |-----------------|--------------------------------------------------------|---------------------------------------------------------|-------|------|-----------|-----------|--------|----------| -!! | mpicomm | mpi_comm | MPI communicator | index | 0 | integer | | in | F | -!! | mpirank | mpi_rank | current MPI-rank | index | 0 | integer | | in | F | -!! | mpisize | mpi_size | number of MPI tasks in communicator | count | 0 | integer | | in | F | -!! | mpiroot | mpi_root | master MPI-rank | index | 0 | integer | | in | T | -!! | ompthreads | omp_threads | number of OpenMP threads available for physics schemes | count | 0 | integer | | in | F | -!! | 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 | -!! - subroutine memcheck_run (mpicomm, mpirank, mpisize, mpiroot, ompthreads, errmsg, errflg) - -#ifdef MPI - use mpi -#endif -#ifdef OPENMP - use omp_lib -#endif - use ccpp_api, only: ccpp_memory_usage - - implicit none - - !--- interface variables - integer, intent(in) :: mpicomm - integer, intent(in) :: mpirank - integer, intent(in) :: mpisize - integer, optional, intent(in) :: mpiroot - integer, intent(in) :: ompthreads - character(len=*), intent(out) :: errmsg - integer, intent(out) :: errflg - - !--- local variables - integer :: impi, ierr - integer :: ompthread - character(len=1024) :: memory_usage - - ! Initialize CCPP error handling variables - errmsg = '' - errflg = 0 - -#ifdef OPENMP - ompthread = OMP_GET_THREAD_NUM() -#else - ompthread = 0 -#endif - - ierr = ccpp_memory_usage(mpicomm, memory_usage) - if (present(mpiroot) .and. mpirank==mpiroot) then - write(0,'(a)') trim(memory_usage) - else if (.not.present(mpiroot)) then - ! Output ordered by MPI rank - do impi=0,mpisize-1 - if (mpirank==impi) then - write(0,'(a)') trim(memory_usage) - end if -#ifdef MPI - call MPI_BARRIER(mpicomm,ierr) -#endif - end do - end if - -#ifdef MPI - call MPI_BARRIER(mpicomm,ierr) -#endif - - end subroutine memcheck_run - - end module memcheck From afc5e22a167ca536d8b2cf0f333ceeece03b4aba Mon Sep 17 00:00:00 2001 From: climbfuji Date: Tue, 19 Mar 2019 15:31:17 -0600 Subject: [PATCH 5/6] CMakeLists.txt: revert parts of the previous change, need to link the NCEPlibs and ccpp-framework to the ccpp physics library for the dynamic build --- CMakeLists.txt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e92d1913a..4781f47c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,7 +274,11 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI") set_property(SOURCE ${CAPS} PROPERTY COMPILE_FLAGS "-Mnobounds") endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") -if (PROJECT STREQUAL "CCPP-SCM") +if (PROJECT STREQUAL "CCPP-FV3") + if (NOT STATIC) + link_directories(${NCEPLIBS_DIR}/lib) + endif (NOT STATIC) +elseif (PROJECT STREQUAL "CCPP-SCM") SET(W3LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/w3nco/v2.0.6/src) SET(BACIOLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/bacio/v2.0.1/src) SET(SPLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../external/sp/v2.0.2/src) @@ -289,7 +293,7 @@ if (PROJECT STREQUAL "CCPP-SCM") INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/ccpp/framework/src) -endif (PROJECT STREQUAL "CCPP-SCM") +endif (PROJECT STREQUAL "CCPP-FV3") #------------------------------------------------------------------------------ @@ -305,10 +309,13 @@ else(STATIC) add_library(ccppphys SHARED ${SCHEMES} ${SCHEMES_SFX} ${CAPS}) endif(STATIC) -if (PROJECT STREQUAL "CCPP-SCM") +if (PROJECT STREQUAL "CCPP-FV3") + if (NOT STATIC) + target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} sp_v2.0.2_d bacio_4 w3nco_d) + endif (NOT STATIC) +elseif (PROJECT STREQUAL "CCPP-SCM") target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio) -endif (PROJECT STREQUAL "CCPP-SCM") - +endif (PROJECT STREQUAL "CCPP-FV3") set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) From dd240c2b22e340a126bd7846e87cdfd3782c8351 Mon Sep 17 00:00:00 2001 From: climbfuji Date: Fri, 22 Mar 2019 11:14:17 -0600 Subject: [PATCH 6/6] CMakeLists.txt: remove selective reduction of optimization for bit-for-bit reproducibility in REPRO mode (no longer needed when -fp-model consistent is used) --- CMakeLists.txt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4781f47c4..60ff5eadc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,21 +164,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") # intrinsic gamma function are different for the non-CCPP and CCPP # version (on Theia with Intel 18). Note this is only required with # dynamic CCPP builds (hybrid, standalone), not with static CCPP builds. - if (${CMAKE_BUILD_TYPE} MATCHES "Debug") - SET_SOURCE_FILES_PROPERTIES(./physics/micro_mg2_0.F90 - ./physics/micro_mg3_0.F90 - PROPERTIES COMPILE_FLAGS "-fimf-arch-consistency=true") - # Add all of the above files to the list of schemes with special compiler flags - list(APPEND SCHEMES_SFX ./physics/micro_mg2_0.F90 - ./physics/micro_mg3_0.F90) - elseif (${CMAKE_BUILD_TYPE} MATCHES "Bitforbit") - SET_SOURCE_FILES_PROPERTIES(./physics/micro_mg2_0.F90 - ./physics/micro_mg3_0.F90 - PROPERTIES COMPILE_FLAGS "-fimf-arch-consistency=true") - # Add all of the above files to the list of schemes with special compiler flags - list(APPEND SCHEMES_SFX ./physics/micro_mg2_0.F90 - ./physics/micro_mg3_0.F90) - elseif (TRANSITION) + if (TRANSITION) # Replace -xHost or -xCORE-AVX2 with -xCORE-AVX-I, -no-prec-div with -prec-div, and # -no-prec-sqrt with -prec-sqrt for certain files for bit-for-bit reproducibility # with non-CCPP builds. These may go in the future once the CCPP solution is fully accepted. @@ -217,7 +203,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") ./physics/cs_conv.F90 ./physics/gcm_shoc.F90 ./physics/gfdl_fv_sat_adj.F90) - endif (${CMAKE_BUILD_TYPE} MATCHES "Debug") + endif (TRANSITION) # Remove files with special compiler flags from list of files with standard compiler flags list(REMOVE_ITEM SCHEMES ${SCHEMES_SFX})