avexy_ibm Subroutine

public subroutine avexy_ibm(aver, var, ib, ie, jb, je, kb, ke, ih, jh, kh, II, IIs, lnan)

Arguments

Type IntentOptional Attributes Name
real :: aver(kb:ke+kh)
real :: var(ib:ie,jb:je,kb:ke+kh)
integer :: ib
integer :: ie
integer :: jb
integer :: je
integer :: kb
integer :: ke
integer :: ih
integer :: jh
integer :: kh
integer :: II(ib:ie,jb:je,kb:ke+kh)
integer :: IIs(kb:ke+kh)
logical :: lnan

Calls

proc~~avexy_ibm~~CallsGraph proc~avexy_ibm modmpi::avexy_ibm mpi_allreduce mpi_allreduce proc~avexy_ibm->mpi_allreduce

Called by

proc~~avexy_ibm~~CalledByGraph proc~avexy_ibm modmpi::avexy_ibm proc~diagfld modthermodynamics::diagfld proc~diagfld->proc~avexy_ibm proc~readinitfiles modstartup::readinitfiles proc~readinitfiles->proc~avexy_ibm proc~thermodynamics modthermodynamics::thermodynamics proc~readinitfiles->proc~thermodynamics proc~statsdump modstatsdump::statsdump proc~statsdump->proc~avexy_ibm proc~tkestatsdump modstatsdump::tkestatsdump proc~statsdump->proc~tkestatsdump proc~thermodynamics->proc~avexy_ibm proc~thermodynamics->proc~diagfld proc~tkestatsdump->proc~avexy_ibm proc~startup modstartup::startup proc~startup->proc~readinitfiles program~dalesurban DALESURBAN program~dalesurban->proc~statsdump program~dalesurban->proc~thermodynamics program~dalesurban->proc~startup

Contents

Source Code


Source Code

  subroutine avexy_ibm(aver,var,ib,ie,jb,je,kb,ke,ih,jh,kh,II,IIs,lnan)
    implicit none

    integer :: ib,ie,jb,je,kb,ke,ih,jh,kh
    real    :: aver(kb:ke+kh)
    real    :: var(ib:ie,jb:je,kb:ke+kh)
    integer :: II(ib:ie,jb:je,kb:ke+kh)
    integer :: IIs(kb:ke+kh)
    integer :: IId(kb:ke+kh)
    real    :: averl(kb:ke+kh)
    real    :: avers(kb:ke+kh)
    integer :: k
    logical :: lnan

    averl       = 0.
    avers       = 0.

    do k=kb,ke+kh
      averl(k) = sum(var(ib:ie,jb:je,k)*II(ib:ie,jb:je,k))
    enddo

    IId = IIs

    ! tg3315 22.03.19 - if not calculating stats and all blocks on lowest layer...
    ! should not be necessary but value at kb is used in modthermo so reasonable value must
    ! be assigned. Potentially should leave as before and only account for in modthermo...
    if ((.not. lnan) .and. (IId(kb)==0)) then
      averl(kb) = sum(var(ib:ie,jb:je,kb))
      IId(kb) = IId(ke)
    end if

    call MPI_ALLREDUCE(averl, avers, ke+kh-kb+1,  MY_REAL, &
                          MPI_SUM, comm3d,mpierr)

    where (IId==0)
      aver = -999.
    elsewhere
      aver = avers/IId
    endwhere

    return
  end subroutine avexy_ibm