FV3 Bundle
pv_operator_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 !> Potential vorticity operator - Adjoint
10 
11 subroutine pv_operator_ad (x,pv,nx,ny,F1,F2,deltax,deltay)
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-operator adjoint variable
20 real(kind=kind_real), intent(in) :: F1 !< Parameter in the PV operator
21 real(kind=kind_real), intent(in) :: F2 !< Parameter in the PV operator
22 real(kind=kind_real), intent(in) :: deltax !< Zonal grid spacing (non-dimensional)
23 real(kind=kind_real), intent(in) :: deltay !< Meridional grid spacing (non-dimensional)
24 
25 !--- vertical differences:
26 
27 x(:,:,1) = x(:,:,1) - f1*pv(:,:,1)
28 x(:,:,2) = x(:,:,2) + f1*pv(:,:,1)
29 x(:,:,1) = x(:,:,1) + f2*pv(:,:,2)
30 x(:,:,2) = x(:,:,2) - f2*pv(:,:,2)
31 
32 !--- del-squared of the streamfunction (5-point laplacian)
33 
34 x(:,1:ny-1,:) = x(:,1:ny-1,:) + (1.0_kind_real/(deltay*deltay))*pv(:,2:ny ,:)
35 x(:,2:ny ,:) = x(:,2:ny ,:) + (1.0_kind_real/(deltay*deltay))*pv(:,1:ny-1,:)
36 
37 x(nx ,:,:) = x(nx ,:,:) + (1.0_kind_real/(deltax*deltax))*pv(1 ,:,:)
38 
39 x(1:nx-1,:,:) = x(1:nx-1,:,:) + (1.0_kind_real/(deltax*deltax))*pv(2:nx ,:,:)
40 
41 x(1 ,:,:) = x(1 ,:,:) + (1.0_kind_real/(deltax*deltax))*pv(nx ,:,:)
42 x(2:nx ,:,:) = x(2:nx ,:,:) + (1.0_kind_real/(deltax*deltax))*pv(1:nx-1,:,:)
43 
44 
45 x(:,:,:) = x(:,:,:) -2.0_kind_real*( 1.0_kind_real/(deltax*deltax) &
46  & +1.0_kind_real/(deltay*deltay))*pv(:,:,:)
47 
48 pv(:,:,:) = 0.0_kind_real
49 
50 end subroutine pv_operator_ad
subroutine pv_operator_ad(x, pv, nx, ny, F1, F2, deltax, deltay)
Potential vorticity operator - Adjoint.