df_cumsum_integer Subroutine

public subroutine df_cumsum_integer(df, col_index)

Calculate cumulative sum for an integer column (modifies in place)

Each element becomes the sum of all elements up to and including that position

@param[in,out] df The data frame instance @param[in] col_index Index of the column

Arguments

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

Source Code

    subroutine df_cumsum_integer(df, col_index)
        type(data_frame), intent(inout) :: df
        integer, intent(in) :: col_index

        integer(ik), dimension(:), allocatable :: col
        integer :: i

        col = df_get_col_integer(df, col_index)
        do i = 2, size(col)
            col(i) = col(i) + col(i - 1)
        end do
        call df_set_col_integer(df, col_index, col)
    end subroutine df_cumsum_integer