Chapter 3. Examining Loops for Fortran 90 Code

This chapter presents an interactive tutorial using the Fortran 90 compiler. It illustrates how the MIPSpro auto-parallelizing compiler transforms Fortran 90 arrays into loops.

Analyzing a Fortran 90 program is very similar to analyzing a Fortran 77 program. See the previous chapter for reference information that applies to both compilers.

This chapter describes the following:

Setting Up the Sample Session

Before starting this sample session, make sure ProMP.sw.demos is installed. The sample session uses the source file f90_tutorial_f90_orig in the directory /usr/demos/ProMP/f90_tutorial. The file Makefile compiles the source file.

The source file contains array statements, each of which exemplifies an aspect of the parallelization process.

Compiling the Sample Code

Prepare for the session by entering the following in a shell window:

% cd /usr/demos/ProMP/f90_tutorial
% make

This creates the following files:


A copy of the demonstration program created by copying f90_tutorial.f90_orig


A transformed source file, which you can view with the Parallel Analyzer View and print


A listing file


An analysis file used by the Parallel Analyzer View

For more information about these files, see the MIPSpro Auto-Parallelizing Option Programmer's Guide.

Starting the Parallel Analyzer View

Once you have created the files, start the session by entering the cvpav(1) command. The command opens the main window of the Parallel Analyzer View and loads the sample file data.

% cvpav -f f90_tutorial.f90

Open the Source View window by clicking the Source button once the main window opens.

Demonstrating Array Statement Transformations

This section demonstrates the following transformations:

Transforming an Array Statement into a DO Loop

To continue the tutorial begun in the last section, go to loop 5 in the Parallel Analyzer View window and double-click the highlighted line in the loop list. First double-click the Source button, and then double-click the Transformed Source button.

Notice in the Transformed Source window that the following array statement has been transformed into a DO loop:

logical*1 l(12),r,r1

l = .true.

The Transformed Loops View window (see Figure 3-1) identifies line 40 from the source as a Fortran 90 array statement. It notes that a loop was generated but indicates that the loop array statement was not made parallel because it contains too little work.

Figure 3-1. Array Statement into DO Loop

Transforming an Array Statement in Nested DO Loops

Pull down the Show All Loop Types menu and click on Show Fortran 90 Array Stmts. Only the Fortran 90 arrays statements that were transformed into DO loops are displayed.

The following is the array statement in the source:

logical*8 l(3,12)
l = .true.

Because the array has two dimensions, two nested DO loops are generated. Double-click first on loop 22, then on loop 23. They are the two new loops generated from the array statement. The Transformed Loops View window gives information on each loop. (See Figure 3-2 for loop 22 and Figure 3-3 for loop 23.)

Figure 3-2. Loop 22

Figure 3-3. Loop 23

Transforming an Array Statement into a Subroutine

Click on loop 26. Notice in the Transformed Source window how the following sliced array statement is transformed into an OMP PARALLEL DO statement, which will itself be converted into a subroutine:

r(:il*2:2) = all(l,id)

The Transformed Loops View (see Figure 3-4) shows the process of converting first to a parallel loop and then to a subroutine:

Figure 3-4. Array Statement into a Subroutine

Exiting From the Session

This completes the session. Quit the Parallel Analyzer View by choosing Admin > Exit and close any windows that may still be open.

To clean up the directory so that the session can be rerun, enter the following in your shell window:

% make clean