cumsum Subroutine

public subroutine cumsum(x, cs)

Calculate cumulative sum

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(in), dimension(:):: x

Array to sum

real(kind=Float64), intent(out), dimension(:):: cs

Cumulative sum of x


Called by

proc~~cumsum~~CalledByGraph proc~cumsum cumsum proc~get_nlaunch get_nlaunch proc~get_nlaunch->proc~cumsum proc~fida_f fida_f proc~fida_f->proc~get_nlaunch proc~dcx dcx proc~dcx->proc~get_nlaunch proc~npa_f npa_f proc~npa_f->proc~get_nlaunch proc~halo halo proc~halo->proc~get_nlaunch proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~get_nlaunch program~fidasim fidasim program~fidasim->proc~fida_f program~fidasim->proc~dcx program~fidasim->proc~npa_f program~fidasim->proc~halo program~fidasim->proc~fida_weights_mc

Contents

Source Code


Source Code

subroutine cumsum(x, cs)
    !+ Calculate cumulative sum
    real(Float64), dimension(:), intent(in)  :: x
        !+ Array to sum
    real(Float64), dimension(:), intent(out) :: cs
        !+ Cumulative sum of `x`

    integer :: i, n
    real(Float64) :: cdf_val, t

    n = size(x)
    t = 0.d0
    do i=1, n
        cs(i) = t + x(i)
        t = cs(i)
    enddo

end subroutine cumsum