IODA Bundle
pb_decode.f90
Go to the documentation of this file.
1 program pb_decode
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
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 NUL PWQ '
12  character(80):: oestr='POE QOE TOE NUL WOE NUL PWE '
13  real(8) :: hdr(mxmn),obs(mxmn,mxlv),qcf(mxmn,mxlv),oer(mxmn,mxlv)
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 :: i,k,iret
25 
26  character (len=80) :: pb_table_fname, pb_data_fname
27  integer :: argc
28 !
29 !
30 
31  ! Grab the bufr table file and bufr data file names from the
32  ! command line.
33  argc = command_argument_count()
34  if (argc .lt. 2) then
35  print*, "ERROR: must supply exactly two arguments"
36  print*, ""
37  print*, "USAGE: pb_decode <input_bufr_file> <output_bufr_table_file>"
38  call exit(-1)
39  endif
40  call get_command_argument(1,pb_data_fname)
41  call get_command_argument(2,pb_table_fname)
42 
43  open(24,file=pb_table_fname)
44  open(unit_in,file=pb_data_fname,form='unformatted',status='old')
45  call openbf(unit_in,'IN',unit_in)
46  call dxdump(unit_in,24)
47  call datelen(10)
48  nmsg=0
49  msg_report: do while (ireadmg(unit_in,subset,idate) == 0)
50  nmsg=nmsg+1
51  ntb = 0
52  write(*,*)
53  write(*,'(3a,i10)') 'subset=',subset,' cycle time =',idate
54  sb_report: do while (ireadsb(unit_in) == 0)
55  ntb = ntb+1
56  !call ufbint(unit_in,hdr,mxmn,1 ,iret,hdstr)
57  !call ufbint(unit_in,obs,mxmn,mxlv,iret,obstr)
58  !call ufbint(unit_in,oer,mxmn,mxlv,iret,oestr)
59  !call ufbint(unit_in,qcf,mxmn,mxlv,iret,qcstr)
60  call ufbint(unit_in,obs,mxmn,mxlv,iret,'TOB')
61  rstation_id=hdr(1)
62  write(*,*)
63  write(*,'(2I10,a14,8f15.1)') ntb,iret,c_sid,(hdr(i),i=2,8)
64  DO k=1,iret
65  !write(*,'(i3,a10,9f15.1)') k,'obs=',(obs(i,k),i=1,9)
66  !write(*,'(i3,a10,9f15.1)') k,'oer=',(oer(i,k),i=1,7)
67  !write(*,'(i3,a10,9f15.1)') k,'qcf=',(qcf(i,k),i=1,7)
68  write(*,'(i3,a10,9f15.1)') k, 'obs=', obs(1,k)
69  ENDDO
70  enddo sb_report
71  enddo msg_report
72  call closbf(unit_in)
73 
74 end program
program pb_decode
Definition: pb_decode.f90:1