File: where_15.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 (31 lines) | stat: -rw-r--r-- 492 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
program where_15
implicit none

real(4), allocatable :: x0(:)
real(4), allocatable :: xl(:)
real(4), allocatable :: xu(:)
real(4) :: rhobeg

rhobeg = 1.0

allocate(x0(5), xl(5), xu(5))

xl = 2.0
xu = 3.0

where (x0 <= xl + 0.5 * rhobeg)
    x0 = xl
elsewhere(x0 < xl + rhobeg)
    x0 = xl + rhobeg
end where

where (x0 >= xu - 0.5 * rhobeg)
    x0 = xu
elsewhere(x0 > xu - rhobeg)
    x0 = xu - rhobeg
end where

print *, x0
if( any(x0 /= [2.0, 2.0, 2.0, 2.0, 2.0]) ) error stop

end program