genstats Subroutine

public subroutine genstats(tsamplep, tstatsdumpp, umint, vmint, wmint)

Uses

  • proc~~genstats~~UsesGraph proc~genstats genstats module~modfields modfields proc~genstats->module~modfields module~modglobal modglobal proc~genstats->module~modglobal module~modmpi modmpi proc~genstats->module~modmpi decomp_2d decomp_2d module~modfields->decomp_2d mpi mpi module~modmpi->mpi

Arguments

Type IntentOptional Attributes Name
real :: tsamplep
real :: tstatsdumpp
real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh) :: umint
real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh) :: vmint
real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh) :: wmint

Calls

proc~~genstats~~CallsGraph proc~genstats genstats proc~tkestats tkestats proc~genstats->proc~tkestats

Source Code

  subroutine genstats(tsamplep,tstatsdumpp,umint,vmint,wmint)

  use modfields,        only : um,up,vm,wm,thlm,uav,vav,wav,uuav,vvav,wwav,uvav,vwav,uwav,thlav,thlwav,thlthlav, &
                               upupav,vpvpav,wpwpav,upvpav,upwpav,vpwpav,thlpwpav
  use modglobal,        only : ib,ie,ih,jb,je,dy,jh,ke,kb,kh,rk3step,timee,cexpnr,tsample,tstatsdump,&
                               ltempeq,dxf,dzf,dzhi
  use modmpi,           only : myid,cmyid,my_real,mpi_sum,mpierr,comm3d
  implicit none

  real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)     :: umint
  real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)     :: vmint
  real, dimension(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)     :: wmint
  real :: tstatsdumppi,tsamplep,tstatsdumpp
  integer :: km

  tstatsdumppi = 1./tstatsdumpp

!  if (lydump) then
    if (.not. rk3step==3)  return
!      if (tsamplep > tsample) then

        !> Interpolate velocity fields to cell centers
!        do k=kb-kh,ke
!          do j=jb-jh,je+jh
!            do i=ib-ih,ie+ih
!              umint(i,j,k) = 0.5*(um(i,j,k)+um(i+1,j,k))
!              vmint(i,j,k) = 0.5*(vm(i,j,k)+vm(i,j+1,k))
!              wmint(i,j,k) = 0.5*(wm(i,j,k)+wm(i,j,k+1))
!            enddo
!          enddo
!        enddo

        do k=kb,ke
          do j=jb,je
            do i=ib,ie
              uav(i,j,k) = (uav(i,j,k)*(tstatsdumpp-tsamplep) + umint(i,j,k)*tsamplep)*tstatsdumppi
              vav(i,j,k) = (vav(i,j,k)*(tstatsdumpp-tsamplep) + vmint(i,j,k)*tsamplep)*tstatsdumppi
              wav(i,j,k) = (wav(i,j,k)*(tstatsdumpp-tsamplep) + wmint(i,j,k)*tsamplep)*tstatsdumppi
              uuav(i,j,k)  = (uuav(i,j,k)*(tstatsdumpp-tsamplep) + (umint(i,j,k)**2)*tsamplep)*tstatsdumppi
              vvav(i,j,k)  = (vvav(i,j,k)*(tstatsdumpp-tsamplep) + (vmint(i,j,k)**2)*tsamplep)*tstatsdumppi
              wwav(i,j,k)  = (wwav(i,j,k)*(tstatsdumpp-tsamplep) + (wmint(i,j,k)**2)*tsamplep)*tstatsdumppi    
              uvav(i,j,k)  = (uvav(i,j,k)*(tstatsdumpp-tsamplep) + umint(i,j,k)*vmint(i,j,k)*tsamplep)*tstatsdumppi
              vwav(i,j,k)  = (vwav(i,j,k)*(tstatsdumpp-tsamplep) + vmint(i,j,k)*wmint(i,j,k)*tsamplep)*tstatsdumppi
              uwav(i,j,k)  = (uwav(i,j,k)*(tstatsdumpp-tsamplep) + umint(i,j,k)*wmint(i,j,k)*tsamplep)*tstatsdumppi
              if (ltempeq) then
                thlav(i,j,k) = (thlav(i,j,k)*(tstatsdumpp-tsamplep) + thlm(i,j,k)*tsamplep)*tstatsdumppi
                thlwav(i,j,k) = (thlwav(i,j,k)*(tstatsdumpp-tsamplep) + thlm(i,j,k)*wmint(i,j,k)*tsamplep)*tstatsdumppi
                thlthlav(i,j,k) = (thlthlav(i,j,k)*(tstatsdumpp-tsamplep) + (thlm(i,j,k)**2)*tsamplep)*tstatsdumppi
              end if
            end do
          end do
        end do

        upupav = uuav - uav**2             ! overline(u'u') = overline(uu) - U^2
        vpvpav = vvav - vav**2             ! overline(v'v') = overline(vv) - V^2
        wpwpav = wwav - wav**2             ! overline(w'w') = overline(ww) - W^2
        upvpav = uvav - uav*vav            ! overline(u'v') = overline(uv) - U*V
        upwpav = uwav - uav*wav            ! overline(u'w') = overline(uw) - U*W
        vpwpav = vwav - vav*wav            ! overline(v'w') = overline(vw) - V*W

        ! thlw and svw: ib:ie jb:je kb:ke+1  (located on w-faces) !tg3315 BUT thlwav is on cell centre...
        do k=kb,ke+1
          km = k-1
          do j=jb,je
            do i=ib,ie
              thlpwpav(i,j,k) = thlwav(i,j,k) - &
                                0.5 * wav(i,j,k) * & ! no interpolation
                                (thlav(i,j,km)*dzf(k) + thlav(i,j,k)*dzf(km))*dzhi(k) ! interpolate thl to w-faces

!              qlpwpav(i,j,k) = thlwav(i,j,k) - &
!                                0.5 * wav(i,j,k) * & ! no interpolation
!                               (qlav(i,j,km)*dzf(k) + qlav(i,j,k)*dzf(km))*dzhi(k) ! interpolate thl to w-faces

!              qtpwpav(i,j,k) = qtwav(i,j,k) - &
!                                0.5 * wav(i,j,k) * & ! no interpolation
!                                (qtav(i,j,km)*dzf(k) + qtav(i,j,k)*dzf(km))*dzhi(k) ! interpolate thl to w-faces
!
!              do n=1,nsv
!                svpwpav(i,j,k,n) = svwav(i,j,k,n) - &
!                                   0.5 * wav(i,j,k) * & ! no interpolation
!                                   (svav(i,j,km,n)*dzf(k) + svav(i,j,k,n)*dzf(km))*dzhi(k) ! interpolate svav to w-faces
!              end do
            end do
          end do
        end do

        !> generate time averaged stats for TKE budget and call subroutine final field values
        if (ltkedump) then
          call tkestats(tsamplep,tstatsdumpp)
        end if

!        tsample = dt

!     else !timestatsdumpp < tsample

!       tsamplep = tsamplep + dt

!      end if
!    end if
!  end if

  end subroutine genstats