zero_all_grads Module Subroutine

recursive module subroutine zero_all_grads(this)

Zero the gradients of this array

Arguments

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

Source Code

  recursive module subroutine zero_all_grads(this)
    !! Zero the gradients of this array
    implicit none
    class(array_type), intent(inout) :: this

    if(associated(this%left_operand))then
       call this%left_operand%zero_all_grads()
    end if
    if(associated(this%right_operand))then
       call this%right_operand%zero_all_grads()
    end if
    if(associated(this%grad))then
       if(allocated(this%grad%val)) this%grad%val = 0.0_real32
    end if
  end subroutine zero_all_grads