B.4.6 COUNT_Scalar Procedure

The main documentation of the COUNT_Scalar Procedure contains additional explanation of this code listing.

  function COUNT_Scalar (L)

    ! Input variable.

    type(logical), intent(in) :: L

    ! Output variable.

    type(integer) :: COUNT_Scalar

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! COUNT_Scalar is equal to the number of trues in L, 
    ! so it is 1 if L is true, 0 if L is false.

    if (L) then
      COUNT_Scalar = 1
    else
      COUNT_Scalar = 0
    end if

    return
  end function COUNT_Scalar



Michael L. Hall