sparse_lMat_t Derived Type

type, public, extends(lMat_t) :: sparse_lMat_t

Implementation for sparsely stored 6-index objects


Components

Type Visibility Attributes Name Initial
procedure(lMatInd_t), public, nopass, pointer :: indexFunc => lMatIndSym
type(shared_array_real_t), private :: nonzero_vals
type(index_rhash_t), private :: htable

Type-Bound Procedures

procedure, public :: read

  • private subroutine read(this, filename)

    Read in the 6-index integrals from disk and histogram the integrals. The file itself only has to store the nonzero integrals, either in ASCII or in HDF5 format. For conventions in the HDF5 format, please refer to the developer’s guide.

    Arguments

    Type IntentOptional Attributes Name
    class(lMat_t), intent(inout) :: this
    character(len=*), intent(in) :: filename

    name of the integrals file

procedure, public :: lMat_size

  • private function lMat_size(this) result(size)

    Return the max. index appearing in this lMat_t (i.e. the number of 6-index integrals)

    Arguments

    Type IntentOptional Attributes Name
    class(lMat_t), intent(in) :: this

    Return Value integer(kind=int64)

procedure, public :: histogram_lMat

  • private subroutine histogram_lMat(this)

    Generate a histogram of the 6-index integrals and write it to stdout

    Arguments

    Type IntentOptional Attributes Name
    class(lMat_t), intent(in) :: this

procedure, public :: get_elem => get_elem_sparse

  • private function get_elem_sparse(this, index) result(element)

    Retrieve an element from the 6-index integrals stored in sparse format

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(in) :: this
    integer(kind=int64), intent(in) :: index

    contiguous index of the element to be retrieved

    Return Value real(kind=dp)

procedure, private :: set_elem => set_elem_sparse

  • private subroutine set_elem_sparse(this, index, element)

    Set an element to the sparsely stored 6-index integrals. This requires the hash table to be set up and CANNOT be done once htable%finalize_setup has been called

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: index

    contiguous index of the element (not the one in the sparse array)

    real(kind=dp), intent(in) :: element

    new value of the element

procedure, public :: alloc => alloc_sparse

  • private subroutine alloc_sparse(this, size)

    Allocate memory for the sparse storage of the 6-index integrals

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: size

    number of non-zero integrals

procedure, public :: safe_dealloc => dealloc_sparse

  • private subroutine dealloc_sparse(this)

    Deallocate memory used for the sparse storage of the 6-index integrals

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this

procedure, private :: read_kernel => read_sparse

  • private subroutine read_sparse(this, filename)

    Read the 6-index integrals from a file to sparse format

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    character(len=*), intent(in) :: filename

    name of the file to read from

procedure, private :: read_op_hdf5 => read_op_sparse

  • private subroutine read_op_sparse(this, indices, entries)

    This is the operation to be performed for sparse storage on each block of data read from an hdf5 file both arguments may or may not be still allocated upon return.

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    integer(kind=int64), intent(inout), allocatable :: indices(:,:)
    integer(kind=int64), intent(inout), allocatable :: entries(:,:)

procedure, private :: read_data

  • private subroutine read_data(this, indices, entries)

    Add the (combined) indices and the corresponding integral values to the sparse storage

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: indices(:)
    integer(kind=int64), intent(in) :: entries(:)

procedure, private :: count_conflicts

  • private subroutine count_conflicts(this, indices)

    Loop through a chunk of indices and count the number of hash conflicts. This is required for setting up the hash table

    Arguments

    Type IntentOptional Attributes Name
    class(sparse_lMat_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: indices(:)

Source Code

    type, extends(lMat_t) :: sparse_lMat_t
        private
        ! The values of the nonzero integrals
#ifdef CMPLX_
        type(shared_array_cmplx_t) :: nonzero_vals
#else
        type(shared_array_real_t) :: nonzero_vals
#endif
        ! read-only shared memory hash table
        type(index_rhash_t) :: htable
    contains
        ! Element getters/setters
        procedure :: get_elem => get_elem_sparse
        procedure, private :: set_elem => set_elem_sparse

        ! Allocation routines
        procedure :: alloc => alloc_sparse
        procedure :: safe_dealloc => dealloc_sparse

        ! I/O routines
        procedure, private :: read_kernel => read_sparse
        procedure, private :: read_op_hdf5 => read_op_sparse

        ! These are auxiliary internal I/O routines
        procedure, private :: read_data
        procedure, private :: count_conflicts
    end type sparse_lMat_t