D.2 Communication Class Code Listing

The main documentation of the Communication Class contains additional explanation of this code listing.

!
! Author: Michael L. Hall
!         P.O. Box 1663, MS-D413, LANL
!         Los Alamos, NM 87545
!         ph: 505-665-4312
!         email: Hall@LANL.gov
! 
! Created on: 11/09/98
! CVS Info:   $Id: communication.F90,v 7.14 2008/09/29 23:37:00 hall Exp $

module Caesar_Communication_Class

  ! Global use associations.

  use Caesar_Intrinsics_Module
  use Caesar_Trace_Class
  ifdef([USE_PGSLIB],[
    use pgslib_module
  ])
 
  ! Start up with everything untyped and private.

  implicit none
  private

  ! Public procedures.

  public :: Initialize, Finalize, Valid_State
  public :: Abort, Assemble, Broadcast, Distribute, Gather, Global_ALL, &
            Global_ANY, Global_Dot_Product, Global_MaxVal, Global_MinVal, &
            Global_Sum, Output, Output_Test, Parallel_Write, Scatter_AND, &
            Scatter_MAX, Scatter_MIN, Scatter_OR, Scatter_SUM

  interface Initialize
    module procedure Initialize_Communication
  end interface

  interface Finalize
    module procedure Finalize_Communication
  end interface

  interface Valid_State
    module procedure Valid_State_Communication
  end interface

  interface Output
    module procedure Output_Communication
  end interface

  interface Parallel_Write
    module procedure Parallel_Write_0
    module procedure Parallel_Write_1
  end interface

  define([EXPLICIT_INTERFACE],[
    pushdef([PROCEDURE], [$1])
    pushdef([OP], [$2])
    pushdef([TYPE], [$3])
    pushdef([DIM], [$4])
    pushdef([PROCEDURE_OP], expand(PROCEDURE_OP))
    pushdef([PROCEDURE_OP_TYPE_DIM], expand(PROCEDURE_OP_TYPE_DIM))

    interface PROCEDURE_OP
      module procedure PROCEDURE_OP_TYPE_DIM
    end interface

    popdef([PROCEDURE])
    popdef([OP])
    popdef([TYPE])
    popdef([DIM])
    popdef([PROCEDURE_OP])
    popdef([PROCEDURE_OP_TYPE_DIM])
  ])

  forloop([Dim],[0],[2],[
    fortext([Type],[Real Integer],[
      fortext([Op],[MaxVal MinVal Sum],[
        EXPLICIT_INTERFACE(Global, Op, Type, Dim)
      ])
    ])
    fortext([Op],[ALL ANY],[
      EXPLICIT_INTERFACE(Global, Op, Logical, Dim)
    ])
  ])

  forloop([Dim],[1],[2],[
    fortext([Type],[Real Integer],[
      fortext([Op],[MAX MIN Sum],[
        EXPLICIT_INTERFACE(Scatter, Op, Type, Dim)
      ])
    ])
    fortext([Op],[AND OR],[
      EXPLICIT_INTERFACE(Scatter, Op, Logical, Dim)
    ])
  ])

  fortext([Type],[Real Integer Logical],[
    interface Global_Dot_Product
      module procedure expand(Global_Dot_Product_Type)
    end interface
  ])

  define([EXPLICIT_INTERFACE],[
    pushdef([PROCEDURE], [$1])
    pushdef([TYPE], [$2])
    pushdef([DIM], [$3])
    pushdef([PROCEDURE_TYPE_DIM], expand(PROCEDURE_TYPE_DIM))

    interface PROCEDURE
      module procedure PROCEDURE_TYPE_DIM
    end interface

    popdef([PROCEDURE])
    popdef([TYPE])
    popdef([DIM])
    popdef([PROCEDURE_TYPE_DIM])
  ])

  forloop([Dim],[0],[3],[
    fortext([Type],[Real Integer Logical],[
      EXPLICIT_INTERFACE(Broadcast, Type, Dim)
    ])
  ])

  forloop([Dim],[0],[2],[
    EXPLICIT_INTERFACE(Broadcast, Character, Dim)
  ])

  forloop([Dim],[0],[1],[
    fortext([Type],[Real Integer Logical],[
      fortext([Proc],[Distribute Assemble],[
        EXPLICIT_INTERFACE(Proc, Type, Dim)
      ])
    ])
  ])

  forloop([Dim],[0],[1],[
    fortext([Type],[Character],[
      EXPLICIT_INTERFACE(Assemble, Type, Dim)
    ])
  ])

  forloop([Dim],[1],[2],[
    fortext([Type],[Real Integer Logical],[
      fortext([Proc],[Gather],[
        EXPLICIT_INTERFACE(Proc, Type, Dim)
      ])
    ])
  ])

  ! Public type definitions.

  public :: Communication_type

  type Communication_type
    ! Place holder to allow generic procedure calls -- real data 
    ! associated with the communication is stored in global class 
    ! variables for easy access.
    type(integer) :: i
  end type Communication_type

  ! Public variables.

  public :: delta_PE_IO_PE, IO_PE, NPEs, Parallel, Parallel_Library, &
            Serial, this_is_IO_PE, this_is_not_IO_PE, this_PE
  save   :: delta_PE_IO_PE, IO_PE, NPEs, Parallel, Parallel_Library, &
            Serial, this_is_IO_PE, this_is_not_IO_PE, this_PE
  ifdef([USE_PGSLIB],[
    public :: Scope
    save :: Scope
  ])

  ! Global class variables.

  type(integer) :: delta_PE_IO_PE        ! Kronecker delta (PE, IO_PE).
  type(integer) :: IO_PE                 ! The PE number which is allowed
                                         ! to do I/O.
  type(integer) :: NPEs                  ! Total number of PEs (1 for
                                         ! serial runs).
  type(logical) :: Parallel              ! True for parallel runs.
  type(character,50) :: Parallel_Library ! The name of the parallel 
                                         ! communication library.
  type(logical) :: Serial                ! True for serial runs.
  type(logical) :: this_is_IO_PE         ! True on the IO PE.
  type(logical) :: this_is_not_IO_PE     ! True everywhere except the IO PE.
  type(integer) :: this_PE               ! The PE number for this processor.
  ifdef([USE_PGSLIB],[    
    type(PGSLib_Scope) :: Scope          ! Local or Global Scope setting.
  ])

contains

The Communication Class contains the following routines which are listed in separate sections:

* Initialize_Communication
* Finalize_Communication
* Valid_State_Communication
* Abort
* Assemble
* Broadcast
* Distribute
* Gather
* Global Reduction
* Output_Communication
* Output_Test
* Parallel_Write
* Scatter

end module Caesar_Communication_Class



Subsections
Michael L. Hall