Manual Reference Pages  - ceiling (3fortran)

NAME

CEILING(3) - [NUMERIC] Integer ceiling function

SYNOPSIS

result = ceiling(a [,kind])

         elemental integer(KIND) function ceiling(a,KIND)

real(kind=**),intent(in) :: a integer,intent(in),optional :: KIND

CHARACTERISTICS

o ** a is of type real
o KIND shall be a scalar integer constant expression. It specifies the kind of the result if present.
o the result is integer. It is default kind if KIND is not specified

DESCRIPTION

CEILING(3) returns the least integer greater than or equal to A.

On the number line -n <-- 0 -> +n the value returned is always at or to the right of the input value.

OPTIONS

o A : A real value to produce a ceiling for.
o KIND : indicates the kind parameter of the result.

RESULT

The result will be the integer value equal to A or the least integer greater than A if the input value is not equal to a whole number.

If A is equal to a whole number, the returned value is INT(A).

The result is undefined if it cannot be represented in the specified integer type.

EXAMPLES

Sample program:

    program demo_ceiling
    implicit none
    ! just a convenient format for a list of integers
    character(len=*),parameter :: ints=’(*("   > ",5(i0:,",",1x),/))’
    real :: x
    real :: y
      ! basic usage
       x = 63.29
       y = -63.59
       print ints, ceiling(x)
       print ints, ceiling(y)
       ! note the result was the next integer larger to the right

! real values equal to whole numbers x = 63.0 y = -63.0 print ints, ceiling(x) print ints, ceiling(y)

! elemental (so an array argument is allowed) print ints , & & ceiling([ & & -2.7, -2.5, -2.2, -2.0, -1.5, & & -1.0, -0.5, 0.0, +0.5, +1.0, & & +1.5, +2.0, +2.2, +2.5, +2.7 ])

end program demo_ceiling

Results:

       > 64
       > -63
       > 63
       > -63
       > -2, -2, -2, -2, -1,
       > -1, 0, 0, 1, 1,
       > 2, 2, 3, 3, 3

STANDARD

Fortran 95

SEE ALSO

FLOOR(3), NINT(3)

AINT(3), ANINT(3), INT(3), SELECTED_INT_KIND(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 ceiling (3fortran) April 28, 2024
Generated by manServer 1.08 from 9edbd800-ecb1-4c51-b43f-1b9f26960d46 using man macros.