dbcsr_make_dense_low Subroutine

public subroutine dbcsr_make_dense_low(und_matrix, dense_matrix, und_local_rows, und_local_cols, und_row_blk_offsets, und_col_blk_offsets, dense_local_rows, dense_local_cols, dense_row_blk_offsets, dense_col_blk_offsets, row_map, col_map, join_rows, join_cols)

Copies a matrix and makes its data dense.

Note

the dense_matrix must have been created

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(in) :: und_matrix

Original non-dense matrix

type(dbcsr_type), intent(inout) :: dense_matrix

Dense copy of und_matrix

integer, intent(in), DIMENSION(:) :: und_local_rows

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: und_local_cols

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: und_row_blk_offsets

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: und_col_blk_offsets

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: dense_local_rows

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: dense_local_cols

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: dense_row_blk_offsets

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: dense_col_blk_offsets

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: row_map

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

integer, intent(in), DIMENSION(:) :: col_map

The process-grid local rows of the non-dense und_matrix The process-grid local columns of the non-dense und_matrix The block offsets of the rows of the non-dense matrix The block offsets of the columns of the non-dense matrix The process-grid local rows of the dense matrix The process-grid local columns of the dense matrix The block offsets of the rows of the dense matrix The block offsets of the columns of the dense matrix Mapping of non-dense rows to dense rows Mapping of non-dense columns to dense columns

logical, intent(in) :: join_rows

Make rows dense Make columns dense

logical, intent(in) :: join_cols

Make rows dense Make columns dense


