The main documentation of the Global Reduction Functions contains additional explanation of this code listing.
define([REDUCTION_ROUTINE],[
pushdef([REDUCTION], [$1])
pushdef([TYPE], [$2])
pushdef([DIM], [$3])
pushdef([Global_REDUCTION_TYPE_DIM], expand(Global_REDUCTION_TYPE_DIM))
pushdef([PGSLib_Global_REDUCTION], expand(PGSLib_Global_REDUCTION))
function Global_REDUCTION_TYPE_DIM (Input) result(Output)
! Input variable.
type(TYPE,DIM,np), intent(in) :: Input ! Variable to be reduced.
! Output variable.
type(TYPE) :: Output ! Reduction result.
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Verify requirements - none.
! Do the global reduction.
ifdef([USE_PGSLIB],[
! PGSLib parallel reduction.
Output = PGSLib_Global_REDUCTION (Input)
],[
! Serial reduction.
Output = REDUCTION (Input)
])
! Verify guarantees - none.
return
end function Global_REDUCTION_TYPE_DIM
popdef([TYPE])
popdef([REDUCTION])
popdef([DIM])
popdef([Global_REDUCTION_TYPE_DIM])
popdef([PGSLib_Global_REDUCTION])
])
forloop([Dim],[0],[2],[
fortext([Type],[real integer],[
fortext([Op],[Sum MaxVal MinVal],[
REDUCTION_ROUTINE(Op, Type, Dim)
])
])
fortext([Op],[ALL ANY],[
REDUCTION_ROUTINE(Op, logical, Dim)
])
])
define([DOT_PRODUCT_ROUTINE],[
pushdef([TYPE], [$1])
pushdef([Global_Dot_Product_TYPE], expand(Global_Dot_Product_TYPE))
function Global_Dot_Product_TYPE (Input1, Input2) result(Output)
! Input variable.
type(TYPE,1,np), intent(in) :: Input1 ! Variable to be reduced.
type(TYPE,1,np), intent(in) :: Input2 ! Variable to be reduced.
! Output variable.
type(TYPE) :: Output ! Dot_Product result.
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Verify requirements - none.
! Do the global dot_product.
ifdef([USE_PGSLIB],[
! PGSLib parallel dot_product.
Output = PGSLib_Global_Dot_Product (Input1, Input2)
],[
! Serial dot_product.
Output = Dot_Product (Input1, Input2)
])
! Verify guarantees - none.
return
end function Global_Dot_Product_TYPE
popdef([TYPE])
popdef([Global_Dot_Product_TYPE])
])
fortext([Type],[real integer logical],[
DOT_PRODUCT_ROUTINE(Type)
])