Conversation
Update_RCONST now uses variable concentrations for rate constants that depend on species concentrations. To ensure backwards compatibility, YIN is an optional input. If YIN is not passed to Update_RCONST, concentrations from the global C array are used instead.
|
@yantosca Should I add something to the documentation that |
yantosca
left a comment
There was a problem hiding this comment.
@srosanka @RolfSander: I ran the C-I tests on the issue93 branch. I found a couple of issues:
- We get a bunch of compile warnings in the C-language tests, that Y is an unused variable. It may be due to the fact that C doesn't allow for optional variables like F90 does.:
> C_rk_Rates.c: In function ‘Update_RCONST’:
> C_rk_Rates.c:166:8: warning: unused variable ‘Y’ [-Wunused-variable]
> 166 | double Y[NSPEC]; /* Concentrations of species (local) */
> | ^
430a435,438
> C_rosadj_Rates.c: In function ‘Update_RCONST’:
> C_rosadj_Rates.c:166:8: warning: unused variable ‘Y’ [-Wunused-variable]
> 166 | double Y[NSPEC]; /* Concentrations of species (local) */
> | ^
527a536,539
> C_sd_Rates.c: In function ‘Update_RCONST’:
> C_sd_Rates.c:166:8: warning: unused variable ‘Y’ [-Wunused-variable]
> 166 | double Y[NSPEC]; /* Concentrations of species (local) */
> | ^
888a901,904
> C_sdadj_Rates.c: In function ‘Update_RCONST’:
> C_sdadj_Rates.c:166:8: warning: unused variable ‘Y’ [-Wunused-variable]
> 166 | double Y[NSPEC]; /* Concentrations of species (local) */
> | ^
978a995,998
> C_small_strato_Rates.c: In function ‘Update_RCONST’:
> C_small_strato_Rates.c:166:8: warning: unused variable ‘Y’ [-Wunused-variable]
> 166 | double Y[NSPEC]; /* Concentrations of species (local) */- The mcm example fails, but this is fixed in the
h211bbranch.
mcm_Rates.f90:431:19:
431 | USE constants_mcm
| 1
Error: Unexpected USE statement at (1)
make: *** [Makefile_mcm:238: mcm_Rates.o] Error 1
make: *** Waiting for unfinished jobs....On the Azure Dev Pipelines we don't run the MCM example as that takes too much memory. So we can live with this until we merge in the h211b branch, I think.
Any thoughts about the warning when generating C-language code? We don't have a lot of C users for KPP but we probably should fix this for reliability's sake.
|
I was not able to reproduce the "unused variable" warning on my Anyway, maybe we can make the changes F90-specific and leave the code in (note that I just typed this code here on github in pseudo-syntax) |
|
@srosanka: That would be great if you could add some documentation about using Y instead of C. @RolfSander: I used gcc 10.2.0 and 11.4.0 in my tests. I can add the IF block around the code as you said. |
I've used gcc 11.4.0, and I'm getting the warning now as well. I really
Thanks! |
|
@RolfSander -- I can also update the C-I script to print the compiler version |
|
Printing the compiler version is always a good idea when debugging (even though in this case, I don't think it can explain why I didn't see a warning initially). |
src/gen.c - Wrap the code to declare UPDATE_RCONST with YIN in an if block that only executes when useLang==F90 - Place code to declare UPDATE_RCONST without any variables in the else block. Signed-off-by: Bob Yantosca <[email protected]>
.ci-pipelinoes/ci-common.defs.sh - Add a function "print_compiler_versions" to print the gcc and gfortran compiler versions that are used to run the tests. .ci-pipelines/ci-testing-script.sh - Call "print_compiler_versions" function before running tests. This will print the compiler versions at the top of stdout output. CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca <[email protected]>
|
@RolfSander @srosanka: I pushed a fix that should only declare Update_Rconst with Y for F90. Also the C-I tests now print at the top of stdout: ###########################################################################
KPP CONTINUOUS INTEGRATION TESTS, USING THESE COMPILERS:
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
########################################################################### |
Thanks, this looks good.
Thanks, this can be very helpful for future debugging! |
|
@yantosca and @RolfSander: thanks for spotting this issue and implementing the necessary changes to the code. @yantosca: Great. I will then make some additions to the documentation. |
|
@yantosca I updated the documentation related to this issue. Please let me know if further adjustments are necessary. |
|
Thanks, @srosanka, for writing the documentation! However, there is one thing I don't understand. Why should the user Maybe the new documentation should be moved from the explanation of the |
Thanks @srosanka and @RolfSander. I agree, I don't think we need to explicitly add Y to the rate constant. In the function template we have something like this: !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SUBROUTINE FunTemplate( T, Y, Ydot, P_VAR, D_VAR )
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Template for the ODE function call.
! Updates the rate coefficients (and possibly the fixed species) at each call
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
IF ( Do_Update_RCONST ) CALL Update_RCONST( Y )
...
END SUBROUTINE FunTemplateso Y is already passed as an argument to the function that will be integrated. |
|
I've adjusted the documentation. Is it ok now? |
yantosca
left a comment
There was a problem hiding this comment.
Thanks @RolfSander! This is good to merge now.
|
Thanks, @RolfSander and @yantosca for making the necessary adjustments to the documentation and for merging the code. |
This pull request includes the necessary changes such that in Update_RCONST variable concentrations for rate constants that depend on species concentrations are used. To ensure backwards compatibility, YIN is an optional input. If YIN is not passed to Update_RCONST, concentrations from the global C array are used instead.
Closes #93