Source Code

   SUBROUTINE dbcsr_make_dense_low(und_matrix, dense_matrix, &
                                   und_local_rows, und_local_cols, &
                                   und_row_blk_offsets, und_col_blk_offsets, &
                                   dense_local_rows, dense_local_cols, &
                                   dense_row_blk_offsets, dense_col_blk_offsets, &
                                   row_map, col_map, join_rows, join_cols)
      !! Copies a matrix and makes its data dense.
      !! @note the dense_matrix must have been created

      TYPE(dbcsr_type), INTENT(IN)                       :: und_matrix
         !! Original non-dense matrix
      TYPE(dbcsr_type), INTENT(INOUT)                    :: dense_matrix
         !! Dense copy of und_matrix
      INTEGER, DIMENSION(:), INTENT(IN) :: und_local_rows, und_local_cols, und_row_blk_offsets, &
                                           und_col_blk_offsets, dense_local_rows, dense_local_cols, dense_row_blk_offsets, &
                                           dense_col_blk_offsets, row_map, col_map
         !! The process-grid local rows of the non-dense und_matrix
         !! The process-grid local columns of the non-dense und_matrix
         !! The block offsets of the rows of the non-dense matrix
         !! The block offsets of the columns of the non-dense matrix
         !! The process-grid local rows of the dense matrix
         !! The process-grid local columns of the dense matrix
         !! The block offsets of the rows of the dense matrix
         !! The block offsets of the columns of the dense matrix
         !! Mapping of non-dense rows to dense rows
         !! Mapping of non-dense columns to dense columns
      LOGICAL, INTENT(IN)                                :: join_rows, join_cols
         !! Make rows dense
         !! Make columns dense

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

      INTEGER :: dense_nblkcols_local, dense_nblkcols_total, dense_nblkrows_local, &
                 dense_nblkrows_total, dense_nlocal_blocks, error_handle, nfullcols, nfullrows, &
                 und_nblkcols_total, und_nblkrows_total
      INTEGER, ALLOCATABLE, DIMENSION(:) :: col_internal_offsets, dense_local_col_blk_offsets, &
                                            dense_local_row_blk_offsets, row_internal_offsets, und_local_col_blk_offsets, &
                                            und_local_row_blk_offsets
      INTEGER, DIMENSION(dbcsr_meta_size)                :: meta
      TYPE(dbcsr_data_obj)                               :: dense_data, und_data

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

      CALL timeset(routineN, error_handle)
      !
      nfullrows = nfull_elements(und_row_blk_offsets, und_local_rows)
      nfullcols = nfull_elements(und_col_blk_offsets, und_local_cols)
      !
      und_nblkrows_total = SIZE(und_row_blk_offsets) - 1
      und_nblkcols_total = SIZE(und_col_blk_offsets) - 1
      !
      ! Find the local data offsets (but indexed by the global
      ! rows/columns) for the undense data.
      ALLOCATE (und_local_row_blk_offsets(und_nblkrows_total + 1))
      ALLOCATE (und_local_col_blk_offsets(und_nblkcols_total + 1))
      CALL global_offsets_to_local( &
         und_row_blk_offsets, &
         und_local_rows, &
         und_local_row_blk_offsets)
      CALL global_offsets_to_local( &
         und_col_blk_offsets, &
         und_local_cols, &
         und_local_col_blk_offsets)
      !
      dense_nblkrows_total = SIZE(dense_row_blk_offsets) - 1
      dense_nblkcols_total = SIZE(dense_col_blk_offsets) - 1
      dense_nblkrows_local = SIZE(dense_local_rows)
      dense_nblkcols_local = SIZE(dense_local_cols)
      !
      ! Find the local data offsets (but indexed by the (dense) global
      ! rows/columns) for the dense data.
      ALLOCATE (dense_local_row_blk_offsets(dense_nblkrows_total + 1))
      ALLOCATE (dense_local_col_blk_offsets(dense_nblkcols_total + 1))
      CALL global_offsets_to_local( &
         dense_row_blk_offsets, &
         dense_local_rows, &
         dense_local_row_blk_offsets)
      CALL global_offsets_to_local( &
         dense_col_blk_offsets, &
         dense_local_cols, &
         dense_local_col_blk_offsets)
      ! Find the offset of blocks within dense rows/columns.  This is needed
      ! since the blocked rows/columns are not necessarily in the same order.
      ALLOCATE (row_internal_offsets(und_nblkrows_total))
      ALLOCATE (col_internal_offsets(und_nblkcols_total))
      CALL get_internal_offsets( &
         und_local_rows, row_map, &
         und_local_row_blk_offsets, &
         dense_local_row_blk_offsets, &
         row_internal_offsets)
      CALL get_internal_offsets( &
         und_local_cols, col_map, &
         und_local_col_blk_offsets, &
         dense_local_col_blk_offsets, &
         col_internal_offsets)
      !
      und_data = und_matrix%data_area
      CALL dbcsr_data_hold(und_data)
      CALL dbcsr_data_init(dense_data)
      CALL dbcsr_data_new(dense_data, dbcsr_data_get_type(und_data), &
                          data_size=nfullrows*nfullcols, &
                          memory_type=dbcsr_data_get_memory_type(und_data))
      !
      ! Reshuffle the data
      CALL make_dense_data(und_matrix, &
                           dense_data, nfullrows, nfullcols, &
                           und_local_row_blk_offsets, und_local_col_blk_offsets, &
                           dense_local_row_blk_offsets, dense_local_col_blk_offsets, &
                           row_map=row_map, col_map=col_map, &
                           row_internal_offsets=row_internal_offsets, &
                           col_internal_offsets=col_internal_offsets, &
                           join_rows=join_rows, join_cols=join_cols, make_tr=.FALSE.)
      CALL dbcsr_switch_data_area(dense_matrix, dense_data)
      CALL dbcsr_data_release(dense_data)
      CALL dbcsr_data_release(und_data)
      !
      ! Create the new dense index.
      dense_nlocal_blocks = dense_nblkrows_local*dense_nblkcols_local
      CALL dbcsr_addto_index_array(dense_matrix, &
                                   dbcsr_slot_row_p, &
                                   reservation=dense_nblkrows_total + 1, extra=2*dense_nlocal_blocks)
      CALL dbcsr_addto_index_array(dense_matrix, &
                                   dbcsr_slot_col_i, &
                                   reservation=dense_nlocal_blocks)
      CALL dbcsr_addto_index_array(dense_matrix, &
                                   dbcsr_slot_blk_p, &
                                   reservation=dense_nlocal_blocks)
      !
      meta = dense_matrix%index(1:dbcsr_meta_size)
      CALL dbcsr_pack_meta(dense_matrix, meta)
      meta(dbcsr_slot_nze) = nfullrows*nfullcols
      meta(dbcsr_slot_nblks) = dense_nlocal_blocks
      CALL make_dense_index(dense_matrix%row_p, &
                            dense_matrix%col_i, &
                            dense_matrix%blk_p, &
                            dense_nblkrows_total, dense_nblkcols_total, &
                            dense_local_rows, &
                            dense_local_cols, &
                            dense_local_row_blk_offsets, &
                            dense_local_col_blk_offsets, &
                            make_tr=.FALSE., &
                            meta=meta)
      CALL dbcsr_unpack_meta(dense_matrix, meta)
      !
      DEALLOCATE (und_local_row_blk_offsets)
      DEALLOCATE (und_local_col_blk_offsets)
      DEALLOCATE (dense_local_row_blk_offsets)
      DEALLOCATE (dense_local_col_blk_offsets)
      DEALLOCATE (row_internal_offsets)
      DEALLOCATE (col_internal_offsets)
      !
      CALL timestop(error_handle)
   END SUBROUTINE dbcsr_make_dense_low