File: where_03.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (38 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
subroutine where_03
    implicit none
    real a(4)
    real b(4)
    
    a = (/ 1.0, 2.0, 3.0, 4.0/)
    b = (/ -1.0, -2.0, 5.0, 7.0/)
    where (a > b) 
        a = 1.0
    endwhere
    
    where(a == 1.0)
        a = 2.0
    else where(a == 2.0)
        b = 3.0
    else where
        a = b * 2.0 / a * 3.0
    endwhere

    if (abs(a(1) - 2.0) > 1e-7  ) error stop
    if (abs(a(2) - 2.0) > 1e-7  ) error stop
    if (abs(a(3) - 10.0) > 1e-7  ) error stop
    if (abs(a(4) - 10.5) > 1e-7  ) error stop

    if (abs(b(1) - (-1.0)) > 1e-7  ) error stop
    if (abs(b(2) - (-2.0)) > 1e-7  ) error stop
    if (abs(b(3) - 5.0) > 1e-7  ) error stop
    if (abs(b(4) - 7.0) > 1e-7  ) error stop

    print *, a
    print *, b


end subroutine

program main
call where_03
end program