dbcsr_work_operations Module

DBCSR work matrix utilities



Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: moduleN = 'dbcsr_work_operations'
logical, private, parameter :: careful_mod = .FALSE.

Interfaces

public interface dbcsr_create

  • private subroutine dbcsr_create_new(matrix, name, dist, matrix_type, row_blk_size, col_blk_size, row_blk_size_obj, col_blk_size_obj, nze, data_type, data_buffer, data_memory_type, index_memory_type, max_rbs, max_cbs, row_blk_offset, col_blk_offset, thread_dist, reuse, reuse_arrays, mutable_work, make_index, replication_type)

    Creates a matrix, allocating the essentials.

    The matrix itself is allocated, as well as the essential parts of the index. When passed the nze argument, the data is also allocated to that size. see dbcsr_types.F

    Arguments

    Type IntentOptional Attributes Name
    type(dbcsr_type), intent(inout) :: matrix

    new matrix

    character(len=*), intent(in) :: name
    type(dbcsr_distribution_obj), intent(in) :: dist

    distribution_2d distribution

    character(len=1), intent(in) :: matrix_type

    'N' for normal, 'T' for transposed, 'S' for symmetric, and 'A' for antisymmetric

    integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: row_blk_size
    integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: col_blk_size
    type(array_i1d_obj), intent(in), optional :: row_blk_size_obj
    type(array_i1d_obj), intent(in), optional :: col_blk_size_obj
    integer, intent(in), optional :: nze

    number of elements type of data from 'rRcC' for single/double precision real/complex, default is 'R'

    integer, intent(in), optional :: data_type

    number of elements type of data from 'rRcC' for single/double precision real/complex, default is 'R'

    type(dbcsr_data_obj), intent(in), optional :: data_buffer
    type(dbcsr_memtype_type), intent(in), optional :: data_memory_type

    allocate indices and data using special memory allocate indices using special memory

    type(dbcsr_memtype_type), intent(in), optional :: index_memory_type

    allocate indices and data using special memory allocate indices using special memory

    integer, intent(in), optional :: max_rbs
    integer, intent(in), optional :: max_cbs
    type(array_i1d_obj), intent(in), optional :: row_blk_offset
    type(array_i1d_obj), intent(in), optional :: col_blk_offset
    type(dbcsr_distribution_obj), intent(in), optional :: thread_dist
    logical, intent(in), optional :: reuse

    reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

    logical, intent(in), optional :: reuse_arrays

    reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

    logical, intent(in), optional :: mutable_work

    reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

    logical, intent(in), optional :: make_index

    reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

    character(len=1), intent(in), optional :: replication_type

    replication to be used for this matrix; default is dbcsr_repl_none

  • private subroutine dbcsr_create_template(matrix, template, name, dist, matrix_type, row_blk_size, col_blk_size, row_blk_size_obj, col_blk_size_obj, nze, data_type, data_buffer, data_memory_type, index_memory_type, max_rbs, max_cbs, row_blk_offset, col_blk_offset, reuse_arrays, mutable_work, make_index, replication_type)

    Arguments

    Type IntentOptional Attributes Name
    type(dbcsr_type), intent(inout) :: matrix
    type(dbcsr_type), intent(in) :: template
    character(len=*), intent(in), optional :: name
    type(dbcsr_distribution_obj), intent(in), optional :: dist
    character(len=1), intent(in), optional :: matrix_type
    integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: row_blk_size
    integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: col_blk_size
    type(array_i1d_obj), intent(in), optional :: row_blk_size_obj
    type(array_i1d_obj), intent(in), optional :: col_blk_size_obj
    integer, intent(in), optional :: nze
    integer, intent(in), optional :: data_type
    type(dbcsr_data_obj), intent(in), optional :: data_buffer
    type(dbcsr_memtype_type), intent(in), optional :: data_memory_type
    type(dbcsr_memtype_type), intent(in), optional :: index_memory_type
    integer, intent(in), optional :: max_rbs
    integer, intent(in), optional :: max_cbs
    type(array_i1d_obj), intent(in), optional :: row_blk_offset
    type(array_i1d_obj), intent(in), optional :: col_blk_offset
    logical, intent(in), optional :: reuse_arrays
    logical, intent(in), optional :: mutable_work
    logical, intent(in), optional :: make_index
    character(len=1), intent(in), optional :: replication_type

Derived Types

type, private ::  i_array_p

Components

Type Visibility Attributes Name Initial
integer, public, DIMENSION(:), POINTER, CONTIGUOUS :: p

Functions

private function can_quickly_finalize(matrix) result(quick)

Checks whether the matrix can be finalized with minimal copying.

Arguments

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

matrix to check

Return Value logical

whether matrix can be quickly finalized

