write_ex_state_header Subroutine

public subroutine write_ex_state_header(nvecs, irepeat)

Uses

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nvecs
integer, intent(in) :: irepeat

Contents

Source Code


Source Code

    subroutine write_ex_state_header(nvecs, irepeat)

        use util_mod, only: int_fmt, get_free_unit

        integer, intent(in) :: nvecs, irepeat
        integer :: ivec, icolumn
        integer :: temp_unit
        character(22) :: column_label
        character(len=*), parameter :: filename = "EIGV_DATA"

        temp_unit = get_free_unit()

        if (irepeat == 1) then
            open(temp_unit, file=trim(filename), status='replace')
        else
            open(temp_unit, file=trim(filename), status='old', position='append')
        end if

        ! Write header.
        if (irepeat == 1) then
            ! The number of the column.
            icolumn = 1

            write(temp_unit, '("#",1X,"1. Iteration")', advance='no')

            ! Energy estimates.
            do ivec = 1, nvecs
                icolumn = icolumn + 1
                write(column_label, '('//int_fmt(icolumn, 0)//',".",1X,"Energy",1X,'//int_fmt(ivec, 0)//')') icolumn, ivec
                column_label = adjustr(column_label)
                write(temp_unit, '(a22)', advance='no') column_label
            end do
            do ivec = 1, nvecs
                icolumn = icolumn + 1
                write(column_label, '('//int_fmt(icolumn, 0)//',".",1X,"Diag. energy",1X,'//int_fmt(ivec, 0)//')') icolumn, ivec
                column_label = adjustr(column_label)
                write(temp_unit, '(a22)', advance='no') column_label
            end do

            ! Spin estimates.
            if (tCalcSpin) then
                do ivec = 1, nvecs
                    icolumn = icolumn + 1
                    write(column_label, '('//int_fmt(icolumn, 0)//',".",1X,"Spin^2",1X,'//int_fmt(ivec, 0)//')') icolumn, ivec
                    column_label = adjustr(column_label)
                    write(temp_unit, '(a22)', advance='no') column_label
                end do
                do ivec = 1, nvecs
                    icolumn = icolumn + 1
                    write(column_label, '('//int_fmt(icolumn, 0)//',".",1X,"Diag spin^2",1X,'//int_fmt(ivec, 0)//')') icolumn, ivec
                    column_label = adjustr(column_label)
                    write(temp_unit, '(a22)', advance='no') column_label
                end do
            end if

            write(temp_unit, '()')
        end if

        write(temp_unit, '("#",1X,"Repeat",'//int_fmt(irepeat, 1)//')') irepeat

        close(temp_unit)

    end subroutine write_ex_state_header