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

CMake Chem and Chem+KPP Build #2018

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
757a1aa
CMake files for initial chem and chem+kpp builds
islas Mar 5, 2024
47a922d
Rewrite of tuv_kpp directory finding
islas Mar 5, 2024
b23cbec
Try to get rid of in situ rewriting files
islas Mar 5, 2024
392cba7
Break up ifdefs for cmake to properly generate dependencies
islas Mar 5, 2024
553be7e
Fix highly irregular indentation so edits are much easier
islas Mar 5, 2024
40917bf
Adjust arguments to allow for finer control of read/write files
islas Mar 7, 2024
8bcc973
Set open mode so no need to manually remove or track file
islas Mar 7, 2024
c7f0dc4
Disable registry_kpp for now
islas Mar 7, 2024
e6d5c60
Prepend sources with src/
islas Mar 7, 2024
fe8455b
Simplify include to just KPP, we know it is KPP no need to specify th…
islas Mar 7, 2024
5930afa
Processing kpp gen files and tuv
islas Mar 7, 2024
fa7925d
Remove any need for in situ source generation listing
islas Mar 7, 2024
96041a8
Fix open mode char assign
islas Mar 7, 2024
7610ad9
Don't use env vars in registry gen, use defines passed in
islas Mar 7, 2024
3a6d8e6
Final set of sources and run registry_kpp
islas Mar 7, 2024
ba75555
Remove unused KPP_SOURCES var
islas Mar 11, 2024
5c1cb94
Adjust defines and registry check to only look for defs not defs with…
islas Mar 11, 2024
a5d9335
Add decomp rewrite as apparently it is used
islas Mar 11, 2024
e496bfd
Only build KPP if requested
islas Mar 15, 2024
48e37af
Reduce kpp gen threads to a more conservative value
islas Jul 25, 2024
8b1e232
Add extra safety check since FindFLEX is insufficient
islas Aug 1, 2024
4d44806
Remove old workaround never used
islas Aug 2, 2024
80b44a8
Ensure lower compilation targets get all flags
islas Aug 2, 2024
7adbe6e
Merge branch 'develop' into cmake-kpp
islas Dec 21, 2024
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
28 changes: 25 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required( VERSION 3.20 )
cmake_policy( SET CMP0118 NEW )
cmake_policy( SET CMP0098 NEW )

enable_language( C )
enable_language( CXX )
Expand Down Expand Up @@ -213,6 +214,13 @@ set( DWORDSIZE 8 )
set( LWORDSIZE 4 )


# To limit the KPP generation to not consume copious amounts of RAM
if ( NOT DEFINED MAX_KPP_GEN_THREADS )
# 1 thread takes about 4.75 GB
set( MAX_KPP_GEN_THREADS 2 )
endif()


########################

################################################################################
Expand Down Expand Up @@ -254,6 +262,7 @@ endif()

if ( ${ENABLE_KPP} AND NOT ${ENABLE_CHEM} )
message( WARNING "ENABLE_KPP requires ENABLE_CHEM but is not set, ignoring" )
set( ENABLE_KPP OFF CACHE BOOL "Force ignore by configuration" FORCE )
endif()


Expand Down Expand Up @@ -472,6 +481,19 @@ if ( ${ENABLE_CTSM} )
# find_package( CTSM REQUIRED )
endif()

if ( ${ENABLE_KPP} )
find_package( BISON REQUIRED )
find_package( FLEX REQUIRED )
if ( ${FLEX_FOUND} AND "${FLEX_LIBRARIES}" STREQUAL "FL_LIBRARY-NOTFOUND" )
message( FATAL_ERROR
"Flex executable found, but libraries were not. Please provide a searchable path for both "
"\n"
"Refer to https://cmake.org/cmake/help/latest/command/find_package.html for more info "
"on providing a suitable path"
)
endif()
endif()

# Will need our own finder
# find_package( GPFS REQUIRED )

Expand Down Expand Up @@ -679,9 +701,9 @@ list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS
# in code since cmake cannot handle basically any others :(
# https://gitlab.kitware.com/cmake/cmake/-/issues/17398
if ( ${ENABLE_CHEM} )
list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CHEM=1 )
list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CHEM )
if ( ${ENABLE_KPP} )
list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_KPP=1 )
list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_KPP )
endif()
endif()
if ( ${ENABLE_CHEM} )
Expand Down Expand Up @@ -914,7 +936,7 @@ add_subdirectory( share )
add_subdirectory( frame )
add_subdirectory( inc )

if ( ${WRF_CHEM} )
if ( ${ENABLE_CHEM} )
add_subdirectory( chem )
endif()

Expand Down
71 changes: 46 additions & 25 deletions chem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
if ( ${ENABLE_KPP} )
add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" )
add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" )
add_subdirectory( KPP )
endif()

########################################################################################################################
#
Expand Down Expand Up @@ -209,31 +214,47 @@ target_sources(
aerosol_driver.F
)

########################################################################################################################
#
# convert_emiss executable
#
########################################################################################################################
add_executable(
convert_emiss
convert_emiss.F
)

target_link_libraries(
convert_emiss
PRIVATE
${PROJECT_NAME}_Core
)
#!TODO: I'm not entirely sure when this exec is supposed to be generated or if it
# is exclusive to the real test case
# ########################################################################################################################
# #
# # convert_emiss executable
# #
# ########################################################################################################################
# set( CONVERT_EMISS_TARGET convert_emiss )
# add_executable(
# ${CONVERT_EMISS_TARGET}
# convert_emiss.F
# )

target_compile_options(
convert_emiss
PRIVATE
${PROJECT_COMPILE_OPTIONS}
)
# target_link_libraries(
# ${CONVERT_EMISS_TARGET}
# PRIVATE
# ${PROJECT_NAME}_Core
# )
# set_target_properties(
# ${CONVERT_EMISS_TARGET}
# PROPERTIES
# # Just dump everything in here
# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${CONVERT_EMISS_TARGET}/
# Fortran_FORMAT FREE
# )
# target_compile_options(
# convert_emiss
# PRIVATE
# ${PROJECT_COMPILE_OPTIONS}
# )


target_compile_definitions(
convert_emiss
PRIVATE
${PROJECT_COMPILE_DEFINITIONS}
)
# target_compile_definitions(
# convert_emiss
# PRIVATE
# ${PROJECT_COMPILE_DEFINITIONS}
# )
# install(
# TARGETS ${CONVERT_EMISS_TARGET}
# EXPORT ${EXPORT_NAME}Targets
# RUNTIME DESTINATION bin/
# ARCHIVE DESTINATION lib/
# LIBRARY DESTINATION lib/
# )
Loading