Skip to content

Commit 58459e6

Browse files
committed
doc [skip ci]
1 parent 10b857a commit 58459e6

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ The examples "array", "malloc", "vector" show distinct ways to send arrays to/fr
7878

7979
### bool
8080

81-
Made workaround for
8281
[nvfortran](https://forums.developer.nvidia.com/t/nvfortran-c-bool-bind-c-not-improper-value/291896)
83-
not yet supporting F2018 standard.
84-
In general, one needs to check that `logical(C_BOOL)` works as expected on the compiler because pre-Fortran 2018, the C_BOOL type was compiler-dependent.
85-
86-
Thanks, I see this in these discussions too.
82+
supports F2018 standard `C_BOOL` if `nvfortran -Munixlogical` is used.
8783

8884
* [ifort might return an incorrect C_BOOL .true. in iso_c_binding - Intel Community](https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-might-return-an-incorrect-C-BOOL-true-in-iso-c-binding/m-p/999050)
8985
* [Internal representation of LOGICAL variables (The GNU Fortran Compiler](https://gcc.gnu.org/onlinedocs/gfortran/Internal-representation-of-LOGICAL-variables.html#Internal-representation-of-LOGICAL-variables)
@@ -94,6 +90,39 @@ Thanks, I see this in these discussions too.
9490
* https://info.ornl.gov/sites/publications/Files/Pub158443.pdf Section 3.1.2
9591
* https://shroud.readthedocs.io/_/downloads/en/latest/pdf/ section 11.4
9692

93+
> The logical constants .TRUE. and .FALSE. are defined to be the four-byte values -1 and 0 respectively.
94+
A logical expression is defined to be .TRUE. if its least significant bit is 1 and .FALSE. otherwise.
95+
96+
Example output, Fortran interfacing with C or C++
97+
98+
* Intel oneAPI 2023 without `-fpscomp logical`
99+
* NVHPC 2023.5 without `-Munixlogical`
100+
101+
```
102+
logical_not(T): F
103+
storage_size() bits hex(in) hex(out)
104+
C_BOOL: 8 1 FE
105+
logical_not(true) should be false: 1
106+
107+
logical_not(F): T
108+
storage_size() bits hex(in) hex(out)
109+
C_BOOL: 8 0 FF
110+
```
111+
112+
* Intel oneAPI 2023 with `-fpscomp logical`
113+
* NVHPC 2023.5 with `-Munixlogical`
114+
115+
```
116+
logical_not(T): F
117+
storage_size() bits hex(in) hex(out)
118+
C_BOOL: 8 1 0
119+
120+
logical_not(F): T
121+
storage_size() bits hex(in) hex(out)
122+
C_BOOL: 8 0 1
123+
OK: boolean-logical not
124+
```
125+
97126
### Error handling
98127

99128
Using Fortran statement "stop" or "error stop" with a C/C++ main program works like with a Fortran main program.

src/bool/logbool.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ logical(c_bool) function logical_not(L) bind(C)
1010

1111
logical(c_bool), intent(in), value :: L
1212

13-
!! The logical constants .TRUE. and .FALSE. are defined to be the four-byte values -1 and 0 respectively.
14-
!! A logical expression is defined to be .TRUE. if its least significant bit is 1 and .FALSE. otherwise.
15-
1613
logical_not = .not. L
1714

1815
print '(/, a, l1, a, l1)', "logical_not(", L, "): ", logical_not

0 commit comments

Comments
 (0)