When optimization is -O0 then both statements of an if statement are calculated, causing the STEPWTD variable to be used in the remainder mod function, but in certain codeflows this will be zero. This causes a SIGFPE, a floating-point exception from an erroneous arithmetic operation, at LandModel/phys/module_sf_noahmpdrv.F:1878
Initialize with STEPWTD = 1 to avoid SIGFPE. The variable STEPWTD gets set in this line:
STEPWTD = max(STEPWTD,1)
This line doesn't get run with certain namelist options, but since the minimum value of STEPWTD should be one, STEPWTD can be initialized as one to fix the bug and void any other side-effects.
Steps to Reproduce (for bugs)
Turn optimization flag in macros file to -O0. Setting RUNOFF_OPTION = 3 in namelist.hrldas should be enough.
Your Environment
Version of the code used: 08.12.2022 Trunk
Operating System and version: Linux
Compiler and version: GNU 12.1.0
Other relevant information: Cheyenne
Expected Behavior
Run without
SIGFPE
.Current Behavior
When optimization is
-O0
then both statements of anif
statement are calculated, causing theSTEPWTD
variable to be used in the remaindermod
function, but in certain codeflows this will be zero. This causes aSIGFPE
, a floating-point exception from an erroneous arithmetic operation, at LandModel/phys/module_sf_noahmpdrv.F:1878Possible Solution
Initialize with
STEPWTD = 1
to avoidSIGFPE
. The variableSTEPWTD
gets set in this line:This line doesn't get run with certain namelist options, but since the minimum value of
STEPWTD
should be one,STEPWTD
can be initialized as one to fix the bug and void any other side-effects.Steps to Reproduce (for bugs)
Turn optimization flag in macros file to
-O0
. SettingRUNOFF_OPTION = 3
innamelist.hrldas
should be enough.Your Environment