reset_graph_inner Subroutine

recursive subroutine reset_graph_inner(this, visit_id)

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this
integer, intent(in) :: visit_id

Source Code

  recursive subroutine reset_graph_inner(this, visit_id)
    implicit none
    class(array_type), intent(inout) :: this
    integer, intent(in) :: visit_id

    if(this%visit_tag .eq. visit_id) return
    this%visit_tag = visit_id

    if(associated(this%left_operand))then
       call reset_graph_inner(this%left_operand, visit_id)
    end if

    if(associated(this%right_operand))then
       call reset_graph_inner(this%right_operand, visit_id)
    end if

    if(associated(this%grad))then
       if(this%owns_gradient)then
          this%grad => null()
       else if(allocated(this%grad%val))then
          this%grad%val = 0.0_real32
       end if
    end if

    this%owns_gradient = .false.

  end subroutine reset_graph_inner