sparse_lMat_t Derived Type

type, public, extends(lMat_t) :: sparse_lMat_t

Implementation for sparsely stored 6-index objects


Contents

Source Code


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. @param[in] filename name of the integrals file

    Arguments

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

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) @return size The number of 6-index integrals of this object, depending on the symmetry.

    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 @param[in] index contiguous index of the element to be retrieved @return element value of the element with the given contiguous index

    Arguments

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

    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 @param[in] index contiguous index of the element (not the one in the sparse array) @param[in] element new value of the element

    Arguments

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

procedure, public, :: alloc => alloc_sparse

  • private subroutine alloc_sparse(this, size)

    Allocate memory for the sparse storage of the 6-index integrals @param[in] size number of non-zero integrals

    Arguments

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

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 @param[in] filename name of the file to read from

    Arguments

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

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. @param[in,out] indices chunk of indices read in from the file @param[in,out] entries chunk of corresponding values

    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 @param[in] indices chunk of combined 6-index values @param[in] entries corresponding values of the 6-index integrals

    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 @param[in] indices chunk combined 6-index values for the 6-index integrals

    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