previous up next print clean
Next: Bugs Up: THE CONNECTION MACHINE DISCONNECTED Previous: The Frame Buffer

The Fortran Language

CM Fortran is a combination of Fortran 90 (more or less) and some CM-specific pre-compiler commands. One of the first things that I noticed about the Fortran 90 language was the possibility for compact code, which would probably lead to fewer coding errors. As an example from my own code, the Fortran 77 loop structure which I would otherwise need:
      DO j1 = 1,n1
        DO j2 = 1,n2
          DO j3 = 1,n3
            DO j4 = 1,n4
              DO k = 1,24
                huygens(k,j4,j3,j2,j1) = 0.0
              END DO
            END DO
          END DO
        END DO
      END DO
is replaced by the single line statement:
      huygens = 0.0
There is more to Fortran 90 than this, but it indicates some of the flavor.

The pre-compiler directives that are specific to the Connection Machine are much more interesting. Of them all, the most powerful is the LAYOUT directive which for my huygens array looks like this as it is embedded in some declarative code:

      INCLUDE 'param.inc'	! which inputs the values of n1,n2,n3,n4
      REAL, ARRAY (24,n4,n3.n2,n1) :: huygens	
CMF$  LAYOUT huygens (:SERIAL,:NEWS,:NEWS,:NEWS,:NEWS)
What the LAYOUT line does is to define, via NEWS (North,East,West, South), the dimensionality and size of a virtual parallel machine tailored to the problem. There is a virtual processing unit at each of the n1*n2*n3*n4 nodes on this machine, and a 24-vector attached to each node. As defined, the 4-space is a closed space. That is, there are circular boundaries to the four NEWS dimensions. A small restriction on the NEWS dimensions is that they are limited to powers of 2. I find the circular boundaries more of a help than a hindrance. My lattice Boltzmann code occupies about a quarter of the space of my old Fortran 77 code, and took about a tenth of the time to write, and the seemless space was a major contributor to this saving in coding time and code length.

In addition to pre-compiler directives there are also some new functions such as CSHIFT (circular shift), which shifts a multi-dimensional array along one of the dimension directions by a stated amount. CSHIFT can be cascaded, which is useful in my linear lattice Boltzmann code where each of the elements of a 24-vector in a 4-space must be shifted to a different next-nearest neighbour.


previous up next print clean
Next: Bugs Up: THE CONNECTION MACHINE DISCONNECTED Previous: The Frame Buffer
Stanford Exploration Project
12/18/1997