File: where_07.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 (55 lines) | stat: -rw-r--r-- 1,123 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
program where_07
   implicit none

   integer :: call_num

   logical(4), dimension(4) :: l

   l = [.true., .false., .true., .false.]
   call_num = 1

   ! neqv operator
   where (l .neqv. .true.)
      l = .true.
   end where

   print *, l
   IF (all(l .neqv. [.true., .true., .true., .true.])) ERROR STOP

   ! or operator
   where (l .or. .false.)
      l = get_boolean_false()
   end where

   print *, l
   IF (all(l .neqv. [.false., .true., .false., .true.])) ERROR STOP

   ! and operator
   where (l .and. get_boolean_true())
      l = .false.
   end where

   print *, l
   IF (all(l .neqv. [.false., .false., .false., .false.])) ERROR STOP

   ! eqv operator
   where (l .eqv. get_boolean_false())
      l = .true.
   end where

   print *, l
   IF (all(l .neqv. [.true., .false., .true., .true.])) ERROR STOP

contains

   pure logical function get_boolean_true() result(value)
      implicit none
      value = .true.
   end function get_boolean_true

   pure logical function get_boolean_false() result(value)
      implicit none
      value = .false.
   end function get_boolean_false

end program where_07