bool(3f) - [M_overload::LOGICAL] returns One if expression is TRUE, else returns Zero. (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
pure elemental integer function bool(expr)
logical,intent(in) :: expr
bool(3f) returns an integer 1 given a true logical expression.
expr A logical expression
The result is a default INTEGER value of 1 if the expression is TRUE, and a 0 otherwise.
Sample usage:
program demo_oz use M_overload, only: bool, zo, lt, le, eq, ne, gt, ge implicit none write (*, *) is 10 < 20 ?, bool(10 < 20) write (*, *) elemental, bool([2 > 1, 3 == 4, 10 < 5, 100 > 50]) if (sum(bool([2 > 1, 3 == 4, 10 < 5, 100 > 50])) >= 2) then write (*, *) two or more are true endif end program demo_ozResults:
> is 10 < 20 ? 1 > elemental 1 0 0 1 > two or more are true
John S. Urban
Public Domain
Nemo Release 3.1 | bool (3) | February 23, 2025 |