WriteMatrix Subroutine

public subroutine WriteMatrix(mat, matname, tOneLine)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: mat(:,:)
character(len=*), intent(in) :: matname
logical :: tOneLine

Contents

Source Code


Source Code

    subroutine WriteMatrix(mat, matname, tOneLine)
        implicit none
        real(dp), intent(in) :: mat(:, :)
        character(len=*), intent(in) :: matname
        integer :: i, j
        logical :: tOneLine

        write(stdout, *) "Writing out matrix: ", trim(matname)
        write(stdout, "(A,I7,A,I7)") "Size: ", size(mat, 1), " by ", size(mat, 2)
        do i = 1, size(mat, 1)
            do j = 1, size(mat, 2)
                if (tOneLine) then
                    write(stdout, "(G25.10)", advance='no') mat(i, j)
                else
                    write(stdout, "(2I6,G25.10)") i, j, mat(i, j)
                end if
            end do
            write(stdout, *)
        end do
    end subroutine WriteMatrix