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

for reserves to ROOT if conc too great (overflow!) #407

Open
gelianxing opened this issue May 8, 2024 · 4 comments
Open

for reserves to ROOT if conc too great (overflow!) #407

gelianxing opened this issue May 8, 2024 · 4 comments

Comments

@gelianxing
Copy link

IF (((LFWT+GROLF-SENLFG-SENLFGRS) ! Prevent divide by zero
& +(STWT+GROST)+(RSWT+GRORS)) .GT. 0.0)THEN
TVR1 = ! Conc
& (RSWT+GRORS-SENRS)/
& ((LFWT+GROLF-SENLFG-SENLFGRS)
& +(STWT+GROST)+(RSWT+GRORS))
ELSE
TVR1 = 0.0
END IF

SENLFG、SENLFGRS why these variables use yesterday’s variables,maybe can move to integr

@chporter
Copy link
Contributor

chporter commented May 9, 2024

This is in CER_Growth.for, line 737. TVR1 uses values SENLFG and SENLFGRS which are calculated later in the routine. Maybe this TVR1 calculation could be moved later in the routine to use today's senescence values. I don't think it should go to integrate because it is still a rate calculation.
@palderman @GerritHoogenboom @fabiooliveira72 - if you have time, please have a look.

@palderman
Copy link
Contributor

Linking directly for convenience:

IF (((LFWT+GROLF-SENLFG-SENLFGRS) ! Prevent divide by zero
& +(STWT+GROST)+(RSWT+GRORS)) .GT. 0.0)THEN
TVR1 = ! Conc
& (RSWT+GRORS-SENRS)/
& ((LFWT+GROLF-SENLFG-SENLFGRS)
& +(STWT+GROST)+(RSWT+GRORS))
ELSE
TVR1 = 0.0
END IF

Just did a quick search and we'd need to be careful about where we move it, because TVR1 is used to calculate RTWTGRS just below:

IF(TVR1.LT.0.0.AND.TVR1.GT.-1.0E-07) TVR1 = 0.0
IF (TVR1.GT.RSPCX/100.0) THEN ! If potential>max
TVR2 = RSWT+GRORS-SENRS ! What rswt could be
TVR3 = ! What rswt should be
& ((RSPCX/100.0)
& *(LFWT+GROLF-SENLFG-SENLFGRS
& +STWT+GROST))
& /(1.0-(RSPCX/100.0))
RTWTGRS = (TVR2 - TVR3)
! Determine FINAL new concentration
IF (LFWT+GROLF+STWT+GROST.GT.0.0) TVR5 =
& (RSWT+GRORS-SENRS-RTWTGRS)/
& ((LFWT+GROLF-SENLFG-SENLFGRS)
& +(STWT+GROST)
& +(RSWT+GRORS-SENRS-RTWTGRS))
ENDIF

and RTWTGRS is then used subsequently:

RTWTG = AMAX1(0.0,(CARBOR+RTWTGRS)*(1.0-RRESP)) ! LAH 280211

RTRESP = (CARBOR+RTWTGRS) * RRESP

The dependency graph seems to balloon rather quickly after that. Would it be easier to move senescence calculations earlier?

@chporter
Copy link
Contributor

chporter commented May 9, 2024

@palderman Thanks for looking. Yes, maybe. But it might be circular logic and we just need to live with the fact that this is a daily model.

@gelianxing
Copy link
Author

I agree move senescence calculations earlier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants