source: LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/utilities/print_matrix.F90 @ 5225

Last change on this file since 5225 was 5185, checked in by abarral, 2 months ago

Replace REPROBUS CPP KEY by logical using handmade wonky wrapper

File size: 1.9 KB
Line 
1module print_matrix_mod
2contains
3  subroutine print_vector(vec, name, unit)
4    use parkind1, only : jprb
5    real(jprb),   intent(in) :: vec(:)
6    character(*), intent(in), optional :: name
7    integer,      intent(in), optional :: unit
8    integer    :: i
9    integer    :: unit_local
10    if (present(unit)) then
11      unit_local = unit
12    else
13      unit_local = 6
14    end if
15    if (present(name)) then
16      write(unit_local,'(a,a,$)') name, '=['
17    end if
18    DO i = 1,size(vec,1)
19       write(unit_local,'(f16.8,$)') vec(i)
20    end do
21    if (present(name)) then
22      write(unit_local,'(a)') ']'
23    else
24      write(unit_local,'(x)')
25    end if
26
27  end subroutine print_vector
28
29  subroutine print_matrix(mat, name, unit)
30    use parkind1, only : jprb
31    real(jprb),   intent(in) :: mat(:,:)
32    character(*), intent(in), optional :: name
33    integer,      intent(in), optional :: unit
34    integer    :: i, j
35    integer    :: unit_local
36    if (present(unit)) then
37      unit_local = unit
38    else
39      unit_local = 6
40    end if
41
42    if (present(name)) then
43      write(unit_local,'(a,a,$)') name, '=['
44    end if
45    DO i = 1,size(mat,1)
46       DO j = 1,size(mat,2)
47          write(unit_local,'(f16.8,$)') mat(i,j)
48       end do
49       if (present(name) .AND. i == size(mat,1)) then
50         write(unit_local,'(a)') ']'
51       else
52         write(unit_local,'(x)')
53       end if
54    end do
55  end subroutine print_matrix
56 
57  subroutine print_array3(name, mat)
58    use parkind1, only : jprb
59    character(*), intent(in) :: name
60    real(jprb),   intent(in) :: mat(:,:,:)
61    integer    :: i, j, k
62    write(6,'(a,a)') name, '='
63    DO k = 1,size(mat,3)
64      DO i = 1,size(mat,1)
65        DO j = 1,size(mat,2)
66             write(6,'(f16.8,$)') mat(i,j,k)
67          end do
68          write(6,'(x)')
69       end do
70       write(6,'(x)')
71    end do
72  end subroutine print_array3
73 
74
75end module print_matrix_mod
Note: See TracBrowser for help on using the repository browser.