readKMatFromFile Subroutine

public subroutine readKMatFromFile(this, filename)

Type Bound

kMat_t

Arguments

Type IntentOptional Attributes Name
class(kMat_t) :: this
character(len=*) :: filename

Contents

Source Code


Source Code

    subroutine readKMatFromFile(this, filename)
        implicit none
        class(kMat_t) :: this
        character(*) :: filename
        integer :: iunit, ierr
        integer :: i, j, k, l
        real(dp) :: matel
        character(*), parameter :: t_r = "readKMatFromFile"

        ! allocate the containers
        call this%setupKMat()

        ! only have root read per node
        if (iProcIndex_intra == 0) then
            ! open the file
            iunit = get_free_unit()
            open(iunit, file=filename, status='old')
            ! read the integrals
            do
                read(iunit, *, iostat=ierr) matel, i, k, j, l
                if (ierr < 0) then
                    exit
                else if (ierr > 0) then
                    call stop_all(t_r, "Error reading KDUMP file")
                else
                    ! store the matrix element
                    this%kMat_p(UMatInd(i, j, k, l)) = matel
                end if
            end do
        end if
    end subroutine readKMatFromFile