get_ptr_from_id Module Function

recursive module function get_ptr_from_id(this, id) result(ptr)

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(in), target :: this
integer, intent(in) :: id

Return Value type(array_type), pointer


Source Code

  recursive module function get_ptr_from_id(this, id) result(ptr)
    use iso_c_binding
    implicit none
    class(array_type), intent(in), target :: this
    integer, intent(in) :: id
    type(array_type), pointer :: ptr

    ptr => null()
    if(this%id .eq. id)then
       ptr => this
       return
    end if
    if(associated(this%left_operand))then
       ptr => this%left_operand%get_ptr_from_id(id)
       if(associated(ptr)) return
    end if
    if(associated(this%right_operand))then
       ptr => this%right_operand%get_ptr_from_id(id)
       if(associated(ptr)) return
    end if
  end function get_ptr_from_id