D.6.5 Assemble_AV_from_DV Procedure

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

  subroutine Assemble_AV_from_DV (AV, DV)
  
    ! Input variable.
  
    type(Distributed_Vector_type), intent(in) :: DV  ! DV to be assembled.
  
    ! Input/Output variable.
    
    type(Assembled_Vector_type), intent(inout) :: AV ! Assembled 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 assembly. 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 Assemble (AV%Values1, DV%Values1)
    case (2)
      do i = 1, DV%Dimensions(1)
        call Assemble (AV%Values2(i,:), DV%Values2(i,:))
      end do
    case (3)
      do i = 1, DV%Dimensions(1)
        do j = 1, DV%Dimensions(2)
          call Assemble (AV%Values3(i,j,:), DV%Values3(i,j,:))
        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 Assemble (AV%Values4(i,j,k,:), DV%Values4(i,j,k,:))
          end do
        end do
      end do
    !case (-1)
    !  call Assemble (AV%ValuesRR, DV%ValuesRR)
    end select

    ! Set the version number.

    AV = Version(DV)

    ! Verify guarantees.

    VERIFY(Valid_State(AV),5)  ! AV is valid.
  
    return
  end subroutine Assemble_AV_from_DV



Michael L. Hall