Newer
Older
cmake_minimum_required(VERSION 3.23)
option(BUILD_DOC "Build documentation" OFF)
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/state_utils.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
src/diag_pbl.f90)
add_library(abl_lib ${lib_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
FetchContent_Declare(
inmcm60_sfx
GIT_REPOSITORY http://tesla.parallel.ru/inmcm-mirror/sfx.git
GIT_TAG origin/main)
FetchContent_MakeAvailable(inmcm60_sfx)
FetchContent_GetProperties(inmcm60_sfx)
if(NOT inmcm60_sfx_POPULATED)
FetchContent_Populate(sfx_lib)
add_subdirectory(${inmcm60_sfx_SOURCE_DIR} ${inmcm60_sfx_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
#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)
if(WITH_RRTMG)
target_link_libraries(gabls1 PRIVATE rrtm)
endif()
target_compile_options(gabls1
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 >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gabls1
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 >)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gabls1
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
endif()
endif()