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

****(3)

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


Nemo Release 3.1 dim (3fortran) April 28, 2024
Generated by manServer 1.08 from 47a2f611-1c3e-4ce7-a5ad-bf7f02ed08b2 using man macros.