1 subroutine da_qc_rad (it, ob, iv)
3 !---------------------------------------------------------------------------
4 ! Purpose: perform quality control for radiance data.
6 ! METHOD: separated QC for each sensor
7 !---------------------------------------------------------------------------
11 integer , intent(in) :: it ! outer loop count
12 type (y_type), intent(in) :: ob ! Observation structure.
13 type (iv_type), intent(inout) :: iv ! O-B structure.
15 integer :: i, nchan,p,j
16 logical :: amsua, amsub, hirs, msu,airs, hsb, ssmis, mhs, iasi, seviri
17 logical :: mwts, mwhs, atms, amsr2, imager, ahi, mwhs2, gmi
19 integer, allocatable :: index(:)
20 integer :: num_tovs_avg
21 integer, allocatable :: excess_count(:)
22 integer, allocatable :: spare_count(:)
25 integer :: temp(num_procs)
27 if (trace_use) call da_trace_entry("da_qc_rad")
29 if ( .not. allocated(num_tovs_before) ) allocate (num_tovs_before(iv%num_inst,num_procs))
30 if ( .not. allocated(num_tovs_after) ) allocate (num_tovs_after(iv%num_inst,num_procs))
32 ! Cannot be more total send,receives than combination of processors
33 if ( .not. allocated(tovs_copy_count) ) allocate (tovs_copy_count(iv%num_inst))
34 if ( .not. allocated(tovs_send_pe) ) allocate (tovs_send_pe(iv%num_inst,num_procs*num_procs))
35 if ( .not. allocated(tovs_recv_pe) ) allocate (tovs_recv_pe(iv%num_inst,num_procs*num_procs))
36 if ( .not. allocated(tovs_send_start) ) allocate (tovs_send_start(iv%num_inst,num_procs*num_procs))
37 if ( .not. allocated(tovs_send_count) ) allocate (tovs_send_count(iv%num_inst,num_procs*num_procs))
38 if ( .not. allocated(tovs_recv_start) ) allocate (tovs_recv_start(iv%num_inst,num_procs*num_procs))
40 call da_trace("da_qc_rad", message="allocated tovs redistibution arrays")
42 if ( .not. allocated(index) ) allocate (index(num_procs))
43 if ( .not. allocated(excess_count) ) allocate (excess_count(num_procs))
44 if ( .not. allocated(spare_count) ) allocate (spare_count(num_procs))
48 !if (iv%instid(i)%info%n2 < iv%instid(i)%info%n1) cycle
50 nchan = iv%instid(i)%nchan
52 amsua = trim(rttov_inst_name(rtminit_sensor(i))) == 'amsua'
53 amsub = trim(rttov_inst_name(rtminit_sensor(i))) == 'amsub'
54 hirs = trim(rttov_inst_name(rtminit_sensor(i))) == 'hirs'
55 msu = trim(rttov_inst_name(rtminit_sensor(i))) == 'msu'
56 airs = trim(rttov_inst_name(rtminit_sensor(i))) == 'airs'
57 hsb = trim(rttov_inst_name(rtminit_sensor(i))) == 'hsb'
58 ssmis = trim(rttov_inst_name(rtminit_sensor(i))) == 'ssmis'
59 mhs = trim(rttov_inst_name(rtminit_sensor(i))) == 'mhs'
60 iasi = trim(rttov_inst_name(rtminit_sensor(i))) == 'iasi'
61 mwts = trim(rttov_inst_name(rtminit_sensor(i))) == 'mwts'
62 mwhs = trim(rttov_inst_name(rtminit_sensor(i))) == 'mwhs'
63 mwhs2 = trim(rttov_inst_name(rtminit_sensor(i))) == 'mwhs2'
64 atms = trim(rttov_inst_name(rtminit_sensor(i))) == 'atms'
65 seviri = trim(rttov_inst_name(rtminit_sensor(i))) == 'seviri'
66 amsr2 = trim(rttov_inst_name(rtminit_sensor(i))) == 'amsr2'
67 imager = trim(rttov_inst_name(rtminit_sensor(i))) == 'imager'
68 ahi = trim(rttov_inst_name(rtminit_sensor(i))) == 'ahi'
69 gmi = trim(rttov_inst_name(rtminit_sensor(i))) == 'gmi'
72 call da_qc_hirs(it, i,nchan,ob,iv)
74 call da_qc_airs(it, i,nchan,ob,iv)
76 ! call da_qc_hsb(it, i,nchan,ob,iv)
77 call da_warning(__FILE__,__LINE__,(/'QC Not implemented for HSB'/))
79 call da_qc_amsua(it,i,nchan,ob,iv)
80 else if ( amsub ) then
81 call da_qc_amsub(it,i,nchan,ob,iv)
83 ! call da_qc_msu(it, i,nchan, ob,iv)
84 call da_warning(__FILE__,__LINE__,(/'QC Not implemented for MSU'/))
86 call da_qc_ssmis(it, i,nchan,ob,iv)
88 call da_qc_mhs(it,i,nchan,ob,iv)
90 call da_qc_iasi(it,i,nchan,ob,iv)
92 call da_qc_mwhs(it,i,nchan,ob,iv)
94 call da_qc_mwhs2(it,i,nchan,ob,iv)
96 call da_qc_mwts(it,i,nchan,ob,iv)
98 call da_qc_atms(it,i,nchan,ob,iv)
100 call da_qc_seviri(it,i,nchan,ob,iv)
102 call da_qc_amsr2(it,i,nchan,ob,iv)
104 call da_qc_ahi(it,i,nchan,ob,iv)
105 else if (imager) then
106 call da_qc_goesimg(it,i,nchan,ob,iv)
108 call da_qc_gmi(it,i,nchan,ob,iv)
110 write(unit=message(1),fmt='(A,A)') &
111 "Unrecognized instrument",trim(rttov_inst_name(rtminit_sensor(i)))
112 call da_error(__FILE__,__LINE__,message(1:1))
115 ! Report number of observations to other processors via rootproc
117 num_tovs_before(i,:) = 0
118 num_tovs_before(i,myproc+1)=iv%instid(i)%num_rad
119 temp(:)= num_tovs_before(i,:)
120 call da_proc_sum_ints(temp(:))
123 call wrf_dm_bcast_integer(temp(:),num_procs)
125 num_tovs_before(i,:) = temp(:)
127 num_tovs_after(i,:) = num_tovs_before(i,:)
129 if (rootproc .and. print_detail_rad) then
130 write(unit=message(1),fmt='(A,I1,A)') "Instrument ",i, &
131 " initial tovs distribution"
132 write(unit=message(2),fmt=*) num_tovs_before(i,:)
133 call da_message(message(1:2))
136 ! Decide how to reallocate observations
138 num_tovs_avg=sum(num_tovs_before(i,:))/num_procs
140 call da_trace_int_sort(num_tovs_before(i,:),num_procs,index)
143 excess_count(p)=num_tovs_before(i,index(p))-num_tovs_avg
144 spare_count(p)=num_tovs_avg-num_tovs_before(i,index(p))
147 tovs_copy_count(i) = 0
148 tovs_send_start(i,:) = 0
149 tovs_send_count(i,:) = 0
154 if (spare_count(p) > tovs_min_transfer) then
156 if (excess_count(j) > tovs_min_transfer) then
158 tovs_copy_count(i)=tovs_copy_count(i)+1
159 tovs_send_pe(i,tovs_copy_count(i)) = index(j)-1
160 tovs_recv_pe(i,tovs_copy_count(i)) = index(p)-1
161 transfer=min(spare_count(p),excess_count(j))
162 tovs_send_count(i,tovs_copy_count(i)) = transfer
163 tovs_recv_start(i,tovs_copy_count(i)) = num_tovs_after(i,index(p))+1
164 num_tovs_after(i,index(p))=num_tovs_after(i,index(p))+transfer
165 num_tovs_after(i,index(j))=num_tovs_after(i,index(j))-transfer
166 tovs_send_start(i,tovs_copy_count(i)) = num_tovs_after(i,index(j))+1
167 spare_count(p)=spare_count(p)-transfer
168 excess_count(j)=excess_count(j)-transfer
174 if (.not. copy_found) exit
177 if (print_detail_rad) then
178 write(unit=message(1),fmt='(A,I1,A)') "Instrument ",i," final tovs distribution"
179 write(unit=message(2),fmt=*) num_tovs_after(i,:)
180 call da_message(message(1:2))
183 iv % instid(i) % num_rad_glo = sum(num_tovs_after(i,:))
187 deallocate (excess_count)
188 deallocate (spare_count)
190 if (trace_use) call da_trace_exit("da_qc_rad")
192 end subroutine da_qc_rad