7 ! INTEGER, PARAMETER :: LONG = SELECTED_REAL_KIND(9,99)
8 INTEGER, PARAMETER :: LONG
= SELECTED_REAL_KIND(15,37)
10 INTEGER, PARAMETER :: JPNX
=8
11 INTEGER, PARAMETER :: JPXEIG
=10
13 INTEGER, PARAMETER :: JPNY
=24
14 INTEGER, PARAMETER :: JPCHAN
=24
15 INTEGER, PARAMETER :: JPSCAN
=90
17 INTEGER, PARAMETER :: JBAND
=18
18 INTEGER, PARAMETER :: BOFF
= JBAND
/2 + 1
19 REAL, PARAMETER :: BDIV
= 180.0/JBAND
+ 0.0001
20 INTEGER, PARAMETER :: AVBAND
=2
22 REAL(KIND
=LONG
), PARAMETER :: VMAX
= 350.0, VMIN
= 50.0, VDMAX
= 20.0
23 CHARACTER(LEN
=10), PARAMETER :: labsel(10) = &
24 (/' WRONG SAT',' PATH 2+3',' LAND', &
25 ' ROGUE TB',' ROGUE DTB','BAD Win CH', &
26 ' OUTLIERS',' MASKED',' ', &
30 INTEGER :: nchan
! number of channels
31 INTEGER :: npred
! number of predictors
32 INTEGER :: platform_id
,satellite_id
,sensor_id
33 INTEGER :: year
, month
, day
, hour
, min
, sec
34 INTEGER :: scanline
,scanpos
37 INTEGER, pointer :: qc_flag(:) ! 1/0:good/bad
38 INTEGER, pointer :: cloud_flag(:) ! 1/0:no-cloud/cloud
39 REAL :: elevation
,lat
,lon
,ps
, t2m
, q2m
, tsk
, clwp
40 REAL, pointer :: tb(:), omb(:), bias(:)
41 REAL, pointer :: pred(:)
46 SUBROUTINE PRINT_BIAS(rads
)
50 TYPE(BIAS
), INTENT(IN
) :: rads
56 WRITE(6,'(a20,3i4)') 'Instrument Triplet :', rads
%platform_id
, &
57 rads
%satellite_id
,rads
%sensor_id
58 WRITE(6,'(a20,6i5)') 'DATE :', rads
%year
, &
59 rads
%month
,rads
%day
,rads
%hour
,rads
%min
,rads
%sec
61 WRITE(6,'(a20,2f10.3)') 'Latitude Longitude :', rads
%lat
,rads
%lon
63 WRITE(6,'(a20,2i5)') 'Scan Line/Position :', rads
%scanline
,rads
%scanpos
64 WRITE(6,'(a20,i3,f10.2)') 'Land/Sea Elevation :', rads
%landmask
, rads
%elevation
66 WRITE(6,'(a20,4f10.2)') 'Ps Ts T2m Q2m :', rads
%ps
, rads
%tsk
, rads
%t2m
, rads
%q2m
68 WRITE(6,'(a20,i5)') 'Number of Channels :', rads
%nchan
70 WRITE(6,'(10x,i3,2f10.2)') lev
, rads
%tb(lev
), rads
%omb(lev
)
73 WRITE(6,'(a60)') ' predictors : 1000-300/200-50mb thickness T_skin TPW'
74 WRITE(6,'(4f10.2)') rads
%pred(1:rads
%npred
)
77 END SUBROUTINE PRINT_BIAS
79 SUBROUTINE MASK(PLAT
,PLONG
,LMASK
)
81 ! ROUTINE TO ACCESS RADIOSONDE MASK:
82 ! RETURNS LMASK=.TRUE. IF PLAT,PLONG CLOSE TO RADIOSONDE
83 ! LOCATION. DISTANCE DEFINED IN CREATION OF MASK.
87 REAL, INTENT(INOUT
) :: PLAT
, PLONG
88 LOGICAL, INTENT(OUT
) :: LMASK
90 INTEGER :: IMASK(360,181) = 0
91 INTEGER :: IERR
, ICL
, ILEN
92 ! INTEGER :: CRAYOPEN, CRAYREAD, CRAYCLOSE
93 INTEGER :: IUMASK
= 39, LOOP
= 0
95 INTEGER, SAVE :: INIT
= 0
98 CHARACTER(LEN
=1) :: C(600000)
103 open(169,FILE
='mask_asc')
104 print * ,' open radiosonde mask file mask_asc '
112 IF (PLONG
< 0.0) PLONG
= PLONG
+ 360.0
113 IX
= MOD(NINT(PLONG
),360) + 1
114 IY
= NINT(90.0-PLAT
) + 1
115 IF (IMASK(IX
,IY
) == 1) THEN
121 ! IF (LOOP.LE.100) WRITE(6,*) LOOP,PLAT,PLONG,IX,IY,IMASK(IX,IY),LMASK
126 LOGICAL FUNCTION USE_CHAN(j
,land
,path
,ICLR
,ICLD
,LNDCH
)
130 INTEGER, INTENT(IN
) :: j
, land
, path
131 INTEGER, INTENT(IN
) :: ICLR(JPNY
), ICLD(JPNY
), LNDCH(JPNY
)
133 INTEGER :: Lmask
, Cmask
137 Lmask
= LNDCH(J
) ! 0:not use; 1: use
146 Cmask
= ICLR(J
) ! 0:not use; 1: use
148 Cmask
= ICLD(J
) ! 0:not use; 1: use
153 IF (Lmask
*Cmask
== 0) THEN
160 END FUNCTION USE_CHAN
162 SUBROUTINE GET_SCORR(JPCHAN
,SCORR
,LAT
,vmnrlb
,JSCAN
)
166 ! Assume JBAND, JPCHAN, JPSCAN, BDIV and BOFF are inherited from main program.
167 ! Will need to be explicitly defined for 1DVAR, presumably #include in future.
169 INTEGER, INTENT(IN
) :: JPCHAN
170 REAL(KIND
=LONG
), INTENT(OUT
) :: SCORR(JPCHAN
)
171 REAL, INTENT(INOUT
) :: LAT
172 REAL(KIND
=LONG
), INTENT(INOUT
) :: vmnrlb(JPCHAN
,JPSCAN
,JBAND
)
173 INTEGER, INTENT(IN
) :: JSCAN
178 sband
= FLOOR(LAT
/BDIV
) + BOFF
179 BLAT
= FLOOR(LAT
/BDIV
)*BDIV
181 IF (LAT
>= BLAT
+BDIV
/2) THEN
183 IF (sband
< JBAND
) THEN
184 SCORR(1:JPCHAN
) = (LAT
- (BLAT
+BDIV
/2)) * vmnrlb(1:JPCHAN
,JSCAN
,sband
+1) / BDIV
&
185 + ((BLAT
+3*BDIV
/2) - LAT
) * vmnrlb(1:JPCHAN
,JSCAN
,sband
) / BDIV
187 SCORR(1:JPCHAN
) = vmnrlb(1:JPCHAN
,JSCAN
,sband
)
190 ELSEIF (LAT
< BLAT
+BDIV
/2) THEN
193 SCORR(1:JPCHAN
) = (LAT
- (BLAT
-BDIV
/2)) * vmnrlb(1:JPCHAN
,JSCAN
,sband
) / BDIV
&
194 + ((BLAT
+BDIV
/2) - LAT
) * vmnrlb(1:JPCHAN
,JSCAN
,sband
-1) / BDIV
196 SCORR(1:JPCHAN
) = vmnrlb(1:JPCHAN
,JSCAN
,sband
)
201 END SUBROUTINE GET_SCORR
203 SUBROUTINE QC_AMSUA(tovs
)
205 TYPE(bias
), intent(inout
) :: tovs
210 !--------------------------------------------------------
212 !--------------------------------------------------------
213 DO j
=1, tovs
%nchan
! Reject silly values
215 IF ((tovs
%tb(jv
) > VMAX
) .OR
. (tovs
%tb(jv
) < VMIN
) ) then
216 tovs
%qc_flag(jv
) = -1
220 !------------------------------------
221 ! 2.2 departure extrem values test
222 !------------------------------------
225 IF (ABS(tovs
%omb(jv
)) > VDMAX
) THEN
226 tovs
%qc_flag(jv
) = -1
230 !------------------------------------
232 !------------------------------------
233 IF (tovs
%surf_flag
> 0) THEN ! not over sea
234 tovs
%qc_flag(1:3) = -1
235 tovs
%qc_flag(15) = -1
238 END SUBROUTINE QC_AMSUA
240 SUBROUTINE QC_AMSUB(tovs
)
242 TYPE(bias
), intent(inout
) :: tovs
246 !--------------------------------------------------------
248 !--------------------------------------------------------
249 DO j
=1, tovs
%nchan
! Reject silly values
251 IF ((tovs
%tb(jv
) > VMAX
) .OR
. (tovs
%tb(jv
) < VMIN
) ) then
252 tovs
%qc_flag(jv
) = -1
256 !------------------------------------
257 ! 2.2 departure extrem values test
258 !------------------------------------
261 IF (ABS(tovs
%omb(jv
)) > VDMAX
) THEN
262 tovs
%qc_flag(jv
) = -1
266 !------------------------------------
268 !------------------------------------
269 IF (tovs
%surf_flag
> 0) THEN ! not over sea
270 tovs
%qc_flag(1:2) = -1
273 END SUBROUTINE QC_AMSUB
275 SUBROUTINE QC_ssmis(tovs
)
277 TYPE(bias
), intent(inout
) :: tovs
281 !--------------------------------------------------------
283 !--------------------------------------------------------
284 DO j
=1, tovs
%nchan
! Reject silly values
286 IF ((tovs
%tb(jv
) > VMAX
) .OR
. (tovs
%tb(jv
) < VMIN
) ) then
287 tovs
%qc_flag(jv
) = -1
291 !------------------------------------
292 ! 2.2 departure extrem values test
293 !------------------------------------
296 IF (ABS(tovs
%omb(jv
)) > VDMAX
) THEN
297 tovs
%qc_flag(jv
) = -1
301 !------------------------------------
303 !------------------------------------
304 IF (tovs
%surf_flag
> 0) THEN ! not over sea
305 tovs
%qc_flag(1:2) = -1
309 END SUBROUTINE QC_ssmis
311 subroutine da_read_biasprep(radbias
,biasprep_unit
,ierr
)
312 TYPE(bias
), INTENT(INOUT
) :: radbias
313 integer, intent(in
) :: biasprep_unit
314 integer, intent(out
) :: ierr
315 read(UNIT
=biasprep_unit
,END=990,ERR
=995) radbias
%nchan
,radbias
%npred
316 read(UNIT
=biasprep_unit
,END=990,ERR
=995) radbias
%platform_id
, &
317 radbias
%satellite_id
, &
319 radbias
%year
,radbias
%month
,&
320 radbias
%day
, radbias
%hour
, &
321 radbias
%min
, radbias
%sec
, &
326 radbias
%lat
,radbias
%lon
, &
327 radbias
%ps
,radbias
%t2m
, &
328 radbias
%q2m
,radbias
%tsk
, &
329 radbias
%tb(1:radbias
%nchan
), &
330 radbias
%omb(1:radbias
%nchan
), &
331 radbias
%bias(1:radbias
%nchan
), &
332 radbias
%pred(1:radbias
%npred
), &
333 radbias
%qc_flag(1:radbias
%nchan
), &
334 radbias
%cloud_flag(1:radbias
%nchan
), &
335 radbias
%surf_flag
, radbias
%clwp
348 end subroutine da_read_biasprep
350 subroutine da_write_biasprep(radbias
,biasprep_unit
)
351 TYPE(bias
), INTENT(IN
) :: radbias
352 integer, INTENT(IN
) :: biasprep_unit
354 write(UNIT
=biasprep_unit
) radbias
%nchan
,radbias
%npred
355 write(UNIT
=biasprep_unit
) radbias
%platform_id
, &
356 radbias
%satellite_id
, &
358 radbias
%year
,radbias
%month
,&
359 radbias
%day
, radbias
%hour
, &
360 radbias
%min
, radbias
%sec
, &
365 radbias
%lat
,radbias
%lon
, &
366 radbias
%ps
,radbias
%t2m
, &
367 radbias
%q2m
,radbias
%tsk
, &
368 radbias
%tb(1:radbias
%nchan
), &
369 radbias
%omb(1:radbias
%nchan
), &
370 radbias
%bias(1:radbias
%nchan
), &
371 radbias
%pred(1:radbias
%npred
), &
372 radbias
%qc_flag(1:radbias
%nchan
), &
373 radbias
%cloud_flag(1:radbias
%nchan
), &
374 radbias
%surf_flag
, radbias
%clwp
375 end subroutine da_write_biasprep
377 subroutine write_biascoef(nchan
,nscan
,nband
,npred
,global
, &
378 scanbias
,scanbias_b
,coef
,coef0
, &
379 nobs
,vmean_abs
,vstd_abs
,vmean_dep
,vstd_dep
)
381 integer, intent(in
) :: nchan
,nscan
,nband
,npred
,nobs(nchan
)
382 logical, intent(in
) :: global
383 real(KIND
=LONG
), intent(in
) :: scanbias(nchan
,nscan
), &
384 scanbias_b(nchan
,nscan
,nband
), &
385 coef(nchan
,npred
),coef0(nchan
), &
386 vmean_abs(nchan
), vstd_abs(nchan
), &
387 vmean_dep(nchan
),vstd_dep(nchan
)
388 integer :: iunit
,j
,i
,stdout
392 open(UNIT
=iunit
,file
='bcor.asc',form
='formatted')
394 write (iunit
,'(4i6)') nchan
,nscan
,nband
,npred
396 write (iunit
,'(i5,i10,4F8.2)') i
,nobs(i
),vmean_abs(i
),vstd_abs(i
),vmean_dep(i
),vstd_dep(i
)
400 write (iunit
,'(i5,5F12.5)') i
,(coef(i
,j
),j
=1,npred
),coef0(i
)
404 write (iunit
,'(a,/8X,90I7)') 'RELATIVE SCAN BIASES ',(j
,j
=1,nscan
)
407 write(iunit
,'(i5,i3,90F7.2)') j
,i
, scanbias_b(j
,1:nscan
,i
)
411 write (iunit
,'(a,/5X,90I7)') 'RELATIVE SCAN BIASES ',(j
,j
=1,nscan
)
413 write(iunit
,'(i5,90F7.2)') j
, scanbias(j
,1:nscan
)
418 end subroutine write_biascoef
420 subroutine read_biascoef(nchan
,nscan
,nband
,npred
,global
, &
421 scanbias
,scanbias_b
,coef
,coef0
, &
422 nobs
,vmean_abs
,vstd_abs
,vmean_dep
,vstd_dep
)
424 integer, intent(in
) :: nchan
,nscan
,nband
,npred
425 logical, intent(in
) :: global
426 integer, intent(out
) :: nobs(nchan
)
427 real(KIND
=LONG
), intent(out
) :: scanbias(nchan
,nscan
), &
428 scanbias_b(nchan
,nscan
,nband
), &
429 coef(nchan
,npred
),coef0(nchan
), &
430 vmean_abs(nchan
), vstd_abs(nchan
), &
431 vmean_dep(nchan
),vstd_dep(nchan
)
433 integer :: iunit
,j
,i
,stdout
, ii
,jj
437 open(UNIT
=iunit
,file
='scor.asc',form
='formatted')
439 !read (iunit,'(4i6)') nchan,nscan,nband,npred
442 read (iunit
,'(i5,i10,4F8.2)') ii
,nobs(i
),vmean_abs(i
),vstd_abs(i
),vmean_dep(i
),vstd_dep(i
)
446 read (iunit
,'(i5,5F12.5)') ii
,(coef(i
,j
),j
=1,npred
),coef0(i
)
454 read(iunit
,'(i5,i3,90F7.2)') jj
,ii
, scanbias_b(j
,1:nscan
,i
)
459 read(iunit
,'(i5,90F7.2)') jj
, scanbias(j
,1:nscan
)
464 end subroutine read_biascoef