D.7.6 Gather_OV_from_DV Procedure

The main documentation of the Gather_OV_from_DV Procedure contains additional explanation of this code listing.

  subroutine Gather_OV_from_DV (OV, DV)
  
    ! Input variable.
  
    type(Distributed_Vector_type), intent(in), target :: DV ! DV to be gathered.
  
    ! Input/Output variable.
    
    type(Overlapped_Vector_type), intent(inout) :: OV ! Gathered vector.
  
    ! Internal variables.

    type(integer) :: i, j, k  ! Loop counters.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
    ! Verify requirements.
  
    VERIFY(Valid_State(OV),5)                        ! OV is valid.
    VERIFY(Valid_State(DV),5)                        ! DV is valid.
    VERIFY(ASSOCIATED(DV%Structure,OV%Many_Structure),5) ! DV, OV ->same struct
    VERIFY(DV%Dimensionality == OV%Dimensionality,5) ! DV, OV have same Dims.

    ! Set the DV values of the OV if necessary.

    if (.not. ASSOCIATED(OV%DV,DV)) then
      select case (OV%Dimensionality)
      case (1)
        OV%DV%Values1 = DV%Values1
      case (2)
        OV%DV%Values2 = DV%Values2
      case (3)
        OV%DV%Values3 = DV%Values3
      case (4)
        OV%DV%Values4 = DV%Values4
      !case (-1)
      !  OV%DV%ValuesRR = DV%ValuesRR
      end select
    end if

    ! Gather the off PE values if they are out-of-date. This could be done
    ! faster for multiple dimensions by packing everything into a single
    ! vector, gathering, and then unpacking. Maybe in a later version.

    if (Version(OV) /= Version(DV)) then
      select case (OV%Dimensionality)
      case (1)
        call Gather (OV%Overlap_Values1, DV%Values1, Trace=OV%Overlap_Trace)
      case (2)
        do i = 1, SIZE(OV%Overlap_Values2,1)
          call Gather (OV%Overlap_Values2(i,:), DV%Values2(i,:), &
                       Trace=OV%Overlap_Trace)
        end do
      case (3)
        do i = 1, SIZE(OV%Overlap_Values3,1)
          do j = 1, SIZE(OV%Overlap_Values3,2)
            call Gather (OV%Overlap_Values3(i,j,:), DV%Values3(i,j,:), &
                         Trace=OV%Overlap_Trace)
          end do
        end do
      case (4)
        do i = 1, SIZE(OV%Overlap_Values4,1)
          do j = 1, SIZE(OV%Overlap_Values4,2)
            do k = 1, SIZE(OV%Overlap_Values4,3)
              call Gather (OV%Overlap_Values4(i,j,k,:), DV%Values4(i,j,k,:), &
                           Trace=OV%Overlap_Trace)
            end do
          end do
        end do
      !case (-1)
      !  call Gather (OV%Overlap_ValuesRR, DV%ValuesRR, &
      !               Trace=OV%Overlap_Trace)
      end select
    end if

    ! Set version.

    OV = Version(DV)
  
    ! Verify guarantees.

    VERIFY(Valid_State(OV),5)  ! OV is valid.
  
    return
  end subroutine Gather_OV_from_DV



Michael L. Hall