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
|
program main
implicit none
logical, parameter :: x1(2) = [.true., .false.]
! parameter variable != logical constant
print *, x1 .neqv. .true.
if (all((x1 .neqv. .true.) .neqv. [.false., .true.])) error stop
! logical array constant == logical array constant
print *, [.false., .true.] .eqv. [.false., .true.]
if (all(([.false., .true.] .eqv. [.false., .true.]) .neqv. [.true., .true.])) error stop
! parameter variable != function returning logical constant
print *, x1 .neqv. get_true()
if (all((x1 .neqv. get_true()) .neqv. [.false., .true.])) error stop
! logical constant == parameter variable
print *, .true. .eqv. x1
if (all((.true. .eqv. x1) .neqv. [.true., .false.])) error stop
! parameter variable and logical constant
print *, x1 .and. .false.
if (all((x1 .and. .false.) .neqv. [.false., .false.])) error stop
! logical constant or parameter variable
print *, .false. .or. x1
if (all((.false. .or. x1) .neqv. [.true., .false.])) error stop
! logical expression or logical constant
print *, 1 > 2 .or. x1
if (all((1 > 2 .or. x1) .neqv. [.true., .false.])) error stop
! logical expression or logical constant
print *, ((1 + 2) > 2) .or. x1
if (all((((1 + 2) > 2) .or. x1) .neqv. [.true., .true.])) error stop
! logical expression or logical constant
print *, ((1 + 2) == 3) .or. x1
if (all((((1 + 2) == 3) .or. x1) .neqv. [.true., .true.])) error stop
! logical expression or logical constant
print *, ((1 + 2) == 3) .or. x1
if (all((((1 + 2) == 3) .or. x1) .neqv. [.true., .true.])) error stop
contains
logical function get_true() result(value)
value = .true.
end function get_true
end program main
|