NCEPLIBS-bufr  12.1.0
binv.F90
Go to the documentation of this file.
1 
5 
11 PROGRAM binv
12 
13  parameter(maxsub=100)
14 
15  CHARACTER*255 file
16  CHARACTER*8 subset
17  CHARACTER*8 sub(maxsub)
18  integer*8 ninv(3,maxsub)
19  real*8 xsub, xmsg
20  logical exist
21 
22  DATA lunbf /20/
23 
24  !-----------------------------------------------------------------------
25  nmbyt(lunit)= iupvs01(lunit,'LENM')
26  !-----------------------------------------------------------------------
27 
28  ! get filename
29 
30  narg=command_argument_count()
31  if(narg/=1) then
32  print *,'Usage: binv <bufrfile> will print bufrfile inventory by message type'
33  call exit(2)
34  endif
35 
36  call get_command_argument(1,file)
37  file = trim(file)//char(0)
38  inquire(file=file,exist=exist)
39  if (.not.exist) then
40  print *,trim(file)//' does not exist'
41  call exit(3)
42  endif
43  open(lunbf,file=file,form='unformatted')
44 
45  ninv = 0
46  nsub = 0
47 
48 
49  ! COMPUTE AN MESSAGE INVENTORY BY SUBSETS
50  ! ---------------------------------------
51 
52  CALL openbf(lunbf,'IN',lunbf)
53  DO WHILE(ireadmg(lunbf,subset,idate)==0)
54  isub = 0
55  DO i=1,nsub
56  IF(subset==sub(i)) isub = i
57  ENDDO
58  IF(isub==0) THEN
59  IF(nsub+1>maxsub) CALL bort('NSUB TOO BIG')
60  sub(nsub+1) = subset
61  nsub = nsub+1
62  isub = nsub
63  ENDIF
64  ninv(1,isub) = ninv(1,isub)+1
65  ninv(2,isub) = ninv(2,isub)+nmsub(lunbf)
66  ninv(3,isub) = ninv(3,isub)+nmbyt(lunbf)
67  ENDDO
68 
69  ! PRINT THE INVENTORY
70  ! -------------------
71 
72  print*
73  print'(a4,6x,2(a10,4x),a11)','type','messages','subsets','bytes'
74  print*
75  DO j=1,nsub
76  xmsg = ninv(1,j)
77  xsub = ninv(2,j)
78  print'(a8,2x,2(i10,4x),i11,4x,f8.2)',sub(j),(ninv(i,j),i=1,3),xsub/xmsg
79  IF(j>1) THEN
80  ninv(1,1) = ninv(1,1)+ninv(1,j)
81  ninv(2,1) = ninv(2,1)+ninv(2,j)
82  ninv(3,1) = ninv(3,1)+ninv(3,j)
83  ENDIF
84  ENDDO
85 
86  print'(a8,2x,2(i10,4x),i11,4x)','TOTAL ',(ninv(i,1),i=1,3)
87  print*
88 
89  stop
90 END PROGRAM binv
program binv
Usage: binv <bufrfile> will print bufrfile inventory by message type.
Definition: binv.F90:11
subroutine bort(str)
Log an error message, then abort the application program.
Definition: borts.F90:15
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 integer function nmsub(lunit)
Get the total number of data subsets available within the BUFR message that was most recently opened ...
recursive integer function ireadmg(lunit, subset, idate)
Call subroutine readmg() and pass back its return code as the function value.
recursive integer function iupvs01(lunit, s01mnem)
Read a specified value from within Section 0 or 1 of a BUFR message.
Definition: s013vals.F90:443