The main documentation of the Get Value Mathematic_Vector Functions contains additional explanation of this code listing.
define([REAL_ACCESS_ROUTINE],[ pushdef([VALUE], [$1]) pushdef([Get_REAL_VALUE_MV], expand(Get_VALUE_MV)) pushdef([VALUE_is_Updated], expand(VALUE_is_Updated)) function Get_REAL_VALUE_MV (MV) result(VALUE) ! Input/Output variables. ! Mathematic_Vector object. type(Mathematic_Vector_type), intent(inout) :: MV ! Output variables. type(real) :: VALUE ! Mathematic_Vector value to be output. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(MV),5) ! Mathematic_Vector is valid. ! Set value. if (MV%VALUE_is_Updated) then VALUE = MV%VALUE else ifelse( VALUE, [Average], [VALUE = Global_Sum(MV%Values)/Length_Total(MV%Structure)], VALUE, [Infinity_Norm], [VALUE = Global_MaxVal(ABS(MV%Values))], VALUE, [Maximum], [VALUE = Global_MaxVal(MV%Values)], VALUE, [Minimum], [VALUE = Global_MinVal(MV%Values)], VALUE, [One_Norm], [VALUE = Global_Sum(ABS(MV%Values))], VALUE, [Sum], [VALUE = Global_Sum(MV%Values)], VALUE, [Two_Norm], [VALUE = SQRT(Global_Sum(MV%Values**2))], []) MV%VALUE_is_Updated = .true. MV%VALUE = VALUE end if ! Verify guarantees - none. return end function Get_REAL_VALUE_MV popdef([VALUE]) popdef([Get_REAL_VALUE_MV]) popdef([VALUE_is_Updated]) ]) fortext([Value], [Average Infinity_Norm Maximum Minimum One_Norm Sum Two_Norm],[ REAL_ACCESS_ROUTINE(Value) ]) define([INTEGER_ACCESS_ROUTINE],[ pushdef([VALUE], [$1]) pushdef([VALUE_Result], expand(VALUE_Result)) pushdef([Get_INTEGER_VALUE_MV], expand(Get_VALUE_MV)) function Get_INTEGER_VALUE_MV (MV) result(VALUE_Result) ! Input/Output variables. ! Mathematic_Vector object. type(Mathematic_Vector_type), intent(inout) :: MV ! Output variables. type(integer) :: VALUE_Result ! Mathematic_Vector value to be output. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(MV),5) ! Mathematic_Vector is valid. ! Set value. ifelse( VALUE, [First_PE], [VALUE_Result = First_PE(MV%Structure)], VALUE, [Last_PE], [VALUE_Result = Last_PE(MV%Structure)], VALUE, [Length_PE], [VALUE_Result = Length_PE(MV%Structure)], VALUE, [Length_Total], [VALUE_Result = Length_Total(MV%Structure)], []) ! Verify guarantees - none. return end function Get_INTEGER_VALUE_MV popdef([VALUE]) popdef([VALUE_Result]) popdef([Get_INTEGER_VALUE_MV]) ]) fortext([Value], [First_PE Last_PE Length_PE Length_Total],[ INTEGER_ACCESS_ROUTINE(Value) ]) function Get_Locus_MV (MV) result(Locus_MV) ! Input variables. ! Mathematic_Vector object. type(Mathematic_Vector_type), intent(in) :: MV ! Output variables. ! Mathematic_Vector value to be output. type(character,name_length) :: Locus_MV !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(MV),5) ! Mathematic_Vector is valid. ! Set value. Locus_MV = Locus(MV%Structure) ! Verify guarantees - none. return end function Get_Locus_MV function Get_Name_MV (MV) result(Name) ! Input variables. ! Mathematic_Vector object. type(Mathematic_Vector_type), intent(in) :: MV ! Output variables. ! Mathematic_Vector value to be output. type(character,name_length) :: Name !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(MV),5) ! Mathematic_Vector is valid. ! Set value. Name = MV%Name ! Verify guarantees - none. return end function Get_Name_MV function Get_P_Norm_MV (MV, P) result(P_Norm) ! Use association information. use Caesar_Numbers_Module, only: one ! Input variables. type(integer), optional, intent(in) :: P ! P_Norm exponent. ! Input/Output variables. ! Mathematic_Vector object. type(Mathematic_Vector_type), intent(inout) :: MV ! Output variables. type(real) :: P_Norm ! Mathematic_Vector value to be output. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(Valid_State(MV),5) ! Mathematic_Vector is valid. ! Set value. if (MV%P_Norm_is_Updated .and. P==MV%P_Norm_Exponent) then P_Norm = MV%P_Norm else P_Norm = (Global_Sum(ABS(MV%Values)**P))**(one/P) MV%P_Norm_is_Updated = .true. MV%P_Norm = P_Norm MV%P_Norm_Exponent = P end if ! Verify guarantees - none. return end function Get_P_Norm_MV