11 use netcdf,
only: nf90_int, nf90_float, nf90_char
40 character(len=ndatetime) :: datetime
48 integer(i_kind) :: t29
49 integer(i_kind) :: rptype
50 integer(i_kind) :: satid
51 character(len=nstring) :: msg_type
52 character(len=nstring) :: stid
53 character(len=ndatetime) :: datetime
54 integer(i_kind) :: nlevels
64 character(len=nstring) :: obtype
65 integer(i_kind) :: obtype_idx
74 integer(i_kind),
parameter ::
lim_qm = 4
84 character (len=*),
intent(in) :: filename
85 character (len=10),
intent(out) :: filedate
87 real(
r_kind),
parameter :: r8bfms = 9.0e08
89 logical :: match, end_of_file, drift
90 character(len=8) :: subset, subst2, csid, csid2
91 character(len=40) :: obstr,hdstr,qmstr,oestr, pcstr, drstr
93 real(
r_double) :: hdr(7), hdr2(7), hdr_save(7)
94 real(
r_double) :: obs(8,255),qms(8,255),oes(8,255),pco(8,255)
95 real(
r_double) :: obs2(8,255),qms2(8,255),oes2(8,255),pco2(8,255)
96 real(
r_double) :: pmo(2,1), pmo2(2,1), pmo_save(2,1)
100 real(
r_double) :: drf(8,255), drf2(8,255)
101 real(
r_double) :: satqc(1), satid(1)
102 equivalence(r8sid, csid), (r8sid2, csid2)
104 character(len=14) :: cdate, dsec, obs_date
105 integer(i_kind) :: idate, idate2
106 integer(i_kind) :: nlevels, nlevels2, lv1, lv2
107 integer(i_kind) :: iyear, imonth, iday, ihour, imin, isec
108 integer(i_kind) :: num_report_infile
109 integer(i_kind) :: iret, iret2, iost, n, i, j, k, i1, i2
110 integer(i_kind) :: kx, t29
111 integer(i_kind) :: tpc
112 integer(i_kind) :: iunit, junit, itype, ivar
113 logical :: use_errtable, combine_mass_wind, do_tv_to_ts
114 real(
r_kind) :: oetab(300,33,6)
118 write(*,*)
'--- reading '//trim(filename)//
' ---'
119 hdstr=
'SID XOB YOB DHR TYP ELV T29'
120 obstr=
'POB QOB TOB ZOB UOB VOB PWO CAT'
121 qmstr=
'PQM QQM TQM ZQM WQM NUL PWQ NUL'
122 oestr=
'POE QOE TOE NUL WOE NUL PWE NUL'
123 pcstr=
'PPC QPC TPC ZPC WPC NUL PWP NUL'
124 drstr=
'XDR YDR HRDR '
128 if ( .not.
associated(
phead) )
then
131 nullify (
phead%next )
134 use_errtable = .false.
135 combine_mass_wind = .false.
136 do_tv_to_ts = .false.
138 num_report_infile = 0
144 open (unit=iunit, file=trim(filename), &
145 iostat=iost, form=
'unformatted', status=
'old')
147 write(unit=*,fmt=
'(a,i5,a)') &
148 "Error",iost,
" opening PREPBUFR obs file "//trim(filename)
152 open (unit=junit, file=
'obs_errtable', form=
'formatted', &
153 status=
'old', iostat=iost)
154 if ( iost /= 0 )
then
155 use_errtable = .false.
157 use_errtable = .true.
158 write(unit=*,fmt=
'(A)') &
159 "obs_errtable file is found. Will use user-provided obs errors."
161 if ( use_errtable )
then
163 read (junit,
'(1x,i3)',iostat=iost) itype
164 if ( iost /=0 )
exit read_loop
166 read (junit,
'(1x,6e12.5)',iostat=iost) (oetab(itype,k,ivar),ivar=1,6)
167 if ( iost /=0 )
exit read_loop
172 call openbf(iunit,
'IN',iunit)
175 call readns(iunit,subset,idate,iret)
176 if ( iret /= 0 )
then
177 write(unit=*,fmt=
'(A,I5,A)') &
178 "Error",iret,
" reading PREPBUFR obs file "//trim(filename)
184 write(unit=*,fmt=
'(1x,a,a,i10)') trim(filename),
' file date is: ', idate
186 write(unit=filedate,fmt=
'(i10)') idate
191 end_of_file = .false.
192 reports:
do while ( .not. end_of_file )
195 call readns(iunit,subset,idate,iret)
196 if ( iret /= 0 )
then
197 write(unit=*,fmt=
'(A,I3,A,I3)') &
198 "return code from readns",iret, &
199 "reach the end of PREPBUFR obs unit",iunit
204 num_report_infile = num_report_infile + 1
206 call ufbint(iunit,satqc,1,1,iret,
'QIFN')
207 call ufbint(iunit,satid,1,1,iret,
'SAID')
208 call ufbint(iunit,hdr,7,1,iret,hdstr)
209 call ufbint(iunit,pmo,2,1,iret,
'PMO PMQ')
210 call ufbint(iunit,qms,8,255,nlevels,qmstr)
211 call ufbint(iunit,oes,8,255,nlevels,oestr)
212 call ufbint(iunit,pco,8,255,nlevels,pcstr)
213 call ufbint(iunit,obs,8,255,nlevels,obstr)
219 if ( use_errtable )
then
223 if ( pob >= oetab(kx,lv1+1,1) .and. pob <= oetab(kx,lv1,1) )
then
224 coef = (pob-oetab(kx,lv1,1))/(oetab(kx,lv1,1)-oetab(kx,lv1+1,1))
225 oes(1,k) = (1.0+coef)*oetab(kx,lv1,5)-coef*oetab(kx,lv1+1,5)
226 oes(2,k) = (1.0+coef)*oetab(kx,lv1,3)-coef*oetab(kx,lv1+1,3)
227 oes(3,k) = (1.0+coef)*oetab(kx,lv1,2)-coef*oetab(kx,lv1+1,2)
228 oes(5,k) = (1.0+coef)*oetab(kx,lv1,4)-coef*oetab(kx,lv1+1,4)
229 oes(7,k) = (1.0+coef)*oetab(kx,lv1,6)-coef*oetab(kx,lv1+1,6)
236 drift = kx==120.or.kx==220.or.kx==221
237 if ( drift )
call ufbint(iunit,drf,8,255,iret,drstr)
239 call readns(iunit,subst2,idate2,iret)
241 if ( iret /= 0 )
then
244 if ( combine_mass_wind )
then
246 call ufbint(iunit,hdr2,7,1,iret2,hdstr)
249 if ( subset /= subst2 )
then
254 if ( csid /= csid2 )
then
259 if ( hdr(i) /= hdr2(i) )
then
264 if ( hdr(6) /= hdr2(6) )
then
269 call ufbint(iunit,pmo2,2,1,nlevels2,
'PMO PMQ')
270 call ufbint(iunit,qms2,8,255,nlevels2,qmstr)
271 call ufbint(iunit,oes2,8,255,nlevels2,oestr)
272 call ufbint(iunit,pco2,8,255,nlevels2,pcstr)
273 call ufbint(iunit,obs2,8,255,nlevels2,obstr)
274 if ( drift )
call ufbint(iunit,drf2,8,255,iret,drstr)
276 if ( use_errtable )
then
281 if ( pob >= oetab(kx,lv1+1,1) .and. pob <= oetab(kx,lv1,1) )
then
282 coef = (pob-oetab(kx,lv1,1))/(oetab(kx,lv1,1)-oetab(kx,lv1+1,1))
283 oes2(1,k) = (1.0+coef)*oetab(kx,lv1,5)-coef*oetab(kx,lv1+1,5)
284 oes2(2,k) = (1.0+coef)*oetab(kx,lv1,3)-coef*oetab(kx,lv1+1,3)
285 oes2(3,k) = (1.0+coef)*oetab(kx,lv1,2)-coef*oetab(kx,lv1+1,2)
286 oes2(5,k) = (1.0+coef)*oetab(kx,lv1,4)-coef*oetab(kx,lv1+1,4)
287 oes2(7,k) = (1.0+coef)*oetab(kx,lv1,6)-coef*oetab(kx,lv1+1,6)
298 if ( kx == 280 .or. kx == 281 .or. kx == 284 .or. &
299 kx == 287 .or. kx == 288 )
then
322 if ( pmo(i,1) > r8bfms )
then
326 lev_loop:
do lv2 = 1, nlevels2
330 if ( pob1 == pob2 )
then
332 if ( obs(i,lv1) > r8bfms )
then
333 obs(i,lv1) = obs2(i,lv2)
334 if ( obs2(i,lv2) <= r8bfms )
then
335 obs(8,lv1) = obs2(8,lv2)
338 if ( oes(i,lv1) > r8bfms )
then
339 oes(i,lv1) = oes2(i,lv2)
341 if ( pco(i,lv1) > r8bfms )
then
342 pco(i,lv1) = pco2(i,lv2)
346 if ( qms(i,lv1) > r8bfms )
then
347 qms(i,lv1) = qms2(i,lv2)
352 if ( drf(i,lv1) > r8bfms )
then
353 drf(i,lv1) = drf2(i,lv2)
358 else if ( (pob2 > pob1) .or. (lv1 .eq. nlevels) )
then
359 nlevels = nlevels + 1
360 obs(:,nlevels) = obs2(:,lv2)
361 qms(:,nlevels) = qms2(:,lv2)
362 oes(:,nlevels) = oes2(:,lv2)
363 pco(:,nlevels) = pco2(:,lv2)
365 drf(:,nlevels) = drf2(:,lv2)
373 do i2 = i1+1, nlevels
374 if ( obs(1,i2) .gt. obs(1,i1) )
then
375 temp(:,1) = obs(:,i1)
376 obs(:,i1) = obs(:,i2)
377 obs(:,i2) = temp(:,1)
378 temp(:,1) = qms(:,i1)
379 qms(:,i1) = qms(:,i2)
380 qms(:,i2) = temp(:,1)
381 temp(:,1) = oes(:,i1)
382 oes(:,i1) = oes(:,i2)
383 oes(:,i2) = temp(:,1)
384 temp(:,1) = pco(:,i1)
385 pco(:,i1) = pco(:,i2)
386 pco(:,i2) = temp(:,1)
388 temp(:,1) = drf(:,i1)
389 drf(:,i1) = drf(:,i2)
390 drf(:,i2) = temp(:,1)
399 if ( .not. match )
then
410 if ( t29 == 61 .or. t29 == 66 .or. t29 == 72 ) cycle reports
418 if ( abs(hdr(6) - 9999.0) < 0.01 .and. t29 /= 41 ) cycle reports
421 if ( abs(hdr(2)) > 360.0 .or. abs(hdr(3)) > 90.0 ) cycle reports
425 write(dsec,
'(i6,a1)') int(hdr(4)*60.0*60.0),
's'
426 write(cdate,
'(i10)') idate
428 read (obs_date(1:14),
'(i4,5i2)') iyear, imonth, iday, ihour, imin, isec
429 if ( iyear < 1900 .or. iyear > 3000 .or. &
430 imonth < 1 .or. imonth > 12 .or. &
431 iday < 1 .or. iday > 31 .or. &
432 ihour < 0 .or. ihour >= 24 .or. &
433 imin < 0 .or. imin >= 60 .or. &
434 isec < 0 .or. isec >= 60 )
then
438 if (.not.
associated(
plink))
then
441 allocate (
plink%next )
443 nullify (
plink%next )
449 plink % msg_type(1:8) = subset
450 plink % stid(1:5) = csid(1:5)
458 write(unit=
plink%datetime, fmt=
'(i4,a,i2.2,a,i2.2,a,i2.2,a,i2.2,a,i2.2,a)') &
459 iyear,
'-', imonth,
'-', iday,
'T', ihour,
':', imin,
':', isec,
'Z'
461 if ( satid(1) < r8bfms )
then
462 plink % satid = nint(satid(1))
465 if ( pmo(1,1) < r8bfms )
then
466 plink % slp % val = pmo(1,1)*100.0
467 plink % slp % qm = nint(pmo(2,1))
469 if ( obs(7,1) < r8bfms )
then
470 plink % pw % val = obs(7,1) * 0.1
471 if ( qms(7,1) < r8bfms )
then
472 plink % pw % qm = nint(qms(7,1))
474 if ( oes(7,1) < r8bfms )
then
475 plink % pw % err = oes(7,1)
481 loop_nlevels:
do k = 1, nlevels
490 if ( qms(1,k) < r8bfms )
then
491 if ( nint(qms(1,k)) == 8 .or. nint(qms(1,k)) == 15 ) cycle loop_nlevels
493 if ( qms(4,k) < r8bfms )
then
494 if ( nint(qms(4,k)) == 8 .or. nint(qms(4,k)) == 15 ) cycle loop_nlevels
499 if ( .not.
associated(
plink % each) )
then
500 allocate (
plink % each )
503 allocate (
plink % each % next)
505 nullify (
plink % each % next )
508 call plink % each % init()
510 if ( satqc(1) < r8bfms )
then
511 plink % each % pccf = satqc(1)
515 if ( drf(1,k) < r8bfms )
plink % each % lon = drf(1,k)
516 if ( drf(2,k) < r8bfms )
plink % each % lat = drf(2,k)
517 if ( drf(3,k) < r8bfms )
then
518 plink % each % dhr = drf(3,k)
519 write(dsec,
'(i6,a1)') int(drf(3,k)*60.0*60.0),
's'
521 read (obs_date(1:14),
'(i4,5i2)') iyear, imonth, iday, ihour, imin, isec
522 write(unit=
plink%each%datetime, fmt=
'(i4,a,i2.2,a,i2.2,a,i2.2,a,i2.2,a,i2.2,a)') &
523 iyear,
'-', imonth,
'-', iday,
'T', ihour,
':', imin,
':', isec,
'Z'
527 if ( obs(1,k) > 0.0 .and. obs(1,k) < r8bfms )
then
528 plink % each % p % val = obs(1,k)*100.0
529 if ( qms(1,k) < r8bfms )
then
530 plink % each % p % qm = nint(qms(1,k))
532 if ( oes(1,k) < r8bfms )
then
533 plink % each % p % err = oes(1,k)*100.0
537 if ( nint(obs(8,k)) == 0 )
then
544 if ( obs(4,k) < r8bfms )
then
545 plink % each % h % val = obs(4,k)
546 if ( qms(4,k) < r8bfms )
then
547 plink % each % h % qm = nint(qms(4,k))
552 if ( obs(3,k) < r8bfms )
then
554 if ( pco(3,k) < r8bfms ) tpc = nint(pco(3,k))
558 if (obs(2,k) > 0.0 .and. obs(2,k) < r8bfms)
then
559 obs(2,k) = obs(2,k)*1e-6
560 if (obs(3,k) > -200.0 .and. obs(3,k) < 350.0)
then
561 if ( do_tv_to_ts .and. tpc == 8 )
then
563 obs(3,k) = obs(3,k) / (1.0 + 0.61 * obs(2,k))
568 if ( do_tv_to_ts .or. tpc /= 8 )
then
570 if ( obs(3,k) < r8bfms )
then
571 plink % each % t % val = obs(3,k)
572 if ( qms(3,k) < r8bfms )
then
573 plink % each % t % qm = nint(qms(3,k))
575 if ( oes(3,k) < r8bfms )
then
576 plink % each % t % err = oes(3,k)
581 if ( obs(3,k) < r8bfms )
then
582 plink % each % tv % val = obs(3,k)
583 if ( qms(3,k) < r8bfms )
then
584 plink % each % tv % qm = nint(qms(3,k))
586 if ( oes(3,k) < r8bfms )
then
587 plink % each % tv % err = oes(3,k)
592 if (obs(5,k) < r8bfms .and. obs(6,k) < r8bfms )
then
593 plink % each % u % val = obs(5,k)
594 plink % each % v % val = obs(6,k)
595 if ( qms(5,k) < r8bfms )
then
596 plink % each % u % qm = nint(qms(5,k))
598 if ( qms(6,k) < r8bfms )
then
599 plink % each % v % qm = nint(qms(6,k))
603 if ( oes(5,k) < r8bfms )
then
604 plink % each % u % err = oes(5,k)
606 if ( oes(6,k) < r8bfms )
then
607 plink % each % v % err = oes(6,k)
609 plink % each % v % err =
plink % each % u % err
613 if ( obs(2,k)>0.0 .and. obs(2,k)<r8bfms )
then
614 plink % each % q % val = obs(2,k)
615 if ( qms(2,k) < r8bfms )
then
616 plink % each % q % qm = nint(qms(2,k))
618 if ( oes(2,k) < r8bfms )
then
623 tval =
plink%each%tv%val / (1.0 + 0.61 * obs(2,k))
626 plink % each % q % err = oes(2,k)*10.0
627 plink % each % q % err =
plink % each % q % err * qs * 0.01
636 write(*,*)
'num_report_infile ', trim(filename),
' : ', num_report_infile
640 if ( use_errtable )
then
652 integer(i_kind) :: i, iv, k, ii
653 integer(i_kind) :: ityp, irec, ivar
654 integer(i_kind),
dimension(nobtype) :: nrecs
655 integer(i_kind),
dimension(nobtype) :: nlocs
656 integer(i_kind),
dimension(nobtype) :: nvars
657 integer(i_kind),
dimension(nobtype) :: iloc
658 character(len=12) :: obtype
659 logical,
dimension(nvar_met) :: vmask
669 write(*,*)
'--- sorting conv obs...'
674 set_obtype_loop:
do while (
associated(
plink) )
680 if (
plink % obtype_idx > 0 )
then
682 nrecs(
plink%obtype_idx) = nrecs(
plink%obtype_idx) + 1
691 end do set_obtype_loop
694 write(*,
'(1x,20x,2a10)')
'nrecs',
'nlocs'
696 write(*,
'(1x,a20,2i10)')
obtype_list(i), nrecs(i), nlocs(i)
702 xdata(i) % nrecs = nrecs(i)
703 xdata(i) % nlocs = nlocs(i)
705 nvars(i) =
count(vmask)
706 xdata(i) % nvars = nvars(i)
708 if ( nlocs(i) > 0 )
then
715 xdata(i)%xinfo_char (:,:) =
''
717 if ( nvars(i) > 0 )
then
718 allocate (
xdata(i)%xfield(nlocs(i), nvars(i)))
719 allocate (
xdata(i)%var_idx(nvars(i)))
727 xdata(i)%var_idx(ivar) = iv
739 reports:
do while (
associated(
plink) )
741 ityp =
plink%obtype_idx
747 levels:
do while (
associated(
plink % each) )
748 iloc(ityp) = iloc(ityp) + 1
753 xdata(ityp)%xinfo_int(iloc(ityp),i) = irec
758 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%each%dhr
760 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%dhr
762 else if ( trim(
name_var_info(i)) ==
'station_elevation' )
then
763 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%elv
766 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%each%lat
768 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%lat
772 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%each%lon
774 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%lon
777 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%each%h%val
779 xdata(ityp)%xinfo_float(iloc(ityp),i) =
plink%each%p%val
784 xdata(ityp)%xinfo_char(iloc(ityp),i) =
plink%each%datetime
786 xdata(ityp)%xinfo_char(iloc(ityp),i) =
plink%datetime
789 xdata(ityp)%xinfo_char(iloc(ityp),i) =
plink%stid
794 do i = 1, nvars(ityp)
795 ivar =
xdata(ityp)%var_idx(i)
797 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%p%val
798 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%p%qm
799 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%p%err
801 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%u%val
802 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%u%qm
803 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%u%err
805 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%v%val
806 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%v%qm
807 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%v%err
809 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%t%val
810 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%t%qm
811 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%t%err
813 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%tv%val
814 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%tv%qm
815 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%tv%err
817 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%each%q%val
818 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%each%q%qm
819 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%each%q%err
821 xdata(ityp)%xfield(iloc(ityp),i)%val =
plink%ps%val
822 xdata(ityp)%xfield(iloc(ityp),i)%qm =
plink%ps%qm
823 xdata(ityp)%xfield(iloc(ityp),i)%err =
plink%ps%err
825 xdata(ityp)%xfield(iloc(ityp),i)%rptype =
plink%rptype
835 do while (
associated(
plink) )
837 do while (
associated(
plink % each) )
838 if (
associated(
plink % each) )
deallocate (
plink % each)
840 nullify (
plink%first)
859 logical :: adjust_obserr
860 integer(i_kind) :: zqm
862 integer(i_kind) :: iuse_ps
863 integer(i_kind) :: iuse_uv
864 integer(i_kind) :: iuse_t
865 integer(i_kind) :: iuse_tv
866 integer(i_kind) :: iuse_q
867 real(
r_kind) :: hpa500 = 50000.0
868 real(
r_kind) :: hpa100 = 10000.0
869 real(
r_kind) :: inflate_factor = 1.2
871 adjust_obserr = .false.
873 write(*,*)
'--- filtering conv obs ---'
875 link_loop:
do while (
associated(
plink) )
879 do while (
associated(
plink % each) )
881 if ( trim(
plink%obtype) ==
'sfc' )
then
886 if (
plink%rptype == 120 .or. &
887 plink%rptype == 180 .or. &
888 plink%rptype == 181 .or. &
889 plink%rptype == 182 .or. &
890 plink%rptype == 187 )
then
894 zqm =
plink % each % h % qm
895 if ( zqm >=
lim_qm .and. zqm /= 15 .and. zqm /= 9 )
then
904 if ( adjust_obserr )
then
905 if (
plink % ps % qm == 3 .or.
plink % ps % qm == 7 )
then
906 plink % ps % err =
plink % ps % err * inflate_factor
923 if (
plink % rptype >= 280 .and.
plink % rptype < 300 )
then
925 if (
plink % rptype == 280 )
then
926 if (
plink % t29 == 522 .or. &
927 plink % t29 == 523 .or. &
928 plink % t29 == 531 )
then
929 plink % each % h % val = 20.0
932 if (
plink % rptype == 282 )
then
935 if (
plink % rptype == 285 .or. &
936 plink % rptype == 286 .or. &
937 plink % rptype == 289 .or. &
938 plink % rptype == 290 )
then
943 if (
plink % rptype >= 221 .and.
plink % rptype <= 229 )
then
945 if (
plink % elv >=
plink % each % h % val )
then
952 if (
plink%rptype == 120 .or. &
953 plink%rptype == 132 .or. &
954 plink%rptype == 133 .or. &
955 plink%rptype == 180 .or. &
956 plink%rptype == 182 )
then
960 if (
plink%rptype == 120 .or. &
961 plink%rptype == 130 .or. &
962 plink%rptype == 132 .or. &
963 plink%rptype == 133 .or. &
964 plink%rptype == 180 .or. &
965 plink%rptype == 182 )
then
970 if (
plink%rptype == 220 .or. &
971 plink%rptype == 221 .or. &
972 plink%rptype == 223 .or. &
973 plink%rptype == 224 .or. &
974 plink%rptype == 229 .or. &
975 plink%rptype == 230 .or. &
976 plink%rptype == 231 .or. &
977 plink%rptype == 232 .or. &
978 plink%rptype == 233 .or. &
979 plink%rptype == 280 .or. &
980 plink%rptype == 282 .or. &
981 plink%rptype == 289 .or. &
982 plink%rptype == 290 )
then
984 else if (
plink%rptype >= 241 .and.
plink%rptype <= 260 )
then
985 if (
plink%rptype == 242 )
then
986 if (
plink % satid == 171 .or. &
987 plink % satid == 172 .or. &
988 plink % satid == 173 .or. &
989 plink % satid == 174 )
then
992 else if (
plink%rptype == 243 )
then
993 if (
plink % satid == 55 .or. &
994 plink % satid == 70 )
then
997 else if (
plink%rptype == 244 )
then
998 if (
plink % satid == 3 .or. &
999 plink % satid == 4 .or. &
1000 plink % satid == 206 .or. &
1001 plink % satid == 207 .or. &
1002 plink % satid == 209 .or. &
1003 plink % satid == 223 )
then
1006 else if (
plink%rptype == 245 )
then
1007 if (
plink % satid == 259 .or. &
1008 plink % satid == 270 )
then
1011 else if (
plink%rptype == 246 )
then
1012 if (
plink % satid == 259 .or. &
1013 plink % satid == 270 )
then
1016 else if (
plink%rptype == 247 )
then
1017 if (
plink % satid == 259 .or. &
1018 plink % satid == 270 )
then
1021 else if (
plink%rptype == 250 )
then
1022 if (
plink % satid == 171 .or. &
1023 plink % satid == 172 .or. &
1024 plink % satid == 173 .or. &
1025 plink % satid == 174 )
then
1028 else if (
plink%rptype == 252 )
then
1029 if (
plink % satid == 171 .or. &
1030 plink % satid == 172 .or. &
1031 plink % satid == 173 .or. &
1032 plink % satid == 174 )
then
1035 else if (
plink%rptype == 253 )
then
1036 if (
plink % satid == 55 .or. &
1037 plink % satid == 70 )
then
1040 else if (
plink%rptype == 254 )
then
1041 if (
plink % satid == 55 .or. &
1042 plink % satid == 70 )
then
1045 else if (
plink%rptype == 257 )
then
1046 if (
plink % satid == 783 .or. &
1047 plink % satid == 784 )
then
1050 else if (
plink%rptype == 258 )
then
1051 if (
plink % satid == 783 .or. &
1052 plink % satid == 784 )
then
1055 else if (
plink%rptype == 259 )
then
1056 if (
plink % satid == 783 .or. &
1057 plink % satid == 784 )
then
1060 else if (
plink%rptype == 260 )
then
1061 if (
plink % satid == 224 )
then
1067 if (
plink%rptype == 243 .or. &
1068 plink%rptype == 253 .or. &
1069 plink%rptype == 254 )
then
1070 if ( iuse_uv ==
itrue .and.
plink % each % pccf < 85.0 )
then
1098 if ( adjust_obserr )
then
1099 if (
plink % each % p % val < hpa100 )
then
1101 plink % each % t % err =
plink % each % t % err * inflate_factor
1104 plink % each % tv % err =
plink % each % tv % err * inflate_factor
1107 if (
plink % each % t % qm == 3 .or. &
1108 plink % each % t % qm == 7 )
then
1109 plink % each % t % err =
plink % each % t % err * inflate_factor
1111 if (
plink % each % tv % qm == 3 .or. &
1112 plink % each % tv % qm == 7 )
then
1113 plink % each % tv % err =
plink % each % tv % err * inflate_factor
1115 if (
plink % each % u % qm == 3 .or. &
1116 plink % each % u % qm == 7 )
then
1117 plink % each % u % err =
plink % each % u % err * inflate_factor
1119 if (
plink % each % v % qm == 3 .or. &
1120 plink % each % v % qm == 7 )
then
1121 plink % each % v % err =
plink % each % v % err * inflate_factor
1123 if (
plink % each % q % qm == 3 .or. &
1124 plink % each % q % qm == 7 )
then
1125 plink % each % q % err =
plink % each % q % err * inflate_factor
1143 real(r_kind) :: rfill
1144 integer(i_kind) :: ifill
1159 real(r_kind) :: rfill
1160 integer(i_kind) :: ifill
1169 self % datetime =
''
1170 call self % h % init()
1171 call self % u % init()
1172 call self % v % init()
1173 call self % t % init()
1174 call self % tv % init()
1175 call self % p % init()
1176 call self % q % init()
1185 real(r_kind) :: rfill
1186 integer(i_kind) :: ifill
1191 self % msg_type =
''
1193 self % datetime =
''
1198 self % rptype = ifill
1200 self % satid = ifill
1202 call self % ps % init()
1203 call self % slp % init()
1204 call self % pw % init()
1217 real(r_kind),
intent(in) :: t, p
1218 real(r_kind),
intent(out) :: qs
1219 logical,
intent(in),
optional :: wrt_ice
1221 real(r_kind),
parameter :: t_kelvin = 273.15
1222 real(r_kind),
parameter :: t_triple = 273.16
1223 real(r_kind),
parameter :: gas_constant = 287.0
1224 real(r_kind),
parameter :: gas_constant_v = 461.6
1225 real(r_kind),
parameter :: rd_over_rv = gas_constant/gas_constant_v
1226 real(r_kind),
parameter :: rd_over_rv1 = 1.0 - rd_over_rv
1227 real(r_kind),
parameter :: es_alpha = 611.2
1228 real(r_kind),
parameter :: es_beta = 17.67
1229 real(r_kind),
parameter :: es_gamma = 243.5
1230 real(r_kind),
parameter :: t_c_ref1 = 0.0
1231 real(r_kind),
parameter :: t_c_ref2 = -20.0
1232 real(r_kind),
parameter :: a0 = 6.107799961
1233 real(r_kind),
parameter :: a1 = 4.436518521e-01
1234 real(r_kind),
parameter :: a2 = 1.428945805e-02
1235 real(r_kind),
parameter :: a3 = 2.650648471e-04
1236 real(r_kind),
parameter :: a4 = 3.031240396e-06
1237 real(r_kind),
parameter :: a5 = 2.034080948e-08
1238 real(r_kind),
parameter :: a6 = 6.136820929e-11
1239 real(r_kind),
parameter :: c1 = 9.09718
1240 real(r_kind),
parameter :: c2 = 3.56654
1241 real(r_kind),
parameter :: c3 = 0.876793
1242 real(r_kind),
parameter :: c4 = 6.1071
1243 real(r_kind) :: t_c, t1_c
1248 if (
present(wrt_ice) )
then
1249 if ( wrt_ice ) ice = .true.
1257 if ( .not. ice )
then
1259 es = es_alpha * exp( es_beta * t_c / ( t_c + es_gamma ) )
1263 if ( t1_c > t_c_ref1 )
then
1264 es = es_alpha * exp( es_beta * t_c / ( t_c + es_gamma ) )
1265 else if ( (t1_c <= t_c_ref1) .and. (t1_c >= t_c_ref2) )
then
1266 es = a0 + t1_c * (a1 + t1_c * (a2 + t1_c * (a3 + t1_c * (a4 + t1_c * (a5 + t1_c * a6)))))
1269 es = 10.0 ** ( -c1 * (t_triple / t - 1.0) - c2 * alog10(t_triple / t) + &
1270 c3 * (1.0 - t / t_triple) + alog10(c4))
1278 qs = rd_over_rv * es / ( p - rd_over_rv1 * es )
static void count(void *counter, const double *data, size_t n)
integer(i_kind), parameter nstring
integer(i_kind), parameter nvar_met
character(len=nstring), dimension(nobtype) obtype_list
character(len=nstring), dimension(nvar_info) name_var_info
integer(i_kind), parameter nobtype
integer(i_kind), parameter itrue
real(r_kind), parameter t_kelvin
integer(i_kind), parameter ifalse
integer(i_kind), parameter not_use
integer(i_kind), parameter missing_i
integer(i_kind), parameter ndatetime
integer(i_kind), parameter nvar_info
character(len=nstring), dimension(nvar_met) name_var_met
subroutine set_obtype_conv(t29, obtype)
real(r_kind), parameter missing_r
type(xdata_type), dimension(:), allocatable xdata
integer(i_kind), dimension(nvar_met, nobtype) vflag
integer(i_kind), dimension(nvar_info) type_var_info
integer, parameter, public i_kind
integer, parameter, public r_kind
integer, parameter, public r_double
subroutine, public sort_obs_conv
integer(i_kind), parameter lim_qm
subroutine, public read_prepbufr(filename, filedate)
subroutine init_field(self)
type(report_conv), pointer phead
subroutine calc_qs(t, p, qs, wrt_ice)
type(report_conv), pointer plink
subroutine init_each_level(self)
subroutine, public filter_obs_conv
subroutine init_report(self)
integer function, public ufo_vars_getindex(vars, varname)
character(len=maxvarlen), parameter, public var_prs
character(len=maxvarlen), parameter, public var_q
character(len=maxvarlen), parameter, public var_v
character(len=maxvarlen), parameter, public var_ts
character(len=maxvarlen), parameter, public var_u
character(len=maxvarlen), parameter, public var_ps
character(len=maxvarlen), parameter, public var_tv
subroutine, public da_advance_time(date_in, dtime, date_out)