private pure function within_limits(row, column, limits)

Checks whether a point is within bounds \return whether the point is within the bounds

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: row

point to check point to check

integer, intent(in) :: column

point to check point to check

integer, intent(in), DIMENSION(4) :: limits

limits (low_row, high_row, low_col, high_col)

Return Value logical


Subroutines

private subroutine dbcsr_create_new(matrix, name, dist, matrix_type, row_blk_size, col_blk_size, row_blk_size_obj, col_blk_size_obj, nze, data_type, data_buffer, data_memory_type, index_memory_type, max_rbs, max_cbs, row_blk_offset, col_blk_offset, thread_dist, reuse, reuse_arrays, mutable_work, make_index, replication_type)

Creates a matrix, allocating the essentials.

Read more…

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

new matrix

character(len=*), intent(in) :: name
type(dbcsr_distribution_obj), intent(in) :: dist

distribution_2d distribution

character(len=1), intent(in) :: matrix_type

'N' for normal, 'T' for transposed, 'S' for symmetric, and 'A' for antisymmetric

integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: row_blk_size
integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: col_blk_size
type(array_i1d_obj), intent(in), optional :: row_blk_size_obj
type(array_i1d_obj), intent(in), optional :: col_blk_size_obj
integer, intent(in), optional :: nze

number of elements type of data from 'rRcC' for single/double precision real/complex, default is 'R'

integer, intent(in), optional :: data_type

number of elements type of data from 'rRcC' for single/double precision real/complex, default is 'R'

type(dbcsr_data_obj), intent(in), optional :: data_buffer
type(dbcsr_memtype_type), intent(in), optional :: data_memory_type

allocate indices and data using special memory allocate indices using special memory

type(dbcsr_memtype_type), intent(in), optional :: index_memory_type

allocate indices and data using special memory allocate indices using special memory

integer, intent(in), optional :: max_rbs
integer, intent(in), optional :: max_cbs
type(array_i1d_obj), intent(in), optional :: row_blk_offset
type(array_i1d_obj), intent(in), optional :: col_blk_offset
type(dbcsr_distribution_obj), intent(in), optional :: thread_dist
logical, intent(in), optional :: reuse

reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

logical, intent(in), optional :: reuse_arrays

reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

logical, intent(in), optional :: mutable_work

reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

logical, intent(in), optional :: make_index

reuses an existing matrix, default is to create a fresh one uses the mutable data for working and not the append-only data; default is append-only

character(len=1), intent(in), optional :: replication_type

replication to be used for this matrix; default is dbcsr_repl_none

private subroutine dbcsr_create_template(matrix, template, name, dist, matrix_type, row_blk_size, col_blk_size, row_blk_size_obj, col_blk_size_obj, nze, data_type, data_buffer, data_memory_type, index_memory_type, max_rbs, max_cbs, row_blk_offset, col_blk_offset, reuse_arrays, mutable_work, make_index, replication_type)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix
type(dbcsr_type), intent(in) :: template
character(len=*), intent(in), optional :: name
type(dbcsr_distribution_obj), intent(in), optional :: dist
character(len=1), intent(in), optional :: matrix_type
integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: row_blk_size
integer, intent(inout), optional, DIMENSION(:), POINTER, CONTIGUOUS :: col_blk_size
type(array_i1d_obj), intent(in), optional :: row_blk_size_obj
type(array_i1d_obj), intent(in), optional :: col_blk_size_obj
integer, intent(in), optional :: nze
integer, intent(in), optional :: data_type
type(dbcsr_data_obj), intent(in), optional :: data_buffer
type(dbcsr_memtype_type), intent(in), optional :: data_memory_type
type(dbcsr_memtype_type), intent(in), optional :: index_memory_type
integer, intent(in), optional :: max_rbs
integer, intent(in), optional :: max_cbs
type(array_i1d_obj), intent(in), optional :: row_blk_offset
type(array_i1d_obj), intent(in), optional :: col_blk_offset
logical, intent(in), optional :: reuse_arrays
logical, intent(in), optional :: mutable_work
logical, intent(in), optional :: make_index
character(len=1), intent(in), optional :: replication_type

private subroutine dbcsr_init_wm(wm, data_type, nblks_guess, sizedata_guess, memory_type)

Initializes one work matrix

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(out) :: wm

initialized work matrix

integer, intent(in) :: data_type
integer, intent(in), optional :: nblks_guess

estimated number of blocks estimated size of data

integer, intent(in), optional :: sizedata_guess

estimated number of blocks estimated size of data

type(dbcsr_memtype_type), intent(in), optional :: memory_type

public subroutine dbcsr_work_create(matrix, nblks_guess, sizedata_guess, n, work_mutable, memory_type)

Creates a the working matrix(es) for a DBCSR matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

