CEILING(3) - [NUMERIC] Integer ceiling function
result = ceiling(a [,kind])
elemental integer(KIND) function ceiling(a,KIND)real(kind=**),intent(in) :: a integer,intent(in),optional :: KIND
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
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.
o A : A real value to produce a ceiling for. o KIND : indicates the kind parameter of the 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.
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 rightResults:! 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
> 64 > -63 > 63 > -63 > -2, -2, -2, -2, -1, > -1, 0, 0, 1, 1, > 2, 2, 3, 3, 3
Fortran 95
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 |