Skip to content

SIMPLACE C2ML generated Fortran source code for log function has division by zero #18

@fabiooliveira72

Description

@fabiooliveira72

File snowcovercalcutor.f90 at subroutine init_snowcovercalculator has a problem with C2ML generated Fortran source code for log function. The function in SIMPLACE init_snowcovercalculator is doing the following math:

Albedo = 0.0226 * LOG(cCarbonContent) / LOG(REAL(10)) + 0.1502

This math generates a division by zero in Fortran. The expression LOG(0.0) is considered invalid by gfortran (not ifort, I think) when delta is 0 constant. It is invalid.
The code was changed manually. A condition to check if cCarbonContent is greater than 0 was provided. See code below:

IF(cCarbonContent .GT. 0.0)THEN
   Albedo = 0.0226 * LOG10(cCarbonContent) / LOG(REAL(10)) + 0.1502
ENDIF

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions