1 subroutine da_read_rand_unit(filename, unit_in,num,obs_type_in, nc)
3 !----------------------------------------------------------------------------
4 ! Purpose: Program to read diagnostics written on rand_unit by WRF-Var
5 !----------------------------------------------------------------------------
9 integer ,intent (in) :: unit_in
10 integer ,intent (inout) :: num
11 character*(*),intent (in) :: obs_type_in
12 character*(*),intent (inout) :: filename
13 integer ,intent (in) :: nc
16 character*20 :: iv_type
19 real :: fld(10), fld1_rad , fld2_rad
20 integer :: n, k, n1,n2, levels, ios
22 if (trace_use) call da_trace_entry("da_read_rand_unit")
24 open(unit=unit_in, file=trim(filename), status='old',iostat=ios)
26 call da_error(__FILE__,__LINE__, &
27 (/"Cannot open file"//filename/))
32 read(unit_in,'(a20,i8)', end = 999, err = 1000)iv_type,num_obs
35 if (index(iv_type,OBS_type_in(1:nc)) > 0) if_write = .true.
37 ! If radiance data treat differently
38 if ( (index(iv_type,'noaa') > 0) .or. (index(iv_type,'eos') > 0) .or. &
39 (index(iv_type,'dmsp') > 0) .or. (index(iv_type,'metop') > 0) ) then
41 if (if_write) num = num + 1
42 read(unit_in,'(2i8,f10.3,e15.7)')n1, n2, fld1_rad,fld2_rad
43 if (if_write)write(rand_unit,'(2i8,f10.3,e15.7)')num,n2, fld1_rad,fld2_rad
47 if (if_write) num = num + 1
48 if (index(iv_type,'bogus') > 0) then
49 read(unit_in,'(i8)', err=1000)levels
50 if (if_write) write(rand_unit,'(i8)')levels
51 read(unit_in,'(2i8,10e15.7)', err= 1000) n1, n2, fld
52 if (if_write) write(rand_unit,'(2i8,10e15.7)') num, levels, fld
54 read(unit_in,'(i8)', err=1000)levels
55 if (if_write) write(rand_unit,'(i8)')levels
57 read(unit_in,'(2i8,10e15.7)', err= 1000) n1, n2, fld
58 if (if_write) write(rand_unit,'(2i8,10e15.7)') num, k, fld
63 if (if_write) goto 999
68 if (trace_use) call da_trace_exit("da_read_rand_unit")
72 write(unit=message(1), fmt='(/a,i3/a/)') &
73 'read error on unit: ',unit_in, &
74 'in da_read_rand_unit'
75 call da_warning(__FILE__,__LINE__,message(1:1))
77 if (trace_use) call da_trace_exit("da_read_rand_unit")
79 end subroutine da_read_rand_unit