Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nemsfv3gfs master ccpp integration #76

Merged
merged 3 commits into from
May 9, 2018
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
6 changes: 0 additions & 6 deletions CCPP_CAPS.mk

This file was deleted.

12 changes: 0 additions & 12 deletions CCPP_SCHEMES.mk

This file was deleted.

307 changes: 181 additions & 126 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Set default project to unknown
if(NOT PROJECT)
message(STATUS "Setting CCPP project to 'unknown' as none was specified.")
set(PROJECT "Unknown")
endif (NOT PROJECT)

#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.11)

Expand All @@ -6,27 +12,34 @@ set(CMAKE_MACOSX_RPATH 1)

if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
project(ccppphys VERSION 0.0.1)
project(ccppphys VERSION 1.0.0)
else(POLICY CMP0048)
project(ccppphys)
set(PROJECT_VERSION 0.0.1)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION 1.0.0)
set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH 1)
set(PROJECT_VERSION_PATCH 0)
endif(POLICY CMP0048)

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

#------------------------------------------------------------------------------
set(PACKAGE "ccppphys")
set(PACKAGE "ccpp-physics")
set(AUTHORS "Grant J. Firl" "Dom Heinzeller")

#------------------------------------------------------------------------------
# Enable Fortran
enable_language(Fortran)

#------------------------------------------------------------------------------
# CMake Modules
# Set the CMake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ccpp-framework/cmake")
# DH this should be a PROJECT == CCPP-SCM test
if (NOT PROJECT MATCHES "CCPP-FV3")
#------------------------------------------------------------------------------
# CMake Modules
# Set the CMake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ccpp-framework/cmake")
endif (NOT PROJECT MATCHES "CCPP-FV3")

#------------------------------------------------------------------------------
# Set OpenMP flags for C/C++/Fortran
Expand Down Expand Up @@ -61,8 +74,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)

# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage")
endif()

#------------------------------------------------------------------------------
Expand All @@ -84,95 +96,103 @@ list(APPEND LIBS "ccpp")
ADD_DEFINITIONS(-DNEMS_GSM)