new matrix

integer, intent(in), optional :: nblks_guess

estimated number of blocks estimated size of data number work matrices to create, default is 1

integer, intent(in), optional :: sizedata_guess

estimated number of blocks estimated size of data number work matrices to create, default is 1

integer, intent(in), optional :: n

estimated number of blocks estimated size of data number work matrices to create, default is 1

logical, intent(in), optional :: work_mutable

use mutable work type, default is what was specified in create

type(dbcsr_memtype_type), intent(in), optional :: memory_type

public subroutine dbcsr_finalize(matrix, reshuffle)

Creates the final dbcsr_type matrix from the working matrix. Work matrices (array or tree-based) are merged into the base DBCSR matrix. If a matrix is marked as having a valid index, then nothing is done. Deleted blocks are pruned from the index.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

final matrix

logical, intent(in), optional :: reshuffle

whether the data should be reshuffled, default is false

public subroutine dbcsr_special_finalize(matrix, reshuffle)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix
logical, intent(in), optional :: reshuffle

private subroutine quick_finalize(matrix)

Performs quick finalization of matrix The data area from the work matrix is accepted as the new matrix's data area and the index is built from the work matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

matrix to finalize

public subroutine dbcsr_add_wm_from_matrix(matrix, limits)

Creates a work matrix from the data present in a finalized matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

DBCSR matrix

integer, intent(in), optional, DIMENSION(4) :: limits

the limits to use for copying

private subroutine dbcsr_fill_wm_from_matrix(wm, matrix, size_used, limits)

Fills index and data of the work matrix from the previously-finalized one.

Read more…

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout), DIMENSION(:) :: wm

the work matrix to fill

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

DBCSR matrix

integer, intent(in) :: size_used
integer, intent(in), optional, DIMENSION(4) :: limits

only fills blocks within this range

public subroutine dbcsr_work_destroy(wm)

Deallocates and destroys a work matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: wm

work matrix

private subroutine dbcsr_work_destroy_all(m)

Deallocates and destroys a work matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: m

public subroutine add_work_coordinate(matrix, row, col, blk, index)

Adds a coordinate (or other data) into a work matrix's row_i and col_i arrays and returns its position.

Read more…

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: matrix

work matrix

integer, intent(in) :: row

row data to add col data to add

integer, intent(in) :: col

row data to add col data to add

integer, intent(in), optional :: blk

block pointer to add

integer, intent(out), optional :: index

saved position

private subroutine dbcsr_merge_all(matrix, old_row_p, old_col_i, old_blk_p, sort_data)

Merge data from matrix and work matrices into the final matrix.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

matrix to work on

integer, intent(in), DIMENSION(*) :: old_row_p
integer, intent(in), DIMENSION(*) :: old_col_i
integer, intent(in), DIMENSION(*) :: old_blk_p
logical, intent(in) :: sort_data

whether data will be fully sorted

private subroutine dbcsr_merge_single_wm(matrix)

Sort data from the WM into the final matrix, based closely on dbcsr_merge_all

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix

matrix to work on

private subroutine merge_index(new_row_p, new_col_i, new_blk_p, blk_d, old_row_p, old_col_i, old_blk_p, all_row_p, all_col_i, all_blk_p, all_data_offsets, nwms, nrows, max_row_count, sort_data)

Builds a new index from several work matrices.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), DIMENSION(*) :: new_row_p
integer, intent(out), DIMENSION(*), TARGET :: new_col_i
integer, intent(out), DIMENSION(*), TARGET :: new_blk_p
integer, intent(in), DIMENSION(*), TARGET :: blk_d
integer, intent(in), DIMENSION(*) :: old_row_p
integer, intent(in), DIMENSION(*) :: old_col_i
integer, intent(in), DIMENSION(*) :: old_blk_p
type(i_array_p), intent(in), DIMENSION(*) :: all_row_p
type(i_array_p), intent(in), DIMENSION(*) :: all_col_i
type(i_array_p), intent(in), DIMENSION(*) :: all_blk_p
integer, intent(in), DIMENSION(*) :: all_data_offsets
integer, intent(in) :: nwms
integer, intent(in) :: nrows
integer, intent(in) :: max_row_count
logical, intent(in) :: sort_data

private subroutine tree_to_linear_d(wm)

Converts mutable data to linear (array) type.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: wm

work matrix to convert

private subroutine tree_to_linear_s(wm)

Converts mutable data to linear (array) type.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: wm

work matrix to convert

private subroutine tree_to_linear_z(wm)

Converts mutable data to linear (array) type.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: wm

work matrix to convert

private subroutine tree_to_linear_c(wm)

Converts mutable data to linear (array) type.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_work_type), intent(inout) :: wm

work matrix to convert