enumerate_blk_sizes Subroutine

public subroutine enumerate_blk_sizes(blk_sizes, max_size, enum, rev_enum)

Enumerate all occurring blocksizes

Arguments

Type IntentOptional Attributes Name
integer, DIMENSION(:), POINTER, CONTIGUOUS :: blk_sizes
integer, intent(in) :: max_size
integer, DIMENSION(:), POINTER, CONTIGUOUS :: enum
integer, DIMENSION(:), POINTER, CONTIGUOUS :: rev_enum

Source Code

   SUBROUTINE enumerate_blk_sizes(blk_sizes, max_size, enum, rev_enum)
      !! Enumerate all occurring blocksizes
      INTEGER, DIMENSION(:), POINTER, CONTIGUOUS         :: blk_sizes
      INTEGER, INTENT(IN)                                :: max_size
      INTEGER, DIMENSION(:), POINTER, CONTIGUOUS         :: enum, rev_enum

      CHARACTER(len=*), PARAMETER :: routineN = 'enumerate_blk_sizes'

      INTEGER                                            :: handle, i, n

      CALL timeset(routineN, handle)

      ALLOCATE (enum(0:max_size))
      enum(:) = 0

      DO i = 1, SIZE(blk_sizes)
         enum(blk_sizes(i)) = 1
      END DO

      n = SUM(enum)
      ALLOCATE (rev_enum(n))

      n = 0
      DO i = 0, SIZE(enum) - 1
         IF (enum(i) > 0) THEN
            n = n + 1
            enum(i) = n
            rev_enum(n) = i
         END IF
      END DO

      CALL timestop(handle)

   END SUBROUTINE enumerate_blk_sizes