dim

Date:

10-12-2011

NAME

DIM, DDIM, IDIM, IIDIM, JIDIM, KIDIM - Compute positive difference of two numbers

SYNOPSIS

DIM ([X=]x,[Y=]y)
DDIM ([X=]x,[Y=]y)
IDIM ([X=]x,[Y=]y)
IIDIM ([X=]x,[Y=]y)
JIDIM ([X=]x,[Y=]y)
KIDIM ([X=]x,[Y=]y)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

Fortran extensions: IIDIM, JIDIM, KIDIM

DESCRIPTION

DIM is the generic function name; the others are specifics. These are elemental intrinsic functions that accept the following arguments:

x

Must be of type integer or real.

y

Must be of the same type and kind type as x.

These functions solve for:

R = x1 - x2, if x1 > x2.

R = 0, if x1 <= x2.

NOTES

The DIM, IDIM, and DDIM intrinsic function names can be passed as arguments; the others cannot.

RETURN VALUES

DIM evaluates two real numbers and subtracts them. The result is a real positive difference.

DDIM evaluates two double-precision real numbers and subtracts them. The result is a double-precision real positive difference.

IDIM evaluates two integers and subtracts them. The result is an integer positive difference.

IIDIM evaluates two integer (KIND=2) numbers and subtracts them. The result is an integer (KIND=2) positive difference.

JIDIM evaluates two integer (KIND=4) numbers and subtracts them. The result is an integer (KIND=4) positive difference.

KIDIM evaluates two integer (KIND=8) numbers and subtracts them. The result is an integer (KIND=8) positive difference.

EXAMPLES

The following program shows the use of IDIM to compute the positive difference between the integers 77 and 10:

   PROGRAM DIMTEST
   INTEGER A,B,C,D,E
   A = 77
   B = 10
   C = IDIM(A,B)
   WRITE 1,A,B,C
1  FORMAT(I2,'POSITIVE DIFFERENCE ',I2,' EQUALS ', I2)
   D = IDIM(B,A)
   WRITE 2,B,A,D
2  FORMAT(I2,'POSITIVE DIFFERENCE ',I2,' EQUALS ',I2)
   STOP
   END

The example program gives the following output:

77 POSITIVE DIFFERENCE 10 EQUALS 67
10 POSITIVE DIFFERENCE 77 EQUALS  0