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
****(3)
fortran-lang intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | dim (3fortran) | April 28, 2024 |