FV3 Bundle
invert_pv_ad.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 - Adjoint
10 
11 subroutine invert_pv_ad (x,pv,nx,ny,deltax,deltay,F1,F2)
12 
13 use kinds
14 
15 implicit none
16 integer, intent(in) :: nx !< Zonal grid dimension
17 integer, intent(in) :: ny !< Meridional grid dimension
18 real(kind=kind_real), intent(inout) :: x(nx,ny,2) !< Streamfunction adjoint variable
19 real(kind=kind_real), intent(inout) :: pv(nx,ny,2) !< PV adjoint variable
20 real(kind=kind_real), intent(in) :: deltax !< Zonal grid spacing (non-dimensional)
21 real(kind=kind_real), intent(in) :: deltay !< Meridional grid spacing (non-dimensional)
22 real(kind=kind_real), intent(in) :: F1 !< Coefficient in PV operator
23 real(kind=kind_real), intent(in) :: F2 !< Coefficient in PV operator
24 
25 real(kind=kind_real) :: pv_nobc(nx,ny,2)
26 
27 !--- Solve the elliptic system. Here, we use the symmetry of the operator,
28 !--- rather than coding the adjoint of the solver.
29 
30 x(:,:,1) = -f1*x(:,:,1)
31 x(:,:,2) = -f2*x(:,:,2)
32 
33 call solve_elliptic_system (pv_nobc,x,nx,ny,deltax,deltay,f1,f2)
34 
35 x(:,:,:) = 0.0_kind_real
36 pv(:,:,1) = pv(:,:,1) + pv_nobc(:,:,1)*(-1.0_kind_real/f1)
37 pv(:,:,2) = pv(:,:,2) + pv_nobc(:,:,2)*(-1.0_kind_real/f2)
38 
39 end subroutine invert_pv_ad
subroutine invert_pv_ad(x, pv, nx, ny, deltax, deltay, F1, F2)
Invert potential vorticity - Adjoint.
subroutine solve_elliptic_system(x, pv, nx, ny, deltax, deltay, F1, F2)
Solves the elliptic system that arises when inverting potential vorticity.