1 subroutine da_test_vtoy_transform(grid, config_flags, vp, vv, xbx, be, iv, y)
3 !---------------------------------------------------------------------------
4 ! Purpose: Perform V To Y Adjoint transform test
6 ! Method: Perform adjoint test on complete transform: <y,y> = <v_adj,v>.
7 !---------------------------------------------------------------------------
11 type(grid_config_rec_type), intent(inout) :: config_flags
12 type(domain), intent(inout) :: grid
13 type(vp_type), intent(inout) :: vv ! Grdipt/EOF CV.
14 type(vp_type), intent(inout) :: vp ! Grdipt/level CV.
15 type(xbx_type), intent(in) :: xbx ! Header & non-gridded vars.
16 type(be_type), intent(in) :: be ! background error structure.
17 type(iv_type), intent(inout) :: iv ! ob. increment vector.
18 type(y_type), intent(inout) :: y ! y = h (xa)
21 real :: cv(1:cv_size) ! Test control variable.
22 real :: cv_2(1:cv_size)
23 real :: field(ims:ime, jms:jme)
24 real :: adj_sum_lhs ! < y, y >
25 real :: adj_rhs,adj_sum_rhs ! < v, v_adj >
26 real :: partial_lhs ! < y, y >
27 real :: pertile_lhs ! < y, y >
29 if (trace_use) call da_trace_entry("da_test_vtoy_transform")
31 write(unit=stdout, fmt='(a)') ' da_test_vtoy_transform:'
32 write(unit=stdout, fmt='(a)') '---------------------------------------'
34 call random_number(cv(:))
37 cv_2(1:cv_size) = cv(1:cv_size)
39 call da_zero_x(grid%xa)
40 call da_zero_vp_type(vp)
41 call da_zero_vp_type(vv)
43 call da_transform_vtoy(be, cv, iv, vp, vv, xbx, y, grid, config_flags )
45 !-------------------------------------------------------------------------
46 ! [3.0] Calculate LHS of adjoint test equation and
47 ! Rescale input to adjoint routine :
48 !-------------------------------------------------------------------------
50 call da_get_y_lhs_value( iv, y, partial_lhs, pertile_lhs, adj_sum_lhs )
54 ! call da_zero_vp_type(vp)
55 ! call da_zero_vp_type(vv)
56 ! call da_zero_x(grid%xa)
58 call da_transform_vtoy_adj(be, cv, iv, vp, vv, xbx, y, grid, config_flags, .true. )
60 adj_rhs = sum( cv(1:cv_size) * cv_2(1:cv_size) )
61 !-------------------------------------------------------------------------
63 !-------------------------------------------------------------------------
64 ! FIX? with wrf_dm_sum_real
70 call mpi_allreduce( adj_rhs, adj_sum_rhs, 1, true_mpi_real, mpi_sum, comm, ierr)
74 adj_sum_lhs = partial_lhs
79 write(unit=stdout, fmt='(A,1pe22.14)') &
80 'Whole Domain < y, y > = ', adj_sum_lhs
81 write(unit=stdout, fmt='(A,1pe22.14)') &
82 'Whole Domain < v, v_adj > = ', adj_sum_rhs
85 write(unit=stdout, fmt='(A,1pe22.14)') &
86 'Whole Domain < y, y > = ', adj_sum_lhs
87 write(unit=stdout, fmt='(A,1pe22.14)') &
88 'Whole Domain < v, v_adj > = ', adj_sum_rhs
91 if (trace_use) call da_trace_exit("da_test_vtoy_transform")
93 end subroutine da_test_vtoy_transform