FV3 Bundle
calc_pv.f90
Go to the documentation of this file.
1 ! (C) Copyright 2009-2016 ECMWF.
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 
10 
11 Contains
12 !> Calculate potential vorticity from streamfunction
13 
14 !> Potential vorticity is defined as
15 !! \f{eqnarray*}{
16 !! q_1 &=& \nabla^2 \psi_1 - F_1 (\psi_1 -\psi_2 ) + \beta y \\\\
17 !! q_2 &=& \nabla^2 \psi_2 - F_2 (\psi_2 -\psi_1 ) + \beta y + R_s
18 !! \f}
19 
20 subroutine calc_pv(kx,ky,pv,x,x_north,x_south,f1,f2,deltax,deltay,bet,rs,lbc)
21 
22 !--- calculate potential vorticity from streamfunction
23 
24 use kinds
25 
26 implicit none
27 integer, intent(in) :: kx !< Zonal grid dimension
28 integer, intent(in) :: ky !< Meridional grid dimension
29 real(kind=kind_real), intent(out) :: pv(kx,ky,2) !< Potential vorticity
30 real(kind=kind_real), intent(in) :: x(kx,ky,2) !< Streamfunction
31 real(kind=kind_real), intent(in) :: x_north(2) !< Streamfunction on northern wall
32 real(kind=kind_real), intent(in) :: x_south(2) !< Streamfunction on southern wall
33 real(kind=kind_real), intent(in) :: f1 !< Coefficient in PV operator
34 real(kind=kind_real), intent(in) :: f2 !< Coefficient in PV operator
35 real(kind=kind_real), intent(in) :: deltax !< Zonal grid spacing (non-dimensional)
36 real(kind=kind_real), intent(in) :: deltay !< Meridional grid spacing (non-dimensional)
37 real(kind=kind_real), intent(in) :: bet !< NS Gradient of Coriolis parameter
38 real(kind=kind_real), intent(in) :: rs(kx,ky) !< Orography
39 logical, optional , intent(in) :: lbc !< Latitudinal boundaries?
40 
41 integer :: jj
42 real(kind=kind_real) :: y
43 logical :: bc
44 
45 if (present(lbc)) then
46  bc = lbc
47 else
48  bc = .true.
49 endIf
50 
51 !--- apply the linear operator
52 
53 call pv_operator(x,pv,kx,ky,f1,f2,deltax,deltay)
54 
55 !--- add the contribution from the boundaries
56 
57 if (bc) then
58  pv(:,1 ,1) = pv(:,1 ,1) + (1.0_kind_real/(deltay*deltay))*x_south(1)
59  pv(:,1 ,2) = pv(:,1 ,2) + (1.0_kind_real/(deltay*deltay))*x_south(2)
60  pv(:,ky,1) = pv(:,ky,1) + (1.0_kind_real/(deltay*deltay))*x_north(1)
61  pv(:,ky,2) = pv(:,ky,2) + (1.0_kind_real/(deltay*deltay))*x_north(2)
62 endif
63 
64 !--- add the beta term
65 
66 do jj=1,ky
67  y = real(jj-(ky+1)/2,kind_real)*deltay;
68  pv(:,jj,:) = pv(:,jj,:) + bet*y
69 enddo
70 
71 !--- add the orography/heating term
72 
73 pv(:,:,2) = pv(:,:,2) + rs(:,:)
74 
75 end subroutine calc_pv
76 
77 end module calculate_pv
subroutine pv_operator(x, pv, nx, ny, F1, F2, deltax, deltay)
Potential vorticity operator.
Definition: pv_operator.f90:21
subroutine calc_pv(kx, ky, pv, x, x_north, x_south, f1, f2, deltax, deltay, bet, rs, lbc)
Calculate potential vorticity from streamfunction.
Definition: calc_pv.f90:21