44 integer,
intent(IN) :: dims, memoryOffset
45 integer, dimension(
1:dims),
intent(IN) :: arrayLBound, arrayUBound
46 integer, dimension(
1:dims),
intent(OUT) :: elementCoord
48 integer, dimension(
1:dims) :: elementCount, elementsToNextIndicy
49 integer :: i, j, memoryOffsetRemainder
52 elementsToNextIndicy(
1)
= 1
54 elementsToNextIndicy(i)
= elementsToNextIndicy(i
-1)
* (arrayUbound(i
-1)
- arrayLbound(i
-1)
+ 1)
57 memoryOffsetRemainder
= memoryOffset
59 elementCount(j)
= (memoryOffsetRemainder
/ elementsToNextIndicy(j))
60 memoryOffsetRemainder
= memoryOffsetRemainder
- (elementCount(j)
* elementsToNextIndicy(j))
62 elementCount(
1)
= memoryOffsetRemainder
67 if (elementCount(i)
> (arrayUbound(i)
- arrayLbound(i)
+ 1))
then
68 print *,
"[ConvertToArrayIndicies]: Invalid data passed!"
75 elementCoord(
1:dims)
= elementCount(
1:dims)
+ arrayLBound(
1:dims)
subroutine ut_convertToArrayIndicies(dims, memoryOffset, arrayLBound, arrayUBound, elementCoord)