1 subroutine reallocate_analysis_grid(grid)
5 type(domain), intent(inout) :: grid
6 integer :: sm31, em31, sm32, em32, sm33, em33, ep_dim
8 if (trace_use) call da_trace_entry("da_solve_dual_res_init")
11 ! First deallocate the arrays associated with alpha and ensemble perturbations
14 if (trace_use) call da_trace("da_solve_dual_res_init", &
15 Message="Deallocating arrays")
18 IF ( ASSOCIATED( grid%ep%v1 ) ) THEN
19 DEALLOCATE(grid%ep%v1,STAT=ierr)
21 print *, ' Failed to deallocate grid%ep%v1. '
24 IF ( ASSOCIATED( grid%ep%v2 ) ) THEN
25 DEALLOCATE(grid%ep%v2,STAT=ierr)
27 print *, ' Failed to deallocate grid%ep%v2. '
30 IF ( ASSOCIATED( grid%ep%v3 ) ) THEN
31 DEALLOCATE(grid%ep%v3,STAT=ierr)
33 print *, ' Failed to deallocate grid%ep%v3. '
36 IF ( ASSOCIATED( grid%ep%v4 ) ) THEN
37 DEALLOCATE(grid%ep%v4,STAT=ierr)
39 print *, ' Failed to deallocate grid%ep%v4. '
42 IF ( ASSOCIATED( grid%ep%v5 ) ) THEN
43 DEALLOCATE(grid%ep%v5,STAT=ierr)
45 print *, ' Failed to deallocate grid%ep%v5. '
48 if ( alpha_hydrometeors ) then
49 IF ( ASSOCIATED( grid%ep%cw ) ) THEN
50 DEALLOCATE(grid%ep%cw,STAT=ierr)
52 write(unit=message(1),fmt='(a)') 'Failed to deallocate grid%ep%cw '
53 call da_error(__FILE__,__LINE__,message(1:1))
56 IF ( ASSOCIATED( grid%ep%rn ) ) THEN
57 DEALLOCATE(grid%ep%rn,STAT=ierr)
59 write(unit=message(1),fmt='(a)') 'Failed to deallocate grid%ep%rn '
60 call da_error(__FILE__,__LINE__,message(1:1))
63 IF ( ASSOCIATED( grid%ep%ci ) ) THEN
64 DEALLOCATE(grid%ep%ci,STAT=ierr)
66 write(unit=message(1),fmt='(a)') 'Failed to deallocate grid%ep%ci '
67 call da_error(__FILE__,__LINE__,message(1:1))
70 IF ( ASSOCIATED( grid%ep%sn ) ) THEN
71 DEALLOCATE(grid%ep%sn,STAT=ierr)
73 write(unit=message(1),fmt='(a)') 'Failed to deallocate grid%ep%sn '
74 call da_error(__FILE__,__LINE__,message(1:1))
77 IF ( ASSOCIATED( grid%ep%gr ) ) THEN
78 DEALLOCATE(grid%ep%gr,STAT=ierr)
80 write(unit=message(1),fmt='(a)') 'Failed to deallocate grid%ep%gr '
81 call da_error(__FILE__,__LINE__,message(1:1))
84 end if ! alpha_hydrometeors
85 IF ( ASSOCIATED( grid%vp%alpha ) ) THEN
86 DEALLOCATE(grid%vp%alpha,STAT=ierr)
88 print *, ' Failed to deallocate grid%vp%alpha. '
91 IF ( ASSOCIATED( grid%vv%alpha ) ) THEN
92 DEALLOCATE(grid%vv%alpha,STAT=ierr)
94 print *, ' Failed to deallocate grid%vv%alpha. '
100 ! Now, reallocate the arrays with the intermediate grid dimensions
103 if (trace_use) call da_trace("da_solve_dual_res_init", &
104 Message="Reallocating arrays")
106 sm31 = grid%intermediate_grid%sm31
107 em31 = grid%intermediate_grid%em31
108 sm32 = grid%intermediate_grid%sm32
109 em32 = grid%intermediate_grid%em32
110 sm33 = grid%intermediate_grid%sm33
111 em33 = grid%intermediate_grid%em33
114 if ( use_4denvar ) ep_dim=num_fgat_time ! 4D-En-Var
116 ! allocate grid%vp%alpha
118 ALLOCATE(grid%vp%alpha(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha),STAT=ierr)
120 print *,' Failed to allocate grid%vp%alpha(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
125 ! allocate grid%vv%alpha
127 ALLOCATE(grid%vv%alpha(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha),STAT=ierr)
129 print *,' Failed to allocate grid%vv%alpha(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
134 ! allocate grid%ep%v1
136 ALLOCATE(grid%ep%v1(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
138 print *,' Failed to allocate grid%ep%v1(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
143 ! allocate grid%ep%v2
145 ALLOCATE(grid%ep%v2(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
147 print *,' Failed to allocate grid%ep%v2(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
153 ! allocate grid%ep%v3
155 ALLOCATE(grid%ep%v3(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
157 print *,' Failed to allocate grid%ep%v3(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
162 ! allocate grid%ep%v4
164 ALLOCATE(grid%ep%v4(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
166 print *,' Failed to allocate grid%ep%v4(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
171 ! allocate grid%ep%v5
173 ALLOCATE(grid%ep%v5(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
175 print *,' Failed to allocate grid%ep%v5(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha). '
179 if ( alpha_hydrometeors ) then
181 ! allocate grid%ep%cw
183 ALLOCATE(grid%ep%cw(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
185 write(unit=message(1),fmt='(a)') 'Failed to allocate grid%ep%cw(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha) '
186 call da_error(__FILE__,__LINE__,message(1:1))
190 ! allocate grid%ep%rn
192 ALLOCATE(grid%ep%rn(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
194 write(unit=message(1),fmt='(a)') 'Failed to allocate grid%ep%rn(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha) '
195 call da_error(__FILE__,__LINE__,message(1:1))
199 ! allocate grid%ep%ci
201 ALLOCATE(grid%ep%ci(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
203 write(unit=message(1),fmt='(a)') 'Failed to allocate grid%ep%ci(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha) '
204 call da_error(__FILE__,__LINE__,message(1:1))
208 ! allocate grid%ep%sn
210 ALLOCATE(grid%ep%sn(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
212 write(unit=message(1),fmt='(a)') 'Failed to allocate grid%ep%sn(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha) '
213 call da_error(__FILE__,__LINE__,message(1:1))
217 ! allocate grid%ep%gr
219 ALLOCATE(grid%ep%gr(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha*ep_dim),STAT=ierr)
221 write(unit=message(1),fmt='(a)') 'Failed to allocate grid%ep%gr(sm31:em31,sm32:em32,sm33:em33,1:config_flags%ensdim_alpha) '
222 call da_error(__FILE__,__LINE__,message(1:1))
225 end if ! alpha_hydrometeors
227 if (trace_use) call da_trace_exit("da_solve_dual_res_init")
229 end subroutine reallocate_analysis_grid
233 subroutine allocate_intermediate_grid(grid)
235 type(domain), intent(inout) :: grid
237 integer :: sm31, em31, sm32, em32, sm33, em33
238 integer :: sm31x, em31x, sm32x, em32x, sm33x, em33x
239 integer :: sm31y, em31y, sm32y, em32y, sm33y, em33y
242 ! First deallocate the arrays
245 IF ( ASSOCIATED( grid%xp%vxy ) ) THEN
246 DEALLOCATE(grid%xp%vxy,STAT=ierr)
248 print *, ' Failed to deallocate grid%xp%vxy. '
251 IF ( ASSOCIATED( grid%xp%v1z ) ) THEN
252 DEALLOCATE(grid%xp%v1z,STAT=ierr)
254 print *, ' Failed to deallocate grid%xp%v1z. '
257 IF ( ASSOCIATED( grid%xp%v1x ) ) THEN
258 DEALLOCATE(grid%xp%v1x,STAT=ierr)
260 print *, ' Failed to deallocate grid%xp%v1x. '
263 IF ( ASSOCIATED( grid%xp%v1y ) ) THEN
264 DEALLOCATE(grid%xp%v1y,STAT=ierr)
266 print *, ' Failed to deallocate grid%xp%v1y. '
269 IF ( ASSOCIATED( grid%xp%v2z ) ) THEN
270 DEALLOCATE(grid%xp%v2z,STAT=ierr)
272 print *, ' Failed to deallocate grid%xp%v2z. '
275 IF ( ASSOCIATED( grid%xp%v2x ) ) THEN
276 DEALLOCATE(grid%xp%v2x,STAT=ierr)
278 print *, ' Failed to deallocate grid%xp%v2x. '
281 IF ( ASSOCIATED( grid%xp%v2y ) ) THEN
282 DEALLOCATE(grid%xp%v2y,STAT=ierr)
284 print *, ' Failed to deallocate grid%xp%v2y. '
287 IF ( ASSOCIATED( grid%xb%grid_box_area ) ) THEN
288 DEALLOCATE(grid%xb%grid_box_area,STAT=ierr)
290 print *, ' Failed to deallocate grid%xb%grid_box_area. '
316 ! allocate grid%xp%vxy
318 ALLOCATE(grid%xp%vxy(sm31:em31,sm32:em32),STAT=ierr)
320 print *,' Failed to allocate grid%xp%vxy'
325 ! allocate grid%xp%v1z
327 ALLOCATE(grid%xp%v1z(sm31:em31,sm32:em32,sm33:em33),STAT=ierr)
329 print *,' Failed to allocate grid%xp%v1z'
334 ! allocate grid%xp%v1x
336 ALLOCATE(grid%xp%v1x(sm31x:em31x,sm32x:em32x,sm33x:em33x),STAT=ierr)
338 print *,' Failed to allocate grid%xp%v1x'
343 ! allocate grid%xp%v1y
345 ALLOCATE(grid%xp%v1y(sm31y:em31y,sm32y:em32y,sm33y:em33y),STAT=ierr)
347 print *,' Failed to allocate grid%xp%v1y'
352 ! allocate grid%xp%v2z
354 ALLOCATE(grid%xp%v2z(sm31:em31,sm32:em32,sm33:em33),STAT=ierr)
356 print *,' Failed to allocate grid%xp%v2z'
362 ! allocate grid%xp%v2x
364 ALLOCATE(grid%xp%v2x(sm31x:em31x,sm32x:em32x,sm33x:em33x),STAT=ierr)
366 print *,' Failed to allocate grid%xp%v2x'
372 ! allocate grid%xp%v2y
374 ALLOCATE(grid%xp%v2y(sm31y:em31y,sm32y:em32y,sm33y:em33y),STAT=ierr)
376 print *,' Failed to allocate grid%xp%v2y'
381 ! allocate grid%xb%grid_box_area
383 ALLOCATE(grid%xb%grid_box_area(sm31:em31,sm32:em32),STAT=ierr)
385 print *,' Failed to allocate grid%xb%grid_box_area(sm31:em31,sm32:em32)'
387 grid%xb%grid_box_area=0.
389 end subroutine allocate_intermediate_grid