zo Function

public pure elemental function zo(expr)

NAME

M_overload(3fm) - [M_overload::LOGICAL] returns Zero if expression is FALSE, else returns One.
(LICENSE:PD)

SYNOPSIS

pure elemental integer function zo(expr)

 logical,intent(in) :: expr

DESCRIPTION

Returns an integer given a logical expression.

OPTIONS

expr  A logical expression

RETURNS

The result is a default INTEGER value of 0 if the expression is TRUE,
and a 1 otherwise.

EXAMPLES

Sample usage:

program demo_zo
use M_overload, only: zo, zo, lt, le, eq, ne, gt, ge
implicit none
write (*, *) zo(10 < 20)
if (sum(zo([1 > 2, 3 == 4, 10 < 5, 100 > 50])) > 2) then
   write (*, *) 'two or more are not true'
endif
end program demo_zo

Results:

>           0
>  two or more are not true

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: expr

Return Value integer


Source Code

pure elemental integer function zo(expr)
! ident_10="@(#) M_strings zo(3f) logical to integer TRUE results in 0 FALSE results in 1"
logical, intent(in) :: expr
   zo = merge(0, 1, expr) ! Zero and One
end function zo