Create variables to track non-passive species, so that they can be excluded from the Rosenbrock error norm (in int/rosenbrock*.f90 integrators only) - #154
Conversation
|
It's good to see that there is now a possibility to exclude dummy With the current implementation, you can use the optional argument only My suggestion is that we put NonDummySpc_Count into ICNTRL(19). The Would that work? |
|
Thanks @RolfSander, I think that's a good idea. I'll try it. |
|
@RolfSander: I just noticed that there is the |
Yes, we should avoid confusion. Unfortunately,
Here is yet another idea: During the discussion, @obin1 used the name |
|
I like If we are looking for something more general, would |
|
Thanks @RolfSander. I think |
ac46cd9 to
d8b35b8
Compare
code_f90.c
- In function F90_Decl:
- Modified the ELM case block to write a F90 scalar argument with the
OPTIONAL attribute when ATTR_F90_OPT is specified
- Updated comments (cosmetic changes)
- Added F90_FunctionBeginNoArgDecl, which is similar to F90_FunctionBegin
except that it doesn't automatically write the F90 function args
immediately below the subroutine header.
- In routine Use_F90:
- Point FunctionBeginNoArgDecl to F90_FunctionBeginNoArgDecl
src/code.c
- Added function prototype for FunctionBeginNoArgDecl
src/code.h
- Added macro DefElmO, which writes an OPTIONAL F90 scalar variable
- Added an extern function prototype for FunctionBeginNoArgDecl
src/code_c.c
src/code_f77.c
src/code_matlab.c
- Point FunctionBeginNoArgDecl to NULL in order to avoid
uninitialized-variable compiler warnings
CHANGELOG.md
- Updated accordingly
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
src/gen.c
- In routine InitGen:
- Added variables NON_PASV_SPC_CT and NON_PASV_SPC_IND, which will
be used to write F90 variables (NonPassiveSpc_Count and
NonPassiveSpc_indices) to keep track of non-passive species
- Updated comments for clarity + other cosmetic changes
- In routine GenerateUpdateRconst
- Now use FunctionBeginNoArgsDecl to write the subroutine interface
for UPDATE_RCONST with YIN as optional input argument
- Updated comments
- In routine GenerateGlobalHeader
- Write NonPassiveSpc_Count and NonPassiveSpc_Indices to ROOT_Global
(for F90 only)
- Now write the autoreduction variables following the non-THREADPRIVATE
variables
- Updated comments, cosmetic changes
- In routine GenerateInitialize
- Use FunctionBeginNoArgsDecl to write the ROOT_Initialize subroutine
header with PassiveSpc_ATOL_Threshold optional variable
- Write the PassiveSpc_ATOL_Threshold variable declaration
following all F90 USE statements
- For F90 only, add inlined code that initializes the variables
NonPassiveSpc_Count and NonPassiveSpc_Indices by testing which
species have ATOL < PassiveSpc_ATOL_Threshold
- Updated comments for clarity
int/rosenbrock.f90
int/rosenbrock_adj.f90
int/rosenbrock_autoreduce.f90
int/rosenbrock_tlm.f90
- Rewrote the ros_ErrorNorm function to use NonPassiveSpc_Count and
NonPassiveSpc_Indices so that passive species won't influence
the Rosenbrock error norm
- Use separate loops for vector tolerance and scalar tolerance,
to faciltate vectorization
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
d8b35b8 to
66c2796
Compare
int/runge_kutta.c - Set Hacc and ErrOldl to zero, which avoids compiler warnings for uninitialized variables CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
src/gen.c
- At top of file:
- Removed NON_PASV_SPC_CT and NON_PASV_SPC_IND integer variables
- In function GenerateUpdateRconst:
- Set YIN and Y to zero when F90 if useLang != F90_LANG
- Free YIN and Y when F90 at function's end if useLang != F90_LANG
(this fixes a segfault)
- In function GenerateGlobalHeader
- Declare NON_PASV_SPC_CT and NON_PASV_SPC_IND as local variables
- Free NON_PASV_SPC_CT and NON_PASV_SPC_IND if useLang != F90_LANG
CHANGELOG.md
- Updated accordingly
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
.github/workflows/run-ci-tests - Added GCC 14 and GCC 15 to the build matrix CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
|
Thanks, @yantosca! The name As I am using Would it be okay to move the new code after the inlined |
|
Thanks @RolfSander. Yes, I can make that change. I'll also update the documentation as well. Stay tuned. |
.github/workflows/run-ci-tests.yml - Added code to manually install the GCC 15 compiler, since it does not come pre-installed with Ubuntu 24.04. Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
src/gen.c
- In routine GenerateInitialize:
- Moved the initialization of NonPassiveSpc_Count and
NonPassiveSpc_Indices after the F90_INIT section.
This will prevent clobbering of inlined ATOL values.
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
.ci-pipelines/ci-common-defs.sh
- Added F90_ros_passivespc to the list of tests
ci-tests/F90_ros_passivespc.kpp
- Added this KPP definition file for the F90_ros_passivespc C-I test.
This is the "small strato" mechanism plus 3 passive species.
docs/source/getting-started/00_revision_history.rst
- Added to the list of recent updates under "Unreleased"
docs/source/tech_info/06_info_for_kpp_developers.rst
- Converted KPP source code files table into a list-table
- Added F90_ros_passivespc to the C-I tests table
- Added a 5th column ("What this tests") with links to the C-I tests
table
docs/source/tech_info/07_numerical_methods.rst
- Renamed "rk_method_comparison" anchor to "rk-methods-3stage"
- Added "rk-methods-radau5", "rk_methods-sdirk", "rk-methods-sdirk4",
"rk-methods-seulex" anchors
src/gen.c
- Updated syntax in comment
CHANGELOG.md
- Updated accordingly
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
.github/workflows/run-ci-tests.yml - Added GCC 16 to the GCC versions matrix for the Run C-I tests action docs/source/index.rst - Converted HTML in header to ReST CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
docs/source/using_kpp/04_input_for_kpp.rst - Added "Filtering out passive species with an absolute tolerance threshold" section - Shortened some ~~~ underlines docs/source/using_kpp/05_output_from_kpp.rst - Added a note under ROOT_Initialize pointing the user to the "Filtering out passive species with an absolute tolerance threshold" section - Converted tables to list-tables Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
.github/workflows/run-ci-tests.yml - Remove unneeded stuff from packages.microsoft.com from the GitHub Actions runner. This will make sure that a failure in checking out these packages does not take down the entire job. CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
77ebaa6 to
3d5c96a
Compare
int/rosenbrock.f90 int/rosenbrock_adj.f90 int/rosenbrock_autoreduce.f90 int/rosenbrock_tlm.f90 - Now use consistent formatting in the comment headers for ICNTRL and RCNTRL Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
93df5cb to
c0a9b02
Compare
|
Thanks, @yantosca!, it looks good now! |
Overview
This is the companion PR to #66 and #144. In this PR we create variables that can be used to exclude dummy species (i.e. those added to chemical reactions for the purpose of obtaining diagnostic information) from the Rosenbrock error norm computation. This should prevent the issue where integration results are changed depending on the number of dummy species in the mechanism (cf geoschem/geos-chem#3175).
Technical description
Two new module-level variables have been added to the
ROOT_Globalmodule (for F90 only). These are:NonPassiveSpc_Count: The number of non-passive speciesNonPassiveSpc_Indices: The KPP species indices for non-passive speciesThese optional variables (which are stored in
ROOT_Global) are constructed when theInitializeroutine is called.If
Initializeis called with thePassiveSpc_ATOL_Thresholdoptional argument, then all species that have an absolute tolerance (ATOL) greater than or equal toPassiveSpc_ATOL_Thresholdwill be denoted as passive species. In this case,NonPassiveSpc_Countwill be equal toNVAR- the number of passive species andNonPassiveSpc_Indiceswill contain the index list of only the non-passive species.If
Initializeis called without any optional arguments, thenNonPassiveSpc_Countwill be equal toNVARandNonPassiveSpc_Indiceswill contain the index list of all variable species.We have also updated the algorithm in the
Ros_ErrorNormfunction (in each of theint/rosenbrock*.f90 files)to compute the error norm on the basis of non-passive species. We have also optimized the function to facilitate vectorization and to remove unnecessary ELSE blocks, which can be a bottleneck:Other modifications bundled into this PR:
F90_ros_passivespc, which adds 3 passive species to thesmall_stratomechanism.drv/general_passivespc.f90, which executesCALL INITIALIZE( PassiveSpc_ATOL_Threshold = 1.0d25 ). This is used in theF90_ros_passivespcC-I test.F90_FunctionBeginNoArgsDecl(insrc/code_f90.c). This is similar toF90_FunctionBegin, except that it does not write any subroutine arguments. This allows us to manually declare subroutine below any F90USEstatements.DefElmOinsrc/code.h, which defines a scalar F90 variable with theOPTIONALattribute.Hacc = ZERO;andErrOld = ZERO;inint/runge_kutta.cto avoid generating compiler warnings during C-I testsICNTRLandRCNTRLcomment headers in theint/rosenbrock*.f90integrator files.Related GitHub issues
Tagging @RolfSander @msl3v @jimmielin @obin1 @fsolmon @ujongebloed @mje1398