1 subroutine da_setup_cv(be)
3 !---------------------------------------------------------------------------
4 ! Purpose: Calculate the size of the 1-dimensional control variable array.
5 !---------------------------------------------------------------------------
9 type (be_type), intent(inout) :: be ! background error.
11 integer :: iy, jx ! Local horizontal domain dimensions.
12 integer :: ij ! Product of horizontal dims.
17 if (trace_use) call da_trace_entry("da_setup_cv")
19 !--------------------------------------------------------------
20 ! [1] Define standard control variable size:
21 !--------------------------------------------------------------
24 be % cv % size1c = (be % v1 % max_wave+1) * (be % v1 % max_wave+2)/2
25 be % cv % size2c = (be % v2 % max_wave+1) * (be % v2 % max_wave+2)/2
26 be % cv % size3c = (be % v3 % max_wave+1) * (be % v3 % max_wave+2)/2
27 be % cv % size4c = (be % v4 % max_wave+1) * (be % v4 % max_wave+2)/2
28 be % cv % size5c = (be % v5 % max_wave+1) * (be % v5 % max_wave+2)/2
30 be % cv % size1 = 2 * be % cv % size1c * be % v1 % mz
31 be % cv % size2 = 2 * be % cv % size2c * be % v2 % mz
32 be % cv % size3 = 2 * be % cv % size3c * be % v3 % mz
33 be % cv % size4 = 2 * be % cv % size4c * be % v4 % mz
34 be % cv % size5 = 2 * be % cv % size5c * be % v5 % mz
38 if( use_rf )then ! Use recursive filters:
39 ij = iy * jx ! cv space size same as state space size
40 else ! cv space size slightly larger for dwtai2():
41 ij = size(be%wsd,1)*size(be%wsd,2)
42 ! call da_setup_cv_iyjx2ij(iy,jx,ij,nij,nb,lf,"tile")
43 write(unit=message(1),fmt='("da_setup_cv: using ",i0," 2D ",A1,i0," wavelets in ",i0," bands.")') ij,namw,lf,nb
44 call da_message(message(1:1))
46 be % cv % size1 = ij * be % v1 % mz
47 be % cv % size2 = ij * be % v2 % mz
48 be % cv % size3 = ij * be % v3 % mz
49 be % cv % size4 = ij * be % v4 % mz
50 be % cv % size5 = ij * be % v5 % mz
52 if ( cloud_cv_options >= 2 ) then
53 be % cv % size6 = ij * be % v6 % mz
54 be % cv % size7 = ij * be % v7 % mz
55 be % cv % size8 = ij * be % v8 % mz
56 be % cv % size9 = ij * be % v9 % mz
57 be % cv % size10= ij * be % v10 % mz
60 be % cv % size11i= ij * be % v11 % mz
65 be % cv % size_jb = be % cv % size1 + be % cv % size2 + be % cv % size3 + &
66 be % cv % size4 + be % cv % size5
68 if ( cloud_cv_options >= 2 ) then
69 be % cv % size_jb = be % cv % size_jb + be % cv % size6 + &
70 be % cv % size7 + be % cv % size8 + be % cv % size9 + &
75 be % cv % size_jb = be % cv % size_jb + be % cv % size11i
78 !--------------------------------------------------------------
79 ! [1.1] Define 4D-Var lateral boundary condition control variable size:
80 !--------------------------------------------------------------
84 if ( .not. global .and. var4d ) then
85 be % cv % size1l = be % cv % size1
86 be % cv % size2l = be % cv % size2
87 be % cv % size3l = be % cv % size3
88 be % cv % size4l = be % cv % size4
89 be % cv % size5l = be % cv % size5
91 be % cv % size_jl = be % cv % size_jb
94 !--------------------------------------------------------------
95 ! [2] Define flow-dependent control variable size:
96 !--------------------------------------------------------------
98 if ( be % ne > 0) then
100 be % cv % size_alphac = (be % alpha % max_wave + 1) * &
101 (be % alpha % max_wave + 2) / 2
102 be % cv % size_je = 2 * be % cv % size_alphac * be % alpha % mz
104 be % cv % size_alphac = ij * be % alpha % mz * be % ne
105 be % cv % size_je = be % cv % size_alphac
109 !--------------------------------------------------------------
110 ! [3] Define domain-wide cv sizes for bit-repro option:
111 !--------------------------------------------------------------
113 cv_size_domain_jb = 0
114 cv_size_domain_je = 0
115 cv_size_domain_jl = 0
117 if (.not. global) then
123 ij = size(be%wsd,1)*size(be%wsd,2)
125 cv_size_domain_jb = ij * (be % v1 % mz + be % v2 % mz + be % v3 % mz + &
126 be % v4 % mz + be % v5 % mz )
127 if ( cloud_cv_options >= 2 ) then
128 cv_size_domain_jb = cv_size_domain_jb + ij * (be % v6 % mz + &
129 be % v7 % mz + be % v8 % mz + be % v9 % mz + be % v10 % mz )
132 cv_size_domain_jb = cv_size_domain_jb + ij * be % v11 % mz
134 cv_size_domain_je = ij * be % alpha % mz * be % ne
136 cv_size_domain_jl = cv_size_domain_jb
140 !--------------------------------------------------------------
141 ! [4] Define and add chem emiss cv sizes
142 !--------------------------------------------------------------
147 ij = iy * jx ! cv space size same as state space size
149 be % cv % sizechemic (:) = 0
150 do ic = PARAM_FIRST_SCALAR, num_chem
151 be % cv % sizechemic (ic) = ij * be % v12(ic-1) % mz
153 be % cv % size_jb = be % cv % size_jb + sum (be % cv % sizechemic (:))
157 if (trace_use) call da_trace_exit("da_setup_cv")
159 end subroutine da_setup_cv