avg_dv Subroutine

public subroutine avg_dv(dv, dv_hist, istep, navg)

Uses

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(dens_vel_diagnostics), intent(inout) :: dv
type(dens_vel_diagnostics), intent(inout), dimension (0:) :: dv_hist
integer, intent(in) :: istep
integer, intent(in) :: navg

Contents

Source Code


Source Code

  subroutine avg_dv (dv, dv_hist, istep, navg)  
    use mp, only: proc0
    implicit none
    type (dens_vel_diagnostics), intent(in out) :: dv
    type (dens_vel_diagnostics), dimension (0:), intent(in out) :: dv_hist
    integer, intent (in) :: istep, navg
    integer :: i

    if (proc0) then
       if (navg > 1) then
          if (istep > 1) then
             dv_hist(mod(istep,navg)) % dvpar(:)     = dv % dvpar(:)
             dv_hist(mod(istep,navg)) % dvperp(:)    = dv % dvperp(:)
             dv_hist(mod(istep,navg)) % dn(:)        = dv % dn(:)
          end if
          
          if (istep >= navg) then
             call zero_dvtype(dv)
             do i=0,navg-1
                dv % dvpar(:)  = dv % dvpar(:)  + dv_hist(i) % dvpar(:)  / real(navg)
                dv % dvperp(:) = dv % dvperp(:) + dv_hist(i) % dvperp(:) / real(navg)
                dv % dn(:)     = dv % dn(:)     + dv_hist(i) % dn (:)    / real(navg)
             end do
          end if
       end if
    end if

  end subroutine avg_dv