next up previous
Next: Subroutines to redistribute data Up: Archetype implementation Previous: Program skeleton

Subroutines and functions

The archetype supplies many subroutines and functions: to perform the needed collective communication operations, to perform reduction operations, to aid in managing global and local indices, etc.

In current implementations, these routines are provided as source file mesh_lib.FM (for Fortran M) or mesh_lib.F (for other versions). Comment headers in the source file provide a detailed specification for each routine, in the form of a precondition (what must hold before the routine is called) and a postcondition (what will hold after the routine completes). The remainder of this section lists the available routines by category and comments on suggested usage.

CAUTION: Care must be taken to ensure that the host process and the grid processes coordinate properly, because some subroutines (those for moving data to and from the host process and those for performing global reductions) must be executed by all processes in order to function correctly. One way to ensure this is to give the two programs (host and grid) the same overall structure, differentiating between them only when necessary. For example, in a program with a time-step loop, the grid program might look like this:

        do m = 1, NSTEPS
C               local computation
                call mesh_update_bdry(mydata)
                do i = 1, NXlocal
                do j = 1, NYlocal
                do k = 1, NZlocal
                        .... computation ....
                enddo
                enddo
                enddo
C               move to host and print
                call mesh_GtoH_grid(mydata)
C               (no printing in grid process)
        enddo

while the host program would look like this:

        do m = 1, NSTEPS
C               local computation
C               (no computation in host process)
C               move to host and print
                call mesh_GtoH_host(mydata_host)
                .... print ....
        enddo





Berna L Massingill
Mon Jun 8 19:35:58 PDT 1998