1 subroutine da_write_vp (grid,vp,filename)
3 !----------------------------------------------------------------------
4 ! Purpose: Write vp, full varibles after balance transform Up
5 ! will be interpolated into higher resolution by offline program
6 ! Method: based on da_write_increments.inc
7 ! Author: Zhiquan (Jake) Liu, NCAR/MMM, 2015-09
8 ! add cloud and w variables, 2017-07
9 !----------------------------------------------------------------------
13 type (domain), intent(in) :: grid
14 type(vp_type), intent(in) :: vp
15 character(len=16), intent(in) :: filename
17 ! Arrays for write out increments:
20 !real, dimension(1:grid%xb%mix,1:grid%xb%mjy) :: gbuf_2d
21 !real, dimension(1:grid%xb%mix+1,1:grid%xb%mjy+1) :: gbuf_2dd
22 real, dimension(1:grid%xb%mix,1:grid%xb%mjy,1:grid%xb%mkz) :: gbuf
24 !real, dimension(1:grid%xb%mix,1:grid%xb%mjy,1:grid%xb%mkz+1) :: wgbuf
25 real, dimension(:,:,:), allocatable :: v1_global, v2_global, &
26 v3_global, v4_global, v5_global
27 real, dimension(:,:,:), allocatable :: v6_global, v7_global, &
28 v8_global, v9_global, v10_global, v11_global
31 integer :: vp_unit, vp_local_unit
32 character(len=7) :: vpfile
34 if (trace_use) call da_trace_entry("da_write_vp")
37 ! Dimension of the domain (unstagered):
44 ! 3-d and 2-d increments:
46 allocate ( v1_global (1:ix,1:jy,1:kz))
47 allocate ( v2_global (1:ix,1:jy,1:kz))
48 allocate ( v3_global (1:ix,1:jy,1:kz))
49 allocate ( v4_global (1:ix,1:jy,1:kz))
50 allocate ( v5_global (1:ix,1:jy,1:kz))
51 if ( cloud_cv_options >= 2 ) then
52 allocate ( v6_global (1:ix,1:jy,1:kz))
53 allocate ( v7_global (1:ix,1:jy,1:kz))
54 allocate ( v8_global (1:ix,1:jy,1:kz))
55 allocate ( v9_global (1:ix,1:jy,1:kz))
56 allocate ( v10_global (1:ix,1:jy,1:kz))
59 allocate ( v11_global (1:ix,1:jy,1:kz))
62 call da_patch_to_global(grid, vp % v1, gbuf) ! psi or u
64 v1_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
67 call da_patch_to_global(grid, vp % v2, gbuf) ! chi_u or v
69 v2_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
72 call da_patch_to_global(grid, vp % v3, gbuf) ! t_u or t
74 v3_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
77 call da_patch_to_global(grid, vp % v4, gbuf) ! q/qs
79 v4_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
82 !print *, "local size v5: ", size(vp % v5,1),size(vp % v5,2),size(vp % v5,3)
83 call da_patch_to_global(grid, vp % v5, gbuf) ! Ps (:,:,1)
85 v5_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
88 if ( cloud_cv_options >= 2 ) then
89 call da_patch_to_global(grid, vp % v6, gbuf) ! qcloud
91 v6_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
94 call da_patch_to_global(grid, vp % v7, gbuf) ! qrain
96 v7_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
99 call da_patch_to_global(grid, vp % v8, gbuf) ! qice
101 v8_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
104 call da_patch_to_global(grid, vp % v9, gbuf) ! qsnow
106 v9_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
109 call da_patch_to_global(grid, vp % v10, gbuf) ! qgraupel
111 v10_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
113 end if ! cloud_cv_options
116 call da_patch_to_global(grid, vp % v11, gbuf) ! w
118 v11_global(1:ix,1:jy,1:kz) = gbuf(1:ix,1:jy,1:kz)
122 !write(unit=vpfile,fmt='(a,i4.4)') 'vp_',myproc
123 !call da_get_unit(vp_local_unit)
124 !open(unit=vp_local_unit, file=trim(vpfile), form='unformatted')
126 !print *, "local: ips,ipe,jps,jpe,kps,kpe=", ips,ipe,jps,jpe,kps,kpe
127 !print *, "local: ims,ime,jms,jme,kms,kme=", ims,ime,jms,jme,kms,kme
128 !print *, "local: dimx, dimy, dimz=", size(vp%v5,1),size(vp%v5,2),size(vp%v5,3)
130 !write (unit=vp_local_unit) ips,ipe,jps,jpe,kps,kpe, &
131 ! ims,ime,jms,jme,kms,kme, &
132 ! size(vp%v5,1),size(vp%v5,2),size(vp%v5,3)
134 !write (unit=vp_local_unit) vp%v1, vp%v2, &
135 ! vp%v3, vp%v4, vp%v5
137 !close(vp_local_unit)
138 !call da_free_unit(vp_local_unit)
144 call da_get_unit(vp_unit)
145 open(unit=vp_unit, file=trim(filename), form='unformatted')
147 !print *, "ANALYSIS_DATE= ", ANALYSIS_DATE
148 !write (unit=vp_unit) ANALYSIS_DATE
150 print *, "write_vp: Global ix, jy, kz=", ix, jy, kz
151 write (unit=vp_unit) ix, jy, kz
155 ! 3d- and 2d-increments in vp space:
156 write (unit=vp_unit) v1_global, v2_global, &
157 v3_global, v4_global, v5_global
159 if ( cloud_cv_options >= 2 ) then
160 write (unit=vp_unit) v6_global, v7_global, &
161 v8_global, v9_global, v10_global
163 if ( use_cv_w ) write (unit=vp_unit) v11_global
166 call da_free_unit(vp_unit)
170 ! 3d- and 2d-increments:
171 write (unit=vp_unit) vp%v1(1:ix,1:jy,1:kz), &
172 vp%v2(1:ix,1:jy,1:kz), &
173 vp%v3(1:ix,1:jy,1:kz), &
174 vp%v4(1:ix,1:jy,1:kz), &
176 if ( cloud_cv_options >= 2 ) then
177 write (unit=vp_unit) vp%v6(1:ix,1:jy,1:kz), &
178 vp%v7(1:ix,1:jy,1:kz), &
179 vp%v8(1:ix,1:jy,1:kz), &
180 vp%v9(1:ix,1:jy,1:kz), &
181 vp%v10(1:ix,1:jy,1:kz)
183 if ( use_cv_w ) write (unit=vp_unit) vp%v11(1:ix,1:jy,1:kz)
186 call da_free_unit(vp_unit)
191 if (trace_use) call da_trace_exit("da_write_vp")
193 end subroutine da_write_vp