FV3 Bundle
invert_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 
9 !> Invert potential vorticity, returning streamfunction
10 
11 !> Streamfunction is determined from potential vorticity by subtracting
12 !! the beta and orography terms and then solving the resulting elliptic
13 !! equation.
14 
15 subroutine invert_pv (x,pv,x_north,x_south,rs,nx,ny,deltax,deltay,F1,F2,bet)
16 
17 !--- invert potential vorticity to get streamfunction
18 
19 use kinds
20 
21 implicit none
22 integer, intent(in) :: nx !< Zonal grid dimension
23 integer, intent(in) :: ny !< Meridional grid dimension
24 real(kind=kind_real), intent(out) :: x(nx,ny,2) !< Streamfunction
25 real(kind=kind_real), intent(in) :: pv(nx,ny,2) !< Potential vorticity
26 real(kind=kind_real), intent(in) :: x_north(2) !< Streamfunction on northern wall
27 real(kind=kind_real), intent(in) :: x_south(2) !< Streamfunction on southern wall
28 real(kind=kind_real), intent(in) :: rs(nx,ny) !< Orography
29 real(kind=kind_real), intent(in) :: deltax !< Zonal grid spacing (non-dimensional)
30 real(kind=kind_real), intent(in) :: deltay !< Meridional grid spacing (non-dimensional)
31 real(kind=kind_real), intent(in) :: F1 !< Coefficient in PV operator
32 real(kind=kind_real), intent(in) :: F2 !< Coefficient in PV operator
33 real(kind=kind_real), intent(in) :: bet !< NS Gradient of Coriolis parameter
34 
35 real(kind=kind_real) :: y
36 real(kind=kind_real) :: pv_nobc(nx,ny,2)
37 integer :: jj
38 
39 !--- subtract the beta term and the orography/heating term
40 
41 do jj=1,ny
42  y = real(jj-(ny+1)/2,kind_real)*deltay;
43  pv_nobc(:,jj,1) = pv(:,jj,1) - bet*y
44  pv_nobc(:,jj,2) = pv(:,jj,2) - bet*y -rs(:,jj)
45 enddo
46 
47 !--- subtract the contribution from the boundaries
48 
49 pv_nobc(:,1 ,1) = pv_nobc(:,1 ,1) - (1.0_kind_real/(deltay*deltay))*x_south(1)
50 pv_nobc(:,1 ,2) = pv_nobc(:,1 ,2) - (1.0_kind_real/(deltay*deltay))*x_south(2)
51 pv_nobc(:,ny,1) = pv_nobc(:,ny,1) - (1.0_kind_real/(deltay*deltay))*x_north(1)
52 pv_nobc(:,ny,2) = pv_nobc(:,ny,2) - (1.0_kind_real/(deltay*deltay))*x_north(2)
53 
54 !--- Solve the elliptic system
55 
56 call solve_elliptic_system (x,pv_nobc,nx,ny,deltax,deltay,f1,f2)
57 
58 end subroutine invert_pv
subroutine invert_pv(x, pv, x_north, x_south, rs, nx, ny, deltax, deltay, F1, F2, bet)
Invert potential vorticity, returning streamfunction.
Definition: invert_pv.f90:16
subroutine solve_elliptic_system(x, pv, nx, ny, deltax, deltay, F1, F2)
Solves the elliptic system that arises when inverting potential vorticity.