NCEPLIBS-bufr  12.2.0
All Data Structures Namespaces Files Functions Variables Macros Pages
cmpbqm.F90
Go to the documentation of this file.
1 
5 
11 program cmpbqm
12 
13  character*255 file
14  character*50 headr,obstr,qmstr
15  character*20 vars(7)
16  character*8 subset,date
17  dimension knt(300,7,0:17),hdr(5),obs(8,255),qms(8,255)
18  logical exist
19  real*8 hdr,obs,qms
20 
21  data headr /'SID XOB YOB DHR TYP '/
22  data obstr /'POB QOB TOB ZOB UOB PWO RHO VOB '/
23  data qmstr /'PQM QQM TQM ZQM WQM PWQ RHQ '/
24 
25  data vars /'PRESSURE ',&
26  'SPECIFIC HUMIDTY',&
27  'TEMPERATURE ',&
28  'HEIGHT ',&
29  'WIND COMPONENTS ',&
30  'PRECIPITABLE H2O',&
31  'RELATIVE HUMIDTY'/
32 
33  data lubfr /8 /
34  data vmax /10e10/
35 
36  !-----------------------------------------------------------------------
37  !-----------------------------------------------------------------------
38 
39  irec = 0
40  knt = 0
41 
42  ! Open a file - get a date
43  ! ------------------------
44 
45  call get_command_argument(1,file); file=trim(adjustl(file))
46  if (file == '') then
47  print *, 'Usage: Usage: cmpbqm <prepbufrfile> will print prep inventory by variable, report type, and qc mark'
48  stop 2
49  endif
50  inquire(file=file,exist=exist)
51  if (.not.exist) then
52  print *, trim(file)//' does not exist'
53  stop 3
54  endif
55 
56  open(lubfr,file=file,form='unformatted')
57  call openbf(lubfr,'IN',lubfr)
58  call readmg(lubfr,subset,idate,iret)
59  if(iret/=0) call bort('CMPBQM - ERROR READING BUFR FILE ')
60  write(date,'(i8)') idate
61  do i=1,8
62  if(date(i:i)==' ') date(i:i) = '0'
63  enddo
64  print'(''DATA VALID AT '',A8)',date
65 
66  ! Read thru the prepda records
67  ! ----------------------------
68 
69 10 call readsb(lubfr,iret)
70  if(iret/=0) then
71  call readmg(lubfr,subset,idate,iret)
72  if(iret/=0) goto 100
73  call ufbcnt(lubfr,irec,isub)
74  goto 10
75  endif
76  qms = 10e10
77  call ufbint(lubfr,hdr,5,1,iret,headr)
78  call ufbint(lubfr,obs,8,255,nlev,obstr)
79  call ufbint(lubfr,qms,8,255,nlev,qmstr)
80 
81  kx = nint(hdr(5))
82 
83  do l=1,nlev
84  do k=1,7
85  iq = -1
86  if(k==5) obs(5,l) = max(obs(5,l),obs(8,l))
87  if(obs(k,l)<vmax .and. qms(k,l)<vmax) then
88  iq = nint(qms(k,l))
89  elseif(obs(k,l)<vmax .and. qms(k,l)>=vmax) then
90  iq = 16
91  elseif(obs(k,l)>=vmax .and. qms(k,l)<vmax) then
92  iq = 17
93  endif
94  if(iq>=0) knt(kx,k,iq) = knt(kx,k,iq)+1
95  enddo
96  enddo
97 
98  goto 10
99 
100  ! Finish up
101  ! ---------
102 
103 100 do k=1,7
104  print*,vars(k)
105  print*
106  do kx=1,300
107  itot = 0; igood=0; ifail=0
108  do iq=0,17
109  itot = itot+knt(kx,k,iq)
110  if(iq<=3) then
111  igood=igood+knt(kx,k,iq)
112  elseif(iq<=7) then
113  ifail=ifail+knt(kx,k,iq)
114  endif
115  enddo
116  if(itot>0) print 101,kx,itot,igood,ifail,(knt(kx,k,iq),iq=8,17)
117 101 format(i3,i6,2('|', i6),&
118  2('|', i6),&
119  1('|',6i6),&
120  2('|', i6))
121  enddo
122  print*
123  enddo
124 
125  print*,'******CMPBQM PROCESSED ',irec,' BUFR RECORDS******'
126  stop
127 end program cmpbqm
subroutine bort(str)
Log an error message, then abort the application program.
Definition: borts.F90:15
program cmpbqm
Usage: cmpbqm <prepbufrfile> will print prep inventory by variable, report type, and qc mark.
Definition: cmpbqm.F90:11
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...
recursive subroutine readmg(lunxx, subset, jdate, iret)
Read the next BUFR message from logical unit abs(lunxx) into internal arrays.
Definition: readwritemg.F90:44
recursive subroutine readsb(lunit, iret)
Read the next data subset from a BUFR message.
Definition: readwritesb.F90:32
recursive subroutine ufbint(lunin, usr, i1, i2, iret, str)
Read or write one or more data values from or to a data subset.