7 character(50) :: optarg
8 character(40) :: hstr,ostr,qstr
10 character(8) :: sid,sta,subset,msg,cmc(17)
11 character(3) :: vars(8)
13 real(8) :: hdr(10),obs(10,255),qms(10,255),qmc(17)
14 logical :: window,steam,level,dump,hedr,exist
16 equivalence(hdr(1),sid)
19 DATA hstr/
'SID XOB YOB DHR ELV T29 ITP TYP SRC PRG '/
20 DATA ostr/
'CAT POB QOB TOB ZOB UOB VOB PSL '/
21 DATA qstr/
'PQM QQM TQM ZQM WQM PSQ '/
23 DATA vars/
'LVL',
'CAT',
'POB',
'SPH',
'TOB',
'ZOB',
'UOB',
'VOB'/
24 DATA cmc /
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'*'/
48 call printx(
'Usage: readbp <-s> <-w> <m> <-k> <-r> <-d> <-n> <-h> prep bufrfile ')
50 call printx(
'Search filter and/or print prepbufr reports in various ways ')
52 call printx(
'-s "station_id " print reports where "station_id" matches the report id up to the len of "station_id" ')
53 call printx(
'-w "x1 x2 y1 y2" print reports within a lon/lat box ')
54 call printx(
'-m "subset " print reports with this subset name ')
55 call printx(
'-k "gsi rtype " print reports with this gsi report type ')
56 call printx(
'-r "on29 rtype " print reports with this on29 report type ')
57 call printx(
'-d print reports using ufdump - note: this works with any NCEP BUFR file ')
58 call printx(
'-n no pause between reports output ')
59 call printx(
'-h print only report headers ')
61 call printx(
'Only a filename is required in which case step through the reports one at a time using "enter" ')
63 call printx(
'Optional arguments can also be applied in the pause between reports output without using a dash ')
65 call printx(
'Optional arguments will be applied in concert in most cases ')
72 call getarg(iarg,file)
73 if(file(1:1)==
'-')
then
74 if(file(2:2)==
's')
then
75 iarg=iarg+1; call getarg(iarg,sta); nsta=len(trim(sta))
76 elseif(file(2:2)==
'w')
then
77 iarg=iarg+1; call getarg(iarg,val);
read(val,*)x1
78 iarg=iarg+1; call getarg(iarg,val);
read(val,*)x2
79 iarg=iarg+1; call getarg(iarg,val);
read(val,*)y1
80 iarg=iarg+1; call getarg(iarg,val);
read(val,*)y2
82 elseif(file(2:2)==
'k')
then
83 iarg=iarg+1; call getarg(iarg,val);
read(val,*)ikx
84 elseif(file(2:2)==
'r')
then
85 iarg=iarg+1; call getarg(iarg,val);
read(val,*)irt
86 elseif(file(2:2)==
'm')
then
87 iarg=iarg+1; call getarg(iarg,val); msg=val
88 elseif(file(2:2)==
'd')
then
89 iarg=iarg+1; dump=.true.
90 elseif(file(2:2)==
'h')
then
91 iarg=iarg+1; hedr=.true.
92 elseif(file(2:2)==
'n')
then
93 iarg=iarg+1; steam=.true.
107 if(file==
'nofile') goto 1
108 file = trim(adjustl(file))
109 inquire(file=file,exist=exist)
110 if (.not.exist) call
bort(trim(file)//
' does not exist')
115 open(lubfr,file=file,form=
'unformatted')
116 call
openbf(lubfr,
'IN',lubfr)
122 do while(
ireadmg(lubfr,subset,idate)==0)
124 call
ufbcnt(lubfr,irec,isub)
126 IF(msg.ne.
' ' .and. msg.ne.subset)
exit
136 CALL
ufbint(lubfr,hdr,10, 1,iret,hstr)
142 IF(sta.NE.
' ' .AND. sta.NE.sid(1:nsta)) cycle
143 IF(irt.ne.0 .and. irt.ne.jrt) cycle
144 IF(itp.ne.0 .and. itp.ne.jtp) cycle
145 IF(ikx.ne.0 .and. ikx.ne.jkx) cycle
147 IF(.NOT.(xob.GE.x1 .AND. xob.LE.x2))cycle
148 IF(.NOT.(yob.GE.y1 .AND. yob.LE.y2))cycle
151 CALL
ufbint(lubfr,obs,10,255,nlev,ostr)
152 CALL
ufbint(lubfr,qms,10,255,nleq,qstr)
153 IF(nlev.NE.nleq) stop
'NLEV<>NLEQ'
158 IF(obs(1,l).EQ.8)
THEN
168 print
'(a8,1x,a8,7(f8.2,1x))',subset,(hdr(i),i=1,8)
175 print
'(''MESSAGE: '',A8,2(2X,I4),i12 )' , subset,irec,isub,idate
176 print
'(''STATION: '',A8,1X,2(F8.2,1X))' , (hdr(i),i= 1,3)
177 print
'(''TIME: '',I10,2x,F8.2 )' , idate,hdr(4)
178 print
'(''ELV: '',F8.2 )' , (hdr(5) )
179 print
'(''TYPE: '',3(F8.0,1X) )' , (hdr(i),i= 6,8)
189 qms(i,l) = qmc(iqm+1)
194 print
'(2(1X,A3),6(8X,A3))',vars
197 print 11, l,nint(obs(1,l)),(obs(i,l),qms(min(i-1,5),l),i=2,7)
198 11
FORMAT(2i4,6(1x,f7.1,
'(',a1,
')'))
206 99
READ(5,
'(a)',iostat=iostat) optarg
207 IF(optarg(1:1)==
'q')
then
209 elseif(optarg(1:1)==
's')
then
210 read(optarg(2:50),*) sta
212 elseif(optarg(1:1)==
'w')
then
213 read(optarg(2:50),*) x1,x2,y1,y2
215 elseif(optarg(1:1)==
'k')
then
216 read(optarg(2:50),*) ikx
217 elseif(optarg(1:1)==
'r')
then
218 read(optarg(2:50),*) irt
219 elseif(optarg(1:1)==
'm')
then
220 read(optarg(2:50),*) msg
221 elseif(optarg(1:1)==
'd')
then
223 elseif(optarg(1:1)==
'h')
then
238 subroutine printx(str)
242 write(*,
'(a1)',advance=
"no")str(i:i)
244 write(*,
'(a1)')str(lens:lens)
function ireadmg(LUNIT, SUBSET, IDATE)
This function calls BUFRLIB subroutine readmg() and passes back its return code as the function value...
function ireadsb(LUNIT)
This function calls BUFRLIB subroutine readsb() and passes back its return code as the function value...
subroutine datelen(LEN)
This subroutine is used to specify the format of Section 1 date-time values that will be output by fu...
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
subroutine ufbint(LUNIN, USR, I1, I2, IRET, STR)
This subroutine reads or writes one or more data values from or to the BUFR data subset that is curre...
subroutine ufbcnt(LUNIT, KMSG, KSUB)
This subroutine returns the current location of the file pointer within a BUFR file, in terms of a message number counting from the beginning of the file, and a data subset number counting from the beginning of that message.
subroutine ufdump(LUNIT, LUPRT)
This subroutine prints a verbose listing of the contents of a data subset, including all data values ...
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...