D.2.7 Distribute Procedure

The main documentation of the Distribute Procedure contains additional explanation of this code listing.

  define([DISTRIBUTE_ROUTINE],[
    pushdef([TYPE], [$1])
    pushdef([Distribute_TYPE_0], expand(Distribute_TYPE_0))

    subroutine Distribute_TYPE_0 (Output, Input)

      ! Input variables.

      type(TYPE,1,np), intent(in) :: Input    ! Variable to be distributed.

      ! Output variable.

      type(TYPE), intent(out) :: Output       ! Distributed variable.
  
      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      ! Verify requirements.
  
      ! Input is the right size.
      VERIFY(SIZE(Input) == NPEs * delta_PE_IO_PE,3)
  
      ! Do the global distribute.

      ifdef([USE_PGSLIB],[
    
        ! PGSLib parallel distribute.
    
        call PGSLib_Dist (Output, Input)
  
      ],[
    
        ! Serial distribute.

        Output = Input(1)
  
      ])

      ! Verify guarantees - none.
  
      return
    end subroutine Distribute_TYPE_0
  
    popdef([TYPE])
    popdef([Distribute_TYPE_0])
  ])

  fortext([Type],[real integer logical],[
    DISTRIBUTE_ROUTINE(Type)
  ])

  define([DISTRIBUTE_ROUTINE],[
    pushdef([TYPE], [$1])
    pushdef([Distribute_TYPE_1], expand(Distribute_TYPE_1))

    subroutine Distribute_TYPE_1 (Output, Input, Lengths)

      ! Input variables.

      type(integer,1,np), intent(in) :: Lengths ! Distribution lengths.
      type(TYPE,1,np), intent(in) :: Input      ! Variable to be distributed.

      ! Output variable.

      type(TYPE,1,np), intent(out) :: Output    ! Distributed variable.
  
      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      ! Verify requirements.

      ! Input is the right size.
      VERIFY(SIZE(Input) == SUM(Lengths) * delta_PE_IO_PE,3)
      ! Lengths is the right size.
      VERIFY(SIZE(Lengths) == NPEs,3)
  
      ! Do the global distribute.

      ifdef([USE_PGSLIB],[
    
        ! PGSLib parallel distribute.
    
        call PGSLib_Dist (Output, Input, Lengths)
  
      ],[
    
        ! Serial distribute.

        Output = Input
  
      ])

      ! Verify guarantees - none.
  
      return
    end subroutine Distribute_TYPE_1
  
    popdef([TYPE])
    popdef([Distribute_TYPE_1])
  ])

  fortext([Type],[real integer logical],[
    DISTRIBUTE_ROUTINE(Type)
  ])



Michael L. Hall