NCEPLIBS-bufr  12.2.0
sinv.F90
Go to the documentation of this file.
1 
5 
18 program sinv
19 
20  parameter(maxa=16000000)
21  parameter(maxs=1000)
22 
23  character(255) file
24  character(240) cmtdir,tbldir
25  character(8) subset
26  character ci*16,cj*80
27  dimension isat(0:maxs,0:maxs)
28  real(8) said(2,maxa)
29  logical exist
30 
31  data lunbf /20/
32 
33  !-----------------------------------------------------------------------
34  !-----------------------------------------------------------------------
35 
36  isat=0
37  jsat=0
38  said=0
39  ssid=0
40 
41  call setpart(.true.) ! put ufbtab in partial read mode
42 
43  ! get filename argument
44 
45  narg=command_argument_count()
46  if(narg<1) then
47  write(*,*)'Usage: sinv satbufrfile <tabledir> will print inventory of satbufrfile by platform and instrument'
48  stop 2
49  endif
50  call get_command_argument(1,file)
51  file = trim(adjustl(file))
52  inquire(file=file,exist=exist)
53  if (.not.exist) call bort(trim(file)//' does not exist')
54 
55  ! define master table directory
56 
57  ! Before calling mtinfo, make an initial call to openbf so that bfrini is called internally.
58  ! Otherwise, if we wait until later to make the initial call to openbf, then the internal call
59  ! to bfrini will end up overwriting the master table directory that we pass in during either
60  ! of the following calls to mtinfo.
61  call openbf(lunbf,'FIRST',lunbf)
62  if(narg==2) then ! arg 2 would be a user defined table dir
63  call get_command_argument(2,tbldir)
64  call mtinfo(tbldir,3,4)
65  else ! otherwise default table dir is used
66  cmtdir = '/home/runner/work/NCEPLIBS-bufr/NCEPLIBS-bufr/bufr/build-doc' // &
67 's/install/tables'
68  call mtinfo(cmtdir,3,4)
69  endif
70 
71  ! read through the file and collect counts of satid and sat inst combinations
72 
73  open(lunbf,file=file,form='unformatted')
74  call openbf(lunbf,'IN',lunbf)
75 
76  nret=0
77  do while(nret<=0)
78  call ufbtab(lunbf,said,2,maxa,nret,'SAID SIID')
79  do n=1,abs(nret)
80  i = nint(said(1,n))
81  j = nint(said(2,n))
82  if(i>maxs.or.i<0) i=0
83  if(j>maxs.or.j<0) j=0
84  isat(i,j) = isat(i,j)+1
85  enddo
86  enddo
87 
88  ! need to open the bufrfile with the satellites of interest
89 
90  call readmg(lunbf,subset,idate,iret)
91  call codflg('Y')
92 
93  ! print the summary of satid and sat inst combinations
94 
95  write(*,*)
96  write(*,'(a14,12x,a14,4x,a10)') 'id satellite', 'subsets id ', 'instrument'
97  write(*,*)
98  do i=0,1000
99  do j=0,1000
100  if(isat(i,j)>0) then
101  jsat=jsat+isat(i,j)
102  call satcode(lunbf,i,ci,j,cj)
103  write(*,'(i3.3,2x,a,2x,i10,2x,i3.3,6x,a)')i,ci,isat(i,j),j,trim(adjustl(cj))
104  endif
105  enddo
106  enddo
107 
108  write(*,'(/23x,i10/)') jsat
109 
110 end program sinv
111 
122 
123 subroutine satcode(lunit,icode,csad,jcode,csid)
124 
125  character(16) :: csad
126  character(80) :: csid
127  character(255) :: str
128 
129  csad(1:16)=' '; csid(1:80)=' '
130 
131  ! call routines to look up the said and siid
132 
133  if(icode>0) then
134  str=repeat(' ',255)
135  call getcfmng(lunit,'SAID',icode,' ',-1,str,len,iret); csad=str(1:16)
136  endif
137  if(jcode>0) then
138  str=repeat(' ',255)
139  call getcfmng(lunit,'SIID',jcode,' ',-1,str,len,iret); csid=str(1:80)
140  endif
141 
142 end subroutine satcode
recursive subroutine bort(str)
Log an error message, then either return to or abort the application program.
Definition: borts.F90:15
recursive subroutine getcfmng(lunit, nemoi, ivali, nemod, ivald, cmeang, lnmng, iret)
Decode the meaning of a numerical value from a code or flag table.
Definition: cftbvs.F90:220
subroutine codflg(cf)
Specify whether or not code and flag table information should be included during all future reads of ...
recursive subroutine mtinfo(cmtdir, lunmt1, lunmt2)
Specify the directory location and Fortran logical unit numbers to be used when reading master BUFR t...
Definition: mastertable.F90:35
recursive subroutine openbf(lunit, io, lundx)
Connect a new file to the NCEPLIBS-bufr software for input or output operations, or initialize the li...
subroutine setpart(xpart)
Specify whether future calls to subroutine ufbtab() should attempt to return full or partial results.
recursive subroutine ufbtab(lunin, tab, i1, i2, iret, str)
Read through every data subset in a BUFR file and return one or more specified data values from each ...
recursive subroutine readmg(lunxx, subset, jdate, iret)
Read the next BUFR message from logical unit abs(lunxx) into internal arrays.
Definition: readwritemg.F90:44
subroutine satcode(lunit, icode, csad, jcode, csid)
This subroutine looks in the master BUFR tables for meaning strings associated with specified code fi...
Definition: sinv.F90:124
program sinv
Usage: sinv satbufrfile <tabledir> will print an inventory of satellites in the satbufrfile by platfo...
Definition: sinv.F90:18