HELPLIB.HLB  —  FORTRAN  Intrinsic Procedures, SUM
  SUM (array [,dim] [,mask])

  Class:  Transformational function - Generic

  Returns the sum of all the elements in an entire array or in a
  specified dimension of an array.

  The "array" can be of integer or real type.  The "dim" is optional
  and must be a scalar integer with a value in the range 1 to n,
  where "n" is the rank of "array".  The "mask" is optional and must
  be a logical array that is conformable with "array".

  The result is the same data type as "array".  The result is a
  scalar if "dim" is absent or "array" has rank one.  Otherwise, the
  result is an array with rank that is one less than "array", and
  shape (d1, d2,..., d"dim"-1, d"dim"+1,..., dn), where (d1, d2,...,
  dn) is the shape of "array".

  If only "array" appears, the result is the sum of all elements of
  "array".  If "array" has size zero, the result is zero.

  If "array" and "mask" both appear, the result is the sum of all
  elements of "array" corresponding to true elements of "mask".  If
  "array" has size zero, or every element of "mask" has the value
  .FALSE., the result is zero.

  If "dim" also appears and "array" has rank one, the value is the
  same as SUM (array [,mask=mask]).  Otherwise, the value of element
  (s1, s2,..., s"dim"-1, s"dim"+1,..., sn) of SUM (array, dim,
  [,mask]) is equal to SUM (array (s1, s2,..., s"dim"-1, :, s"dim"+1,
  ..., sn)) [mask=mask (s1, s2, ..., s"dim"-1, :, s "dim"+1 ...,
  sn)].

  Examples:

  SUM ((/2, 3, 4/)) and SUM ((/2, 3, 4/), DIM=1) returns the value 9.

  SUM (B, MASK=B .LT.  0.0) returns the arithmetic sum of the
  negative elements of B.

  Consider that C is the array:

   |1 2 3|
   |4 5 6|.

  SUM (C, DIM=1) returns the value (5, 7, 9).

  SUM (C, DIM=2) returns the value (6, 15).
Close Help