Skip to content

Bugfix suggestion conditions.f90: "plant_name_gro" for evaluation of Decision Tables #124

@jenskiesel

Description

@jenskiesel

The current implementation of the case("plant_name_gro") is not working correctly. Lines 210 - 213 are intended to set the act_hit to n if the plant is not in the community:

          !plant not in community of ipl = 0
          if (ipl == 0) then
            d_tbl%act_hit(ialt) = "n"
          else 

However, ialt is not correctly set at this stage - it still contains the initialized value or from the previous iteration in lines 215ff, causing unexpected behaviour and too many false positive evaluations (as all actions are set to y in line 60 d_tbl%act_hit = "y" initially).

Here is my suggested (and tested) fix making sure d_tbl%act_hit(ialt) = "n" is only set for the appropriate ialt:

        case ("plant_name_gro")
          ob_num = d_tbl%cond(ic)%ob_num
          if (ob_num == 0) ob_num = ob_cur
          ipl = 0
          do iipl = 1, pcom(ob_num)%npl
            if (d_tbl%cond(ic)%lim_var == pcom(ob_num)%pl(iipl)) then
              ipl = iipl
              exit
            end if
          end do
          ! set action to 'n' if plant is not in community or not growing
          do ialt = 1, d_tbl%alts
            if (d_tbl%alt(ic,ialt) == '=') then
              if (ipl == 0) then
                d_tbl%act_hit(ialt) = 'n'
              else if (pcom(ob_num)%plcur(ipl)%gro == 'n') then
                d_tbl%act_hit(ialt) = 'n'
              end if
            end if
          end do

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions