DIM(3) - [NUMERIC] Positive difference of X - Y
result = dim(x, y)
elemental TYPE(kind=KIND) function dim(x, y )TYPE(kind=KIND),intent(in) :: x, y
o X and Y may be any real or integer but of the same type and kind o the result is of the same type and kind as the arguments
DIM(3) returns the maximum of X - Y and zero. That is, it returns the difference X - Y if the result is positive; otherwise it returns zero. It is equivalent to
max(0,x-y)
o X : the subtrahend, ie. the number being subtracted from. o Y : the minuend; ie. the number being subtracted
Returns the difference X - Y or zero, whichever is larger.
Sample program:
program demo_dim use, intrinsic :: iso_fortran_env, only : real64 implicit none integer :: i real(kind=real64) :: xResults:! basic usage i = dim(4, 15) x = dim(4.321_real64, 1.111_real64) print *, i print *, x
! elemental print *, dim([1,2,3],2) print *, dim([1,2,3],[3,2,1]) print *, dim(-10,[0,-10,-20])
end program demo_dim
> 0 > 3.21000000000000 > 0 0 1 > 0 0 2 > 0 0 10
FORTRAN 77
Fortran intrinsic descriptions (license: MIT) @urbanjost
o ABS(3) - Absolute value o AINT(3) - Truncate toward zero to a whole number o ANINT(3) - Real nearest whole number o CEILING(3) - Integer ceiling function o CONJG(3) - Complex conjugate of a complex value o DIM(3) - Positive difference of X - Y o DPROD(3) - Double precision real product o FLOOR(3) - Function to return largest integral value o MAX(3) - Maximum value of an argument list o MIN(3) - Minimum value of an argument list o MOD(3) - Remainder function o SIGN(3) - Sign copying function
Nemo Release 3.1 | dim (3fortran) | November 02, 2024 |