Newer
Older
option(USE_NETCDF "Enable netcdf library for tests output" OFF)
option(WITH_RRTMG "with(out) RRTMG radiation transfer" OFF)
option(WITH_TESTS "Generate and compile test cases" OFF)
#project cmake includes
include(FetchContent)
# Project main definitions
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
if(BUILD_DOC)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/config) # doxygen config file
# option ALL allows to build the docs together with the code
add_custom_target( pbl_doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_IN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) # WORKING_DIRECTORY: Execute the command with the given current working directory. If it is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory.
else()
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif(BUILD_DOC)
set(lib_files
src/parkinds.f90
src/pbl_grid.f90
src/scm_state_data.f90
src/pbl_turb_data.f90
src/pbl_solver.f90
src/fo_stability_functions.f90
src/pbl_fo_turb.f90
src/pbl_turb_common.f90
src/diag_pbl.f90)
add_library(abl_lib ${lib_files})
set (sublib_files
src/parkinds.f90
src/pbl_grid.f90
src/phys_fluid.f90
src/scm_state_data.f90
src/pbl_turb_data.f90
src/pbl_solver.f90
src/pbl_dry_contrgradient.f90
)
add_library(abl_sublib ${sublib_files})
target_compile_options(abl_lib
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -cpp>)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(abl_lib
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(abl_lib
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -O0 -fbacktrace -ffpe-trap=zero,overflow,underflow >)
endif()
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(abl_lib
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(abl_lib
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
endif()
endif()
if (WITH_TESTS)
# RRTMG option
if (WITH_RRTMG)
add_definitions(-DUSE_RRTMG)
add_subdirectory(radiation)
endif()
# adding sfx and config-parser stuff
#fetch sfx model
sfxlib
GIT_REPOSITORY https://gitlab.inm.ras.ru/climate-model/sfx-tesla.git
GIT_TAG 56d94a6226b60b521e5096a1826e2d7dcf890b7b)
FetchContent_MakeAvailable(sfxlib)
FetchContent_GetProperties(sfxlib)
#Config parser from sfx_lib is needed
if (WITH_RRTMG)
list(APPEND test_files src/rrtm_interface.f90)
endif()
#gabls1 experiment
add_executable(gabls1 src/tests/gabls1.f90
src/config-utils.f90
src/scm_io_default.f90
src/scm_sfx_data.f90)
target_include_directories(gabls1 PUBLIC ${CMAKE_BINARY_DIR}/modules/)
target_link_libraries( gabls1 PRIVATE abl_lib )
target_link_libraries(gabls1 PRIVATE sfx_lib)
target_link_libraries(gabls1 PRIVATE config_parser_F config_parser_CXX)
#gabls2 experiment
add_executable(gabls2 src/tests/gabls2.f90
src/config-utils.f90
src/scm_io_default.f90
src/scm_sfx_data.f90)
target_include_directories(gabls2 PUBLIC ${CMAKE_BINARY_DIR}/modules/)
target_link_libraries( gabls2 PRIVATE abl_lib )
target_link_libraries(gabls2 PRIVATE sfx_lib)
target_link_libraries(gabls2 PRIVATE config_parser_F config_parser_CXX)
#cbl experiment
add_executable(cbl_exp src/tests/cbl_exp.f90
src/config-utils.f90
src/scm_io_default.f90
src/scm_sfx_data.f90)
target_include_directories(cbl_exp PUBLIC ${CMAKE_BINARY_DIR}/modules/)
target_link_libraries( cbl_exp PRIVATE abl_lib )
target_link_libraries(cbl_exp PRIVATE sfx_lib)
target_link_libraries(cbl_exp PRIVATE config_parser_F config_parser_CXX)
if(WITH_RRTMG)
target_link_libraries(gabls1 PRIVATE rrtm)
target_link_libraries(gabls2 PRIVATE rrtm)
target_link_libraries(cbl_exp PRIVATE rrtm)
endif()
target_compile_options(gabls1
PRIVATE $<$<COMPILE_LANGUAGE:Fortran>: -cpp>)
target_compile_options(gabls2
PRIVATE $<$<COMPILE_LANGUAGE:Fortran>: -cpp>)
target_compile_options(cbl_exp
PRIVATE $<$<COMPILE_LANGUAGE:Fortran>: -cpp>)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(gabls1
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
target_compile_options(gabls2
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
target_compile_options(cbl_exp
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gabls1
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -O0 -fbacktrace -ffpe-trap=zero,overflow,underflow >)
target_compile_options(gabls2
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -O0 -fbacktrace -ffpe-trap=zero,overflow,underflow >)
target_compile_options(cbl_exp
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -O0 -fbacktrace -ffpe-trap=zero,overflow,underflow >)
endif()
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(gabls1
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
target_compile_options(gabls2
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
target_compile_options(cbl_exp
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gabls1
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
target_compile_options(gabls2
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
target_compile_options(cbl_exp
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)