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

NAG compiler runtime error in FatesHydroWTFMod #790

Closed
glemieux opened this issue Oct 5, 2021 · 2 comments · Fixed by #791
Closed

NAG compiler runtime error in FatesHydroWTFMod #790

glemieux opened this issue Oct 5, 2021 · 2 comments · Fixed by #791

Comments

@glemieux
Copy link
Contributor

glemieux commented Oct 5, 2021

While updating the fates suite of regression tests (PR 1275) to use only non-debug nag compiler tests for izumi, I stumbled across this runtime error:

Runtime Error: *** Arithmetic exception: Floating invalid operation - aborting
/home/glemieux/ctsm/src/fates/biogeophys/FatesHydroWTFMod.F90, line 1060: Error occurred in FATESHYDROWTFMOD:FTC_FROM_PSI_TFS
/home/glemieux/ctsm/src/fates/biogeophys/FatesPlantHydraulicsMod.F90, line 637: Called by FATESPLANTHYDRAULICSMOD:UPDATEPLANTPSIFTCFROMTHETA
/home/glemieux/ctsm/src/fates/biogeophys/FatesPlantHydraulicsMod.F90, line 2564: Called by FATESPLANTHYDRAULICSMOD:HYDRAULICS_BC
/home/glemieux/ctsm/src/fates/biogeophys/FatesPlantHydraulicsMod.F90, line 291: Called by FATESPLANTHYDRAULICSMOD:HYDRAULICS_DRIVE
/home/glemieux/ctsm/src/utils/clmfates_interfaceMod.F90, line 2887: Called by CLMFATESINTERFACEMOD:WRAP_HYDRAULICS_DRIVE
/home/glemieux/ctsm/src/biogeophys/CanopyFluxesMod.F90, line 1549: Called by CANOPYFLUXESMOD:CANOPYFLUXES
/home/glemieux/ctsm/src/main/clm_driver.F90, line 685: Called by CLM_DRIVER:CLM_DRV
/home/glemieux/ctsm/src/cpl/mct/lnd_comp_mct.F90, line 451: Called by LND_COMP_MCT:LND_RUN_MCT
/home/glemieux/ctsm/components/cpl7/driver/main/component_mod.F90, line 737: Called by COMPONENT_MOD:COMPONENT_RUN
/home/glemieux/ctsm/components/cpl7/driver/main/cime_comp_mod.F90, line 2855: Called by CIME_COMP_MOD:CIME_RUN
/home/glemieux/ctsm/components/cpl7/driver/main/cime_driver.F90, line 153: Called by CIME_DRIVER

The relevant line of code is:

psi_eff = min(0._r8,psi)
ftc = max(min_ftc,1._r8/(1._r8 + (psi_eff/this%p50)**this%avuln))

@rgknox and I determined that the issue has to do with the compiler returning a -0.0000000 value for the psi_eff/this%p50 calculation when psi_eff returns zero and the p50 value is negative (which are valid values). NAG apparently doesn't like raising a negative value to a power.

Are the expected ranges psi_eff and p50 always be non-positive and negative, respectively? If so, then psi_eff/this%p50 >= 0 should always be true, in which case we could change the code to be:

ftc = max(min_ftc,1._r8/(1._r8 + abs(psi_eff/this%p50)**this%avuln)) 

which I think would work. Alternatively, @rgknox noted we could change the psi_eff calculation to use psi_eff = min(-nearzero,psi) instead of 0._r8.

@rgknox
Copy link
Contributor

rgknox commented Oct 6, 2021

Thanks for posting @glemieux
Did the tests complete after the two fixes? Or was there more tomfoolery lurking further down the call sequence?

@glemieux
Copy link
Contributor Author

glemieux commented Oct 6, 2021

Did the tests complete after the two fixes? Or was there more tomfoolery lurking further down the call sequence?

Using abs did the trick thankfully. Testing out the nearzero option next. To avoid making PR 1275 more complex since this just requires a fates-side change, I figure we can handle this with a quick bug fix PR. I'll whip up a branch for this soon.

Test path for reference: /scratch/cluster/glemieux/ctsm-tests/tests_fates-testmods-update-hydrofail-diag3

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

Successfully merging a pull request may close this issue.

2 participants