SPMODEL: A Series of Hierarchical Spectral Models for GFD << Prev | Index| Next >>

2. Array operation features of Fortran90

In this section, we briefly introduce the array operation features, the most important features among those of Fortran90 used in the SPMODEL. As for the detailed and strict description of the other features enhanced in Fortran90, please refer to other more appropriate language reference manuals (ex. [3]).

2.1. Array operation

Compared to FORTRAN77, functions of array operation are enhanced in Fortran90. One of the features is that we can omit specifying indices of arrays when performing the same operation on every element of the arrays. In FORTRAN77, however, we must specify the indices of arrays for each case . Below is a simple example.

The following FORTRAN77 statements,

! FORTRAN 77 style

      REAL*8    A(10,10), B(10,10), C(10,10)
      INTEGER   I, J

      ...
      DO 1000 J=1,10
          DO 1000 I=1,10
          C(I,J) = A(I,J) + B(I,J)
 1000 CONTINUE

can be rewritten by Fortran90 as follows:

real(8) :: a(10,10), b(10,10), c(10,10)

...
c = a + b

Note that only one line is required to write the array calculation.

A statement similar to the array assignment statement can be used for the intrinsic functions. For example, calculation of exponents for every element in an array must be written in FORTRAN77 program as follows:

! FORTRAN 77 style

       DO 1000 J=1,10
       DO 1000 I=1,10
          B(I,J) = EXP(A(I,J))
  1000 CONTINUE

On the other hand, the Fortran90 program simply performs the same calculation with the following:

b = exp(a)

2.2. User-defined array-valued functions

One of the enhanced features of Fortran90 is that the array-valued functions, which return arrayed values like the intrinsic functions as in the example above, can be defined also by the users. In FORTRAN77 programs, users were only able to define scalar-valued functions.

Furthermore, in the user-defined functions, the following features are available:

By the application of these features, procedures which can be realized only as subroutines in FORTRAN77 can be redefined as array-valued functions in Fortran90.


SPMODEL: A Series of Hierarchical Spectral Models for GFD << Prev | Index| Next >>