1 subroutine da_write_increments (grid, q_cgrid, mu_cgrid, ph_cgrid)
3 !----------------------------------------------------------------------
4 ! Purpose: Write analysis increments
5 !----------------------------------------------------------------------
9 type (domain), intent(inout) :: grid
10 real,intent(in) :: q_cgrid(ims:ime,jms:jme,kms:kme)
11 real,intent(in) :: ph_cgrid(ims:ime,jms:jme,kms:kme)
12 real,intent(in) :: mu_cgrid(ims:ime,jms:jme)
14 ! Arrays for write out increments:
17 real, dimension(1:grid%xb%mix,1:grid%xb%mjy) :: gbuf_2d
18 real, dimension(1:grid%xb%mix+1,1:grid%xb%mjy+1) :: gbuf_2dd
19 real, dimension(1:grid%xb%mix,1:grid%xb%mjy,1:grid%xb%mkz) :: gbuf
21 real, dimension(1:grid%xb%mix,1:grid%xb%mjy,1:grid%xb%mkz+1) :: wgbuf
22 real, dimension(:,:,:), allocatable :: u_global, v_global, w_global, &
23 p_global, t_global, q_global, &
25 real, dimension(:,:) , allocatable :: mu_global, psfc_global, &
26 psac_global, tgrn_global, terr_global, snow_global,&
27 lat_global, lon_global, lanu_global, &
28 map_factor_global, cori_global, landmask_global
31 integer :: anl_inc_unit
33 if (trace_use) call da_trace_entry("da_write_increments")
36 ! Dimension of the domain:
43 ! 3-d and 2-d increments:
45 allocate ( p_global (1:ix+1,1:jy+1,1:kz+1))
46 allocate ( t_global (1:ix+1,1:jy+1,1:kz+1))
47 allocate ( q_global (1:ix+1,1:jy+1,1:kz+1))
48 allocate ( u_global (1:ix+1,1:jy+1,1:kz+1))
49 allocate ( v_global (1:ix+1,1:jy+1,1:kz+1))
50 allocate ( w_global (1:ix+1,1:jy+1,1:kz+1))
51 allocate ( ph_global (1:ix+1,1:jy+1,1:kz+1))
52 allocate (psfc_global (1:ix+1,1:jy+1))
53 allocate ( mu_global (1:ix+1,1:jy+1))
54 call da_patch_to_global(grid, grid%xa % p, gbuf)
56 p_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
58 call da_patch_to_global(grid, grid%xa % t, gbuf)
60 t_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
62 call da_patch_to_global(grid, q_cgrid, gbuf)
64 q_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
66 call da_patch_to_global(grid, grid%xa % u, gbuf)
68 u_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
70 call da_patch_to_global(grid, grid%xa % v, gbuf)
72 v_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
75 ! One more level for w and ph:
76 grid%xp%kde=grid%xp%kde+1
78 call da_patch_to_global(grid, grid%xa % w, wgbuf)
80 w_global(1:ix,1:jy,1:kz+1) = wgbuf(1:ix,1:jy,1:kz+1)
82 call da_patch_to_global(grid, ph_cgrid, wgbuf)
84 ph_global(1:ix,1:jy,1:kz+1) = wgbuf(1:ix,1:jy,1:kz+1)
87 grid%xp%kde=grid%xp%kde-1
89 call da_patch_to_global(grid, grid%xa % psfc, gbuf_2d)
91 psfc_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
93 call da_patch_to_global(grid, mu_cgrid, gbuf_2d)
95 mu_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
100 allocate ( psac_global (1:ix+1,1:jy+1))
101 allocate ( tgrn_global (1:ix+1,1:jy+1))
102 allocate ( terr_global (1:ix+1,1:jy+1))
103 allocate ( snow_global (1:ix+1,1:jy+1))
104 allocate ( lat_global (1:ix+1,1:jy+1))
105 allocate ( lon_global (1:ix+1,1:jy+1))
106 allocate ( lanu_global (1:ix+1,1:jy+1))
107 allocate (map_factor_global (1:ix+1,1:jy+1))
108 allocate ( cori_global (1:ix+1,1:jy+1))
109 allocate ( landmask_global (1:ix+1,1:jy+1))
111 call da_patch_to_global(grid, grid%xb%psac, gbuf_2d)
113 psac_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
115 call da_patch_to_global(grid, grid%xb%tgrn, gbuf_2d)
117 tgrn_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
119 call da_patch_to_global(grid, grid%xb%terr, gbuf_2d)
121 terr_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
123 call da_patch_to_global(grid, grid%xb%snow, gbuf_2d)
125 snow_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
127 call da_patch_to_global(grid, grid%xb%lat , gbuf_2d)
129 lat_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
131 call da_patch_to_global(grid, grid%xb%lon , gbuf_2d)
133 lon_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
135 call da_patch_to_global(grid, grid%xb%lanu, gbuf_2d)
137 lanu_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
139 call da_patch_to_global(grid, grid%xb%map_factor, gbuf_2d)
141 map_factor_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
144 ! temporary increase to dimensions for cori
147 grid%xp%ide=grid%xp%ide+1
148 grid%xp%jde=grid%xp%jde+1
149 call da_patch_to_global(grid, grid%xb%cori, gbuf_2dd)
151 cori_global(1:ix+1,1:jy+1) = gbuf_2dd(1:ix+1,1:jy+1)
155 grid%xp%ide=grid%xp%ide-1
156 grid%xp%jde=grid%xp%jde-1
158 call da_patch_to_global(grid, grid%xb%landmask, gbuf_2d)
160 landmask_global(1:ix,1:jy) = gbuf_2d(1:ix,1:jy)
166 call da_get_unit(anl_inc_unit)
167 open(unit=anl_inc_unit, file='analysis_increments', form='unformatted')
169 write (unit=anl_inc_unit) ANALYSIS_DATE
171 write (unit=anl_inc_unit) 1, ix, 1, jy, 1, kz
173 ! Map projection information:
174 write (unit=anl_inc_unit) map_projection, coarse_ix, coarse_jy
175 write (unit=anl_inc_unit) &
176 coarse_ds, start_x, start_y, &
177 phic, xlonc, cone_factor, truelat1_3dv, truelat2_3dv, pole, dsm, &
178 psi1, c2, ptop, base_pres, t0, base_lapse, base_temp
180 ! 1d constant fields:
182 write (unit=anl_inc_unit) grid%xb%sigmah, grid%xb%sigmaf
186 ! 3d- and 2d-increments:
187 write (unit=anl_inc_unit) u_global, v_global, w_global, p_global, &
188 t_global, q_global, ph_global, mu_global, psfc_global
190 ! 2d-constant fields:
191 write (unit=anl_inc_unit) psac_global, tgrn_global, terr_global, &
192 snow_global, lat_global, lon_global, lanu_global, map_factor_global, &
193 cori_global, landmask_global
195 call da_free_unit(anl_inc_unit)
198 ! 3d- and 2d-increments:
199 write (unit=anl_inc_unit) grid%xa%u(1:ix+1,1:jy+1,1:kz+1), &
200 grid%xa%v(1:ix+1,1:jy+1,1:kz+1), &
201 grid%xa%w(1:ix+1,1:jy+1,1:kz+1), &
202 grid%xa%p(1:ix+1,1:jy+1,1:kz+1), &
203 grid%xa%t(1:ix+1,1:jy+1,1:kz+1), &
204 q_cgrid(1:ix+1,1:jy+1,1:kz+1), &
205 ph_cgrid(1:ix+1,1:jy+1,1:kz+1), &
206 mu_cgrid(1:ix+1,1:jy+1), &
207 grid%xa%psfc(1:ix+1,1:jy+1)
209 ! .. 2d-constant fields:
210 write (unit=anl_inc_unit) grid%xb%psac(1:ix+1,1:jy+1), &
211 grid%xb%tgrn(1:ix+1,1:jy+1), &
212 grid%xb%terr(1:ix+1,1:jy+1), &
213 grid%xb%snow(1:ix+1,1:jy+1), &
214 grid%xb%lat(1:ix+1,1:jy+1), &
215 grid%xb%lon(1:ix+1,1:jy+1), &
216 grid%xb%lanu(1:ix+1,1:jy+1), &
217 grid%xb%map_factor(1:ix+1,1:jy+1), &
218 grid%xb%cori(1:ix+1,1:jy+1), &
219 grid%xb%landmask(1:ix+1,1:jy+1)
221 call da_free_unit(anl_inc_unit)
226 if (trace_use) call da_trace_exit("da_write_increments")
228 end subroutine da_write_increments