#------------------------------------------------------------------------------
# Set the sources
set(SOURCES
./physics/machine.F
./physics/physcons.f90
./physics/funcphys.f90
./GFS_layer/GFS_typedefs.F90
./physics/radlw_param.f
./physics/physparam.f
./physics/radsw_param.f
./physics/radiation_aerosols.f
./physics/iounitdef.f
./physics/gfs_phy_tracer_config.f
./physics/radiation_clouds.f
./physics/module_bfmicrophysics.f
./physics/radiation_gases.f
./physics/ozne_def.f
./physics/radiation_surface.f
./physics//h2o_def.f
./physics/sfcsub.F
./physics/mersenne_twister.f
./physics/rascnvv2.f
./physics/GFDL_parse_tracers.F90
./physics/wam_f107_kp_mod.f90
./physics/num_parthds.F
./physics/gocart_tracer_config_stub.f
./GFS_layer/GFS_initialize_scm.F90
./GFS_layer/GFS_finalize_scm.F90
./physics/cldwat2m_micro.F
./physics/wv_saturation.F
./physics/aer_cloud.F
./physics/rad_initialize.f
./GFS_layer/GFS_radiation_driver.F90
./physics/radcons.f90
./physics/radiation_astronomy.f
./physics/radsw_main.f
./physics/radsw_datatb.f
./physics/GFS_rrtmg_pre.F90
./physics/GFS_rrtmg_post.F90
./physics/rrtmg_sw_pre.F90
./physics/rrtmg_sw_post.F90
./physics/rrtmg_lw_pre.F90
./physics/rrtmg_lw_post.F90
./physics/radlw_main.f
./physics/radlw_datatb.f
./physics/set_soilveg.f
./physics/namelist_soilveg.f
./physics/GFS_phys_time_vary.scm.f90
./physics/ozinterp.f90
./physics/h2ointerp.f90
./physics/gcycle.f90
./physics/GFS_rad_time_vary.scm.f90
./physics/GFS_radupdate.f90
./physics/GFS_suite_interstitial.ccpp.f90
./physics/get_prs_fv3.f90
./physics/sfc_sice.f
./physics/dcyc2.f
./physics/GFS_surface_generic.f90
./physics/GFS_PBL_generic.f90
./physics/sfc_drv.f
./physics/sflx.f
./physics/sfc_diff.f
./physics/GFS_surface_loop_control.f
./physics/sfc_nst.f
./physics/date_def.f
./physics/module_nst_water_prop.f90
./physics/module_nst_parameters.f90
./physics/module_nst_model.f90
./physics/sfc_diag.f
./physics/moninedmf.f
./physics/mfpbl.f
./physics/tridi.f
./physics/gwdps.f
./physics/rayleigh_damp.f
./physics/ozphys.f
./physics/GFS_DCNV_generic.f90
./physics/GFS_zhao_carr_pre.f90
./physics/mfdeepcnv.f
./physics/gwdc.f
./physics/GFS_SCNV_generic.f90
./physics/mfshalcnv.f
./physics/cnvc90.f
./physics/GFS_MP_generic_pre.f90
./physics/gscond.f
./physics/precpd.f
./physics/GFS_calpreciptype.f90
./physics/GFS_MP_generic_post.f90
)
# Set the sources: physics schemes
if (PROJECT MATCHES "CCPP-FV3")
include(./CCPP_SCHEMES.cmake)
else (PROJECT MATCHES "CCPP-FV3")
set(SCHEMES
./physics/machine.F
./physics/physcons.f90
./physics/funcphys.f90
./GFS_layer/GFS_typedefs.F90
./physics/radlw_param.f
./physics/physparam.f
./physics/radsw_param.f
./physics/radiation_aerosols.f
./physics/iounitdef.f
./physics/gfs_phy_tracer_config.f
./physics/radiation_clouds.f
./physics/module_bfmicrophysics.f
./physics/radiation_gases.f
./physics/ozne_def.f
./physics/radiation_surface.f
./physics//h2o_def.f
./physics/sfcsub.F
./physics/mersenne_twister.f
./physics/rascnvv2.f
./physics/GFDL_parse_tracers.F90
./physics/wam_f107_kp_mod.f90
./physics/num_parthds.F
./physics/gocart_tracer_config_stub.f
./GFS_layer/GFS_initialize_scm.F90
./GFS_layer/GFS_finalize_scm.F90
./physics/cldwat2m_micro.F
./physics/wv_saturation.F
./physics/aer_cloud.F
./physics/rad_initialize.f
./GFS_layer/GFS_radiation_driver.F90
./physics/radcons.f90
./physics/radiation_astronomy.f
./physics/radsw_main.f
./physics/radsw_datatb.f
./physics/GFS_rrtmg_pre.F90
./physics/GFS_rrtmg_post.F90
./physics/rrtmg_sw_pre.F90
./physics/rrtmg_sw_post.F90
./physics/rrtmg_lw_pre.F90
./physics/rrtmg_lw_post.F90
./physics/radlw_main.f
./physics/radlw_datatb.f
./physics/set_soilveg.f
./physics/namelist_soilveg.f
./physics/GFS_phys_time_vary.scm.f90
./physics/ozinterp.f90
./physics/h2ointerp.f90
./physics/gcycle.f90
./physics/GFS_rad_time_vary.scm.f90
./physics/GFS_radupdate.f90
./physics/GFS_suite_interstitial.ccpp.f90
./physics/get_prs_fv3.f90
./physics/sfc_sice.f
./physics/dcyc2.f
./physics/GFS_surface_generic.f90
./physics/GFS_PBL_generic.f90
./physics/sfc_drv.f
./physics/sflx.f
./physics/sfc_diff.f
./physics/GFS_surface_loop_control.f
./physics/sfc_nst.f
./physics/date_def.f
./physics/module_nst_water_prop.f90
./physics/module_nst_parameters.f90
./physics/module_nst_model.f90
./physics/sfc_diag.f
./physics/moninedmf.f
./physics/mfpbl.f
./physics/tridi.f
./physics/gwdps.f
./physics/rayleigh_damp.f
./physics/ozphys.f
./physics/GFS_DCNV_generic.f90
./physics/GFS_zhao_carr_pre.f90
./physics/mfdeepcnv.f
./physics/gwdc.f
./physics/GFS_SCNV_generic.f90
./physics/mfshalcnv.f
./physics/cnvc90.f
./physics/GFS_MP_generic_pre.f90
./physics/gscond.f
./physics/precpd.f
./physics/GFS_calpreciptype.f90
./physics/GFS_MP_generic_post.f90
)
endif (PROJECT MATCHES "CCPP-FV3")

