1 subroutine da_uv_to_vorticity(xb , u, v, vor)
3 !---------------------------------------------------------------------------
4 ! Purpose: Calculate vorticity on a co-ordinate surface, given an input
7 ! Method: vor = m**2 (d(v/m)/dx - d(u/m)/dy)
8 !---------------------------------------------------------------------------
12 type (xb_type), intent(in) :: xb ! First guess structure.
13 real, intent(in) :: u(ims:ime,jms:jme,kms:kme) ! u wind comp.
14 real, intent(in) :: v(ims:ime,jms:jme,kms:kme) ! v wind comp.
15 real, intent(inout) :: vor(ims:ime,jms:jme,kms:kme) ! Vorticity.
17 integer :: i, j, k ! Loop counters.
18 integer :: is, ie ! 1st dim. end points.
19 integer :: js, je ! 2nd dim. end points.
20 real :: one_third ! 1/3.
21 real :: inv_2ds ! 1/2ds.
22 real :: coeff(ims:ime,jms:jme) ! Mult. coefficient.
23 real :: um(ims:ime,jms:jme) ! Temp. storage of u/m.
24 real :: vm(ims:ime,jms:jme) ! Temp. storage of v/m.
26 if (trace_use) call da_trace_entry("da_uv_to_vorticity")
28 !---------------------------------------------------------------------------
30 !---------------------------------------------------------------------------
36 !---------------------------------------------------------------------------
37 ! Computation to check for edge of domain:
38 !---------------------------------------------------------------------------
44 if (.not. global .and. its == ids) is = ids+1
45 if (.not. global .and. ite == ide) ie = ide-1
46 if (jts == jds) js = jds+1
47 if (jte == jde) je = jde-1
51 coeff(its:ite,jts:jte) = xb%map_factor(its:ite,jts:jte) * &
52 xb%map_factor(its:ite,jts:jte) * inv_2ds
55 !---------------------------------------------------------------------------
56 ! [2.0] Calculate vorticity:
57 !---------------------------------------------------------------------------
60 ! [2.1] Compute finite difference vorticity at interior points:
65 vor(i,j,k) = xb%coefy(i,j) * (-u(i,j+1,k) + u(i,j-1,k)) + &
66 xb%coefx(i,j) * ( v(i+1,j,k) - v(i-1,j,k))
72 um(is-1:ie+1,js-1:je+1) = u(is-1:ie+1,js-1:je+1,k) / xb%map_factor(is-1:ie+1,js-1:je+1)
73 vm(is-1:ie+1,js-1:je+1) = v(is-1:ie+1,js-1:je+1,k) / xb%map_factor(is-1:ie+1,js-1:je+1)
75 ! [2.1] Compute finite difference vorticity at interior points:
79 vor(i,j,k) = (-um(i,j+1) + um(i,j-1) + vm(i+1,j) - vm(i-1,j)) * coeff(i,j)
83 ! [2.2] Impose zero vorticity gradient condition at boundaries:
85 ! [2.2.1] Bottom boundaries:
90 vor(i,j,k) = one_third * (4.0 * vor(i+1,j,k) - vor(i+2,j,k))
94 ! [2.2.2] Top boundaries:
99 vor(i,j,k) = one_third * (4.0 * vor(i-1,j,k) - vor(i-2,j,k))
103 ! [2.2.3] Left boundaries:
108 vor(i,j,k) = one_third * (4.0 * vor(i,j+1,k) - vor(i,j+2,k))
112 ! [2.2.4] right boundaries:
117 vor(i,j,k) = one_third * (4.0 * vor(i,j-1,k) - vor(i,j-2,k))
124 call da_set_boundary_3d(vor)
127 if (trace_use) call da_trace_exit("da_uv_to_vorticity")
129 end subroutine da_uv_to_vorticity