This lightly commented program performs a unit test on the Distributed_Vector Class.
program Unit_Test use Caesar_Intrinsics_Module use Caesar_Base_Structure_Class use Caesar_Assembled_Vector_Class use Caesar_Distributed_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(Assembled_Vector_type) :: Processed_Coordinates_Cells_AV type(Distributed_Vector_type) :: Coordinates_Cells_DV 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, & NDimensions 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 else 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, assembled vectors, and distributed vector. call Initialize (Cell_Structure, Cells_Length_Vector, Locus_Name, status) call Initialize (Coordinates_Cells_AV, Cell_Structure, Dimensionality, & Name_Name, status, NDimensions) call Initialize (Processed_Coordinates_Cells_AV, Cell_Structure, & Dimensionality, Name_Name, status, NDimensions) call Initialize (Coordinates_Cells_DV, Cell_Structure, Dimensionality, & Name_Name, status, NDimensions) ! Version number check. Coordinates_Cells_DV = 123 Success = Version(Coordinates_Cells_DV) == 123 call Output_Test ('Version number', Success) ! Send Coordinates into Assembled Vector, then Distributed Vector, ! and back again. Coordinates_Cells_AV = Coordinates Coordinates_Cells_DV = Coordinates_Cells_AV Processed_Coordinates_Cells_AV = Coordinates_Cells_DV Processed_Coordinates = Processed_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 the DV. call Output (Coordinates_Cells_DV, MAX(1, NCells/10), & MIN(NCells, NCells/10+50)) ! Check state of various objects. VERIFY(Valid_State(Coordinates_Cells_AV),0) VERIFY(Valid_State(Coordinates_Cells_DV),0) VERIFY(Valid_State(Cell_Structure),0) ! Finalize assembled vector, base structure and communications. call Finalize (Coordinates_Cells_DV) call Finalize (Coordinates_Cells_AV) call Finalize (Processed_Coordinates_Cells_AV) call Finalize (Cell_Structure) call Finalize (Comm) end