IODA Bundle
pb_decode_events.f90
Go to the documentation of this file.
2 !
3 ! read all observations out from prepbufr.
4 ! read bufr table from prepbufr file
5 !
6  implicit none
7 
8  integer, parameter :: mxmn=35, mxlv=250, mxev=10
9  character(80):: hdstr='SID XOB YOB DHR TYP ELV SAID T29'
10  character(80):: obstr='POB QOB TOB ZOB UOB VOB PWO CAT PRSS'
11  character(80):: qcstr='PQM QQM TQM ZQM WQM QPC PWQ TPC '
12  character(80):: oestr='POE QOE TOE NUL WOE NUL PWE '
13  real(8) :: hdr(mxmn),obs(mxmn,mxlv,mxev),qcf(mxmn,mxlv,mxev),oer(mxmn,mxlv,mxev)
14 
15  INTEGER :: ireadmg,ireadsb
16 
17  character(8) :: subset
18  integer :: unit_in=10,idate,nmsg,ntb
19 
20  character(8) :: c_sid
21  real(8) :: rstation_id
22  equivalence(rstation_id,c_sid)
23 
24  integer :: itype
25  integer :: i,k,iret, numobs,n
26 
27  character (len=80) :: pb_table_fname, pb_data_fname
28  integer :: argc
29 !
30 !
31 
32  ! Grab the bufr table file and bufr data file names from the
33  ! command line.
34  argc = command_argument_count()
35  if (argc .lt. 2) then
36  print*, "ERROR: must supply exactly two arguments"
37  print*, ""
38  print*, "USAGE: pb_decode_events <input_bufr_file> <output_bufr_table_file>"
39  call exit(-1)
40  endif
41  call get_command_argument(1,pb_data_fname)
42  call get_command_argument(2,pb_table_fname)
43 
44  open(24,file=pb_table_fname)
45  open(unit_in,file=pb_data_fname,form='unformatted',status='old')
46  call openbf(unit_in,'IN',unit_in)
47  call dxdump(unit_in,24)
48  call datelen(10)
49  nmsg=0
50  numobs=0
51  msg_report: do while (ireadmg(unit_in,subset,idate) == 0)
52  nmsg=nmsg+1
53  ntb = 0
54  write(*,*)
55  write(*,'(3a,i10)') 'subset=',subset,' cycle time =',idate
56  sb_report: do while (ireadsb(unit_in) == 0)
57  ntb = ntb+1
58  !call ufbint(unit_in,hdr,mxmn,1 ,iret,hdstr)
59 ! call ufbint(unit_in,obs,mxmn,mxlv,iret,obstr)
60  !call UFBEVN(unit_in,obs,mxmn,mxlv,mxev,iret,obstr)
61 ! call ufbint(unit_in,oer,mxmn,mxlv,iret,oestr)
62  !call UFBEVN(unit_in,oer,mxmn,mxlv,mxev,iret,oestr)
63 ! call ufbint(unit_in,qcf,mxmn,mxlv,iret,qcstr)
64  !call UFBEVN(unit_in,qcf,mxmn,mxlv,mxev,iret,qcstr)
65  call ufbevn(unit_in,obs,mxmn,mxlv,mxev,iret,'TOB')
66  rstation_id=hdr(1)
67  itype=hdr(5)
68  write(*,*)
69  write(*,'(2I10,a14,8f15.1)') ntb,iret,c_sid,(hdr(i),i=2,8)
70  numobs=numobs+1
71  DO k=1,iret
72  DO n=1,5
73  !write(*,'(i3,a10,9f15.1)') n,'obs=',(obs(i,k,n),i=1,6)
74 ! write(*,'(i3,a10,9f15.1)') k,'oer=',(oer(i,k,n),i=1,7)
75  !write(*,'(i3,a10,9f15.1)') n,'qcf=',(qcf(i,k,n),i=1,8)
76  write(*,'(2i3,a10,9f15.1)') n, k, 'obs=', obs(1,k,n)
77  ENDDO
78  ENDDO
79  enddo sb_report
80  enddo msg_report
81  call closbf(unit_in)
82  write(*,*) 'numobs=',numobs
83 
84 end program
program pb_decode_events