File: where_01.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (36 lines) | stat: -rw-r--r-- 487 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
25
26
27
28
29
30
31
32
33
34
35
36
program where_01
implicit none
integer :: a(10), b(10), i
a = -2
a(1) = 1
a(5) = 8
b = -3
where (a >= 0)
    b = 1
else where
    b = 0
end where

where (a >= 0)
    b = 1
elsewhere
    b = 0
end where

where (a >= 0)
    b = 1
elsewhere
    b = 0
endwhere

if (abs(b(1) - 1) > 1e-6) error stop
if (abs(b(5) - 1) > 1e-6) error stop
do i = 2, 4
    if (abs(b(i) - 0) > 1e-6) error stop
end do
do i = 6, 10
    if (abs(b(i) - 0) > 1e-6) error stop
end do
print *, b
print *, a
end program