D.5.12 Assembled_Vector Class Unit Test Program

This lightly commented program performs a unit test on the Assembled_Vector Class.

program Unit_Test
  use Caesar_Intrinsics_Module
  use Caesar_Base_Structure_Class
  use Caesar_Assembled_Vector_Class
  use Caesar_Communication_Class
  implicit none

  type(Communication_type) :: Comm
  type(Base_Structure_type) :: Cell_Structure
  type(Assembled_Vector_type) :: Coordinates_Cells_AV
  type(Status_type) :: status
  type(character,name_length) :: Locus_Name, Name_Name
  type(real,2) :: Coordinates, Processed_Coordinates
  type(integer,1) :: Cells_Length_Vector
  type(integer) :: c, CellSize, d, Dimensionality, DimSize, i, NCells, &
  type(logical) :: Success

  ! Initializations.

  call Initialize (Comm)
  call Output (Comm)
  call Initialize (status)
  call Initialize (Locus_Name)
  call Initialize (Name_Name)
  call Initialize (Cells_Length_Vector, NPEs)
  Locus_Name = 'Cells'
  Name_Name = 'Coordinates of Cells'
  Cells_Length_Vector = (/ (i**2, i = 1, NPEs) /)
  Dimensionality = 2
  NDimensions = 4

  ! Set up Coordinates array on IO PE only.

  NCells = SUM(Cells_Length_Vector)
  if (this_is_IO_PE) then
    DimSize = NDimensions
    CellSize = NCells
    DimSize = 0
    CellSize = 0
  end if
  call Initialize (Coordinates, DimSize, CellSize)
  call Initialize (Processed_Coordinates, DimSize, CellSize)
  if (this_is_IO_PE) then
    Coordinates = RESHAPE( &
      (/ (( changetype(real,(d + 10*c)), d = 1,NDimensions), c = 1,NCells) /), &
      (/ NDimensions, NCells /) )
  end if

  ! Initialize base structure and assembled vector.
  call Initialize (Cell_Structure, Cells_Length_Vector, Locus_Name, status)
  call Initialize (Coordinates_Cells_AV, Cell_Structure, Dimensionality, &
                   Name_Name, status, NDimensions)

  ! Version number check.

  Coordinates_Cells_AV = 123
  Success = Version(Coordinates_Cells_AV) == 123
  call Output_Test ('Version number', Success)

  ! Send Coordinates into Assembled Vector and back again.

  Coordinates_Cells_AV = Coordinates
  Processed_Coordinates = Coordinates_Cells_AV

  ! Check to see if the round trip had any effect.

  Success = ALL(Processed_Coordinates == Coordinates)
  call Output_Test ('Round trip', Success)

  ! Output a fraction of the AV.

  call Output (Coordinates_Cells_AV, MAX(1, NCells/10), MIN(NCells, NCells/10+50))

  ! Check state of base structure and assembled vector.


  ! Finalize assembled vector, base structure and communications.

  call Finalize (Coordinates_Cells_AV)
  call Finalize (Cell_Structure)
  call Finalize (Comm)


Michael L. Hall