File: array_section_12.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (24 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
program array_section_12
    use, intrinsic :: iso_fortran_env, only: wp => real64
    implicit none
    real(wp) :: default_colors(3, 5)
    real(wp) :: plot_color(3)
    integer :: i

    do i = 1, 5
        default_colors(:, i) = [real(i, wp), real(i + 10, wp), real(i + 20, wp)]
    end do

    call pick_color(default_colors, 4, plot_color)

    if (any(abs(plot_color - [4.0_wp, 14.0_wp, 24.0_wp]) > 1e-12_wp)) error stop
    print *, "PASS"
contains
    subroutine pick_color(colors, idx, out_color)
        real(wp), intent(in) :: colors(:,:)
        integer, intent(in) :: idx
        real(wp), intent(out) :: out_color(3)

        out_color = colors(:, idx)
    end subroutine pick_color
end program array_section_12