Manual Reference Pages  - dim (3fortran)

NAME

DIM(3) - [NUMERIC] Positive difference of X - Y

SYNOPSIS

result = dim(x, y)

         elemental TYPE(kind=KIND) function dim(x, y )

TYPE(kind=KIND),intent(in) :: x, y

CHARACTERISTICS

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

DESCRIPTION

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)

OPTIONS

o X : the subtrahend, ie. the number being subtracted from.
o Y : the minuend; ie. the number being subtracted

RESULT

Returns the difference X - Y or zero, whichever is larger.

EXAMPLES

Sample program:

    program demo_dim
    use, intrinsic :: iso_fortran_env, only : real64
    implicit none
    integer           :: i
    real(kind=real64) :: x

! 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

Results:

     >            0
     >    3.21000000000000
     >            0           0           1
     >            0           0           2
     >            0           0          10

STANDARD

FORTRAN 77

SEE ALSO

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
Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 dim (3fortran) November 02, 2024
Generated by manServer 1.08 from 775e58d6-fd53-4bf7-ac45-f4395b301a28 using man macros.