df_sum_real Function

public function df_sum_real(df, col_index) result(total)

Calculate sum of real column

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index

Return Value real(kind=rk)


Source Code

    function df_sum_real(df, col_index) result(total)
        type(data_frame), intent(in) :: df
        integer, intent(in) :: col_index
        real(rk) :: total

        real(rk), dimension(:), allocatable :: col
        type(column) :: data_col

        if (col_index < 1 .or. col_index > df % ncols()) error stop "column index out of range"

        data_col = df % get_data_col(col_index)
        if (data_col % get_type() /= REAL_NUM) error stop "column is not real type"

        col = data_col % getr()
        total = sum(col)
    end function df_sum_real