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

Set a C-preprocessor switch so that we can block out code specific to the KPP rosenbrock_autoreduce integrator #2689

Draft
wants to merge 9 commits into
base: dev/14.6.0
Choose a base branch
from

Conversation

yantosca
Copy link
Contributor

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Describe the update

This PR adds code to automatically set a C-preprocessor switch KPP_INT_AUTOREDUCE based on the name of the KPP integrator that is being used. This is necessary so that we can block out code that is specific to the rosenbrock_autoreduce integrator, which would result in a compile-time error when we use other integrators.

This is a necessary step before we can implement use other KPP integrators (e.g. LSODE, Backwards Euler, etc) with the GEOS-Chem chemistry mechanism.

Expected changes

This is a zero-diff update but should go into 14.6.0. It can be bundled with any other 14.6.0 PR.

Related Github Issue

NOTE: These modifications were made because the prior method
of using "#if KPP_INTEGRATOR == rosenbrock_autoreduce" did not
work as expected.  We assumed wrongly about how C-preprocssor
conditionals work.

KPP/carbon/CMakeLists.txt
KPP/custom/CMakeLists.txt
KPP/Hg/CMakeLists.txt
KPP/fullchem/CMakeLists.txt
- Added CMake code to define the KPP_INT_AUTOREDUCE and
  KPP_INT_LSODE switches based on the value of #INTEGRATOR
  in the *.kpp file.
- Also print the KPP integrator name at configure time

GeosCore/fullchem_mod.F90
KPP/fullchem/fullchem_AutoReduceFuncs.F90
KPP/stubs/stub_fullchem_AutoReduceFuncs.F90
- Wrap code specific to the rosenbrock_autoreduce integrator
  in "#ifdef KPP_INT_AUTOREDUCE" conditional blocks
- Wrap code specific to the LSODE integrator in
  "#ifdef KPP_INT_LSODE" conditional blocks

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
KPP/fullchem/CMakeLists.txt
- Changed KPP_INTEGRATOR_NAME (incorrect) to KPP_INT_NAME when
  testing if the KPP integrator is "lsode"

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
KPP/custom/CMakeLists.txt
KPP/fullchem/CMakeLists.txt
- Added "target_compile_definitions" statements to make sure that
  the KPP_INT_AUTOREDUCE and KPP_INT_LSODE variables are also
  saved to the GEOSChemBuildProperties.  This will define them
  as C-preprocessor switches.  Prior to this commit, these variables
  were defined but the corresponding C-preprocessor switches were not.
- Updated comments

KPP/carbon/CMakeLists.txt
KPP/Hg/CMakeLists.txt
- Added comments

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
GeosCore/fullchem_mod.F90
- Set relevant ICNTRL and RCNTRL values within the
  #ifdef KPP_INT_LSODE C-preprocessor block for the LSODE
  integrator.  These may need to be tweaked further.
GeosCore/fullchem_mod.F90
- Now pass 0.0 and DT instead of TIN and TOUT to the Integrate function.
  Some KPP integrators like LSODE will update the TIN variable upon
  output, which could have unintended consequences upstream.
- Removed T, TIN, TOUT variables from routine DO_FULLCHEM
- Updated and/or removed obsolete comments
- Added TODO comments to denote code that could potentially be abstracted
  out of DO_FULLCHEM and into other subroutines, for clarity

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
GeosCore/fullchem_mod.F90
- Add an #ifdef KPP_INT_BEULER block to set ICNTRL and RCNTRL for beuler

KPP/custom/CMakeLists.txt
KPP/fullchem/CMakeLists.txt
- Add CMake code to define the KPP_INT_BEULER flag to 1 if the
  integrator name in custom.kpp/fullchem.kpp is "beuler"

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
This merge brings updates (as of PR #2661) into the
feature/integrator-specific-handling branch.  This is necessary
in order to avoid compilation errors w/ the new HEMCO logfile
handling updates.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
This merge brings updates from GEOS-Chem 14.6.0-alpha.2 into
the feature/integrator-specific-handling branch.  This is needed
in order to block out code specific to the rosenbrock_autoreduce
integrator if we are using other integrators like LSODE or
BEuler.


Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
GeosCore/fullchem_mod.F90
- Removed #ifdef blocks for LSODE and BEuler integrators

KPP/custom/CMakeLists.txt
KPP/fullchem/CMakeLists.txt
- Remove code to define KPP_INT_LSODE and KPP_INT_BEULER Cpp switches

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
@yantosca yantosca added category: Feature Request New feature or request topic: Chemical Mechanisms Related to KPP and/or GEOS-Chem chemistry mechanisms topic: Structural Modifications Related to GEOS-Chem structural modifications (as opposed to scientific updates) no-diff-to-benchmark This update will not change the results of fullchem benchmark simulations labels Jan 16, 2025
@yantosca yantosca added this to the 14.6.0 milestone Jan 16, 2025
@yantosca yantosca self-assigned this Jan 16, 2025
@yantosca
Copy link
Contributor Author

Integration tests are running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Feature Request New feature or request no-diff-to-benchmark This update will not change the results of fullchem benchmark simulations topic: Chemical Mechanisms Related to KPP and/or GEOS-Chem chemistry mechanisms topic: Structural Modifications Related to GEOS-Chem structural modifications (as opposed to scientific updates)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant