next up previous contents index
Next: Declaring Arrays Up: ConstantsVariables, and Arrays Previous: Variables

Arrays

  An array is a group of memory locations given a single name. The elements of the array all have the same data type.

In mathematics the elements of an array a would be denoted by a1, a2, a3, and so on. In Fortran a particular array element is identified by providing a subscript expression in parentheses after the array name: A(1), A(2), A(3), etc. Subscripts must have integer type but they may be specified by expressions of arbitrary complexity, including function calls.

An array element can be used in the same way as a variable in almost all executable statements. Array elements are most often used within loops: typically an integer loop counter selects each element of the array in turn.

 
*Add array OLD to array NEW making array TOTAL 
      PARAMETER (NDATA = 1024) 
      REAL OLD(NDATA), NEW(NDATA), TOTAL(NDATA) 
*...... 
      DO 100, I = 1,NDATA 
          TOTAL(I) = OLD(I) + NEW(I) 
100   CONTINUE



Mario Storti
Wed Nov 4 19:32:56 ART 1998