print a matrix of values
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | matrix(:,:) | |||
| character(len=*), | intent(in), | optional | :: | format_type | ||
| type(error_t), | intent(inout), | optional | :: | err |
set to ERROR_VALIDATION for an unsupported format_type; the matrix is printed with NumPy brackets regardless |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=20), | private | :: | print_format |
subroutine print_matrix_sp(matrix, format_type, err) !! print a matrix of ${T} values real(sp), intent(in) :: matrix(:, :) character(len=*), intent(in), optional :: format_type type(error_t), intent(inout), optional :: err !! set to ERROR_VALIDATION for an unsupported format_type; the matrix !! is printed with NumPy brackets regardless character(len=20) :: print_format print_format = pic_optional(format_type, default_format) print: block character(len=1) :: open_bracket, close_bracket integer(default_int) :: i, j, rows, cols rows = size(matrix, 1) cols = size(matrix, 2) call set_brackets(print_format, open_bracket, close_bracket, err) print *, open_bracket do i = 1, rows write (*, "(A)", advance="no") open_bracket do j = 1, cols if (j == cols) then ! Last element in the row write (*, fmt_edge, advance="no") to_char(matrix(i, j)) else ! Elements in between write (*, fmt_in, advance="no") to_char(matrix(i, j)) end if end do if (i == rows) then print *, close_bracket else print *, close_bracket, "," end if end do print *, close_bracket end block print end subroutine print_matrix_sp