NCEPLIBS-bufr  12.0.1
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=iargc()
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 getarg(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).EQ.0)
54  isub = 0
55  DO i=1,nsub
56  IF(subset.EQ.sub(i)) isub = i
57  ENDDO
58  IF(isub.EQ.0) THEN
59  IF(nsub+1.GT.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.GT.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 one error message and abort application program.
Definition: bort.f:18
recursive function ireadmg(LUNIT, SUBSET, IDATE)
Calls NCEPLIBS-bufr subroutine readmg() and passes back its return code as the function value.
Definition: ireadmg.f:27
recursive function iupvs01(LUNIT, S01MNEM)
Read a specified value from within Section 0 or 1 of a BUFR message.
Definition: iupvs01.f:64
recursive function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:22
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124