Skip to content

Commit 82eaa90

Browse files
committed
C_BOOL logical interface demo
1 parent d8c9889 commit 82eaa90

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

test/bool/main.f90

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@ logical(C_BOOL) function logical_not(a) bind(C)
1111
end function
1212
end interface
1313

14-
logical(C_BOOL) :: t, f
14+
logical(C_BOOL) :: tc, fc
15+
logical :: t0, f0, t1, f1
16+
!! show there's no warnings
1517

1618
logical :: true_f, false_f
1719

18-
t = .true.
19-
f = .false.
20+
t0 = .true.
21+
f0 = .false.
22+
tc = t0
23+
fc = f0
24+
t1 = tc
25+
f1 = fc
2026

21-
false_f = logical_not(t)
22-
true_f = logical_not(f)
27+
if (.not. t1) error stop "logical(C_BOOL) .true. should be .true."
28+
if (.not. t1 .eqv. t0) error stop "logical(C_BOOL) .true. should EQV .true."
29+
if (f1) error stop "logical(C_BOOL) .false. should be .false."
30+
if(.not. f1 .eqv. f0) error stop "logical(C_BOOL) .false. should EQV .false."
31+
32+
false_f = logical_not(tc)
33+
true_f = logical_not(fc)
2334

2435
if (false_f) error stop "logical_not(.true.) should be .false."
2536
if (.not. true_f) error stop "logical_not(.false.) should be .true."

0 commit comments

Comments
 (0)