20 character(120) :: file
21 character(50) :: optarg
22 character(40) :: hstr,ostr,qstr
24 character(8) :: sid,sta,subset,msg,cmc(17)
25 character(3) :: vars(8)
27 real(8) :: hdr(10),obs(10,255),qms(10,255),qmc(17),xob,yob
28 logical :: window,steam,level,dump,hedr,exist
30 equivalence(hdr(1),sid)
33 DATA hstr/
'SID XOB YOB DHR ELV T29 ITP TYP SRC PRG '/
34 DATA ostr/
'CAT POB QOB TOB ZOB UOB VOB PSL '/
35 DATA qstr/
'PQM QQM TQM ZQM WQM PSQ '/
37 DATA vars/
'LVL',
'CAT',
'POB',
'SPH',
'TOB',
'ZOB',
'UOB',
'VOB'/
38 DATA cmc /
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E''F''*'
58 narg=command_argument_count()
61 call printx(
'Usage: readbp <-s> <-w> <m> <-k> <-r> <-d> <-n> <-h> prep bufrfile '
63 call printx(
'Search filter and/or print prepbufr reports in various ways '
65 call printx(
'-s "station_id " print reports where "station_id" matches the report id up to the len of "station_id" '
66 call printx(
'-w "x1 x2 y1 y2" print reports within a lon/lat box '
67 call printx(
'-m "subset " print reports with this subset name '
68 call printx(
'-k "gsi rtype " print reports with this gsi report type '
69 call printx(
'-r "on29 rtype " print reports with this on29 report type '
70 call printx(
'-d print reports using ufdump - note: this works with any NCEP BUFR file '
71 call printx(
'-n no pause between reports output '
72 call printx(
'-h print only report headers '
74 call printx(
'Only a filename is required in which case step through the reports one at a time using "enter" '
76 call printx(
'Optional arguments can also be applied in the pause between reports output without using a dash '
78 call printx(
'Optional arguments will be applied in concert in most cases '
85 call get_command_argument(iarg,file)
86 if(file(1:1)==
'-')
then
87 if(file(2:2)==
's')
then
88 iarg=iarg+1;
call get_command_argument(iarg,sta); nsta=len(trim
89 elseif(file(2:2)==
'w')
then
90 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)x1
91 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)x2
92 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)y1
93 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)y2
95 elseif(file(2:2)==
'k')
then
96 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)ikx
97 elseif(file(2:2)==
'r')
then
98 iarg=iarg+1;
call get_command_argument(iarg,val);
read(val,*)irt
99 elseif(file(2:2)==
'm')
then
100 iarg=iarg+1;
call get_command_argument(iarg,val); msg=val(1:8
101 elseif(file(2:2)==
'd')
then
102 iarg=iarg+1; dump=.true.
103 elseif(file(2:2)==
'h')
then
104 iarg=iarg+1; hedr=.true.
105 elseif(file(2:2)==
'n')
then
106 iarg=iarg+1; steam=.true.
119 if(file==
'nofile')
goto 1
120 file = trim(adjustl(file))
121 inquire(file=file,exist=exist)
123 print *, trim(file)//
' does not exist'
130 open(lubfr,file=file,form=
'unformatted')
131 call openbf(lubfr,
'IN',lubfr)
137 do while(
ireadmg(lubfr,subset,idate)==0)
139 call ufbcnt(lubfr,irec,isub)
141 IF(msg/=
' ' .and. msg/=subset)
exit
151 CALL ufbint(lubfr,hdr,10, 1,iret,hstr)
157 IF(sta/=
' ' .AND. sta/=sid(1:nsta)) cycle
158 IF(irt/=0 .and. irt/=jrt) cycle
159 IF(itp/=0 .and. itp/=jtp) cycle
160 IF(ikx/=0 .and. ikx/=jkx) cycle
162 if(.not.(xob>=x1 .and. xob<=x2))cycle
163 if(.not.(yob>=y1 .and. yob<=y2))cycle
166 CALL ufbint(lubfr,obs,10,255,nlev,ostr)
167 CALL ufbint(lubfr,qms,10,255,nleq,qstr)
168 IF(nlev/=nleq) stop
'NLEV<>NLEQ'
183 print
'(a8,1x,a8,7(f8.2,1x))',subset,(hdr(i),i=1,8)
190 print
'(''MESSAGE: '',A8,2(2X,I4),i12 )' , subset,irec,isub,idate
191 print
'(''STATION: '',A8,1X,2(F8.2,1X))' , (hdr(i),i= 1,3)
192 print
'(''TIME: '',I10,2x,F8.2 )' , idate,hdr(4)
193 print
'(''ELV: '',F8.2 )' , (hdr(5) )
194 print
'(''TYPE: '',3(F8.0,1X) )' , (hdr(i),i= 6,8)
204 qms(i,l) = qmc(iqm+1)
209 print
'(2(1X,A3),6(8X,A3))',vars
212 print 11, l,nint(obs(1,l)),(obs(i,l),qms(min(i-1,5),l),i=2,7)
213 11
FORMAT(2i4,6(1x,f7.1,
'(',a1,
')'))
221 99
READ(5,
'(a)',iostat=iostat) optarg
222 IF(optarg(1:1)==
'q')
then
224 elseif(optarg(1:1)==
's')
then
225 read(optarg(2:50),*) sta
227 elseif(optarg(1:1)==
'w')
then
228 read(optarg(2:50),*) x1,x2,y1,y2
230 elseif(optarg(1:1)==
'k')
then
231 read(optarg(2:50),*) ikx
232 elseif(optarg(1:1)==
'r')
then
233 read(optarg(2:50),*) irt
234 elseif(optarg(1:1)==
'm')
then
235 read(optarg(2:50),*) msg
236 elseif(optarg(1:1)==
'd')
then
238 elseif(optarg(1:1)==
'h')
then
260 write(*,
'(a1)',advance=
"no")str(i:i)
262 write(*,
'(a1)')str(lens:lens)
recursive subroutine ufdump(lunit, luprt)
Print a verbose listing of the contents of a data subset, including all data values and replicated se...
recursive subroutine openbf(lunit, io, lundx)
Connect a new file to the NCEPLIBS-bufr software for input or output operations, or initialize the li...
recursive subroutine ufbcnt(lunit, kmsg, ksub)
Get the current location of the file pointer within a BUFR file, in terms of a message number countin...
subroutine printx(str)
Print long lines to stdout using advance=no format clause.
program readbp
Read PREPBUFR file containing embedded DX BUFR tables, and print each report one at a time.
recursive integer function ireadmg(lunit, subset, idate)
Call subroutine readmg() and pass back its return code as the function value.
recursive integer function ireadsb(lunit)
Call subroutine readsb() and pass back its return code as the function value.
recursive subroutine ufbint(lunin, usr, i1, i2, iret, str)
Read or write one or more data values from or to a data subset.
recursive subroutine datelen(len)
Specify the format of Section 1 date-time values that will be output by future calls to any of the NC...