subroutine grwdamp use modglobal, only:ke, kmax, lcoriol, igrw_damp, geodamptime use modfields, only:up, vp, wp, thlp, qtp, u0, v0, w0, thl0, qt0, ug, vg, thl0av, qt0av, u0av, v0av use modmpi, only:myid implicit none integer k select case (igrw_damp) case (0) !do nothing case (1) do k = ksp, ke up(:, :, k) = up(:, :, k) - (u0(:, :, k) - u0av(k))*tsc(k) vp(:, :, k) = vp(:, :, k) - (v0(:, :, k) - v0av(k))*tsc(k) wp(:, :, k) = wp(:, :, k) - w0(:, :, k)*tsc(k) thlp(:, :, k) = thlp(:, :, k) - (thl0(:, :, k) - thl0av(k))*tsc(k) qtp(:, :, k) = qtp(:, :, k) - (qt0(:, :, k) - qt0av(k))*tsc(k) end do if (lcoriol) then do k = ksp, ke up(:, :, k) = up(:, :, k) - (u0(:, :, k) - ug(k))*((1./(geodamptime*rnu0))*tsc(k)) vp(:, :, k) = vp(:, :, k) - (v0(:, :, k) - vg(k))*((1./(geodamptime*rnu0))*tsc(k)) end do end if case (2) do k = ksp, ke up(:, :, k) = up(:, :, k) - (u0(:, :, k) - ug(k))*tsc(k) vp(:, :, k) = vp(:, :, k) - (v0(:, :, k) - vg(k))*tsc(k) wp(:, :, k) = wp(:, :, k) - w0(:, :, k)*tsc(k) thlp(:, :, k) = thlp(:, :, k) - (thl0(:, :, k) - thl0av(k))*tsc(k) qtp(:, :, k) = qtp(:, :, k) - (qt0(:, :, k) - qt0av(k))*tsc(k) end do case (3) do k = ksp, ke up(:, :, k) = up(:, :, k) - (u0(:, :, k) - u0av(k))*tsc(k) vp(:, :, k) = vp(:, :, k) - (v0(:, :, k) - v0av(k))*tsc(k) wp(:, :, k) = wp(:, :, k) - w0(:, :, k)*tsc(k) thlp(:, :, k) = thlp(:, :, k) - (thl0(:, :, k) - thl0av(k))*tsc(k) qtp(:, :, k) = qtp(:, :, k) - (qt0(:, :, k) - qt0av(k))*tsc(k) end do case default write(0, *) "ERROR: no gravity wave damping option selected" stop 1 end select return end subroutine grwdamp