geoschem / KPP

The Kinetic PreProcessor, which is used to generate efficient chemistry-solver code from a mechanism specification.
https://people.cs.vt.edu/~asandu/Software/Kpp/
Other
4 stars 1 forks source link

[FEATURE REQUEST] Add toggle for calling UPDATE_SUN, UPDATE_RCONST within integrator step #5

Open yantosca opened 3 years ago

yantosca commented 3 years ago

@RolfSander wrote:

Indeed, calling UPDATE_RCONST several times (i.e., once for each KPP substep) is often not necessary. It's good to have the option to switch that off. Maybe this could be implemented via a currently not-used element in the ICNTRL array, e.g.:

IF (ICNTRL(15)==1) THEN
    CALL Update_SUN()
    CALL Update_RCONST()
ENDIF
yantosca commented 3 years ago

@RolfSander, thanks for this. I had removed those calls from the integrator files but this is an easy way to be able to toggle these calls. I'll add this into the next KPP update.

RolfSander commented 3 years ago

After taking a closer look at these subroutines, I think that Update_SUN is probably never necessary. I guess it would be sufficient to use the ICNTRL(15) switch only for Update_RCONST:

IF (ICNTRL(15)==1) THEN
    CALL Update_RCONST()
ENDIF
yantosca commented 3 years ago

This is now done in commit e7540d3f7d0047c8bfdae2433eb5640df5fd7273. All of the F90 integrator modules have this IF statement that can toggle UPDATE_RCONST if the user wishes. This will go into the next KPP version.

I will close out this issue now.

yantosca commented 3 years ago

My updates actually broke KPP so I went back to the GC_updates branch and started a new dev branch. In commit 342a4acab395ac799c3742d8c6622e61c75e0425 I added the call to Update_RCONST if ICNTRL(15)==1 only to the F90 Rosenbrock integrator file (int/rosenbrock.f90) since that is what GEOS-Chem users. As time allows, I'll make the similar edits into the other F90 integrator files.

It was more complex than I thought, I had to pass a logical flag with the value of (ICNTRL(15)==1) that down a few levels from the ros_Integrator routine. Straightforward but I didn't have time to do that for the rest of the code. I'll reopen this issue to denote that this still has to be done for the other integrator files.

RolfSander commented 3 years ago

Hmm, I didn't realize that this would be so complex. An alternative for a quick implementation in the other solvers might be to declare

LOGICAL :: Do_Update_Rates

as a module-wide variable, i.e., before the CONTAINS statement of the module