The main documentation of the Distribute_AV_to_DV Procedure contains additional explanation of this code listing.
subroutine Distribute_AV_to_DV (DV, AV) ! Input variable. type(Assembled_Vector_type), intent(in) :: AV ! AV to be distributed. ! Input/Output variable. type(Distributed_Vector_type), intent(inout) :: DV ! Distributed vector. ! Internal variables. type(integer) :: i, j, k ! Loop counters. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(DV),5) ! DV is valid. VERIFY(Valid_State(AV),5) ! AV is valid. VERIFY(ASSOCIATED(AV%Structure,DV%Structure),5) ! AV, DV -> same structure. VERIFY(AV%Dimensionality == DV%Dimensionality,5) ! AV, DV have same Dims. ! Do the distribution. This could be done faster for multiple dimensions ! by packing everything into a single vector, assembling, and then ! unpacking. Maybe in a later version. select case (DV%Dimensionality) case (1) call Distribute (DV%Values1, AV%Values1, Length_Vector(AV%Structure)) case (2) do i = 1, DV%Dimensions(1) call Distribute (DV%Values2(i,:), AV%Values2(i,:), & Length_Vector(AV%Structure)) end do case (3) do i = 1, DV%Dimensions(1) do j = 1, DV%Dimensions(2) call Distribute (DV%Values3(i,j,:), AV%Values3(i,j,:), & Length_Vector(AV%Structure)) end do end do case (4) do i = 1, DV%Dimensions(1) do j = 1, DV%Dimensions(2) do k = 1, DV%Dimensions(3) call Distribute (DV%Values4(i,j,k,:), AV%Values4(i,j,k,:), & Length_Vector(AV%Structure)) end do end do end do !case (-1) ! call Distribute (DV%ValuesRR, AV%ValuesRR) end select ! Set the version number. DV = Version(AV) ! Verify guarantees. VERIFY(Valid_State(DV),5) ! DV is valid. return end subroutine Distribute_AV_to_DV