get_internal_offsets Subroutine

public subroutine get_internal_offsets(blk_local_els, el_map, blk_el_offsets, dense_el_offsets, internal_offsets)

Finds internal offsets For all local blocks in blk_local_els, it calculates its offset in the dense block to which it belongs.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), DIMENSION(:) :: blk_local_els
integer, intent(in), DIMENSION(:) :: el_map
integer, intent(in), DIMENSION(:) :: blk_el_offsets
integer, intent(in), DIMENSION(:) :: dense_el_offsets
integer, intent(out), DIMENSION(:) :: internal_offsets

Source Code

   SUBROUTINE get_internal_offsets(blk_local_els, el_map, blk_el_offsets, &
                                   dense_el_offsets, internal_offsets)
      !! Finds internal offsets
      !! For all local blocks in blk_local_els, it calculates its offset in
      !! the dense block to which it belongs.

      INTEGER, DIMENSION(:), INTENT(IN)                  :: blk_local_els, el_map, blk_el_offsets, &
                                                            dense_el_offsets
      INTEGER, DIMENSION(:), INTENT(OUT)                 :: internal_offsets

      INTEGER                                            :: blk_el, d_el, i, ndense, nlblk
      INTEGER, ALLOCATABLE, DIMENSION(:)                 :: off_acc

!   ---------------------------------------------------------------------------

      nlblk = SIZE(blk_local_els)
      ndense = SIZE(dense_el_offsets)
      ALLOCATE (off_acc(ndense))
      off_acc(:) = 0
      internal_offsets(:) = 0
      DO i = 1, nlblk
         blk_el = blk_local_els(i)
         d_el = el_map(blk_el)
         internal_offsets(blk_el) = off_acc(d_el)
         off_acc(d_el) = off_acc(d_el) + blk_el_offsets(blk_el + 1) - blk_el_offsets(blk_el)
      END DO
      DEALLOCATE (off_acc)
   END SUBROUTINE get_internal_offsets