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 35 commits into
base: release-v4.6.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5b024c0
Force fail on genexp in defines
islas May 31, 2024
7c6e773
Rewrite the defines to not use genexp
islas May 31, 2024
980aca8
Move internal flags and compile definitions to variables rather than …
islas Apr 24, 2024
6b9d27e
Make sure hydro gets all the flags similar to original cmake build
islas Jul 30, 2024
4dda109
Prepare cmake build to not have core selection
islas Aug 1, 2024
bee8ddd
Make sure appropriate selection of option for non-ARW cores
islas Aug 1, 2024
4e30de1
Shortcut selections for other cores
islas Aug 1, 2024
5598e7c
Generalize the sanitization logic for stanzas
islas Aug 1, 2024
96930f5
Create properties for flag and defines organization
islas Jul 30, 2024
0203d61
Fine-tuned control of compile flags
islas Aug 1, 2024
86c3707
Don't force specific define able to come from stanza
islas Aug 1, 2024
1769477
Allow for regular defines to be passed in
islas Aug 1, 2024
0ece67a
CMake files for initial chem and chem+kpp builds
islas Mar 5, 2024
0d46e97
Rewrite of tuv_kpp directory finding
islas Mar 5, 2024
c9deb52
Try to get rid of in situ rewriting files
islas Mar 5, 2024
6f4cf56
Break up ifdefs for cmake to properly generate dependencies
islas Mar 5, 2024
3b5af1d
Fix highly irregular indentation so edits are much easier
islas Mar 5, 2024
ae1db9e
Adjust arguments to allow for finer control of read/write files
islas Mar 7, 2024
fbb6c55
Set open mode so no need to manually remove or track file
islas Mar 7, 2024
d421104
Disable registry_kpp for now
islas Mar 7, 2024
8aa6bbf
Prepend sources with src/
islas Mar 7, 2024
8450ecd
Simplify include to just KPP, we know it is KPP no need to specify th…
islas Mar 7, 2024
da23500
Processing kpp gen files and tuv
islas Mar 7, 2024
e7fd33e
Remove any need for in situ source generation listing
islas Mar 7, 2024
8371f04
Fix open mode char assign
islas Mar 7, 2024
9f72488
Don't use env vars in registry gen, use defines passed in
islas Mar 7, 2024
ac062fd
Final set of sources and run registry_kpp
islas Mar 7, 2024
ad7a968
Remove unused KPP_SOURCES var
islas Mar 11, 2024
4b9455c
Adjust defines and registry check to only look for defs not defs with…
islas Mar 11, 2024
f24f2b5
Add decomp rewrite as apparently it is used
islas Mar 11, 2024
5c8bbe6
Only build KPP if requested
islas Mar 15, 2024
54c47e6
Reduce kpp gen threads to a more conservative value
islas Jul 25, 2024
9b4ec97
Add extra safety check since FindFLEX is insufficient
islas Aug 1, 2024
3fb51ae
Remove old workaround never used
islas Aug 2, 2024
d4b7b16
Ensure lower compilation targets get all flags
islas Aug 2, 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
665 changes: 449 additions & 216 deletions CMakeLists.txt

Large diffs are not rendered by default.

63 changes: 13 additions & 50 deletions arch/configure_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I )

referenceVar = re.compile( r"[$]([(])?(\w+)(?(1)[)])", re.I )
compileObject = re.compile( r"(\W)-c(\W)" )
compileObject = re.compile( r"(\W|^)-c(\W|$)" )
configureRepl = re.compile( r"(\W|^)CONFIGURE_\w+(\W|$)" )

class Stanza():

Expand Down Expand Up @@ -160,52 +161,9 @@ def sanitize( self ) :
self.dereference( "FCBASEOPTS" )

# Remove rogue compile commands that should *NOT* even be here
keysToSanitize = [
"ARFLAGS","ARFLAGS",
"CC",
"CFLAGS_LOCAL",
"CFLAGS",
"COMPRESSION_INC",
"COMPRESSION_LIBS",
"CPP",
"CPPFLAGS",
"DM_CC",
"DM_FC",
"ESMF_LDFLAG",
"F77FLAGS",
"FC",
"FCBASEOPTS_NO_G",
"FCBASEOPTS",
"FCOPTIM",
"FCSUFFIX",
"FDEFS",
"FFLAGS",
"FNGFLAGS",
"FORMAT_FIXED",
"FORMAT_FREE",
"LD",
"LDFLAGS_LOCAL",
"LDFLAGS",
"MODULE_SRCH_FLAG",
"RLFLAGS",
"SCC",
"SFC",
"TRADFLAG",
]

for keyToSan in keysToSanitize :
if keyToSan in self.kvPairs_ :
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_L", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_I", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FC", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CC", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FDEFS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_MPI", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMPAT_FLAGS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CPPFLAGS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_TRADFLAG", "" )

self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
for keyToSan in self.kvPairs_.keys() :
self.kvPairs_[ keyToSan ] = configureRepl.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()


# Now fix certain ones that are mixing programs with flags all mashed into one option
Expand Down Expand Up @@ -546,6 +504,7 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD

configStanza = cmakeToolChainTemplateLines.format(
ARCH_LOCAL=stanza.kvPairs_["ARCH_LOCAL"],
LDFLAGS_LOCAL=stanza.kvPairs_["LDFLAGS_LOCAL"],
BYTESWAPIO=stanza.kvPairs_["BYTESWAPIO"],
CFLAGS_LOCAL=stanza.kvPairs_["CFLAGS_LOCAL"],
DM_CC=stanza.kvPairs_["DM_CC"],
Expand Down Expand Up @@ -575,8 +534,12 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD

def projectSpecificOptions( options, stanzaCfg ) :
coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS", "WRF_CORE" )
nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 )
caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" )
if coreOption == "ARW" :
nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 )
caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" )
else :
nestingOption = "NONE"
caseOption = "NONE"

# These are yes
yesValues = [ "yes", "y", "true", "1" ]
Expand Down Expand Up @@ -625,4 +588,4 @@ def projectSpecificOptions( options, stanzaCfg ) :
return additionalOptions

if __name__ == '__main__' :
main()
main()
62 changes: 48 additions & 14 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,18 +214,47 @@ target_sources(
aerosol_driver.F
)

########################################################################################################################
#
# convert_emiss executable
#
########################################################################################################################
add_executable(
convert_emiss
convert_emiss.F
)
#!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_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_link_libraries(
convert_emiss
PRIVATE
${PROJECT_NAME}_Core
)
# 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