write_ex_state_data Subroutine

public subroutine write_ex_state_data(niters, nlowdin, lowdin_evals, hamil_matrix, overlap_matrix, spin_matrix, lowdin_spin)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: niters
integer, intent(in) :: nlowdin
real(kind=dp), intent(in) :: lowdin_evals(:,:)
real(kind=dp), intent(in) :: hamil_matrix(:,:)
real(kind=dp), intent(in) :: overlap_matrix(:,:)
real(kind=dp), intent(in), optional :: spin_matrix(:,:)
real(kind=dp), intent(in), optional :: lowdin_spin(:,:)

Contents

Source Code


Source Code

    subroutine write_ex_state_data(niters, nlowdin, lowdin_evals, hamil_matrix, overlap_matrix, spin_matrix, lowdin_spin)

        use SystemData, only: nel
        use util_mod, only: get_free_unit

        integer, intent(in) :: niters
        integer, intent(in) :: nlowdin
        real(dp), intent(in) :: lowdin_evals(:, :)
        real(dp), intent(in) :: hamil_matrix(:, :), overlap_matrix(:, :)
        real(dp), optional, intent(in) :: spin_matrix(:, :), lowdin_spin(:, :)

        integer :: ivec, nvecs
        integer :: temp_unit
        character(len=*), parameter :: filename = "EIGV_DATA"

        temp_unit = get_free_unit()
        open(temp_unit, file=trim(filename), status='old', position='append')

        nvecs = size(lowdin_evals, 1)

        write(temp_unit, '(5X,i9)', advance='no') niters

        do ivec = 1, nlowdin
            write(temp_unit, '(3X,es19.12)', advance='no') lowdin_evals(ivec, nlowdin)
        end do
        do ivec = nlowdin + 1, nvecs
            write(temp_unit, '(12X,"NaN",7X)', advance='no')
        end do

        ! Diagonal energies.
        do ivec = 1, nvecs
            write(temp_unit, '(3X,es19.12)', advance='no') hamil_matrix(ivec, ivec) / overlap_matrix(ivec, ivec)
        end do

        if (present(lowdin_spin)) then
            do ivec = 1, nlowdin
                write(temp_unit, '(3X,es19.12)', advance='no') lowdin_spin(ivec, nlowdin) + (0.75_dp * nel)
            end do
            do ivec = nlowdin + 1, nvecs
                write(temp_unit, '(12X,"NaN",7X)', advance='no')
            end do
        end if

        ! Diagonal spin entries.
        if (present(spin_matrix)) then
            do ivec = 1, nvecs
                write(temp_unit, '(3X,es19.12)', advance='no') spin_matrix(ivec, ivec) / overlap_matrix(ivec, ivec) + (0.75_dp * nel)
            end do
        end if

        close(temp_unit)

    end subroutine write_ex_state_data