43 INTEGER :: extent,entry_num
49 INTEGER :: num_entries = 0
82 INTEGER,
OPTIONAL,
INTENT(IN) :: n
86 print *,
"ERROR in CreateMArray_compound: n should be larger than 0" 104 CLASS(marray_compound),
INTENT(INOUT) :: this
106 TYPE(compound_item),
POINTER :: p
110 CALL this%marray_base%AssignPointers()
113 p => this%FirstItem()
116 DO WHILE (
ASSOCIATED(p))
120 p%item%data1d(1:n) => this%data1d(m+1:m+n)
122 CALL p%item%AssignPointers()
123 p => this%NextItem(p)
131 CLASS(marray_compound),
INTENT(INOUT) :: this
132 CLASS(marray_base),
INTENT(IN) :: ma
134 TYPE(compound_item),
POINTER :: p
136 CALL this%marray_base%AssignMArray_0(ma)
137 SELECT TYPE(src => ma)
140 IF (.NOT.
ASSOCIATED(p).OR.src%num_entries.LT.1)
THEN 144 IF (.NOT.
ASSOCIATED(this%list))
THEN 149 CALL this%AppendItem(p%item)
150 IF (
ASSOCIATED(p%next))
THEN 157 CALL this%AssignPointers()
160 IF (src%num_entries.NE.this%num_entries)
THEN 161 print *,
"ERROR in marray_compound::AssignMArray_0: src%num_entries != dest%num_entries" 179 CLASS(marray_compound),
INTENT(INOUT) :: this
180 TYPE(marray_base),
POINTER :: ma
183 REAL,
DIMENSION(:),
POINTER,
CONTIGUOUS :: data1d
185 IF (.NOT.(
ASSOCIATED(ma%data1d).AND.
ASSOCIATED(this%data1d)))
THEN 186 print *,
"ERROR in marray_compound::AppendMArray: at least one of this%data1d,ma%data1d is not associated" 190 SELECT CASE(this%RANK)
192 this%DIMS(1) = this%DIMS(1) + ma%DIMS(1)*ma%DIMS(2)
199 IF (this%DIMS(1).NE.ma%DIMS(1))
THEN 200 print *,
"ERROR in marray_compound::AppendMArray: this%dims(1) != ma%dims(1)" 204 this%DIMS(2) = this%DIMS(2) + ma%DIMS(2)
210 IF (
ASSOCIATED(this%data1d))
THEN 211 m =
SIZE(this%data1d(:))
212 IF (m.EQ.0)
DEALLOCATE(this%data1d)
217 n =
SIZE(ma%data1d(:))
219 ALLOCATE(data1d(m+n),stat=err)
221 print *,
"ERROR in marray_compound::AppendMArray: memory allocation failed" 225 data1d(1:m) = this%data1d(1:m)
226 data1d(m+1:m+n) = ma%data1d(1:n)
228 CALL this%AppendItem(ma)
230 DEALLOCATE(ma%data1d,this%data1d)
232 this%data1d(1:) => data1d(1:)
235 this%data1d(1:) => ma%data1d(1:)
237 CALL this%AppendItem(ma)
240 CALL this%AssignPointers()
267 FUNCTION lastitem(this)
RESULT(item)
274 IF (.NOT.
ASSOCIATED(item))
RETURN 275 DO WHILE (
ASSOCIATED(item%next))
281 FUNCTION nextitem(this,item)
RESULT(next)
287 IF (
ASSOCIATED(item))
THEN 295 FUNCTION getitem(this,list_entry)
RESULT(ma)
302 ma => list_entry%item
309 CLASS(marray_compound) :: this
310 TYPE(marray_base),
POINTER :: ma
312 TYPE(compound_item),
POINTER :: p
315 IF (
ASSOCIATED(ma).AND.
ASSOCIATED(ma%data1d).AND.
SIZE(ma%data1d).GT.0)
THEN 317 IF (.NOT.
ASSOCIATED(p))
THEN 319 ALLOCATE(this%list,stat=err)
325 ALLOCATE(p%next,stat=err)
328 this%num_entries = this%num_entries + 1
332 p%extent =
SIZE(ma%data1d)
333 p%entry_num = this%num_entries
340 print *,
"ERROR in marray_compound::AppendItem: memory allocation failed" 350 CLASS(marray_compound) :: this
352 TYPE(compound_item),
POINTER :: p,q
355 p => this%FirstItem()
356 DO WHILE (
ASSOCIATED(p))
358 p => this%NextItem(p)
362 CALL this%marray_base%Destroy()
subroutine appendmarray(this, ma)
subroutine assignpointers(this)
assign pointers of different shapes to the 1D data
subroutine abortonerror()
derived class for compound of mesh arrays
base class for mesh arrays
subroutine appenditem(this, ma)
append an item to the list of compound elements
type(marray_base) function, pointer getitem(this, list_entry)
get pointer to the mesh array from a given item
subroutine destroy(this)
deconstructor of the mesh array
type(compound_item) function, pointer firstitem(this)
get the first item from the list of compound elements
type(compound_item) function, pointer nextitem(this, item)
get the next item from the list of compound elements
type(marray_compound) function createmarray_compound(n)
constructor for compound of mesh arrays
type(compound_item) function, pointer lastitem(this)
get the last item from the list of compound elements
subroutine assignmarray_0(this, ma)
assigns one mesh array to another mesh array