make_undense_index Subroutine

public subroutine make_undense_index(row_p, col_i, blk_p, distribution, local_row_offsets, local_col_offsets, meta)

Makes a blocked index from a dense matrix

Note

Used for making matrices dense/undense

Arguments

Type IntentOptional Attributes Name
integer, intent(out), DIMENSION(:) :: row_p

Storage for new index Storage for new index Storage for new index

integer, intent(out), DIMENSION(:) :: col_i

Storage for new index Storage for new index Storage for new index

integer, intent(out), DIMENSION(:) :: blk_p

Storage for new index Storage for new index Storage for new index

type(dbcsr_distribution_obj) :: distribution

Blocked distribution

integer, intent(in), DIMENSION(:) :: local_row_offsets
integer, intent(in), DIMENSION(:) :: local_col_offsets
integer, intent(inout), DIMENSION(dbcsr_meta_size) :: meta

Metadata updates for new index


Source Code

   SUBROUTINE make_undense_index( &
      row_p, col_i, blk_p, &
      distribution, local_row_offsets, local_col_offsets, &
      meta)
      !! Makes a blocked index from a dense matrix
      !! @note Used for making matrices dense/undense

      INTEGER, DIMENSION(:), INTENT(OUT)                 :: row_p, col_i, blk_p
         !! Storage for new index
         !! Storage for new index
         !! Storage for new index
      TYPE(dbcsr_distribution_obj)                       :: distribution
         !! Blocked distribution
      INTEGER, DIMENSION(:), INTENT(IN)                  :: local_row_offsets, local_col_offsets
      INTEGER, DIMENSION(dbcsr_meta_size), INTENT(INOUT) :: meta
         !! Metadata updates for new index

      INTEGER                                            :: col, lr, lrow, nblkcols_local, &
                                                            nblkrows_local, nblkrows_total, &
                                                            nfullcols_local, prev_row, row
      INTEGER, DIMENSION(:), POINTER                     :: local_cols, local_rows

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

      local_cols => dbcsr_distribution_local_cols(distribution)
      local_rows => dbcsr_distribution_local_rows(distribution)
      meta(dbcsr_slot_nblkrows_total) = dbcsr_distribution_nrows(distribution)
      meta(dbcsr_slot_nblkcols_total) = dbcsr_distribution_ncols(distribution)
      meta(dbcsr_slot_nblkrows_local) = dbcsr_distribution_nlocal_rows(distribution)
      meta(dbcsr_slot_nblkcols_local) = dbcsr_distribution_nlocal_cols(distribution)
      nblkrows_total = meta(dbcsr_slot_nblkrows_total)
      nblkcols_local = meta(dbcsr_slot_nblkcols_local)
      nblkrows_local = meta(dbcsr_slot_nblkrows_local)
      nfullcols_local = meta(dbcsr_slot_nfullcols_local)
      ! Fill the row_p array.
      lr = 0
      row_p(1) = 0
      prev_row = 1
      DO lrow = 1, nblkrows_local
         row = local_rows(lrow)
         row_p(prev_row + 1:row) = lr
         lr = lr + nblkcols_local
         row_p(row + 1) = lr
         prev_row = row
      END DO
      row_p(prev_row + 1:nblkrows_total + 1) = lr
      !
      DO row = 1, nblkrows_local
         DO col = 1, nblkcols_local
            col_i(nblkcols_local*(row - 1) + col) = local_cols(col)
            blk_p(nblkcols_local*(row - 1) + col) = 1 + &
                                                    (local_row_offsets(row) - 1)*nfullcols_local &
                                                    + (local_col_offsets(col) - 1)* &
                                                    (local_row_offsets(row + 1) - local_row_offsets(row))
         END DO
      END DO
   END SUBROUTINE make_undense_index