From 88edb2a1307fd347a9d1e6b1e85cb786d46cda17 Mon Sep 17 00:00:00 2001 From: vsande Date: Mon, 2 Nov 2015 17:27:43 +0100 Subject: [PATCH 1/7] Refactoring/Renaming --- .../uniform_grid_descriptor.f90 | 234 +++++++++--------- .../xdmf_contiguous_hyperslab_handler.f90 | 30 +-- src/lib/xh5for_metainfo.f90 | 76 +++--- 3 files changed, 170 insertions(+), 170 deletions(-) diff --git a/src/lib/grid_descriptors/uniform_grid_descriptor.f90 b/src/lib/grid_descriptors/uniform_grid_descriptor.f90 index ab1322b..d664dfd 100644 --- a/src/lib/grid_descriptors/uniform_grid_descriptor.f90 +++ b/src/lib/grid_descriptors/uniform_grid_descriptor.f90 @@ -18,41 +18,41 @@ private integer(I8P) :: NumberOfNodes = XDMF_NO_VALUE integer(I8P) :: NumberOfElements = XDMF_NO_VALUE integer(I4P) :: NumberOfAttributes = 0 - type(xh5for_metadata_t) :: geometry_info - type(xh5for_metadata_t) :: topology_info - type(xh5for_metadata_t), allocatable :: attributes_info(:) + type(xh5for_metadata_t) :: GeometryMetadata + type(xh5for_metadata_t) :: TopologyMetadata + type(xh5for_metadata_t), allocatable :: AttributesMetadata(:) logical :: warn = .true. !< Flag to show warnings on screen contains private - procedure :: is_valid_TopologyType => uniform_grid_descriptor_is_valid_TopologyType - procedure :: is_valid_GeometryType => uniform_grid_descriptor_is_valid_GeometryType - procedure, public :: Initialize => uniform_grid_descriptor_Initialize - procedure, public :: Free => uniform_grid_descriptor_Free - procedure, public :: SetNumberOfNodes => uniform_grid_descriptor_SetNumberOfNodes - procedure, public :: SetNumberOfElements => uniform_grid_descriptor_SetNumberOfElements - procedure, public :: SetTopologyType => uniform_grid_descriptor_SetTopologyType - procedure, public :: SetGeometryType => uniform_grid_descriptor_SetGeometryType - procedure, public :: GetNumberOfNodes => uniform_grid_descriptor_GetNumberOfNodes - procedure, public :: GetNumberOfAttributes => uniform_grid_descriptor_GetNumberOfAttributes - procedure, public :: GetNumberOfElements => uniform_grid_descriptor_GetNumberOfElements - procedure, public :: GetTopologyXPath => uniform_grid_descriptor_GetTopologyXPath - procedure, public :: GetTopologyType => uniform_grid_descriptor_GetTopologyType - procedure, public :: GetTopologyPrecision => uniform_grid_descriptor_GetTopologyPrecision - procedure, public :: GetTopologyDimension => uniform_grid_descriptor_GetTopologyDimension - procedure, public :: GetGeometryXPath => uniform_grid_descriptor_GetGeometryXPath - procedure, public :: GetGeometryType => uniform_grid_descriptor_GetGeometryType - procedure, public :: GetGeometryPrecision => uniform_grid_descriptor_GetGeometryPrecision - procedure, public :: GetGeometryDimension => uniform_grid_descriptor_GetGeometryDimension - procedure, public :: GetAttributeXPath => uniform_grid_descriptor_GetAttributeXPath - procedure, public :: GetAttributeType => uniform_grid_descriptor_GetAttributeType - procedure, public :: GetAttributePrecision => uniform_grid_descriptor_GetAttributePrecision - procedure, public :: GetAttributeDimension => uniform_grid_descriptor_GetAttributeDimension - procedure, public :: GetAttributeDataType => uniform_grid_descriptor_GetAttributeDataType - procedure, public :: GetAttributeCenter => uniform_grid_descriptor_GetAttributeCenter - procedure, public :: SetGeometryInfo => uniform_grid_descriptor_SetGeometryInfo - procedure, public :: SetTopologyInfo => uniform_grid_descriptor_SetTopologyInfo - procedure, public :: SetLastAttributeInfo => uniform_grid_descriptor_SetLastAttributeInfo - procedure, public :: UpdateNumberOfAttributes => uniform_grid_descriptor_UpdateNumberOfAttributes + procedure :: is_valid_TopologyType => uniform_grid_descriptor_is_valid_TopologyType + procedure :: is_valid_GeometryType => uniform_grid_descriptor_is_valid_GeometryType + procedure, public :: Initialize => uniform_grid_descriptor_Initialize + procedure, public :: Free => uniform_grid_descriptor_Free + procedure, public :: SetNumberOfNodes => uniform_grid_descriptor_SetNumberOfNodes + procedure, public :: SetNumberOfElements => uniform_grid_descriptor_SetNumberOfElements + procedure, public :: SetTopologyType => uniform_grid_descriptor_SetTopologyType + procedure, public :: SetGeometryType => uniform_grid_descriptor_SetGeometryType + procedure, public :: GetNumberOfNodes => uniform_grid_descriptor_GetNumberOfNodes + procedure, public :: GetNumberOfAttributes => uniform_grid_descriptor_GetNumberOfAttributes + procedure, public :: GetNumberOfElements => uniform_grid_descriptor_GetNumberOfElements + procedure, public :: GetTopologyName => uniform_grid_descriptor_GetTopologyName + procedure, public :: GetTopologyType => uniform_grid_descriptor_GetTopologyType + procedure, public :: GetTopologyPrecision => uniform_grid_descriptor_GetTopologyPrecision + procedure, public :: GetTopologyArrayDimensions => uniform_grid_descriptor_GetTopologyArrayDimensions + procedure, public :: GetGeometryName => uniform_grid_descriptor_GetGeometryName + procedure, public :: GetGeometryType => uniform_grid_descriptor_GetGeometryType + procedure, public :: GetGeometryPrecision => uniform_grid_descriptor_GetGeometryPrecision + procedure, public :: GetGeometryArrayDimensions => uniform_grid_descriptor_GetGeometryArrayDimensions + procedure, public :: GetAttributeName => uniform_grid_descriptor_GetAttributeName + procedure, public :: GetAttributeType => uniform_grid_descriptor_GetAttributeType + procedure, public :: GetAttributePrecision => uniform_grid_descriptor_GetAttributePrecision + procedure, public :: GetAttributeArrayDimensions => uniform_grid_descriptor_GetAttributeArrayDimensions + procedure, public :: GetAttributeDataType => uniform_grid_descriptor_GetAttributeDataType + procedure, public :: GetAttributeCenter => uniform_grid_descriptor_GetAttributeCenter + procedure, public :: SetGeometryMetadata => uniform_grid_descriptor_SetGeometryMetadata + procedure, public :: SetTopologyMetadata => uniform_grid_descriptor_SetTopologyMetadata + procedure, public :: SetLastAttributeMetadata => uniform_grid_descriptor_SetLastAttributeMetadata + procedure, public :: UpdateNumberOfAttributes => uniform_grid_descriptor_UpdateNumberOfAttributes end type uniform_grid_descriptor_t public:: uniform_grid_descriptor_t @@ -170,9 +170,9 @@ contains integer(I4P), intent(IN) :: TopologyType !< XDMF topology type !----------------------------------------------------------------- if(this%is_valid_TopologyType(TopologyType)) then - call this%topology_info%SetType(Type = TopologyType) + call this%TopologyMetadata%SetType(Type = TopologyType) else - call this%topology_info%SetType(Type = XDMF_NO_VALUE) + call this%TopologyMetadata%SetType(Type = XDMF_NO_VALUE) endif end subroutine uniform_grid_descriptor_SetTopologyType @@ -184,30 +184,30 @@ contains class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P) :: uniform_grid_descriptor_GetTopologyType !< XDMF Topology type !----------------------------------------------------------------- - uniform_grid_descriptor_GetTopologyType = this%Topology_info%GetType() + uniform_grid_descriptor_GetTopologyType = this%TopologyMetadata%GetType() end function uniform_grid_descriptor_GetTopologyType - subroutine uniform_grid_descriptor_SetTopologyXPath(this, Xpath) + subroutine uniform_grid_descriptor_SetTopologyName(this, Name) !----------------------------------------------------------------- - !< Set XDMF Topology XPath + !< Set XDMF Topology Name !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - character(len=*), intent(IN) :: XPath !< Topology XPath + character(len=*), intent(IN) :: Name !< Topology Name !----------------------------------------------------------------- - call this%Topology_info%SetXPath(XPath=XPath) - end subroutine uniform_grid_descriptor_SetTopologyXPath + call this%TopologyMetadata%SetName(Name=Name) + end subroutine uniform_grid_descriptor_SetTopologyName - function uniform_grid_descriptor_GetTopologyXPath(this) + function uniform_grid_descriptor_GetTopologyName(this) !----------------------------------------------------------------- - !< Return XDMF topology XPath + !< Return XDMF topology Name !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - Character(len=:), allocatable :: uniform_grid_descriptor_GetTopologyXPath !< Topology XPath + Character(len=:), allocatable :: uniform_grid_descriptor_GetTopologyName !< Topology Name !----------------------------------------------------------------- - uniform_grid_descriptor_GetTopologyXPath = this%tOPOLOGY_info%GetXPath() - end function uniform_grid_descriptor_GetTopologyXPath + uniform_grid_descriptor_GetTopologyName = this%TopologyMetadata%GetName() + end function uniform_grid_descriptor_GetTopologyName function uniform_grid_descriptor_GetTopologyPrecision(this) @@ -217,19 +217,19 @@ contains class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P) :: uniform_grid_descriptor_GetTopologyPrecision !< Topology Precision !----------------------------------------------------------------- - uniform_grid_descriptor_GetTopologyPrecision = this%Topology_info%GetPrecision() + uniform_grid_descriptor_GetTopologyPrecision = this%TopologyMetadata%GetPrecision() end function uniform_grid_descriptor_GetTopologyPrecision - function uniform_grid_descriptor_GetTopologyDimension(this) + function uniform_grid_descriptor_GetTopologyArrayDimensions(this) !----------------------------------------------------------------- !< Return XDMF topology Dimension !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - integer(I4P) :: uniform_grid_descriptor_GetTopologyDimension !< Topology Dimension + integer(I4P) :: uniform_grid_descriptor_GetTopologyArrayDimensions !< Topology Dimension !----------------------------------------------------------------- - uniform_grid_descriptor_GetTopologyDimension = this%Topology_info%GetDimension() - end function uniform_grid_descriptor_GetTopologyDimension + uniform_grid_descriptor_GetTopologyArrayDimensions = this%TopologyMetadata%GetArrayDimensions() + end function uniform_grid_descriptor_GetTopologyArrayDimensions function uniform_grid_descriptor_is_valid_GeometryType(this, GeometryType) result(is_valid) @@ -261,9 +261,9 @@ contains integer(I4P), intent(IN) :: GeometryType !< Local grid geometry type !---------------------------------------------------------------- if(this%is_valid_GeometryType(GeometryType)) then - call this%Geometry_info%SetType(Type=GeometryType) + call this%GeometryMetadata%SetType(Type=GeometryType) else - call this%Geometry_info%SetType(Type=XDMF_NO_VALUE) + call this%GeometryMetadata%SetType(Type=XDMF_NO_VALUE) endif end subroutine uniform_grid_descriptor_SetGeometryType @@ -275,30 +275,30 @@ contains class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P) :: uniform_grid_descriptor_GetGeometryType !< XDMF geometry type !----------------------------------------------------------------- - uniform_grid_descriptor_GetGeometryType = this%Geometry_info%GetType() + uniform_grid_descriptor_GetGeometryType = this%GeometryMetadata%GetType() end function uniform_grid_descriptor_GetGeometryType - subroutine uniform_grid_descriptor_SetGeometryXPath(this, Xpath) + subroutine uniform_grid_descriptor_SetGeometryName(this, Name) !----------------------------------------------------------------- - !< Set XDMF geometry XPath + !< Set XDMF geometry Name !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - character(len=*), intent(IN) :: XPath !< Geometry XPath + character(len=*), intent(IN) :: Name !< Geometry Name !----------------------------------------------------------------- - call this%Geometry_info%SetXPath(XPath=XPath) - end subroutine uniform_grid_descriptor_SetGeometryXPath + call this%GeometryMetadata%SetName(Name=Name) + end subroutine uniform_grid_descriptor_SetGeometryName - function uniform_grid_descriptor_GetGeometryXPath(this) + function uniform_grid_descriptor_GetGeometryName(this) !----------------------------------------------------------------- - !< Return XDMF geometry XPath + !< Return XDMF geometry Name !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - Character(len=:), allocatable :: uniform_grid_descriptor_GetGeometryXPath !< Geometry XPath + Character(len=:), allocatable :: uniform_grid_descriptor_GetGeometryName !< Geometry Name !----------------------------------------------------------------- - uniform_grid_descriptor_GetGeometryXPath = this%Geometry_info%GetXPath() - end function uniform_grid_descriptor_GetGeometryXPath + uniform_grid_descriptor_GetGeometryName = this%GeometryMetadata%GetName() + end function uniform_grid_descriptor_GetGeometryName function uniform_grid_descriptor_GetGeometryPrecision(this) @@ -308,19 +308,19 @@ contains class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P) :: uniform_grid_descriptor_GetGeometryPrecision !< Geometry Precision !----------------------------------------------------------------- - uniform_grid_descriptor_GetGeometryPrecision = this%Geometry_info%GetPrecision() + uniform_grid_descriptor_GetGeometryPrecision = this%GeometryMetadata%GetPrecision() end function uniform_grid_descriptor_GetGeometryPrecision - function uniform_grid_descriptor_GetGeometryDimension(this) + function uniform_grid_descriptor_GetGeometryArrayDimensions(this) !----------------------------------------------------------------- !< Return XDMF geometry Dimension !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor - integer(I4P) :: uniform_grid_descriptor_GetGeometryDimension !< Geometry Dimension + integer(I4P) :: uniform_grid_descriptor_GetGeometryArrayDimensions !< Geometry Dimension !----------------------------------------------------------------- - uniform_grid_descriptor_GetGeometryDimension = this%Geometry_info%GetDimension() - end function uniform_grid_descriptor_GetGeometryDimension + uniform_grid_descriptor_GetGeometryArrayDimensions = this%GeometryMetadata%GetArrayDimensions() + end function uniform_grid_descriptor_GetGeometryArrayDimensions function uniform_grid_descriptor_GetAttributeType(this, AttributeNumber) @@ -331,20 +331,20 @@ contains integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number integer(I4P) :: uniform_grid_descriptor_GetAttributeType !< XDMF attribute type !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributeType = this%Attributes_info(AttributeNumber)%GetType() + uniform_grid_descriptor_GetAttributeType = this%AttributesMetadata(AttributeNumber)%GetType() end function uniform_grid_descriptor_GetAttributeType - function uniform_grid_descriptor_GetAttributeXPath(this, AttributeNumber) + function uniform_grid_descriptor_GetAttributeName(this, AttributeNumber) !----------------------------------------------------------------- - !< Return XDMF attribute XPath + !< Return XDMF attribute Name !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number - Character(len=:), allocatable :: uniform_grid_descriptor_GetAttributeXPath !< Attribute XPath + Character(len=:), allocatable :: uniform_grid_descriptor_GetAttributeName !< Attribute Name !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributeXPath = this%Attributes_info(AttributeNumber)%GetXPath() - end function uniform_grid_descriptor_GetAttributeXPath + uniform_grid_descriptor_GetAttributeName = this%AttributesMetadata(AttributeNumber)%GetName() + end function uniform_grid_descriptor_GetAttributeName function uniform_grid_descriptor_GetAttributeDataType(this, AttributeNumber) @@ -355,7 +355,7 @@ contains integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number Character(len=:), allocatable :: uniform_grid_descriptor_GetAttributeDataType !< Attribute DataType !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributeDataType = this%Attributes_info(AttributeNumber)%GetDataType() + uniform_grid_descriptor_GetAttributeDataType = this%AttributesMetadata(AttributeNumber)%GetDataType() end function uniform_grid_descriptor_GetAttributeDataType @@ -367,20 +367,20 @@ contains integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number integer(I4P) :: uniform_grid_descriptor_GetAttributePrecision !< Attribute Precision !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributePrecision = this%Attributes_info(AttributeNumber)%GetPrecision() + uniform_grid_descriptor_GetAttributePrecision = this%AttributesMetadata(AttributeNumber)%GetPrecision() end function uniform_grid_descriptor_GetAttributePrecision - function uniform_grid_descriptor_GetAttributeDimension(this, AttributeNumber) + function uniform_grid_descriptor_GetAttributeArrayDimensions(this, AttributeNumber) !----------------------------------------------------------------- !< Return XDMF Attribute Dimension !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number - integer(I4P) :: uniform_grid_descriptor_GetAttributeDimension !< Attribute Dimension + integer(I4P) :: uniform_grid_descriptor_GetAttributeArrayDimensions !< Attribute Dimension !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributeDimension = this%Attributes_info(AttributeNumber)%GetDimension() - end function uniform_grid_descriptor_GetAttributeDimension + uniform_grid_descriptor_GetAttributeArrayDimensions = this%AttributesMetadata(AttributeNumber)%GetArrayDimensions() + end function uniform_grid_descriptor_GetAttributeArrayDimensions function uniform_grid_descriptor_GetAttributeCenter(this, AttributeNumber) @@ -391,7 +391,7 @@ contains integer(I4P), intent(IN) :: AttributeNumber !< Attribute Number integer(I4P) :: uniform_grid_descriptor_GetAttributeCenter !< Attribute Center !----------------------------------------------------------------- - uniform_grid_descriptor_GetAttributeCenter = this%Attributes_info(AttributeNumber)%GetCenter() + uniform_grid_descriptor_GetAttributeCenter = this%AttributesMetadata(AttributeNumber)%GetCenter() end function uniform_grid_descriptor_GetAttributeCenter @@ -412,72 +412,72 @@ contains end subroutine uniform_grid_descriptor_initialize - subroutine uniform_grid_descriptor_SetGeometryInfo(this, XPath, Precision, Dimension) + subroutine uniform_grid_descriptor_SetGeometryMetadata(this, Name, Precision, ArrayDimensions) !----------------------------------------------------------------- !< Set Uniform Grid Descriptor geometry info !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Uniform Grid Descriptor - character(len=*), intent(IN) :: XPath !< XPath to the HDF5 connetivities + character(len=*), intent(IN) :: Name !< Name to the HDF5 connetivities integer(I4P), intent(IN) :: Precision !< Precision of the Coordinates in the HDF5 file - integer(I4P), intent(IN) :: Dimension !< Dimensions of the Coordinates array in the HDF5 file + integer(I4P), intent(IN) :: ArrayDimensions !< Dimensions of the Coordinates array in the HDF5 file !----------------------------------------------------------------- - call this%geometry_info%SetXPath(XPath = XPath) - call this%geometry_info%SetPrecision(Precision = Precision) - call this%geometry_info%SetDimension(Dimension = Dimension) - end subroutine uniform_grid_descriptor_SetGeometryInfo + call this%GeometryMetadata%SetName(Name = Name) + call this%GeometryMetadata%SetPrecision(Precision = Precision) + call this%GeometryMetadata%SetArrayDimensions(ArrayDimensions = ArrayDimensions) + end subroutine uniform_grid_descriptor_SetGeometryMetadata - subroutine uniform_grid_descriptor_SetTopologyInfo(this, XPath, Precision, Dimension) + subroutine uniform_grid_descriptor_SetTopologyMetadata(this, Name, Precision, ArrayDimensions) !----------------------------------------------------------------- !< Set Uniform Grid Descriptor topology info !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Uniform Grid Descriptor - character(len=*), intent(IN) :: XPath !< XPath to the HDF5 coordinates + character(len=*), intent(IN) :: Name !< Name to the HDF5 coordinates integer(I4P), intent(IN) :: Precision !< Precision of the coordinates in the HDF5 file - integer(I4P), intent(IN) :: Dimension !< Dimensions of the coordinates array in the HDF5 file + integer(I4P), intent(IN) :: ArrayDimensions !< Dimensions of the coordinates array in the HDF5 file !----------------------------------------------------------------- - call this%topology_info%SetXPath(XPath = XPath) - call this%topology_info%SetPrecision(Precision = Precision) - call this%topology_info%SetDimension(Dimension = Dimension) - end subroutine uniform_grid_descriptor_SetTopologyInfo + call this%TopologyMetadata%SetName(Name = Name) + call this%TopologyMetadata%SetPrecision(Precision = Precision) + call this%TopologyMetadata%SetArrayDimensions(ArrayDimensions = ArrayDimensions) + end subroutine uniform_grid_descriptor_SetTopologyMetadata - subroutine uniform_grid_descriptor_SetLastAttributeInfo(this, XPath, Type, DataType, Center, Precision, Dimension) + subroutine uniform_grid_descriptor_SetLastAttributeMetadata(this, Name, Type, DataType, Center, Precision, ArrayDimensions) !----------------------------------------------------------------- !< Set XH5For geometry info !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Uniform Grid Descriptor - character(len=*), intent(IN) :: XPath !< XPath to the HDF5 coordinates + character(len=*), intent(IN) :: Name !< Name to the HDF5 coordinates integer(I4P), intent(IN) :: Type !< XH5For attribute type (Scalar, Vector, Tensor, etc.) character(len=*), intent(IN) :: DataType !< XH5For attribute data type (Int or Float) integer(I4P), intent(IN) :: Center !< Center property of the attribute (Node, Face, Edge, Cell or Grid) integer(I4P), intent(IN) :: Precision !< Precision of the attribute in the HDF5 file - integer(I4P), intent(IN) :: Dimension !< Dimensions of the attribute array in the HDF5 file + integer(I4P), intent(IN) :: ArrayDimensions !< Dimensions of the attribute array in the HDF5 file !----------------------------------------------------------------- - call this%attributes_info(this%NumberOfAttributes)%SetXPath(XPath = XPath) - call this%attributes_info(this%NumberOfAttributes)%SetType(Type = Type) - call this%attributes_info(this%NumberOfAttributes)%SetDataType(DataType = DataType) - call this%attributes_info(this%NumberOfAttributes)%SetCenter(Center = Center) - call this%attributes_info(this%NumberOfAttributes)%SetPrecision(Precision = Precision) - call this%attributes_info(this%NumberOfAttributes)%SetDimension(Dimension = Dimension) - end subroutine uniform_grid_descriptor_SetLastAttributeInfo + call this%AttributesMetadata(this%NumberOfAttributes)%SetName(Name = Name) + call this%AttributesMetadata(this%NumberOfAttributes)%SetType(Type = Type) + call this%AttributesMetadata(this%NumberOfAttributes)%SetDataType(DataType = DataType) + call this%AttributesMetadata(this%NumberOfAttributes)%SetCenter(Center = Center) + call this%AttributesMetadata(this%NumberOfAttributes)%SetPrecision(Precision = Precision) + call this%AttributesMetadata(this%NumberOfAttributes)%SetArrayDimensions(ArrayDimensions = ArrayDimensions) + end subroutine uniform_grid_descriptor_SetLastAttributeMetadata subroutine uniform_grid_descriptor_UpdateNumberOfAttributes(this) !----------------------------------------------------------------- - !< Increase the number of attributes and allocate the attributes_info array to the right size + !< Increase the number of attributes and allocate the AttributesMetadata array to the right size !----------------------------------------------------------------- class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Uniform Grid Descriptor type(xh5for_metadata_t), allocatable :: aux_attrs_info(:) !< Aux XH5For attributes metadata !----------------------------------------------------------------- - if(.not. allocated(this%attributes_info)) then + if(.not. allocated(this%AttributesMetadata)) then this%NumberOfAttributes = 0 - allocate(this%attributes_info(1)) - elseif(size(this%attributes_info) < (this%NumberOfAttributes+1)) then + allocate(this%AttributesMetadata(1)) + elseif(size(this%AttributesMetadata) < (this%NumberOfAttributes+1)) then allocate(aux_attrs_info(this%NumberOfAttributes)) - aux_attrs_info(:) = this%attributes_info(:) - deallocate(this%attributes_info); allocate(this%attributes_info(this%NumberOfAttributes+1)) - this%attributes_info(1:this%NumberOfAttributes) = aux_attrs_info(1:this%NumberOfAttributes) + aux_attrs_info(:) = this%AttributesMetadata(:) + deallocate(this%AttributesMetadata); allocate(this%AttributesMetadata(this%NumberOfAttributes+1)) + this%AttributesMetadata(1:this%NumberOfAttributes) = aux_attrs_info(1:this%NumberOfAttributes) deallocate(aux_attrs_info) endif this%NumberOfAttributes = this%NumberOfAttributes + 1 @@ -495,15 +495,15 @@ contains this%GridType = XDMF_GRID_TYPE_UNSTRUCTURED this%NumberOfNodes = XDMF_NO_VALUE this%NumberOfElements = XDMF_NO_VALUE - if(allocated(this%Attributes_info)) then + if(allocated(this%AttributesMetadata)) then do i = 1, this%NumberOfAttributes - call this%Attributes_info(i)%Free() + call this%AttributesMetadata(i)%Free() enddo - deallocate(this%Attributes_info) + deallocate(this%AttributesMetadata) endif this%NumberOfAttributes = 0 - call this%Geometry_info%Free() - call this%Topology_info%Free() + call this%GeometryMetadata%Free() + call this%TopologyMetadata%Free() end subroutine uniform_grid_descriptor_Free diff --git a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 index 62da5fa..97dfa91 100644 --- a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 +++ b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 @@ -106,7 +106,7 @@ contains real(R4P), intent(IN) :: Coordinates(:) !< Grid coordinates character(len=*), intent(IN) :: Name !< Topology name !----------------------------------------------------------------- - call this%UniformGridDescriptor%SetGeometryInfo(XPath = Name, Precision=4, Dimension=1) + call this%UniformGridDescriptor%SetGeometryMetadata(Name = Name, Precision=4, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_SetGeometry_R4P @@ -118,7 +118,7 @@ contains real(R8P), intent(IN) :: Coordinates(:) !< Grid coordinates character(len=*), intent(IN) :: Name !< Geometry name !----------------------------------------------------------------- - call this%UniformGridDescriptor%SetGeometryInfo(XPath=Name, Precision=8, Dimension=1) + call this%UniformGridDescriptor%SetGeometryMetadata(Name=Name, Precision=8, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_SetGeometry_R8P @@ -130,7 +130,7 @@ contains integer(I4P), intent(IN) :: Connectivities(:) !< Grid Connectivities character(len=*), intent(IN) :: Name !< Topology name !----------------------------------------------------------------- - call this%UniformGridDescriptor%SetTopologyInfo(XPath=Name, Precision=4, Dimension=1) + call this%UniformGridDescriptor%SetTopologyMetadata(Name=Name, Precision=4, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_SetTopology_I4P @@ -142,7 +142,7 @@ contains integer(I8P), intent(IN) :: Connectivities(:) !< Grid Connectivities character(len=*), intent(IN) :: Name !< Topology name !----------------------------------------------------------------- - call this%UniformGridDescriptor%SetTopologyInfo(XPath=Name, Precision=8, Dimension=1) + call this%UniformGridDescriptor%SetTopologyMetadata(Name=Name, Precision=8, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_SetTopology_I8P @@ -157,7 +157,7 @@ contains integer(I4P), intent(IN) :: Attribute(:) !< I4P Grid attribute !----------------------------------------------------------------- call this%UniformGridDescriptor%UpdateNumberOfAttributes() - call this%UniformGridDescriptor%SetLastAttributeInfo(XPath=trim(adjustl(Name)), Type=Type, DataType='Int', Center=Center, Precision=4, Dimension=1) + call this%UniformGridDescriptor%SetLastAttributeMetadata(Name=trim(adjustl(Name)), Type=Type, DataType='Int', Center=Center, Precision=4, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_AppendAttribute_I4P @@ -172,7 +172,7 @@ contains integer(I8P), intent(IN) :: Attribute(:) !< I8P Grid attribute !----------------------------------------------------------------- call this%UniformGridDescriptor%UpdateNumberOfAttributes() - call this%UniformGridDescriptor%SetLastAttributeInfo(XPath=trim(adjustl(Name)), Type=Type, DataType='Int', Center=Center, Precision=8, Dimension=1) + call this%UniformGridDescriptor%SetLastAttributeMetadata(Name=trim(adjustl(Name)), Type=Type, DataType='Int', Center=Center, Precision=8, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_AppendAttribute_I8P @@ -187,7 +187,7 @@ contains real(R4P), intent(IN) :: Attribute(:) !< R4P Grid attribute !----------------------------------------------------------------- call this%UniformGridDescriptor%UpdateNumberOfAttributes() - call this%UniformGridDescriptor%SetLastAttributeInfo(XPath=trim(adjustl(Name)), Type=Type, DataType='Float', Center=Center, Precision=8, Dimension=1) + call this%UniformGridDescriptor%SetLastAttributeMetadata(Name=trim(adjustl(Name)), Type=Type, DataType='Float', Center=Center, Precision=8, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_AppendAttribute_R4P @@ -202,7 +202,7 @@ contains real(R8P), intent(IN) :: Attribute(:) !< R4P Grid attribute !----------------------------------------------------------------- call this%UniformGridDescriptor%UpdateNumberOfAttributes() - call this%UniformGridDescriptor%SetLastAttributeInfo(XPath=trim(adjustl(Name)), Type=Type, DataType='Float', Center=Center, Precision=8, Dimension=1) + call this%UniformGridDescriptor%SetLastAttributeMetadata(Name=trim(adjustl(Name)), Type=Type, DataType='Float', Center=Center, Precision=8, ArrayDimensions=1) end subroutine xdmf_contiguous_hyperslab_handler_AppendAttribute_R8P @@ -538,7 +538,7 @@ contains ItemType = 'HyperSlab',& Format = 'HDF') call dataitem%open( xml_handler = this%file%xml_handler, & - Dimensions = (/3_I4P,this%UniformGridDescriptor%GetTopologyDimension()/),& + Dimensions = (/3_I4P,this%UniformGridDescriptor%GetTopologyArrayDimensions()/),& NumberType = 'Int',& Format = 'XML',& Precision = 4 ) @@ -551,7 +551,7 @@ contains Format = 'HDF',& Precision = this%UniformGridDescriptor%GetTopologyPrecision()) call chardata%write( xml_handler = this%file%xml_handler, & - Data = trim(adjustl(this%prefix))//'.h5'//':'//this%UniformGridDescriptor%GetTopologyXPath() ) + Data = trim(adjustl(this%prefix))//'.h5'//':'//this%UniformGridDescriptor%GetTopologyName() ) call dataitem%close(xml_handler=this%file%xml_handler) call dataitem%close(xml_handler=this%file%xml_handler) call topology%close(xml_handler=this%file%xml_handler) @@ -594,7 +594,7 @@ contains ItemType = 'HyperSlab', & Format = 'HDF') call dataitem%open(xml_handler = this%file%xml_handler, & - Dimensions = (/3_I4P,this%UniformGridDescriptor%GetGeometryDimension()/), & + Dimensions = (/3_I4P,this%UniformGridDescriptor%GetGeometryArrayDimensions()/), & NumberType = 'Int', & Format = 'XML', & Precision = 4) @@ -607,7 +607,7 @@ contains Format = 'HDF', & Precision = this%UniformGridDescriptor%GetGeometryPrecision()) call chardata%write( xml_handler = this%file%xml_handler, & - Data = trim(adjustl(this%prefix))//'.h5'//':'//this%UniformGridDescriptor%GetGeometryXPath()) + Data = trim(adjustl(this%prefix))//'.h5'//':'//this%UniformGridDescriptor%GetGeometryName()) call dataitem%close(xml_handler = this%file%xml_handler) call dataitem%close(xml_handler = this%file%xml_handler) call geometry%close(xml_handler = this%file%xml_handler) @@ -658,7 +658,7 @@ contains XDMFCenterTypeName = GetXDMFCenterTypeName( & this%UniformGridDescriptor%GetAttributeCenter(AttributeNumber=indx)) call attribute%open(xml_handler = this%file%xml_handler, & - Name = this%UniformGridDescriptor%GetAttributeXPath(AttributeNumber=indx), & + Name = this%UniformGridDescriptor%GetAttributeName(AttributeNumber=indx), & AttributeType = XDMFAttributeTypeName, & Center = XDMFCenterTypeName) call dataitem%open(xml_handler = this%file%xml_handler, & @@ -666,7 +666,7 @@ contains ItemType = 'HyperSlab', & Format = 'HDF') call dataitem%open(xml_handler = this%file%xml_handler, & - Dimensions = (/3_I4P,this%UniformGridDescriptor%GetAttributeDimension(AttributeNumber=indx)/), & + Dimensions = (/3_I4P,this%UniformGridDescriptor%GetAttributeArrayDimensions(AttributeNumber=indx)/), & NumberType = 'Int', & Format = 'XML', & Precision=4) @@ -680,7 +680,7 @@ contains Precision = this%UniformGridDescriptor%GetAttributePrecision(AttributeNumber=indx)) call chardata%write( xml_handler = this%file%xml_handler, & Data = trim(adjustl(this%prefix))//'.h5'//':'//& - this%UniformGridDescriptor%GetAttributeXPath(AttributeNumber=indx)) + this%UniformGridDescriptor%GetAttributeName(AttributeNumber=indx)) call dataitem%close(xml_handler = this%file%xml_handler) call dataitem%close(xml_handler = this%file%xml_handler) call attribute%close(xml_handler = this%file%xml_handler) diff --git a/src/lib/xh5for_metainfo.f90 b/src/lib/xh5for_metainfo.f90 index 56dd827..6082a0d 100644 --- a/src/lib/xh5for_metainfo.f90 +++ b/src/lib/xh5for_metainfo.f90 @@ -8,41 +8,41 @@ private type :: xh5for_metadata_t private - character(len=:), allocatable :: XPath - integer(I4P) :: Type = XDMF_NO_VALUE - integer(I4P) :: Center = XDMF_NO_VALUE + character(len=:), allocatable :: Name + integer(I4P) :: Type = XDMF_NO_VALUE + integer(I4P) :: Center = XDMF_NO_VALUE character(len=:), allocatable :: DataType - integer(I4P) :: Precision = XDMF_NO_VALUE - integer(I4P) :: Dimension = XDMF_NO_VALUE + integer(I4P) :: Precision = XDMF_NO_VALUE + integer(I4P) :: ArrayDimensions = XDMF_NO_VALUE contains - procedure, public :: SetXPath => xh5for_metadata_SetXPath - procedure, public :: SetType => xh5for_metadata_SetType - procedure, public :: SetCenter => xh5for_metadata_SetCenter - procedure, public :: SetDataType => xh5for_metadata_SetDataType - procedure, public :: SetPrecision => xh5for_metadata_SetPrecision - procedure, public :: SetDimension => xh5for_metadata_SetDimension - procedure, public :: GetXPath => xh5for_metadata_GetXPath - procedure, public :: GetType => xh5for_metadata_GetType - procedure, public :: GetCenter => xh5for_metadata_GetCenter - procedure, public :: GetDataType => xh5for_metadata_GetDataType - procedure, public :: GetPrecision => xh5for_metadata_GetPrecision - procedure, public :: GetDimension => xh5for_metadata_GetDimension - procedure, public :: Free => xh5for_metadata_Free + procedure, public :: SetName => xh5for_metadata_SetName + procedure, public :: SetType => xh5for_metadata_SetType + procedure, public :: SetCenter => xh5for_metadata_SetCenter + procedure, public :: SetDataType => xh5for_metadata_SetDataType + procedure, public :: SetPrecision => xh5for_metadata_SetPrecision + procedure, public :: SetArrayDimensions => xh5for_metadata_SetArrayDimensions + procedure, public :: GetName => xh5for_metadata_GetName + procedure, public :: GetType => xh5for_metadata_GetType + procedure, public :: GetCenter => xh5for_metadata_GetCenter + procedure, public :: GetDataType => xh5for_metadata_GetDataType + procedure, public :: GetPrecision => xh5for_metadata_GetPrecision + procedure, public :: GetArrayDimensions => xh5for_metadata_GetArrayDimensions + procedure, public :: Free => xh5for_metadata_Free end type xh5for_metadata_t public :: xh5for_metadata_t contains - subroutine xh5for_metadata_SetXPath(this, XPath) + subroutine xh5for_metadata_SetName(this, Name) !----------------------------------------------------------------- - !< Set the XPath + !< Set the Name !----------------------------------------------------------------- class(xh5for_metadata_t), intent(INOUT) :: this !< XH5For metadata type - character(len=*), intent(IN) :: XPath !< XPath + character(len=*), intent(IN) :: Name !< DataSet Name !----------------------------------------------------------------- - this%XPath = XPath - end subroutine xh5for_metadata_setXPath + this%Name = Name + end subroutine xh5for_metadata_setName subroutine xh5for_metadata_SetType(this, Type) @@ -89,26 +89,26 @@ contains end subroutine xh5for_metadata_setPrecision - subroutine xh5for_metadata_SetDimension(this, Dimension) + subroutine xh5for_metadata_SetArrayDimensions(this, ArrayDimensions) !----------------------------------------------------------------- !< Set the Dimension !----------------------------------------------------------------- class(xh5for_metadata_t), intent(INOUT) :: this !< XH5For metadata type - integer(I4P), intent(IN) :: Dimension !< Dimension + integer(I4P), intent(IN) :: ArrayDimensions !< Array Dimensions !----------------------------------------------------------------- - this%Dimension = Dimension - end subroutine xh5for_metadata_setDimension + this%ArrayDimensions = ArrayDimensions + end subroutine xh5for_metadata_SetArrayDimensions - function xh5for_metadata_GetXPath(this) + function xh5for_metadata_GetName(this) !----------------------------------------------------------------- - !< Return the XPath + !< Return the Name !----------------------------------------------------------------- class(xh5for_metadata_t), intent(IN) :: this !< XH5For metadata type - character(len=:), allocatable :: xh5for_metadata_GetXPath !< Returned XPath + character(len=:), allocatable :: xh5for_metadata_GetName !< Returned Name !----------------------------------------------------------------- - xh5for_metadata_GetXPath = this%XPath - end function xh5for_metadata_GetXPath + xh5for_metadata_GetName = this%Name + end function xh5for_metadata_GetName function xh5for_metadata_GetType(this) @@ -155,15 +155,15 @@ contains end function xh5for_metadata_GetPrecision - function xh5for_metadata_GetDimension(this) + function xh5for_metadata_GetArrayDimensions(this) !----------------------------------------------------------------- !< Return the Dimension !----------------------------------------------------------------- class(xh5for_metadata_t), intent(IN) :: this !< XH5For metadata type - integer(I4P) :: xh5for_metadata_GetDimension !< Returned Dimension + integer(I4P) :: xh5for_metadata_GetArrayDimensions !< Returned Dimension !----------------------------------------------------------------- - xh5for_metadata_GetDimension = this%Dimension - end function xh5for_metadata_GetDimension + xh5for_metadata_GetArrayDimensions = this%ArrayDimensions + end function xh5for_metadata_GetArrayDimensions subroutine xh5for_metadata_Free(this) @@ -172,12 +172,12 @@ contains !----------------------------------------------------------------- class(xh5for_metadata_t), intent(INOUT) :: this !< XH5For metadata type !----------------------------------------------------------------- - if(allocated(this%XPath)) deallocate(this%XPath) + if(allocated(this%Name)) deallocate(this%Name) if(allocated(this%DataType)) deallocate(this%DataType) this%Type = XDMF_NO_VALUE this%Center = XDMF_NO_VALUE this%Precision = XDMF_NO_VALUE - this%Dimension = XDMF_NO_VALUE + this%ArrayDimensions = XDMF_NO_VALUE end subroutine -- GitLab From a960d7d4ad4df56ed39402b871d3ed5ca3c6fb7e Mon Sep 17 00:00:00 2001 From: vsande Date: Tue, 3 Nov 2015 13:23:07 +0100 Subject: [PATCH 2/7] Mixed topology type writing. When writing a mixed topology, "number of elements" and "nodes per element" could not be enough information to know the dataset size, hyperslab size and hyperslab offset of the connectivities. When working with Mixed topologies we have to know explicitly this information. Now there are some more variables in the uniform and spatial grid descriptors to store this information (ConnectivitySize, GlobalConnectivitySize, ConnectivitySizePerGrid, ...). As a difference with the other required distribute data, this data is distributed when calling to "WriteTopology" and not in the initialization procedure. --- .../spatial_grid_descriptor.f90 | 80 ++++++++++++++++++- .../uniform_grid_descriptor.f90 | 33 ++++++-- .../hdf5_contiguous_hyperslab_handler.f90 | 42 +++++----- .../xdmf_contiguous_hyperslab_handler.f90 | 15 ++-- src/lib/xh5for.f90 | 4 + 5 files changed, 136 insertions(+), 38 deletions(-) diff --git a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 index 16a0aad..99aef85 100644 --- a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 +++ b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 @@ -26,8 +26,10 @@ private integer(I4P) :: NumberOfGrids !< Number of uniform grids of the spatial grid integer(I8P) :: GlobalNumberOfNodes = 0 !< Total number of nodes of the spatial grid integer(I8P) :: GlobalNumberOfElements = 0 !< Total number of elements of the spatial grid + integer(I8P) :: GlobalConnectivitySize = 0 !< Total size of the connectivities of the spatial grid integer(I8P), allocatable :: NumberOfNodesPerGrid(:) !< Array of number of nodes per grid integer(I8P), allocatable :: NumberOfElementsPerGrid(:) !< Array of number of elements per grid + integer(I8P), allocatable :: ConnectivitySizePerGrid(:) !< Array of sizes of array connectivities per grid integer(I4P), allocatable :: GeometryTypePerGrid(:) !< Array of geometry type per grid integer(I4P), allocatable :: TopologyTypePerGrid(:) !< Array of topology type per grid type(mpi_env_t), pointer :: MPIEnvironment => null() !< MPI environment @@ -38,18 +40,23 @@ private procedure :: Initialize_Reader => spatial_grid_descriptor_Initialize_Reader procedure :: SetGlobalNumberOfNodes => spatial_grid_descriptor_SetGlobalNumberOfNodes procedure :: SetGlobalNumberOfElements => spatial_grid_descriptor_SetGlobalNumberOfElements + procedure :: SetGlobalConnectivitySize => spatial_grid_descriptor_SetGlobalConnectivitySize procedure, public :: GetGlobalNumberOfNodes => spatial_grid_descriptor_GetGlobalNumberOfNodes procedure, public :: GetGlobalNumberOfElements => spatial_grid_descriptor_GetGlobalNumberOfElements + procedure, public :: GetGlobalConnectivitySize => spatial_grid_descriptor_GetGlobalConnectivitySize + procedure, public :: SetConnectivitySizePerGrid => spatial_grid_descriptor_SetConnectivitySizePerGrid procedure, public :: SetNumberOfNodesByGridID => spatial_grid_descriptor_SetNumberOfNodesByGridID procedure, public :: SetNumberOfElementsByGridID => spatial_grid_descriptor_SetNumberOfElementsByGridID procedure, public :: SetTopologyTypeByGridID => spatial_grid_descriptor_SetTopologyTypeByGridID procedure, public :: SetGeometryTypeByGridID => spatial_grid_descriptor_SetGeometryTypeByGridID procedure, public :: GetNumberOfNodesFromGridID => spatial_grid_descriptor_GetNumberOfNodesFromGridID procedure, public :: GetNumberOfElementsFromGridID => spatial_grid_descriptor_GetNumberOfElementsFromGridID + procedure, public :: GetConnectivitySizeFromGridID => spatial_grid_descriptor_GetConnectivitySizeFromGridID procedure, public :: GetTopologyTypeFromGridID => spatial_grid_descriptor_GetTopologyTypeFromGridID procedure, public :: GetGeometryTypeFromGridID => spatial_grid_descriptor_GetGeometryTypeFromGridID procedure, public :: GetNodeOffsetFromGridID => spatial_grid_descriptor_GetNodeOffsetFromGridID procedure, public :: GetElementOffsetFromGridID => spatial_grid_descriptor_GetElementOffsetFromGridID + procedure, public :: GetConnectivitySizeOffsetFromGridID => spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID generic, public :: Initialize => Initialize_Writer, & Initialize_Reader procedure, public :: Allocate => spatial_grid_descriptor_Allocate @@ -119,6 +126,28 @@ contains end function spatial_grid_descriptor_GetGlobalNumberOfElements + subroutine spatial_grid_descriptor_SetGlobalConnectivitySize(this, GlobalConnectivitySize) + !----------------------------------------------------------------- + !< Set the total connectivity size of the spatial grid + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), intent(IN) :: GlobalConnectivitySize !< Total size of connectivities of the spatial grid + !----------------------------------------------------------------- + this%GlobalConnectivitySize = GlobalConnectivitySize + end subroutine spatial_grid_descriptor_SetGlobalConnectivitySize + + + function spatial_grid_descriptor_GetGlobalConnectivitySize(this) result(GlobalConnectivitySize) + !----------------------------------------------------------------- + !< Get the total connectivity size of the spatial grid + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P) :: GlobalConnectivitySize !< Total size of connectivities of the spatial grid + !----------------------------------------------------------------- + GlobalConnectivitySize = this%GlobalConnectivitySize + end function spatial_grid_descriptor_GetGlobalConnectivitySize + + subroutine spatial_grid_descriptor_SetNumberOfNodesByGridID(this, NumberOfNodes, ID) !----------------------------------------------------------------- !< Set the number of nodes of a particular grid given its ID @@ -167,6 +196,30 @@ contains end function spatial_grid_descriptor_GetNumberOfElementsFromGridID + subroutine spatial_grid_descriptor_SetConnectivitySizeByGridID(this, ConnectivitySize, ID) + !----------------------------------------------------------------- + !< Set the connectivity size of a particular grid given its ID + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), intent(IN) :: ConnectivitySize!< Connectivity size of the grid ID + integer(I4P), intent(IN) :: ID !< Grid identifier + !----------------------------------------------------------------- + this%ConnectivitySizePerGrid(ID+1) = ConnectivitySize + end subroutine spatial_grid_descriptor_SetConnectivitySizeByGridID + + + function spatial_grid_descriptor_GetConnectivitySizeFromGridID(this, ID) + !----------------------------------------------------------------- + !< Return the number of elements of a particular grid given its ID + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier + integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeFromGridID !< Connectivity Size of a grid + !----------------------------------------------------------------- + spatial_grid_descriptor_GetConnectivitySizeFromGridID = this%ConnectivitySizePerGrid(ID+1) + end function spatial_grid_descriptor_GetConnectivitySizeFromGridID + + subroutine spatial_grid_descriptor_SetTopologyTypeByGridID(this, TopologyType, ID) !----------------------------------------------------------------- !< Set the topology type of a particular grid given its ID @@ -239,6 +292,18 @@ contains end function spatial_grid_descriptor_GetElementOffsetFromGridID + function spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID(this, ID) + !----------------------------------------------------------------- + !< Return the connectivity size offset of a particular grid given its ID + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier + integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID !< Connectivity size offset of a grid + !----------------------------------------------------------------- + spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID = sum(this%ConnectivitySizePerGrid(:ID)) + end function spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID + + subroutine spatial_grid_descriptor_Initialize_Writer(this, MPIEnvironment, NumberOfNodes, NumberOfElements, TopologyType, GeometryType) !----------------------------------------------------------------- !< Initilized the spatial grid descriptor type @@ -249,8 +314,6 @@ contains integer(I8P), intent(IN) :: NumberOfElements !< Number of elements of the current grid integer(I4P), intent(IN) :: TopologyType !< Topology type of the current grid integer(I4P), intent(IN) :: GeometryType !< Geometry type of the current grid - integer(I4P), allocatable :: TopologyTypePerGrid(:) !< Array of topology type per grid - integer(I4P), allocatable :: GeometryTypePerGrid(:) !< Array of geometry type per grid integer(I4P) :: i !< Loop index in NumberOfGrids !----------------------------------------------------------------- call this%Free() @@ -277,6 +340,19 @@ contains end subroutine spatial_grid_descriptor_Initialize_Reader + subroutine spatial_grid_descriptor_SetConnectivitySizePerGrid(this, ConnectivitySize) + !----------------------------------------------------------------- + !< Initilized the spatial grid descriptor type + !----------------------------------------------------------------- + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), optional, intent(IN) :: ConnectivitySize !< Size of the array of connectivities + integer(I4P) :: i !< Loop index in NumberOfGrids + !----------------------------------------------------------------- + call this%MPIEnvironment%mpi_allgather(ConnectivitySize, this%ConnectivitySizePerGrid) + call this%SetGlobalConnectivitySize(sum(this%ConnectivitySizePerGrid)) + end subroutine spatial_grid_descriptor_SetConnectivitySizePerGrid + + subroutine spatial_grid_descriptor_DistributeData(this) !----------------------------------------------------------------- !< Initilized the spatial grid descriptor type diff --git a/src/lib/grid_descriptors/uniform_grid_descriptor.f90 b/src/lib/grid_descriptors/uniform_grid_descriptor.f90 index d664dfd..29fda03 100644 --- a/src/lib/grid_descriptors/uniform_grid_descriptor.f90 +++ b/src/lib/grid_descriptors/uniform_grid_descriptor.f90 @@ -14,9 +14,10 @@ private !----------------------------------------------------------------- !< Save local grid information !----------------------------------------------------------------- - integer(I4P) :: GridType = XDMF_GRID_TYPE_UNSTRUCTURED - integer(I8P) :: NumberOfNodes = XDMF_NO_VALUE - integer(I8P) :: NumberOfElements = XDMF_NO_VALUE + integer(I4P) :: GridType = XDMF_GRID_TYPE_UNSTRUCTURED + integer(I8P) :: NumberOfNodes = XDMF_NO_VALUE + integer(I8P) :: NumberOfElements = XDMF_NO_VALUE + integer(I8P) :: ConnectivitySize = XDMF_NO_VALUE integer(I4P) :: NumberOfAttributes = 0 type(xh5for_metadata_t) :: GeometryMetadata type(xh5for_metadata_t) :: TopologyMetadata @@ -30,11 +31,13 @@ private procedure, public :: Free => uniform_grid_descriptor_Free procedure, public :: SetNumberOfNodes => uniform_grid_descriptor_SetNumberOfNodes procedure, public :: SetNumberOfElements => uniform_grid_descriptor_SetNumberOfElements + procedure, public :: SetConnectivitySize => uniform_grid_descriptor_SetConnectivitySize procedure, public :: SetTopologyType => uniform_grid_descriptor_SetTopologyType procedure, public :: SetGeometryType => uniform_grid_descriptor_SetGeometryType procedure, public :: GetNumberOfNodes => uniform_grid_descriptor_GetNumberOfNodes procedure, public :: GetNumberOfAttributes => uniform_grid_descriptor_GetNumberOfAttributes procedure, public :: GetNumberOfElements => uniform_grid_descriptor_GetNumberOfElements + procedure, public :: GetConnectivitySize => uniform_grid_descriptor_GetConnectivitySize procedure, public :: GetTopologyName => uniform_grid_descriptor_GetTopologyName procedure, public :: GetTopologyType => uniform_grid_descriptor_GetTopologyType procedure, public :: GetTopologyPrecision => uniform_grid_descriptor_GetTopologyPrecision @@ -80,6 +83,15 @@ contains this%NumberOfElements = NumberOfElements end subroutine uniform_grid_descriptor_SetNumberOfElements + subroutine uniform_grid_descriptor_SetConnectivitySize(this, ConnectivitySize) + !----------------------------------------------------------------- + !< Set the size of the connectivities array + !----------------------------------------------------------------- + class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor + integer(I8P), intent(IN) :: ConnectivitySize !< Size of the array of connectivities + !----------------------------------------------------------------- + this%ConnectivitySize = ConnectivitySize + end subroutine uniform_grid_descriptor_SetConnectivitySize function uniform_grid_descriptor_GetNumberOfNodes(this) !----------------------------------------------------------------- @@ -114,6 +126,17 @@ contains end function uniform_grid_descriptor_GetNumberOfElements + function uniform_grid_descriptor_GetConnectivitySize(this) result(ConnectivitySize) + !----------------------------------------------------------------- + !< Get the size of the connectivities array + !----------------------------------------------------------------- + class(uniform_grid_descriptor_t), intent(INOUT) :: this !< Local grid descriptor + integer(I8P) :: ConnectivitySize !< Size of the array of connectivities + !----------------------------------------------------------------- + ConnectivitySize = this%ConnectivitySize + end function uniform_grid_descriptor_GetConnectivitySize + + function uniform_grid_descriptor_is_valid_TopologyType(this, TopologyType) result(is_valid) !----------------------------------------------------------------- !< Return True if is a valid dataitem NumberType @@ -154,8 +177,8 @@ contains XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512, & XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729, & XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000, & - XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 & -! XDMF_TOPOLOGY_TYPE_MIXED & + XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331, & + XDMF_TOPOLOGY_TYPE_MIXED & /) is_valid = MINVAL(ABS(allowed_TopologyTypes - TopologyType)) == 0_I4P if(.not. is_valid .and. this%warn) call warning_message('Wrong Topology Type: "'//trim(str(no_sign=.true., n=TopologyType))//'"') diff --git a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 index 92749e7..561789a 100644 --- a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 +++ b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 @@ -692,10 +692,9 @@ contains class(hdf5_contiguous_hyperslab_handler_t), intent(IN) :: this !< HDF5 contiguous hyperslab handler integer(I4P), intent(IN) :: Connectivities(:) !< I4P Grid connectivities character(len=*), intent(IN) :: Name !< Topology dataset name - integer(HSIZE_T) :: nodesperelement !< Nodes per element - integer(HSIZE_T) :: globalnumberofelements !< Global number of elements - integer(HSIZE_T) :: localnumberofelements !< Local number of elements - integer(HSIZE_T) :: elementoffset !< Elements offset for a particular grid + integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities + integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid + integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier integer(HID_T) :: plist_id !< HDF5 Property list identifier integer(HID_T) :: dset_id !< HDF5 Dataset identifier @@ -706,14 +705,14 @@ contains !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) - globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%UniformGridDescriptor%GetNumberOfElements(),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) + LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + call this%WriteHyperSlab(DatasetName=Name, & - DatasetDims = (/nodesperelement*globalnumberofelements/), & - HyperSlabOffset = (/nodesperelement*elementoffset/), & - HyperSlabSize = (/nodesperelement*localnumberofelements/), & + DatasetDims = (/GlobalConnectivitySize/), & + HyperSlabOffset = (/ConnectivitySizeOffset/), & + HyperSlabSize = (/LocalConnectivitySize/), & Values = Connectivities) #endif end subroutine hdf5_contiguous_hyperslab_handler_WriteTopology_I4P @@ -726,10 +725,9 @@ contains class(hdf5_contiguous_hyperslab_handler_t), intent(IN) :: this !< HDF5 contiguous hyperslab handler integer(I8P), intent(IN) :: Connectivities(:) !< I8P Grid connectivities character(len=*), intent(IN) :: Name !< Topology dataset name - integer(HSIZE_T) :: nodesperelement !< Nodes per element - integer(HSIZE_T) :: globalnumberofelements !< Global number of elements - integer(HSIZE_T) :: localnumberofelements !< Local number of elements - integer(HSIZE_T) :: elementoffset !< Elements offset for a particular grid + integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities + integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid + integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier integer(HID_T) :: plist_id !< HDF5 Property list identifier integer(HID_T) :: dset_id !< HDF5 Dataset identifier @@ -740,14 +738,14 @@ contains !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) - globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%UniformGridDescriptor%GetNumberOfElements(),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) + LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) +print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset call this%WriteHyperSlab(DatasetName=Name, & - DatasetDims = (/nodesperelement*globalnumberofelements/), & - HyperSlabOffset = (/nodesperelement*elementoffset/), & - HyperSlabSize = (/nodesperelement*localnumberofelements/), & + DatasetDims = (/GlobalConnectivitySize/), & + HyperSlabOffset = (/ConnectivitySizeOffset/), & + HyperSlabSize = (/LocalConnectivitySize/), & Values = Connectivities) #endif end subroutine hdf5_contiguous_hyperslab_handler_WriteTopology_I8P diff --git a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 index 97dfa91..786c732 100644 --- a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 +++ b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 @@ -509,8 +509,7 @@ contains type(xdmf_dataitem_t) :: dataitem !< XDMF Dataitem type type(xdmf_character_data_t) :: chardata !< XDMF Character Data type integer(I8P) :: LocalNumberOfElements !< Local number of elements - integer(I8P) :: GlobalNumberOfElements !< Global number of elements - integer(I8P) :: NodesPerElement !< Number of nodes per element + integer(I8P) :: GlobalConnectivitySize !< Global connectivity size integer(I8P) :: Start !< Hyperslab start integer(I8P) :: Count !< Hyperslab count character(len=:), allocatable :: XMDFTopologyTypeName !< String topology type identifier @@ -519,16 +518,14 @@ contains if(this%MPIEnvironment%is_root()) then if(present(GridID)) then LocalNumberOfElements = this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=GridID) - NodesPerElement = GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypeFromGridID(ID=GridID)) - Start = this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=GridID)*NodesPerElement + Start = this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=GridID) else LocalNumberOfElements = this%UniformGridDescriptor%GetNumberOfElements() - NodesPerElement = GetNumberOfNodesPerElement(this%UniformGridDescriptor%GetTopologyType()) Start = 0 endif - GlobalNumberOfElements = this%SpatialGridDescriptor%GetGlobalNumberOfElements() + GlobalConnectivitySize = this%SpatialGridDescriptor%GetGlobalConnectivitySize() XMDFTopologyTypeName = GetXDMFTopologyTypeName(this%UniformGridDescriptor%getTopologyType()) - Count = LocalNumberOfElements*NodesPerElement + Count = this%SpatialGridDescriptor%GetConnectivitySizeFromGridID(ID=GridID) call topology%open( xml_handler = this%file%xml_handler, & Dimensions = (/LocalNumberOfelements/), & @@ -545,8 +542,8 @@ contains call chardata%write( xml_handler = this%file%xml_handler, & Data = (/Start,1_I8P,Count/) ) call dataitem%close(xml_handler = this%file%xml_handler) - call dataitem%open( xml_handler = this%file%xml_handler, & - Dimensions = (/GlobalNumberOfElements*NodesPerElement/),& + call dataitem%open( xml_handler = this%file%xml_handler, & + Dimensions = (/GlobalConnectivitySize/),& NumberType = 'Int',& Format = 'HDF',& Precision = this%UniformGridDescriptor%GetTopologyPrecision()) diff --git a/src/lib/xh5for.f90 b/src/lib/xh5for.f90 index 03429a7..ef24592 100644 --- a/src/lib/xh5for.f90 +++ b/src/lib/xh5for.f90 @@ -345,6 +345,8 @@ contains integer(I4P), intent(IN) :: Connectivities(:) !< I4P grid topology connectivities character(len=*), optional, intent(IN) :: Name !< Topology dataset name !----------------------------------------------------------------- + call this%UniformGridDescriptor%SetConnectivitySize(int(size(connectivities,dim=1),I8P)) + call this%SpatialGridDescriptor%SetConnectivitySizePerGrid(int(size(connectivities,dim=1),I8P)) if(present(Name)) then call this%Handler%WriteTopology(Connectivities = Connectivities, Name = Name) else @@ -361,6 +363,8 @@ contains integer(I8P), intent(IN) :: Connectivities(:) !< I8P grid topology connectivities character(len=*), optional, intent(IN) :: Name !< Topology dataset name !----------------------------------------------------------------- + call this%UniformGridDescriptor%SetConnectivitySize(int(size(connectivities,dim=1),I8P)) + call this%SpatialGridDescriptor%SetConnectivitySizePerGrid(int(size(connectivities,dim=1),I8P)) if(present(Name)) then call this%Handler%WriteTopology(Connectivities = Connectivities, Name = Name) else -- GitLab From 3632127fd06ae8f22164f6255cc67e3bb45a80d3 Mon Sep 17 00:00:00 2001 From: vsande Date: Tue, 3 Nov 2015 15:24:23 +0100 Subject: [PATCH 3/7] Refactoring/Renaming --- .../spatial_grid_descriptor.f90 | 148 +++++++++--------- .../hdf5_contiguous_hyperslab_handler.f90 | 48 +++--- .../xdmf_contiguous_hyperslab_handler.f90 | 32 ++-- src/lib/xh5for.f90 | 4 +- 4 files changed, 116 insertions(+), 116 deletions(-) diff --git a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 index 99aef85..0561e23 100644 --- a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 +++ b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 @@ -36,32 +36,32 @@ private contains private - procedure :: Initialize_Writer => spatial_grid_descriptor_Initialize_Writer - procedure :: Initialize_Reader => spatial_grid_descriptor_Initialize_Reader - procedure :: SetGlobalNumberOfNodes => spatial_grid_descriptor_SetGlobalNumberOfNodes - procedure :: SetGlobalNumberOfElements => spatial_grid_descriptor_SetGlobalNumberOfElements - procedure :: SetGlobalConnectivitySize => spatial_grid_descriptor_SetGlobalConnectivitySize - procedure, public :: GetGlobalNumberOfNodes => spatial_grid_descriptor_GetGlobalNumberOfNodes - procedure, public :: GetGlobalNumberOfElements => spatial_grid_descriptor_GetGlobalNumberOfElements - procedure, public :: GetGlobalConnectivitySize => spatial_grid_descriptor_GetGlobalConnectivitySize - procedure, public :: SetConnectivitySizePerGrid => spatial_grid_descriptor_SetConnectivitySizePerGrid - procedure, public :: SetNumberOfNodesByGridID => spatial_grid_descriptor_SetNumberOfNodesByGridID - procedure, public :: SetNumberOfElementsByGridID => spatial_grid_descriptor_SetNumberOfElementsByGridID - procedure, public :: SetTopologyTypeByGridID => spatial_grid_descriptor_SetTopologyTypeByGridID - procedure, public :: SetGeometryTypeByGridID => spatial_grid_descriptor_SetGeometryTypeByGridID - procedure, public :: GetNumberOfNodesFromGridID => spatial_grid_descriptor_GetNumberOfNodesFromGridID - procedure, public :: GetNumberOfElementsFromGridID => spatial_grid_descriptor_GetNumberOfElementsFromGridID - procedure, public :: GetConnectivitySizeFromGridID => spatial_grid_descriptor_GetConnectivitySizeFromGridID - procedure, public :: GetTopologyTypeFromGridID => spatial_grid_descriptor_GetTopologyTypeFromGridID - procedure, public :: GetGeometryTypeFromGridID => spatial_grid_descriptor_GetGeometryTypeFromGridID - procedure, public :: GetNodeOffsetFromGridID => spatial_grid_descriptor_GetNodeOffsetFromGridID - procedure, public :: GetElementOffsetFromGridID => spatial_grid_descriptor_GetElementOffsetFromGridID - procedure, public :: GetConnectivitySizeOffsetFromGridID => spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID - generic, public :: Initialize => Initialize_Writer, & - Initialize_Reader - procedure, public :: Allocate => spatial_grid_descriptor_Allocate - procedure, public :: DistributeData => spatial_grid_descriptor_DistributeData - procedure, public :: Free => spatial_grid_descriptor_Free + procedure :: Initialize_Writer => spatial_grid_descriptor_Initialize_Writer + procedure :: Initialize_Reader => spatial_grid_descriptor_Initialize_Reader + procedure :: SetGlobalNumberOfNodes => spatial_grid_descriptor_SetGlobalNumberOfNodes + procedure :: SetGlobalNumberOfElements => spatial_grid_descriptor_SetGlobalNumberOfElements + procedure :: SetGlobalConnectivitySize => spatial_grid_descriptor_SetGlobalConnectivitySize + procedure, public :: GetGlobalNumberOfNodes => spatial_grid_descriptor_GetGlobalNumberOfNodes + procedure, public :: GetGlobalNumberOfElements => spatial_grid_descriptor_GetGlobalNumberOfElements + procedure, public :: GetGlobalConnectivitySize => spatial_grid_descriptor_GetGlobalConnectivitySize + procedure, public :: AllgatherConnectivitySize => spatial_grid_descriptor_AllgatherConnectivitySize + procedure, public :: BroadcastMetadata => spatial_grid_descriptor_BroadcastMetadata + procedure, public :: SetNumberOfNodesPerGridID => spatial_grid_descriptor_SetNumberOfNodesPerGridID + procedure, public :: SetNumberOfElementsPerGridID => spatial_grid_descriptor_SetNumberOfElementsPerGridID + procedure, public :: SetTopologyTypePerGridID => spatial_grid_descriptor_SetTopologyTypePerGridID + procedure, public :: SetGeometryTypePerGridID => spatial_grid_descriptor_SetGeometryTypePerGridID + procedure, public :: GetNumberOfNodesPerGridID => spatial_grid_descriptor_GetNumberOfNodesPerGridID + procedure, public :: GetNumberOfElementsPerGridID => spatial_grid_descriptor_GetNumberOfElementsPerGridID + procedure, public :: GetConnectivitySizePerGridID => spatial_grid_descriptor_GetConnectivitySizePerGridID + procedure, public :: GetTopologyTypePerGridID => spatial_grid_descriptor_GetTopologyTypePerGridID + procedure, public :: GetGeometryTypePerGridID => spatial_grid_descriptor_GetGeometryTypePerGridID + procedure, public :: GetNodeOffsetPerGridID => spatial_grid_descriptor_GetNodeOffsetPerGridID + procedure, public :: GetElementOffsetPerGridID => spatial_grid_descriptor_GetElementOffsetPerGridID + procedure, public :: GetConnectivitySizeOffsetPerGridID => spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID + generic, public :: Initialize => Initialize_Writer, & + Initialize_Reader + procedure, public :: Allocate => spatial_grid_descriptor_Allocate + procedure, public :: Free => spatial_grid_descriptor_Free end type spatial_grid_descriptor_t public :: spatial_grid_descriptor_t @@ -148,7 +148,7 @@ contains end function spatial_grid_descriptor_GetGlobalConnectivitySize - subroutine spatial_grid_descriptor_SetNumberOfNodesByGridID(this, NumberOfNodes, ID) + subroutine spatial_grid_descriptor_SetNumberOfNodesPerGridID(this, NumberOfNodes, ID) !----------------------------------------------------------------- !< Set the number of nodes of a particular grid given its ID !----------------------------------------------------------------- @@ -157,22 +157,22 @@ contains integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%NumberOfNodesPerGrid(ID+1) = NumberOfNodes - end subroutine spatial_grid_descriptor_SetNumberOfNodesByGridID + end subroutine spatial_grid_descriptor_SetNumberOfNodesPerGridID - function spatial_grid_descriptor_GetNumberOfNodesFromGridID(this, ID) + function spatial_grid_descriptor_GetNumberOfNodesPerGridID(this, ID) !----------------------------------------------------------------- !< Return the number of nodes of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetNumberOfNodesFromGridID !< Number of nodes of a grid + integer(I8P) :: spatial_grid_descriptor_GetNumberOfNodesPerGridID !< Number of nodes of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetNumberOfNodesFromGridID = this%NumberOfNodesPerGrid(ID+1) - end function spatial_grid_descriptor_GetNumberOfNodesFromGridID + spatial_grid_descriptor_GetNumberOfNodesPerGridID = this%NumberOfNodesPerGrid(ID+1) + end function spatial_grid_descriptor_GetNumberOfNodesPerGridID - subroutine spatial_grid_descriptor_SetNumberOfElementsByGridID(this, NumberOfElements, ID) + subroutine spatial_grid_descriptor_SetNumberOfElementsPerGridID(this, NumberOfElements, ID) !----------------------------------------------------------------- !< Set the number of nodes of a particular grid given its ID !----------------------------------------------------------------- @@ -181,22 +181,22 @@ contains integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%NumberOfElementsPerGrid(ID+1) = NumberOfElements - end subroutine spatial_grid_descriptor_SetNumberOfElementsByGridID + end subroutine spatial_grid_descriptor_SetNumberOfElementsPerGridID - function spatial_grid_descriptor_GetNumberOfElementsFromGridID(this, ID) + function spatial_grid_descriptor_GetNumberOfElementsPerGridID(this, ID) !----------------------------------------------------------------- !< Return the number of elements of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetNumberOfElementsFromGridID !< Number of elements of a grid + integer(I8P) :: spatial_grid_descriptor_GetNumberOfElementsPerGridID !< Number of elements of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetNumberOfElementsFromGridID = this%NumberOfElementsPerGrid(ID+1) - end function spatial_grid_descriptor_GetNumberOfElementsFromGridID + spatial_grid_descriptor_GetNumberOfElementsPerGridID = this%NumberOfElementsPerGrid(ID+1) + end function spatial_grid_descriptor_GetNumberOfElementsPerGridID - subroutine spatial_grid_descriptor_SetConnectivitySizeByGridID(this, ConnectivitySize, ID) + subroutine spatial_grid_descriptor_SetConnectivitySizePerGridID(this, ConnectivitySize, ID) !----------------------------------------------------------------- !< Set the connectivity size of a particular grid given its ID !----------------------------------------------------------------- @@ -205,22 +205,22 @@ contains integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%ConnectivitySizePerGrid(ID+1) = ConnectivitySize - end subroutine spatial_grid_descriptor_SetConnectivitySizeByGridID + end subroutine spatial_grid_descriptor_SetConnectivitySizePerGridID - function spatial_grid_descriptor_GetConnectivitySizeFromGridID(this, ID) + function spatial_grid_descriptor_GetConnectivitySizePerGridID(this, ID) !----------------------------------------------------------------- !< Return the number of elements of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeFromGridID !< Connectivity Size of a grid + integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizePerGridID !< Connectivity Size of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetConnectivitySizeFromGridID = this%ConnectivitySizePerGrid(ID+1) - end function spatial_grid_descriptor_GetConnectivitySizeFromGridID + spatial_grid_descriptor_GetConnectivitySizePerGridID = this%ConnectivitySizePerGrid(ID+1) + end function spatial_grid_descriptor_GetConnectivitySizePerGridID - subroutine spatial_grid_descriptor_SetTopologyTypeByGridID(this, TopologyType, ID) + subroutine spatial_grid_descriptor_SetTopologyTypePerGridID(this, TopologyType, ID) !----------------------------------------------------------------- !< Set the topology type of a particular grid given its ID !----------------------------------------------------------------- @@ -229,22 +229,22 @@ contains integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%TopologyTypePerGrid(ID+1) = TopologyType - end subroutine spatial_grid_descriptor_SetTopologyTypeByGridID + end subroutine spatial_grid_descriptor_SetTopologyTypePerGridID - function spatial_grid_descriptor_GetTopologyTypeFromGridID(this, ID) + function spatial_grid_descriptor_GetTopologyTypePerGridID(this, ID) !----------------------------------------------------------------- !< Return the topology type of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I4P) :: spatial_grid_descriptor_GetTopologyTypeFromGridID !< Topology type of a grid + integer(I4P) :: spatial_grid_descriptor_GetTopologyTypePerGridID !< Topology type of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetTopologyTypeFromGridID = this%TopologyTypePerGrid(ID+1) - end function spatial_grid_descriptor_GetTopologyTypeFromGridID + spatial_grid_descriptor_GetTopologyTypePerGridID = this%TopologyTypePerGrid(ID+1) + end function spatial_grid_descriptor_GetTopologyTypePerGridID - subroutine spatial_grid_descriptor_SetGeometryTypeByGridID(this, GeometryType, ID) + subroutine spatial_grid_descriptor_SetGeometryTypePerGridID(this, GeometryType, ID) !----------------------------------------------------------------- !< Set the topology type of a particular grid given its ID !----------------------------------------------------------------- @@ -253,55 +253,55 @@ contains integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%GeometryTypePerGrid(ID+1) = GeometryType - end subroutine spatial_grid_descriptor_SetGeometryTypeByGridID + end subroutine spatial_grid_descriptor_SetGeometryTypePerGridID - function spatial_grid_descriptor_GetGeometryTypeFromGridID(this, ID) + function spatial_grid_descriptor_GetGeometryTypePerGridID(this, ID) !----------------------------------------------------------------- !< Return the geometry type of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I4P) :: spatial_grid_descriptor_GetGeometrytypeFromGridID !< Geometry type of a grid + integer(I4P) :: spatial_grid_descriptor_GetGeometryTypePerGridID !< Geometry type of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetGeometryTypeFromGridID = this%GeometryTypePerGrid(ID+1) - end function spatial_grid_descriptor_GetGeometryTypeFromGridID + spatial_grid_descriptor_GetGeometryTypePerGridID = this%GeometryTypePerGrid(ID+1) + end function spatial_grid_descriptor_GetGeometryTypePerGridID - function spatial_grid_descriptor_GetNodeOffsetFromGridID(this, ID) + function spatial_grid_descriptor_GetNodeOffsetPerGridID(this, ID) !----------------------------------------------------------------- !< Return the node offset of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetNodeOffsetFromGridID !< Node offset of a grid + integer(I8P) :: spatial_grid_descriptor_GetNodeOffsetPerGridID !< Node offset of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetNodeOffsetFromGridID = sum(this%NumberOfNodesPerGrid(:ID)) - end function spatial_grid_descriptor_GetNodeOffsetFromGridID + spatial_grid_descriptor_GetNodeOffsetPerGridID = sum(this%NumberOfNodesPerGrid(:ID)) + end function spatial_grid_descriptor_GetNodeOffsetPerGridID - function spatial_grid_descriptor_GetElementOffsetFromGridID(this, ID) + function spatial_grid_descriptor_GetElementOffsetPerGridID(this, ID) !----------------------------------------------------------------- !< Return the element offset of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetElementOffsetFromGridID !< Element offset of a grid + integer(I8P) :: spatial_grid_descriptor_GetElementOffsetPerGridID !< Element offset of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetElementOffsetFromGridID = sum(this%NumberOfElementsPerGrid(:ID)) - end function spatial_grid_descriptor_GetElementOffsetFromGridID + spatial_grid_descriptor_GetElementOffsetPerGridID = sum(this%NumberOfElementsPerGrid(:ID)) + end function spatial_grid_descriptor_GetElementOffsetPerGridID - function spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID(this, ID) + function spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID(this, ID) !----------------------------------------------------------------- !< Return the connectivity size offset of a particular grid given its ID !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I4P), intent(IN) :: ID !< Grid identifier - integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID !< Connectivity size offset of a grid + integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID !< Connectivity size offset of a grid !----------------------------------------------------------------- - spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID = sum(this%ConnectivitySizePerGrid(:ID)) - end function spatial_grid_descriptor_GetConnectivitySizeOffsetFromGridID + spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID = sum(this%ConnectivitySizePerGrid(:ID)) + end function spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID subroutine spatial_grid_descriptor_Initialize_Writer(this, MPIEnvironment, NumberOfNodes, NumberOfElements, TopologyType, GeometryType) @@ -340,9 +340,9 @@ contains end subroutine spatial_grid_descriptor_Initialize_Reader - subroutine spatial_grid_descriptor_SetConnectivitySizePerGrid(this, ConnectivitySize) + subroutine spatial_grid_descriptor_AllgatherConnectivitySize(this, ConnectivitySize) !----------------------------------------------------------------- - !< Initilized the spatial grid descriptor type + !< Allgather the connectivity size and sets the global connectivity seize !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type integer(I8P), optional, intent(IN) :: ConnectivitySize !< Size of the array of connectivities @@ -350,12 +350,12 @@ contains !----------------------------------------------------------------- call this%MPIEnvironment%mpi_allgather(ConnectivitySize, this%ConnectivitySizePerGrid) call this%SetGlobalConnectivitySize(sum(this%ConnectivitySizePerGrid)) - end subroutine spatial_grid_descriptor_SetConnectivitySizePerGrid + end subroutine spatial_grid_descriptor_AllgatherConnectivitySize - subroutine spatial_grid_descriptor_DistributeData(this) + subroutine spatial_grid_descriptor_BroadcastMetadata(this) !----------------------------------------------------------------- - !< Initilized the spatial grid descriptor type + !< Broadcast metadata after XDMF parsing !----------------------------------------------------------------- class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type !----------------------------------------------------------------- @@ -366,7 +366,7 @@ contains call this%MPIEnvironment%mpi_broadcast(this%TopologyTypePerGrid) call this%MPIEnvironment%mpi_broadcast(this%GeometryTypePerGrid) this%NumberOfGrids = size(this%NumberOfNodesPerGrid, dim=1) - end subroutine spatial_grid_descriptor_DistributeData + end subroutine spatial_grid_descriptor_BroadcastMetadata subroutine spatial_grid_descriptor_Free(this) diff --git a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 index 561789a..42e5587 100644 --- a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 +++ b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 @@ -72,20 +72,20 @@ contains select case(Center) case (XDMF_ATTRIBUTE_CENTER_NODE) GlobalNumberOfData = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) - LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - DataOffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + DataOffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) case (XDMF_ATTRIBUTE_CENTER_CELL) GlobalNumberOfData = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - DataOffset = int(this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + DataOffset = int(this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) case (XDMF_ATTRIBUTE_CENTER_GRID) GlobalNumberOfData = int(this%MPIEnvironment%get_comm_size(),HSIZE_T) LocalNumberOfData = 1_HSIZE_T DataOffset = this%MPIEnvironment%get_rank() case Default GlobalNumberOfData = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) - LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - DataOffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + LocalNumberOfData = int(this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + DataOffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) end select #endif end subroutine hdf5_contiguous_hyperslab_handler_CalculateHyperSlabDimensions @@ -637,10 +637,10 @@ contains !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofnodes = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) localnumberofnodes = int(this%UniformGridDescriptor%GetNumberOfNodes(),HSIZE_T) - nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%WriteHyperSlab(DatasetName=Name, & DatasetDims = (/spacedim*globalnumberofnodes/), & HyperSlabOffset = (/spacedim*nodeoffset/), & @@ -672,10 +672,10 @@ contains !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofnodes = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) localnumberofnodes = int(this%UniformGridDescriptor%GetNumberOfNodes(),HSIZE_T) - nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%WriteHyperSlab(DatasetName=Name, & DatasetDims = (/spacedim*globalnumberofnodes/), & HyperSlabOffset = (/spacedim*nodeoffset/), & @@ -707,7 +707,7 @@ contains #ifdef ENABLE_HDF5 GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) - ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%WriteHyperSlab(DatasetName=Name, & DatasetDims = (/GlobalConnectivitySize/), & @@ -740,7 +740,7 @@ contains #ifdef ENABLE_HDF5 GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) - ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset call this%WriteHyperSlab(DatasetName=Name, & DatasetDims = (/GlobalConnectivitySize/), & @@ -908,10 +908,10 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofnodes = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) - localnumberofnodes = int(this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + localnumberofnodes = int(this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%ReadHyperSlab(DatasetName = Name, & DatasetDims = (/spacedim*globalnumberofnodes/), & HyperSlabOffset = (/spacedim*nodeoffset/), & @@ -942,10 +942,10 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + spacedim = int(GetSpaceDimension(this%SpatialGridDescriptor%GetGeometryTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofnodes = int(this%SpatialGridDescriptor%GetGlobalNumberOfNodes(),HSIZE_T) - localnumberofnodes = int(this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + localnumberofnodes = int(this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + nodeoffset = int(this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%ReadHyperSlab(DatasetName = Name, & DatasetDims = (/spacedim*globalnumberofnodes/), & HyperSlabOffset = (/spacedim*nodeoffset/), & @@ -976,10 +976,10 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%ReadHyperSlab(DatasetName = Name, & DatasetDims = (/nodesperelement*globalnumberofelements/), & HyperSlabOffset = (/nodesperelement*elementoffset/), & @@ -1010,10 +1010,10 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypeFromGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) + nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) call this%WriteHyperSlab(DatasetName = Name, & DatasetDims = (/nodesperelement*globalnumberofelements/), & HyperSlabOffset = (/nodesperelement*elementoffset/), & diff --git a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 index 786c732..d9488cf 100644 --- a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 +++ b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 @@ -221,20 +221,20 @@ contains select case(Center) case (XDMF_ATTRIBUTE_CENTER_NODE) GlobalNumberOfData = this%SpatialGridDescriptor%GetGlobalNumberOfNodes() - LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=GridID) - DataOffset = this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=GridID) + LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=GridID) + DataOffset = this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=GridID) case (XDMF_ATTRIBUTE_CENTER_CELL) GlobalNumberOfData = this%SpatialGridDescriptor%GetGlobalNumberOfElements() - LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=GridID) - DataOffset = this%SpatialGridDescriptor%GetElementOffsetFromGridID(ID=GridID) + LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=GridID) + DataOffset = this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=GridID) case (XDMF_ATTRIBUTE_CENTER_GRID) GlobalNumberOfData = this%MPIEnvironment%get_comm_size() LocalNumberOfData = 1_I8P DataOffset = GridID case Default GlobalNumberOfData = this%SpatialGridDescriptor%GetGlobalNumberOfNodes() - LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=GridID) - DataOffset = this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=GridID) + LocalNumberOfData = this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=GridID) + DataOffset = this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=GridID) end select end subroutine xdmf_contiguous_hyperslab_handler_CalculateHyperSlabDimensions @@ -355,11 +355,11 @@ contains if(.not. associated(TopologyNode)) return call Topology%Parse(DOMNode = TopologyNode) ! Set TopologyType - call this%SpatialGridDescriptor%SetTopologyTypeByGridID(& + call this%SpatialGridDescriptor%SetTopologyTypePerGridID(& TopologyType = GetXDMFTopologyTypeFromName(Topology%get_TopologyType()), ID=ID) ! Set NumberOfElements auxDims = Topology%get_Dimensions() - call this%SpatialGridDescriptor%SetNumberOfElementsByGridID(AuxDims(1),ID=ID) + call this%SpatialGridDescriptor%SetNumberOfElementsPerGridID(AuxDims(1),ID=ID) call Topology%Free() nullify(DataItemNode) end subroutine xdmf_contiguous_hyperslab_handler_FillSpatialGridTopology @@ -382,14 +382,14 @@ contains if(.not. associated(GeometryNode)) return call Geometry%Parse(DOMNode = GeometryNode) ! Set GeometryType - call this%SpatialGridDescriptor%SetGeometryTypeByGridID(& + call this%SpatialGridDescriptor%SetGeometryTypePerGridID(& GeometryType = GetXDMFGeometryTypeFromName(Geometry%get_GeometryType()),ID=ID) ! Set NumberOfNodes DataItemNode => this%GetFirstChildByTag(FatherNode = GeometryNode, Tag = 'DataItem') call DataItem%Parse(DomNode = DataItemNode) auxDims = DataItem%get_Dimensions() spacedims = GetSpaceDimension(GetXDMFGeometryTypeFromName(Geometry%get_GeometryType())) - call this%SpatialGridDescriptor%SetNumberOfNodesByGridID(AuxDims(1)/spacedims,ID=ID) + call this%SpatialGridDescriptor%SetNumberOfNodesPerGridID(AuxDims(1)/spacedims,ID=ID) nullify(DataItemNode) call Geometry%Free() call DataItem%Free() @@ -459,7 +459,7 @@ contains endif call destroy(this%file%get_document_root()) endif - call this%SpatialGridDescriptor%DistributeData() + call this%SpatialGridDescriptor%BroadcastMetadata() end subroutine xdmf_contiguous_hyperslab_handler_ParseFile @@ -517,15 +517,15 @@ contains !< @Note: allow different Topology or Topology for each part of the spatial grid? if(this%MPIEnvironment%is_root()) then if(present(GridID)) then - LocalNumberOfElements = this%SpatialGridDescriptor%GetNumberOfElementsFromGridID(ID=GridID) - Start = this%SpatialGridDescriptor%GetConnectivitySizeOffsetFromGridID(ID=GridID) + LocalNumberOfElements = this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=GridID) + Start = this%SpatialGridDescriptor%GetConnectivitySizeOffsetPerGridID(ID=GridID) else LocalNumberOfElements = this%UniformGridDescriptor%GetNumberOfElements() Start = 0 endif GlobalConnectivitySize = this%SpatialGridDescriptor%GetGlobalConnectivitySize() XMDFTopologyTypeName = GetXDMFTopologyTypeName(this%UniformGridDescriptor%getTopologyType()) - Count = this%SpatialGridDescriptor%GetConnectivitySizeFromGridID(ID=GridID) + Count = this%SpatialGridDescriptor%GetConnectivitySizePerGridID(ID=GridID) call topology%open( xml_handler = this%file%xml_handler, & Dimensions = (/LocalNumberOfelements/), & @@ -575,8 +575,8 @@ contains if(this%MPIEnvironment%is_root()) then SpaceDimension = GetSpaceDimension(this%UniformGridDescriptor%getGeometryType()) if(present(GridID)) then - LocalNumberOfNodes = this%SpatialGridDescriptor%GetNumberOfNodesFromGridID(ID=GridID) - Start = this%SpatialGridDescriptor%GetNodeOffsetFromGridID(ID=GridID)*SpaceDimension + LocalNumberOfNodes = this%SpatialGridDescriptor%GetNumberOfNodesPerGridID(ID=GridID) + Start = this%SpatialGridDescriptor%GetNodeOffsetPerGridID(ID=GridID)*SpaceDimension else localNumberOfNodes = this%UniformGridDescriptor%GetNumberOfNodes() Start = 0 diff --git a/src/lib/xh5for.f90 b/src/lib/xh5for.f90 index ef24592..d0b9329 100644 --- a/src/lib/xh5for.f90 +++ b/src/lib/xh5for.f90 @@ -346,7 +346,7 @@ contains character(len=*), optional, intent(IN) :: Name !< Topology dataset name !----------------------------------------------------------------- call this%UniformGridDescriptor%SetConnectivitySize(int(size(connectivities,dim=1),I8P)) - call this%SpatialGridDescriptor%SetConnectivitySizePerGrid(int(size(connectivities,dim=1),I8P)) + call this%SpatialGridDescriptor%AllgatherConnectivitySize(int(size(connectivities,dim=1),I8P)) if(present(Name)) then call this%Handler%WriteTopology(Connectivities = Connectivities, Name = Name) else @@ -364,7 +364,7 @@ contains character(len=*), optional, intent(IN) :: Name !< Topology dataset name !----------------------------------------------------------------- call this%UniformGridDescriptor%SetConnectivitySize(int(size(connectivities,dim=1),I8P)) - call this%SpatialGridDescriptor%SetConnectivitySizePerGrid(int(size(connectivities,dim=1),I8P)) + call this%SpatialGridDescriptor%AllgatherConnectivitySize(int(size(connectivities,dim=1),I8P)) if(present(Name)) then call this%Handler%WriteTopology(Connectivities = Connectivities, Name = Name) else -- GitLab From 8b0aa52581386fef6f2ce54f930be926a64f04ec Mon Sep 17 00:00:00 2001 From: vsande Date: Tue, 3 Nov 2015 17:32:13 +0100 Subject: [PATCH 4/7] Mixed topology read. Now parse Topology Hyperslab DataItem in order to get the ConnectivitySizePerGrid. Allocate and Free this variable in the usual flow of the application (SpatialGridDescriptor%Allocate and SPatialGridDescriptor%Free). It also broadcast the variable from processor 0 to all processors before H5DRead. HDF5%ReadTopology uses this new ConnecitivitySizePerGrid. This commit also contains some code cleaning and renaming. --- .../spatial_grid_descriptor.f90 | 96 ++++++++++--------- .../hdf5_contiguous_hyperslab_handler.f90 | 84 ++++------------ src/lib/mpi_environment.f90 | 2 +- .../xdmf_contiguous_hyperslab_handler.f90 | 11 ++- .../xh5for_contiguous_hyperslab_handler.f90 | 2 +- 5 files changed, 82 insertions(+), 113 deletions(-) diff --git a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 index 0561e23..967393a 100644 --- a/src/lib/grid_descriptors/spatial_grid_descriptor.f90 +++ b/src/lib/grid_descriptors/spatial_grid_descriptor.f90 @@ -48,6 +48,7 @@ private procedure, public :: BroadcastMetadata => spatial_grid_descriptor_BroadcastMetadata procedure, public :: SetNumberOfNodesPerGridID => spatial_grid_descriptor_SetNumberOfNodesPerGridID procedure, public :: SetNumberOfElementsPerGridID => spatial_grid_descriptor_SetNumberOfElementsPerGridID + procedure, public :: SetConnectivitySizePerGridID => spatial_grid_descriptor_SetConnectivitySizePerGridID procedure, public :: SetTopologyTypePerGridID => spatial_grid_descriptor_SetTopologyTypePerGridID procedure, public :: SetGeometryTypePerGridID => spatial_grid_descriptor_SetGeometryTypePerGridID procedure, public :: GetNumberOfNodesPerGridID => spatial_grid_descriptor_GetNumberOfNodesPerGridID @@ -72,12 +73,13 @@ contains !----------------------------------------------------------------- !< Set the total number of nodes of the spatial grid !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: NumberOfGrids !< Total number of grids of the spatial grid + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: NumberOfGrids !< Total number of grids of the spatial grid !----------------------------------------------------------------- this%NumberOfGrids = NumberOfGrids allocate(this%NumberOfNodesPerGrid(NumberOfGrids)) allocate(this%NumberOfElementsPerGrid(NumberOfGrids)) + allocate(this%ConnectivitySizePerGrid(NumberOfGrids)) allocate(this%TopologyTypePerGrid(NumberOfGrids)) allocate(this%GeometryTypePerGrid(NumberOfGrids)) end subroutine spatial_grid_descriptor_Allocate @@ -86,8 +88,8 @@ contains !----------------------------------------------------------------- !< Set the total number of nodes of the spatial grid !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I8P), intent(IN) :: GlobalNumberOfNodes !< Total number of nodes of the spatial grid + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), intent(IN) :: GlobalNumberOfNodes !< Total number of nodes of the spatial grid !----------------------------------------------------------------- this%GlobalNumberOfNodes = GlobalNumberOfNodes end subroutine spatial_grid_descriptor_SetGlobalNumberOfNodes @@ -164,8 +166,8 @@ contains !----------------------------------------------------------------- !< Return the number of nodes of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetNumberOfNodesPerGridID !< Number of nodes of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetNumberOfNodesPerGridID = this%NumberOfNodesPerGrid(ID+1) @@ -176,9 +178,9 @@ contains !----------------------------------------------------------------- !< Set the number of nodes of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I8P), intent(IN) :: NumberOfElements!< Number of elements of the grid ID - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), intent(IN) :: NumberOfElements !< Number of elements of the grid ID + integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%NumberOfElementsPerGrid(ID+1) = NumberOfElements end subroutine spatial_grid_descriptor_SetNumberOfElementsPerGridID @@ -188,8 +190,8 @@ contains !----------------------------------------------------------------- !< Return the number of elements of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetNumberOfElementsPerGridID !< Number of elements of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetNumberOfElementsPerGridID = this%NumberOfElementsPerGrid(ID+1) @@ -200,9 +202,9 @@ contains !----------------------------------------------------------------- !< Set the connectivity size of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I8P), intent(IN) :: ConnectivitySize!< Connectivity size of the grid ID - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), intent(IN) :: ConnectivitySize !< Connectivity size of the grid ID + integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%ConnectivitySizePerGrid(ID+1) = ConnectivitySize end subroutine spatial_grid_descriptor_SetConnectivitySizePerGridID @@ -212,8 +214,8 @@ contains !----------------------------------------------------------------- !< Return the number of elements of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizePerGridID !< Connectivity Size of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetConnectivitySizePerGridID = this%ConnectivitySizePerGrid(ID+1) @@ -224,9 +226,9 @@ contains !----------------------------------------------------------------- !< Set the topology type of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: TopologyType !< Topology type of the grid ID - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: TopologyType !< Topology type of the grid ID + integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%TopologyTypePerGrid(ID+1) = TopologyType end subroutine spatial_grid_descriptor_SetTopologyTypePerGridID @@ -236,8 +238,8 @@ contains !----------------------------------------------------------------- !< Return the topology type of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I4P) :: spatial_grid_descriptor_GetTopologyTypePerGridID !< Topology type of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetTopologyTypePerGridID = this%TopologyTypePerGrid(ID+1) @@ -248,9 +250,9 @@ contains !----------------------------------------------------------------- !< Set the topology type of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: GeometryType !< Geometry type of the grid ID - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: GeometryType !< Geometry type of the grid ID + integer(I4P), intent(IN) :: ID !< Grid identifier !----------------------------------------------------------------- this%GeometryTypePerGrid(ID+1) = GeometryType end subroutine spatial_grid_descriptor_SetGeometryTypePerGridID @@ -260,8 +262,8 @@ contains !----------------------------------------------------------------- !< Return the geometry type of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I4P) :: spatial_grid_descriptor_GetGeometryTypePerGridID !< Geometry type of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetGeometryTypePerGridID = this%GeometryTypePerGrid(ID+1) @@ -272,8 +274,8 @@ contains !----------------------------------------------------------------- !< Return the node offset of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetNodeOffsetPerGridID !< Node offset of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetNodeOffsetPerGridID = sum(this%NumberOfNodesPerGrid(:ID)) @@ -284,8 +286,8 @@ contains !----------------------------------------------------------------- !< Return the element offset of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetElementOffsetPerGridID !< Element offset of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetElementOffsetPerGridID = sum(this%NumberOfElementsPerGrid(:ID)) @@ -296,8 +298,8 @@ contains !----------------------------------------------------------------- !< Return the connectivity size offset of a particular grid given its ID !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I4P), intent(IN) :: ID !< Grid identifier + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I4P), intent(IN) :: ID !< Grid identifier integer(I8P) :: spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID !< Connectivity size offset of a grid !----------------------------------------------------------------- spatial_grid_descriptor_GetConnectivitySizeOffsetPerGridID = sum(this%ConnectivitySizePerGrid(:ID)) @@ -308,13 +310,13 @@ contains !----------------------------------------------------------------- !< Initilized the spatial grid descriptor type !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - type(mpi_env_t), target, intent(IN) :: MPIEnvironment !< MPI environment type - integer(I8P), intent(IN) :: NumberOfNodes !< Number of nodes of the current grid - integer(I8P), intent(IN) :: NumberOfElements !< Number of elements of the current grid - integer(I4P), intent(IN) :: TopologyType !< Topology type of the current grid - integer(I4P), intent(IN) :: GeometryType !< Geometry type of the current grid - integer(I4P) :: i !< Loop index in NumberOfGrids + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + type(mpi_env_t), target, intent(IN) :: MPIEnvironment !< MPI environment type + integer(I8P), intent(IN) :: NumberOfNodes !< Number of nodes of the current grid + integer(I8P), intent(IN) :: NumberOfElements !< Number of elements of the current grid + integer(I4P), intent(IN) :: TopologyType !< Topology type of the current grid + integer(I4P), intent(IN) :: GeometryType !< Geometry type of the current grid + integer(I4P) :: i !< Loop index in NumberOfGrids !----------------------------------------------------------------- call this%Free() this%MPIEnvironment => MPIEnvironment @@ -332,8 +334,8 @@ contains !----------------------------------------------------------------- !< Initilized the spatial grid descriptor type !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - type(mpi_env_t), target, intent(IN) :: MPIEnvironment !< MPI environment type + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + type(mpi_env_t), target, intent(IN) :: MPIEnvironment !< MPI environment type !----------------------------------------------------------------- call this%Free() this%MPIEnvironment => MPIEnvironment @@ -342,11 +344,10 @@ contains subroutine spatial_grid_descriptor_AllgatherConnectivitySize(this, ConnectivitySize) !----------------------------------------------------------------- - !< Allgather the connectivity size and sets the global connectivity seize + !< Allgather the connectivity size and sets the global connectivity size !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type - integer(I8P), optional, intent(IN) :: ConnectivitySize !< Size of the array of connectivities - integer(I4P) :: i !< Loop index in NumberOfGrids + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + integer(I8P), optional, intent(IN) :: ConnectivitySize !< Size of the array of connectivities !----------------------------------------------------------------- call this%MPIEnvironment%mpi_allgather(ConnectivitySize, this%ConnectivitySizePerGrid) call this%SetGlobalConnectivitySize(sum(this%ConnectivitySizePerGrid)) @@ -357,12 +358,14 @@ contains !----------------------------------------------------------------- !< Broadcast metadata after XDMF parsing !----------------------------------------------------------------- - class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type + class(spatial_grid_descriptor_t), intent(INOUT) :: this !< Spatial grid descriptor type !----------------------------------------------------------------- call this%MPIEnvironment%mpi_broadcast(this%NumberOfNodesPerGrid) call this%MPIEnvironment%mpi_broadcast(this%NumberOfElementsPerGrid) + call this%MPIEnvironment%mpi_broadcast(this%ConnectivitySizePerGrid) call this%SetGlobalNumberOfElements(sum(this%NumberOfElementsPerGrid)) call this%SetGlobalNumberOfNodes(sum(this%NumberOfNodesPerGrid)) + call this%SetGlobalConnectivitySize(sum(this%ConnectivitySizePerGrid)) call this%MPIEnvironment%mpi_broadcast(this%TopologyTypePerGrid) call this%MPIEnvironment%mpi_broadcast(this%GeometryTypePerGrid) this%NumberOfGrids = size(this%NumberOfNodesPerGrid, dim=1) @@ -382,6 +385,7 @@ contains This%GlobalNumberOfElements = 0 if(allocated(this%NumberOfNodesPerGrid)) deallocate(this%NumberOfNodesPerGrid) if(allocated(this%NumberOfElementsPerGrid)) deallocate(this%NumberOfElementsPerGrid) + if(allocated(this%ConnectivitySizePerGrid)) deallocate(this%ConnectivitySizePerGrid) if(allocated(this%TopologyTypePerGrid)) deallocate(this%TopologyTypePerGrid) if(allocated(this%GeometryTypePerGrid)) deallocate(this%GeometryTypePerGrid) nullify(this%MPIEnvironment) diff --git a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 index 42e5587..a5b78b1 100644 --- a/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 +++ b/src/lib/hdf5_handler/hdf5_contiguous_hyperslab_handler.f90 @@ -627,11 +627,6 @@ contains integer(HSIZE_T) :: globalnumberofnodes !< Global number of nodes integer(HSIZE_T) :: localnumberofnodes !< Local number of nodes integer(HSIZE_T) :: nodeoffset !< Node offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -662,11 +657,6 @@ contains integer(HSIZE_T) :: globalnumberofnodes !< Global number of nodes integer(HSIZE_T) :: localnumberofnodes !< Local number of nodes integer(HSIZE_T) :: nodeoffset !< Node offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -695,11 +685,6 @@ contains integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -728,11 +713,6 @@ contains integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -898,11 +878,6 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset integer(HSIZE_T) :: globalnumberofnodes !< Global number of nodes integer(HSIZE_T) :: localnumberofnodes !< Local number of nodes integer(HSIZE_T) :: nodeoffset !< Node offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -932,11 +907,6 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset integer(HSIZE_T) :: globalnumberofnodes !< Global number of nodes integer(HSIZE_T) :: localnumberofnodes !< Local number of nodes integer(HSIZE_T) :: nodeoffset !< Node offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? @@ -962,28 +932,21 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset class(hdf5_contiguous_hyperslab_handler_t), intent(IN) :: this !< HDF5 contiguous hyperslab handler integer(I4P), allocatable, intent(OUT):: Connectivities(:) !< I4P Grid connectivities character(len=*), intent(IN) :: Name !< Topology dataset name - integer(HSIZE_T) :: nodesperelement !< Nodes per element - integer(HSIZE_T) :: globalnumberofelements !< Global number of elements - integer(HSIZE_T) :: localnumberofelements !< Local number of elements - integer(HSIZE_T) :: elementoffset !< Elements offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code + integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities + integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid + integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) - globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - call this%ReadHyperSlab(DatasetName = Name, & - DatasetDims = (/nodesperelement*globalnumberofelements/), & - HyperSlabOffset = (/nodesperelement*elementoffset/), & - HyperSlabSize = (/nodesperelement*localnumberofelements/), & + GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) + LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + call this%ReadHyperSlab(DatasetName = Name, & + DatasetDims = (/GlobalConnectivitySize/), & + HyperSlabOffset = (/ConnectivitySizeOffset/), & + HyperSlabSize = (/LocalConnectivitySize/), & Values = Connectivities) #endif end subroutine hdf5_contiguous_hyperslab_handler_ReadTopology_I4P @@ -996,28 +959,21 @@ print*, LocalConnectivitySize, GlobalConnectivitySize, ConnectivitySizeOffset class(hdf5_contiguous_hyperslab_handler_t), intent(IN) :: this !< HDF5 contiguous hyperslab handler integer(I8P), allocatable, intent(OUT):: Connectivities(:) !< I8P Grid connectivities character(len=*), intent(IN) :: Name !< Topology dataset name - integer(HSIZE_T) :: nodesperelement !< Nodes per element - integer(HSIZE_T) :: globalnumberofelements !< Global number of elements - integer(HSIZE_T) :: localnumberofelements !< Local number of elements - integer(HSIZE_T) :: elementoffset !< Elements offset for a particular grid - integer(HID_T) :: filespace !< HDF5 fiel Dataspace identifier - integer(HID_T) :: plist_id !< HDF5 Property list identifier - integer(HID_T) :: dset_id !< HDF5 Dataset identifier - integer(HID_T) :: memspace !< HDF5 memory Dataspace identifier - integer :: hdferror !< HDF5 error code + integer(HSIZE_T) :: GlobalConnectivitySize !< Global size of connectivities + integer(HSIZE_T) :: LocalConnectivitySize !< Local size of connectivities for a particular grid + integer(HSIZE_T) :: ConnectivitySizeOffset !< Connectivity Size offset for a particular grid !----------------------------------------------------------------- !< @Note: Fixed rank 1? !< @Note: Fixed dataset name? !< @Note: Fixed rank 1? #ifdef ENABLE_HDF5 - nodesperelement = int(GetNumberOfNodesPerElement(this%SpatialGridDescriptor%GetTopologyTypePerGridID(ID=this%MPIEnvironment%get_rank())),HSIZE_T) - globalnumberofelements = int(this%SpatialGridDescriptor%GetGlobalNumberOfElements(),HSIZE_T) - localnumberofelements = int(this%SpatialGridDescriptor%GetNumberOfElementsPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - elementoffset = int(this%SpatialGridDescriptor%GetElementOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) - call this%WriteHyperSlab(DatasetName = Name, & - DatasetDims = (/nodesperelement*globalnumberofelements/), & - HyperSlabOffset = (/nodesperelement*elementoffset/), & - HyperSlabSize = (/nodesperelement*localnumberofelements/), & + GlobalConnectivitySize = int(this%SpatialGridDescriptor%GetGlobalConnectivitySize(),HSIZE_T) + LocalConnectivitySize = int(this%UniformGridDescriptor%GetConnectivitySize(),HSIZE_T) + ConnectivitySizeOffset = int(this%SpatialGridDescriptor%GetConnectivitySizeOffsetPerGridID(ID=this%MPIEnvironment%get_rank()),HSIZE_T) + call this%ReadHyperSlab(DatasetName = Name, & + DatasetDims = (/GlobalConnectivitySize/), & + HyperSlabOffset = (/ConnectivitySizeOffset/), & + HyperSlabSize = (/LocalConnectivitySize/), & Values = Connectivities) #endif end subroutine hdf5_contiguous_hyperslab_handler_ReadTopology_I8P diff --git a/src/lib/mpi_environment.f90 b/src/lib/mpi_environment.f90 index 05d8908..84e5a6a 100644 --- a/src/lib/mpi_environment.f90 +++ b/src/lib/mpi_environment.f90 @@ -97,7 +97,7 @@ contains !----------------------------------------------------------------- !< Free MPI derived type !----------------------------------------------------------------- - class(mpi_env_t), intent(INOUT) :: this !< MPI environment + class(mpi_env_t), intent(INOUT) :: this !< MPI environment !----------------------------------------------------------------- ! No allocatable variables. Default initialization call this%Initialize() diff --git a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 index d9488cf..16d7ad8 100644 --- a/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 +++ b/src/lib/xdmf_handler/xdmf_contiguous_hyperslab_handler.f90 @@ -320,7 +320,7 @@ contains type(NodeList), pointer :: Childrens !< Fox DOM node list type(Node), pointer :: ChildNode !< Fox DOM node type(xdmf_dataitem_t) :: dataitem !< XDMF Topology derived type - integer(I4P) :: i !< Index for a loop in Childrens + integer(I4P) :: i !< Index for a loop in Childrens !----------------------------------------------------------------- if(.not. associated(DataItemNode)) return if(hasChildNodes(DataItemNode)) then @@ -348,6 +348,7 @@ contains type(Node), pointer, intent(IN) :: TopologyNode !< Fox DOM Topology node integer(I4P), intent(IN) :: ID !< Grid IDentifier type(xdmf_topology_t) :: Topology !< XDMF Topology derived type + type(xdmf_dataitem_t) :: DataItem !< XDMF DataItem derived type type(Node), pointer :: DataItemNode !< Fox DOM Dataitem node integer(I8P), allocatable :: auxDims(:) !< Aux dimensions variable character(len=:), allocatable :: XPath !< Topology XPath @@ -360,7 +361,14 @@ contains ! Set NumberOfElements auxDims = Topology%get_Dimensions() call this%SpatialGridDescriptor%SetNumberOfElementsPerGridID(AuxDims(1),ID=ID) + ! Set ConnectivitySize + DataItemNode => this%GetFirstChildByTag(FatherNode = TopologyNode, Tag = 'DataItem') + call DataItem%Parse(DomNode = DataItemNode) + auxDims = DataItem%get_Dimensions() + call this%SpatialGridDescriptor%SetConnectivitySizePerGridID(AuxDims(1),ID=ID) + ! Free call Topology%Free() + call DataItem%Free() nullify(DataItemNode) end subroutine xdmf_contiguous_hyperslab_handler_FillSpatialGridTopology @@ -390,6 +398,7 @@ contains auxDims = DataItem%get_Dimensions() spacedims = GetSpaceDimension(GetXDMFGeometryTypeFromName(Geometry%get_GeometryType())) call this%SpatialGridDescriptor%SetNumberOfNodesPerGridID(AuxDims(1)/spacedims,ID=ID) + ! Free nullify(DataItemNode) call Geometry%Free() call DataItem%Free() diff --git a/src/lib/xh5for_handler/xh5for_contiguous_hyperslab_handler.f90 b/src/lib/xh5for_handler/xh5for_contiguous_hyperslab_handler.f90 index e276e03..54cc5b2 100644 --- a/src/lib/xh5for_handler/xh5for_contiguous_hyperslab_handler.f90 +++ b/src/lib/xh5for_handler/xh5for_contiguous_hyperslab_handler.f90 @@ -102,7 +102,7 @@ contains !----------------------------------------------------------------- !< Close the lightdata and the heavydata files !----------------------------------------------------------------- - class(xh5for_contiguous_hyperslab_handler_t), intent(INOUT) :: this !< XH5For contigous hyperslab handler + class(xh5for_contiguous_hyperslab_handler_t), intent(INOUT) :: this !< XH5For contigous hyperslab handler integer(I4P), intent(IN) :: action !< XH5For Close action (Read or Write) !----------------------------------------------------------------- call this%HeavyData%CloseFile() -- GitLab From 61fb8d8a151e1163a5adcef0d048564e5fff29ec Mon Sep 17 00:00:00 2001 From: vsande Date: Tue, 3 Nov 2015 17:38:30 +0100 Subject: [PATCH 5/7] Example to test mixed topology Reading/Writing. --- .../xh5for_unstructured_mixedtopology.f90 | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/examples/topology_types/xh5for_unstructured_mixedtopology.f90 diff --git a/src/examples/topology_types/xh5for_unstructured_mixedtopology.f90 b/src/examples/topology_types/xh5for_unstructured_mixedtopology.f90 new file mode 100644 index 0000000..3222fad --- /dev/null +++ b/src/examples/topology_types/xh5for_unstructured_mixedtopology.f90 @@ -0,0 +1,103 @@ +program example_unstructured_triangles + +use xh5for +#ifdef ENABLE_MPI +#ifdef MPI_MOD + use mpi +#else + include 'mpif.h' +#endif +#endif + +implicit none + !----------------------------------------------------------------- + !< Variable definition + !----------------------------------------------------------------- + type(xh5for_t) :: xh5 + real(R8P), dimension(72):: geometry = (/ 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, & + 1, 1, 0, 2, 1, 0, 0, 0, 1, 1, 0, 1, & + 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, & + 0, 1, 2, 1, 1, 2, 2, 1, 2, 0, 1, 3, & + 1, 1, 3, 2, 1, 3, 0, 1, 4, 1, 1, 4, & + 2, 1, 4, 0, 1, 5, 1, 1, 5, 2, 1, 5 /) + + integer(I4P), dimension(57):: topology = (/ 9, 0 ,1 ,4 ,3 ,6 ,7 ,10,9 , & ! Hexahedron + 9, 1 ,2 ,5 ,4 ,7 ,8 ,11,10, & ! Hexahedron + 6, 6 ,10,9 ,12, & ! Tetrahedron + 6, 5 ,11,10,14, & ! Tetrahedron + 3, 6, 15,16,17,14,13,12, & ! Polygon + 4, 18,15,19, & ! Triangle + 4, 16,20,17, & ! Triangle + 5, 22,23,20,19, & ! Quadrilateral + 4, 21,22,18, & ! Triangle + 4, 22,19,18 /) ! Triangle + + integer(I4P), dimension(10):: cellfield = (/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9/) + + real(R8P), dimension(24):: nodefield = (/ 0.0, 1.0, 2.0,3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, & + 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, & + 18.0, 19.0, 20.0, 21.0, 22.0, 23.0 /) + + real(R4P), allocatable :: out_geometry(:) + integer(I4P), allocatable :: out_topology(:) + integer(I4P), allocatable :: out_cellfield(:) + real(R8P), allocatable :: out_nodefield(:) + integer(I4P), allocatable :: out_gridfield(:) + + integer :: rank = 0 + integer :: mpierr + integer :: exitcode = 0 + + + !----------------------------------------------------------------- + !< Main program + !----------------------------------------------------------------- + +#ifdef ENABLE_MPI + call MPI_INIT(mpierr) + call MPI_Comm_rank(MPI_COMM_WORLD, rank, mpierr); +#endif + + !< Initialize some values depending on the mpi rank + geometry = geometry/2 + rank + + !< Write XDMF/HDF5 file + call xh5%SetStrategy(Strategy=XDMF_STRATEGY_CONTIGUOUS_HYPERSLAB) + call xh5%Initialize(NumberOfNodes=24, NumberOfElements=10,TopologyType=XDMF_TOPOLOGY_TYPE_MIXED, GeometryType=XDMF_GEOMETRY_TYPE_XYZ) + call xh5%Open(action=XDMF_ACTION_WRITE, fileprefix='contiguous_hyperslab_mixedtopology') + call xh5%WriteTopology(Connectivities = topology) + call xh5%WriteGeometry(Coordinates = geometry) + call xh5%WriteAttribute(Name='NodeField', Type=XDMF_ATTRIBUTE_TYPE_SCALAR ,Center=XDMF_ATTRIBUTE_CENTER_NODE , Values=nodefield) + call xh5%WriteAttribute(Name='CellField', Type=XDMF_ATTRIBUTE_TYPE_SCALAR ,Center=XDMF_ATTRIBUTE_CENTER_CELL , Values=cellfield) + call xh5%Close() + call xh5%Free() + + !< Read XDMF/HDF5 file + call xh5%SetStrategy(Strategy=XDMF_STRATEGY_CONTIGUOUS_HYPERSLAB) + call xh5%Initialize() + call xh5%Open(action=XDMF_ACTION_READ, fileprefix='contiguous_hyperslab_mixedtopology') + call xh5%Parse() + call xh5%ReadTopology(Connectivities = out_topology) + call xh5%ReadGeometry(Coordinates = out_geometry) + call xh5%ReadAttribute(Name='NodeField', Type=XDMF_ATTRIBUTE_TYPE_SCALAR ,Center=XDMF_ATTRIBUTE_CENTER_NODE , Values=out_nodefield) + call xh5%ReadAttribute(Name='CellField', Type=XDMF_ATTRIBUTE_TYPE_SCALAR ,Center=XDMF_ATTRIBUTE_CENTER_CELL , Values=out_cellfield) + call xh5%Close() + call xh5%Free() + +#ifdef ENABLE_HDF5 + !< Check results + if(.not. (sum(out_geometry - geometry)<=epsilon(0._R4P))) exitcode = -1 + if(.not. (sum(out_topology - topology)==0)) exitcode = -1 + if(.not. (sum(out_cellfield - cellfield)==0)) exitcode = -1 + if(.not. (sum(out_nodefield - nodefield)<=epsilon(0._R8P))) exitcode = -1 +#else + if(rank==0) write(*,*) 'Warning: HDF5 is not enabled. Please enable HDF5 and recompile to write the HeavyData' +#endif + +#ifdef ENABLE_MPI + call MPI_FINALIZE(mpierr) +#endif + + call exit(exitcode) + +end program example_unstructured_triangles -- GitLab From 7a4d86d54ad5e51e51874242f6219d72c59c81bd Mon Sep 17 00:00:00 2001 From: vsande Date: Wed, 4 Nov 2015 09:39:38 +0100 Subject: [PATCH 6/7] fix test_xdmf_contiguous_hyperslabs_handler.f90 bug --- .../test_xdmf_contiguous_hyperslabs_handler.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/test_xdmf_handlers/test_xdmf_contiguous_hyperslabs_handler.f90 b/src/tests/test_xdmf_handlers/test_xdmf_contiguous_hyperslabs_handler.f90 index 5935c2d..beade6d 100644 --- a/src/tests/test_xdmf_handlers/test_xdmf_contiguous_hyperslabs_handler.f90 +++ b/src/tests/test_xdmf_handlers/test_xdmf_contiguous_hyperslabs_handler.f90 @@ -32,6 +32,7 @@ implicit none #endif call mpienv%initialize() call spatialgrid%initialize(MPIEnvironment=mpienv, NumberOfNodes=4_I8P, NumberOfElements=2_I8P, TopologyType=XDMF_TOPOLOGY_TYPE_TRIANGLE, GeometryType=XDMF_GEOMETRY_TYPE_XY) + call spatialgrid%AllgatherConnectivitySize(ConnectivitySize=int(size(topology,dim=1),I8P)) call uniformgrid%initialize(NumberOfNodes=4_I8P, NumberOfElements=2_I8P, TopologyType=XDMF_TOPOLOGY_TYPE_TRIANGLE, GeometryType=XDMF_GEOMETRY_TYPE_XY) call lightdata%initialize(MPIEnvironment=mpienv, SpatialGridDescriptor=spatialgrid, UniformGridDescriptor=uniformgrid) call lightdata%OpenFile(action=XDMF_ACTION_WRITE, fileprefix='xdmf_hyperslab') -- GitLab From 40f910ff9ee2c200aed578de31e7b50b6b3f979c Mon Sep 17 00:00:00 2001 From: vsande Date: Wed, 4 Nov 2015 09:44:57 +0100 Subject: [PATCH 7/7] update documentation --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 147fde6..1c24a19 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # XdmfHdf5Fortran The Fortran way to easy write partitioned XDMF/HDF5 meshes -[![Build Status](https://travis-ci.org/victorsndvg/XdmfHdf5Fortran.svg?branch=master)](https://travis-ci.org/victorsndvg/XdmfHdf5Fortran) +[![Build Status](https://travis-ci.org/victorsndvg/XH5For.svg?branch=master)](https://travis-ci.org/victorsndvg/XH5For) + ## What is XdmfHdf5Fortran? Is a library to read and write partitioned FEM meshes taking advantage of the collective/independent IO provided by the HDF5 library. @@ -29,7 +30,8 @@ Is a library to read and write partitioned FEM meshes taking advantage of the co * [x] Quadrangle * [x] Tretrahedron * [x] Hexahedron - * [ ] Mixed + * [x] Mixed + * [ ] ... * Field: * Center on: * [x] Node @@ -56,9 +58,9 @@ Is a library to read and write partitioned FEM meshes taking advantage of the co * [x] Character data * HDF5: * [ ] Manage Files - * [ ] Groups - * [ ] DataSpaces - * [ ] DataSets + * [x] Groups + * [x] DataSpaces + * [x] DataSets * [x] HyperSlabs ### Exporters: @@ -71,7 +73,8 @@ Is a library to read and write partitioned FEM meshes taking advantage of the co * [x] Quadrangle * [x] Tretrahedron * [x] Hexahedron - * [ ] Mixed + * [x] Mixed + * [ ] ... * Field: * Center on: * [x] Node @@ -98,7 +101,7 @@ Is a library to read and write partitioned FEM meshes taking advantage of the co * [x] Character data * HDF5: * [ ] Manage Files - * [ ] Groups + * [x] Groups * [x] DataSpaces * [x] DataSets * [x] HyperSlabs -- GitLab