set(CAPS
# Set the sources: physics scheme caps
if (PROJECT MATCHES "CCPP-FV3")
include(./CCPP_CAPS.cmake)
else (PROJECT MATCHES "CCPP-FV3")
set(CAPS
./physics/cnvc90_cap.F90
./physics/lsm_noah_pre_cap.F90
./physics/GFS_DCNV_generic_post_cap.F90
Expand Down Expand Up @@ -240,7 +260,8 @@ set(CAPS
./physics/GFS_rrtmg_post_cap.F90
./physics/get_phi_fv3_cap.F90
./physics/rrtmg_sw_pre_cap.F90
)
)
endif (PROJECT MATCHES "CCPP-FV3")

if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none")
Expand All @@ -250,11 +271,27 @@ if (${CMAKE_Fortran_COMPILER_ID} MATCHES "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 PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fdefault-double-8")
elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.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/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free")
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -ftz")
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-extend-source 132 -r8 -free")
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-r8")
if (PROJECT MATCHES "CCPP-FV3")
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f
./physics/rascnvv2.f
./physics/sflx.f
./physics/sfc_diff.f
./physics/sfc_diag.f
./physics/module_nst_model.f90
./physics/GFS_calpreciptype.f90
./physics/mersenne_twister.f
./physics/module_nst_water_prop.f90
./physics/aer_cloud.F
./physics/wv_saturation.F
./physics/cldwat2m_micro.F
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -ftz")
else (PROJECT MATCHES "CCPP-FV3")
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.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/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free")
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -ftz")
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-extend-source 132 -r8 -free")
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-r8")
endif (PROJECT MATCHES "CCPP-FV3")
elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.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/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -Mfree")
Expand All @@ -270,36 +307,39 @@ endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
#apply general fortran tags to all fortran source files
if(${CMAKE_VERSION} LESS 3.3)
string (REPLACE ";" " " f_flags_str "${f_flags}")
SET_PROPERTY(SOURCE ${SOURCES} ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " ${f_flags_str}")
SET_PROPERTY(SOURCE ${SCHEMES} ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " ${f_flags_str}")
else(${CMAKE_VERSION} LESS 3.3)
add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:${f_flags}>")
endif (${CMAKE_VERSION} LESS 3.3)

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)
if (PROJECT MATCHES "CCPP-FV3")
link_directories(${NCEPLIBS_DIR}/lib)
# DH this should be a PROJECT == CCPP-SCM and else undefined test (similar in other places)
else (PROJECT MATCHES "CCPP-FV3")
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)

#add "sibling" directories (must specify the build directory too)
ADD_SUBDIRECTORY(${W3LIB_SRC} ${CMAKE_BINARY_DIR}/w3nco)
ADD_SUBDIRECTORY(${BACIOLIB_SRC} ${CMAKE_BINARY_DIR}/bacio)
ADD_SUBDIRECTORY(${SPLIB_SRC} ${CMAKE_BINARY_DIR}/sp)
#add "sibling" directories (must specify the build directory too)
ADD_SUBDIRECTORY(${W3LIB_SRC} ${CMAKE_BINARY_DIR}/w3nco)
ADD_SUBDIRECTORY(${BACIOLIB_SRC} ${CMAKE_BINARY_DIR}/bacio)
ADD_SUBDIRECTORY(${SPLIB_SRC} ${CMAKE_BINARY_DIR}/sp)

INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/w3nco)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/sp)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/w3nco)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/sp)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio)

INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/ccpp-framework/src)
endif (PROJECT MATCHES "CCPP-FV3")

#------------------------------------------------------------------------------
# Add the auto-generated caps
#add_custom_command(
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90
# DEPENDS ${CCPP_MKCAP}
# COMMAND ${CCPP_MKCAP} -o ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90
# ${CMAKE_CURRENT_SOURCE_DIR}/scheme.xml
#)
#list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/scm_test1_cap.f90)

add_library(ccppphys ${SOURCES} ${CAPS})
target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio)
add_library(ccppphys ${SCHEMES} ${CAPS})
if (PROJECT MATCHES "CCPP-FV3")
target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} sp_v2.0.2_d bacio_4 w3nco_d)
else (PROJECT MATCHES "CCPP-FV3")
target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio)
endif (PROJECT MATCHES "CCPP-FV3")
set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
COMPILE_FLAGS "${CMAKE_Fortran_FLAGS}"
Expand All @@ -319,3 +359,18 @@ add_custom_command(TARGET ccppphys
COMMENT "Running pgifix_wrapper.py over all scheme caps")
endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
# *DH end hack for PGI compiler

if (PROJECT MATCHES "CCPP-FV3")
# Define where to install the library
install(TARGETS ccppphys
EXPORT ccppphys-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
)
# Export our configuration
install(EXPORT ccppphys-targets
FILE ccppphys-config.cmake
DESTINATION lib/cmake
)
endif (PROJECT MATCHES "CCPP-FV3")
Loading