print_plain_matrix Subroutine

private subroutine print_plain_matrix(mat, n_cols, n_rows)

private subroutine that prints a plain matrix of n_cols by n_rows

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: mat(:,:)
integer(kind=default_int), intent(in), optional :: n_cols
integer(kind=default_int), intent(in), optional :: n_rows

Called by

proc~~print_plain_matrix~~CalledByGraph proc~print_plain_matrix print_plain_matrix proc~print_matrix print_matrix proc~print_matrix->proc~print_plain_matrix proc~print_matrix_m_n print_matrix_m_n proc~print_matrix_m_n->proc~print_plain_matrix interface~print_array print_array interface~print_array->proc~print_matrix interface~print_array_with_bounds print_array_with_bounds interface~print_array_with_bounds->proc~print_matrix_m_n

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: i
integer(kind=default_int), private :: j
integer(kind=default_int), private :: loop_bound_i
integer(kind=default_int), private :: loop_bound_j

Source Code

   subroutine print_plain_matrix(mat, n_cols, n_rows)
    !! private subroutine that prints a plain matrix of n_cols by n_rows
      real(kind=dp), intent(in) :: mat(:, :)
      integer(kind=default_int), intent(in), optional :: n_cols, n_rows
      integer(kind=default_int) :: i, j, loop_bound_i, loop_bound_j
      if (present(n_cols) .and. present(n_rows)) then
         loop_bound_i = n_cols
         loop_bound_j = n_rows
      else
         loop_bound_i = size(mat, 1)
         loop_bound_j = size(mat, 2)
      end if
      print *, "Matrix (Plain format):"
      do i = 1, loop_bound_i
         do j = 1, loop_bound_j
            if (j == loop_bound_j) then
               write (*, fmt_edge, advance="yes") mat(i, j)  ! Last element in the row, new line
            else
               write (*, fmt_in, advance="no") mat(i, j)  ! In-between elements
            end if
         end do
      end do
   end subroutine print_plain_matrix