NorESMhub / CTSM

Community Terrestrial Systems Model (includes the Community Land Model of CESM)
http://www.cesm.ucar.edu/models/cesm2.0/land/
Other
2 stars 9 forks source link

Short-circuit logic NOT avoiding FPE (Floating Point Exception) #11

Closed j34ni closed 3 years ago

j34ni commented 3 years ago

@ctsm-core @MichaelSchulzMETNO

I found another bug in release-clm5.0.14-Nor_v1.0.1, but the option to raise an issue has not been activated for the repository https://github.com/NorESMhub/CTSM

This is one of those bugs which make NorESM crash randomly, and it is not result changing otherwise

Notice that it has been recently fixed in ESCOMP/CTSM (before release-cesm2.2)

Can someone indicate me the "official" procedure to make this correction for NorESM?

MichaelSchulzMETNO commented 3 years ago

To my understanding Issue tracking is enabled for NorESMhub/CTSM.

MichaelSchulzMETNO commented 3 years ago

@huitang-earth @DirkOlivie This bug needs to be fixed in branch release-clm5.0.14-Nor. It is not answer changing. @j34ni Jean can you please point to the code which needs to be changed.

j34ni commented 3 years ago

I suggest that in components/clm/src/biogeochem/ch4Mod.F90 this test:

3605                   else if (.not. lake .and. sat == 1 .and. frac_h2osfc(c) > 0._r8 .and. &
3606                        h2osfc(c)/frac_h2osfc(c) > capthick) then ! Assuming short-circuit logic will avoid FPE here.
3607                      ! assume surface ice is impermeable
3608                      pondres = 1/smallnumber
3609                   end if

is written as:

                  else if (.not. lake .and. sat == 1 .and. frac_h2osfc(c) > 0._r8) then 
                          if (h2osfc(c)/frac_h2osfc(c) > capthick) then ! Since short-circuit logic will NOT avoid FPE here.
                             ! assume surface ice is impermeable
                             pondres = 1/smallnumber
                          end if
                  end if

to prevent random crashes when frac_h2osfc(c)=0

huitang-earth commented 3 years ago

@j34ni Could you make a pull request for these changes?