SUM intrinsic function
Standard: F77 F90 F95 F2003
 Example Program
<Syntax>
SUM ( ARRAY, DIM [ , MASK ] )
SUM ( ARRAY [ , MASK ] )

ARRAY : rank N array of type Integer, Real or Complex;
DIM : scalar Integer in the range 1 to N;
MASK : array of type Logical with the same shape as ARRAY;

Result: Same type and kind as ARRAY.
<Semantics>
The result is ARRAY reduced by addition ( + ). If DIM is absent, this is a scalar equal to the sum of all the masked elements of ARRAY. If DIM is present, the result has rank N-1 and the shape of ARRAY with dimension DIM removed; each element of the result is the sum of the masked elements in that dimension.

If no elements contribute to a result value, that value is zero.
<Related>
Array-array operations, Array-scalar operations, ALL intrinsic function, ANY intrinsic function, COUNT intrinsic function, IALL intrinsic function, IANY intrinsic function, IPARITY intrinsic function, MAXLOC intrinsic function, MAXVAL intrinsic function, MINLOC intrinsic function, MINVAL intrinsic function, PARITY intrinsic function, PRODUCT intrinsic function, Reduction intrinsic functions