C Library Functions  - oz (3)

NAME

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

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

pure elemental integer function oz(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 1 if the expression is TRUE, and a 0 otherwise.

EXAMPLES

Sample usage:

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

Results:

    > is 10 < 20 ? 1
    > elemental 1 0 0 1
    > two or more are true

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 oz (3) July 22, 2023
Generated by manServer 1.08 from 91595da8-67dc-4b1f-950b-f45715951e8c using man macros.