print_vector Subroutine

public subroutine print_vector(this, filename)

Arguments

Type IntentOptional Attributes Name
real(kind=dp) :: this(:)
character(len=*), intent(in), optional :: filename

Contents

Source Code


Source Code

    subroutine print_vector(this, filename)
        ! Just prints a vector (useful for debug)
        ! General routine, does not require global data

        real(dp) :: this(:)
        character(len=*), intent(in), optional :: filename
        integer :: length
        integer :: i, iunit

        length = size(this, 1)
        iunit = get_free_unit()
        if (present(filename)) open(iunit, file=filename)
        do i = 1, length
            if (present(filename)) then
                write(iunit, *) i, this(i)
            else
                write(stdout, *) i, this(i)
            end if
        end do
        if (present(filename)) close(iunit)

    end subroutine print_vector