1 subroutine da_transform_vtovv_adj(grid, cv_size, be, cv, vv &
7 !-----------------------------------------------------------------------
9 !-----------------------------------------------------------------------
13 type(domain), intent(inout) :: grid
14 integer, intent(in) :: cv_size ! Size of cv array.
15 type(be_type), intent(in) :: be ! Background error structure.
16 real, intent(inout) :: cv(cv_size) ! control variables.
17 type(vp_type), intent(inout) :: vv ! Grid point/EOF control var.
20 type(xchem_type), optional, intent(inout) :: vchem ! Grid point/EOF equivalent.
24 integer :: s(4) ! Index bounds into arrays.
25 integer :: n ! Loop counter.
26 integer :: mz ! Vertical truncation.
27 integer :: ne ! Ensemble size.
31 if (trace_use) call da_trace_entry("da_transform_vtovv_adj")
33 if( .not. use_rf .or. do_normalize ) s(1:2)=1
35 !-------------------------------------------------------------------------
36 ! [2.0] Perform VToVV Transform:
37 !-------------------------------------------------------------------------
39 ! [2.1] Transform 1st control variable:
42 if( do_normalize )call da_transform_rescale(mz,be%sd(:,:,s(1):s(3)),vv%v1)
43 if( use_rf .and. mz > 0 .and. len_scaling1(1) /= 0.0) then
44 call da_transform_through_rf_adj(grid, mz, be % v1 % rf_alpha, be % v1 % val, vv % v1)
46 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
47 call da_transform_through_wavelet_adj(grid,mz,be%wsd(:,:,s(1):s(3)),cv(s(2):s(4)),vv%v1)
50 ! print'(a,": be%v1%mz=",I0)',__FILE__,mz
54 ! [2.2] Transform 2nd control variable:
58 if( do_normalize )call da_transform_rescale(mz,be%sd(:,:,s(1):s(3)),vv%v2)
59 if( use_rf .and. mz > 0 .and. len_scaling2(1) /= 0.0) then
60 call da_transform_through_rf_adj(grid, mz, be % v2 % rf_alpha, be % v2 % val, vv % v2)
62 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
63 call da_transform_through_wavelet_adj(grid,mz,be%wsd(:,:,s(1):s(3)),cv(s(2):s(4)),vv%v2)
66 ! print'(a,": be%v2%mz=",I0)',__FILE__,mz
70 ! [2.3] Transform 3rd control variable
74 if( do_normalize )call da_transform_rescale(mz,be%sd(:,:,s(1):s(3)),vv%v3)
75 if( use_rf .and. mz > 0 .and. len_scaling3(1) /= 0.0) then
76 call da_transform_through_rf_adj(grid, mz, be % v3 % rf_alpha, be % v3 % val, vv % v3)
78 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
79 call da_transform_through_wavelet_adj(grid,mz,be%wsd(:,:,s(1):s(3)),cv(s(2):s(4)),vv%v3)
82 ! print'(a,": be%v3%mz=",I0)',__FILE__,mz
86 ! [2.4] Transform 4th control variable
90 if( do_normalize )call da_transform_rescale(mz,be%sd(:,:,s(1):s(3)),vv%v4)
91 if( use_rf .and. mz > 0 .and. len_scaling4(1) /= 0.0) then
92 call da_transform_through_rf_adj(grid, mz, be % v4 % rf_alpha, be % v4 % val, vv % v4)
94 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
95 call da_transform_through_wavelet_adj(grid,mz,be%wsd(:,:,s(1):s(3)),cv(s(2):s(4)),vv%v4)
98 ! print'(a,": be%v4%mz=",I0)',__FILE__,mz
102 ! [2.5] Transform 5th control variable
106 if( do_normalize )call da_transform_rescale(mz,be%sd(:,:,s(1):s(3)),vv%v5)
107 if( use_rf .and. mz > 0 .and. len_scaling5(1) /= 0.0) then
108 call da_transform_through_rf_adj(grid, mz, be % v5 % rf_alpha, be % v5 % val, vv % v5)
109 elseif( mz > 0 ) then
110 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
111 call da_transform_through_wavelet_adj(grid,mz,be%wsd(:,:,s(1):s(3)),cv(s(2):s(4)),vv%v5)
114 ! print'(a,": be%v5%mz=",I0)',__FILE__,mz
118 if ( .not. use_rf .and. cloud_cv_options > 0 ) then
119 call da_error(__FILE__,__LINE__,(/"no da_transform_through_wavelet_adj for v6-v11"/))
122 if ( use_rf .and. cloud_cv_options <= 1 ) then
131 if ( use_rf .and. cloud_cv_options >= 2 ) then
132 select case ( cloud_cv_options )
134 !hcl-check array index of len_scaling
136 if ( mz > 0 .and. len_scaling6(1) > 0.0 ) then
137 call da_transform_through_rf_adj(grid, mz, be % v6 % rf_alpha, be % v6 % val, vv % v6)
140 if ( mz > 0 .and. len_scaling7(1) > 0.0 ) then
141 call da_transform_through_rf_adj(grid, mz, be % v7 % rf_alpha, be % v7 % val, vv % v7)
144 if ( mz > 0 .and. len_scaling8(1) > 0.0 ) then
145 call da_transform_through_rf_adj(grid, mz, be % v8 % rf_alpha, be % v8 % val, vv % v8)
148 if ( mz > 0 .and. len_scaling9(1) > 0.0 ) then
149 call da_transform_through_rf_adj(grid, mz, be % v9 % rf_alpha, be % v9 % val, vv % v9)
152 if ( mz > 0 .and. len_scaling10(1) > 0.0 ) then
153 call da_transform_through_rf_adj(grid, mz, be % v10 % rf_alpha, be % v10 % val, vv % v10)
158 if ( mz > 0 .and. len_scaling6(1) > 0.0 ) then
159 call da_transform_through_rf_adj(grid, mz, be % v6 % rf_alpha, be % v6 % val, vv % v6, scaling)
162 if ( mz > 0 .and. len_scaling7(1) > 0.0 ) then
163 call da_transform_through_rf_adj(grid, mz, be % v7 % rf_alpha, be % v7 % val, vv % v7, scaling)
166 if ( mz > 0 .and. len_scaling8(1) > 0.0 ) then
167 call da_transform_through_rf_adj(grid, mz, be % v8 % rf_alpha, be % v8 % val, vv % v8, scaling)
170 if ( mz > 0 .and. len_scaling9(1) > 0.0 ) then
171 call da_transform_through_rf_adj(grid, mz, be % v9 % rf_alpha, be % v9 % val, vv % v9, scaling)
174 if ( mz > 0 .and. len_scaling10(1) > 0.0 ) then
175 call da_transform_through_rf_adj(grid, mz, be % v10 % rf_alpha, be % v10 % val, vv % v10, scaling)
180 ! [2.7] Transform w control variables
183 if ( .not. use_cv_w ) then
187 if ( mz > 0 .and. len_scaling11(1) > 0.0 ) then
188 if ( cloud_cv_options == 2 ) then
189 call da_transform_through_rf_adj(grid, mz, be % v11 % rf_alpha, be % v11 % val, vv % v11)
190 else if ( cloud_cv_options == 3 ) then
192 call da_transform_through_rf_adj(grid, mz, be % v11 % rf_alpha, be % v11 % val, vv % v11, scaling)
198 ! [2.8] Transform alpha control variable
203 if( do_normalize )then
205 call da_transform_rescale(mz,be%alpha%sd,vv%alpha(:,:,:,n))
210 if ( anal_type_hybrid_dual_res ) then
211 call da_transform_through_rf_adj_dual_res(grid % intermediate_grid, mz, be % alpha % rf_alpha, &
212 be % alpha % val, vv % alpha(:,:,:,n))
214 call da_transform_through_rf_adj(grid, mz, be % alpha % rf_alpha, be % alpha % val, vv % alpha(:,:,:,n))
219 s(4)=s(2)+nij(0,0,2)*nij(0,1,2)*mz-1
220 call da_transform_through_wavelet_adj(grid,mz,be%alpha%wsd,cv(s(2):s(4)),vv%alpha(:,:,:,n))
227 ! if (present(vchem) .and. iv%info(chemic_surf)%nlocal > 0) then
228 if (present(vchem)) then
229 !!! do ic = 1, num_chem-1
230 do ic = PARAM_FIRST_SCALAR, num_chem
231 mz = be % v12 (ic-1) % mz
232 if( use_rf .and. mz > 0 ) then
233 call da_transform_through_rf_adj(grid, mz, be % v12 (ic-1) % rf_alpha, &
234 be % v12 (ic-1) % val, &
235 vchem % chem_ic (:,:,:,ic) )
236 elseif( .not. use_rf ) then
237 call da_error(__FILE__,__LINE__,(/"no da_transform_through_wavelet for chem_ic"/))
244 !-------------------------------------------------------------------------
245 ! [1.0] Fill 1D cv array from 3-dimensional vv arrays.
246 !-------------------------------------------------------------------------
248 if (present(vchem)) then
249 call da_vv_to_cv( vv, grid%xp, be%cv_mz, be%ncv_mz, cv_size, cv, be%cv_mz_chemic, vchem)
252 call da_vv_to_cv( vv, grid%xp, be%cv_mz, be%ncv_mz, cv_size, cv)
258 if (trace_use) call da_trace_exit("da_transform_vtovv_adj")
260 endsubroutine da_transform_vtovv_adj