1 subroutine da_setup_obs_structures_bufr(grid, ob, iv)
3 !---------------------------------------------------------------------------
4 ! Purpose: Define, allocate and read observation structure.
5 !---------------------------------------------------------------------------
9 type (domain) , intent(in) :: grid ! model data
10 type (y_type), intent(out) :: ob ! Observation structure.
11 type (iv_type), intent(inout) :: iv ! O-B structure.
15 character(len=filename_len) :: filename
18 logical :: has_errtable
19 integer :: junit, iost, itype, ivar, k
22 if (trace_use) call da_trace_entry("da_setup_obs_structures_bufr")
24 !-------------------------------
25 ! 0.0 Make thinning grids
26 !------------------------------
29 allocate(thinning_grid_conv(num_ob_indexes))
30 do n = 1, num_ob_indexes
31 if ( use_satwnd_bufr .and. n==polaramv ) cycle ! handled separately below
32 if ( thin_conv_opt(n) > no_thin ) then
33 call make3grids (n,thin_mesh_conv(n))
36 if ( rootproc ) then ! for satwnd_bufr, thinning is done on rootproc
37 if ( use_satwnd_bufr .and. thin_conv_opt(polaramv) > no_thin ) then
38 if ( thin_conv_opt(polaramv) /= thin_superob_hv ) then
39 call make3grids (polaramv, thin_mesh_conv(polaramv))
42 nplev = int(1200/thin_mesh_vert_conv(polaramv))
43 call make3grids (polaramv, thin_mesh_conv(polaramv), thin_3d=.true., nlev=nplev)
49 ! check for external obs error table
50 inquire(file='obs_errtable', exist=has_errtable)
51 if ( has_errtable ) then
52 allocate (oetab(300,33,6))
54 if ( rootproc ) then ! only rootproc reads the file
55 if ( has_errtable ) then
56 call da_get_unit(junit)
57 open(unit=junit, file='obs_errtable', form='formatted', status='old', &
59 write(unit=message(1),fmt='(A)') "Reading obs_errtable file"
60 call da_message(message(1:1))
61 read_loop: do while ( iost == 0 )
62 read (junit,'(1x,i3)',iostat=iost) itype
63 if ( itype < 100 .or. itype > 300 ) then
64 call da_warning(__FILE__,__LINE__, (/'Error reading obs_errtable'/))
67 ! 6 columns (p coord in hPa, t, q, uv, p, pw)
68 read (junit,'(1x,6e12.5)',iostat=iost) (oetab(itype,k,ivar),ivar=1,6)
72 call da_free_unit(junit)
75 if ( has_errtable ) then
77 call wrf_dm_bcast_real(oetab, isize)
80 !--------------------------------------------------------------------------
82 !--------------------------------------------------------------------------
85 call da_read_obs_bufr(iv)
89 if ( use_gpsrefobs ) then
90 call da_read_obs_bufrgpsro(iv)
93 if ( use_gpsephobs ) then
94 call da_read_obs_bufrgpsro_eph(iv)
97 if ( use_satwnd_bufr ) then
98 call da_read_obs_bufr_satwnd('satwnd.bufr', iv, ob)
101 if ( has_errtable ) then
105 if ( thin_conv ) then
106 do n = 1, num_ob_indexes
107 if ( use_satwnd_bufr .and. n==polaramv ) cycle ! handled separately below
108 if ( thin_conv_opt(n) > no_thin ) then
109 call destroygrids_conv (n)
112 if ( rootproc ) then ! for satwnd_bufr, thinning is done on rootproc
113 if ( use_satwnd_bufr .and. thin_conv_opt(polaramv) > no_thin ) then
114 if ( thin_conv_opt(polaramv) /= thin_superob_hv ) then
115 call destroygrids_conv (polaramv)
118 call destroygrids_conv (polaramv, thin_3d=.true.)
122 deallocate(thinning_grid_conv)
125 !--------------------------------------------------------------------------
126 ! [3.0] Calculate innovation vector (O-B) and create (smaller) ob structure:
127 !--------------------------------------------------------------------------
129 call da_fill_obs_structures(iv, ob)
134 call da_error(__FILE__,__LINE__,(/"Needs to be compiled with a BUFR library"/))
137 if (trace_use) call da_trace_exit("da_setup_obs_structures_bufr")
139 end subroutine da_setup_obs_structures_bufr