NCEPLIBS-bufr  12.2.0
All Data Structures Namespaces Files Functions Variables Macros Pages
sinv.F90
Go to the documentation of this file.
1 
5 
13 program sinv
14 
15  parameter(maxa=16000000)
16  parameter(maxs=1000)
17 
18  character(255) file
19  character(240) cmtdir,tbldir
20  character(8) subset
21  character ci*16,cj*80
22  dimension isat(0:maxs,0:maxs)
23  real(8) said(maxa),siid(maxa)
24  logical exist
25 
26  data lunbf /20/
27 
28  !-----------------------------------------------------------------------
29  !-----------------------------------------------------------------------
30 
31  isat=0
32  jsat=0
33  said=0
34  ssid=0
35 
36  ! get filename argument
37 
38  narg=command_argument_count()
39  if(narg<1) then
40  write(*,*)'Usage: sinv satbufrfile <tabledir> will print inventory of satbufrfile by platform and instrument'
41  stop 2
42  endif
43  call get_command_argument(1,file)
44  file = trim(adjustl(file))
45  inquire(file=file,exist=exist)
46  if (.not.exist) call bort(trim(file)//' does not exist')
47 
48  ! define master table directory
49 
50  ! Before calling mtinfo, make an initial call to openbf so that bfrini is called internally.
51  ! Otherwise, if we wait until later to make the initial call to openbf, then the internal call
52  ! to bfrini will end up overwriting the master table directory that we pass in during either
53  ! of the following calls to mtinfo.
54  call openbf(lunbf,'FIRST',lunbf)
55  if(narg==2) then ! arg 2 would be a user defined table dir
56  call get_command_argument(2,tbldir)
57  call mtinfo(tbldir,3,4)
58  else ! otherwise default table dir is used
59  cmtdir = '/home/runner/work/NCEPLIBS-bufr/NCEPLIBS-bufr/bufr/build-doc' // &
60 's/install/tables'
61  call mtinfo(cmtdir,3,4)
62  endif
63 
64  ! read through the file and collect counts of satid and sat inst combinations
65 
66  open(lunbf,file=file,form='unformatted')
67  call ufbtab(lunbf,said,1,maxa,nret,'SAID')
68  call ufbtab(lunbf,siid,1,maxa,nrex,'SIID')
69 
70  ! need to open the bufrfile with the satellites of interest
71 
72  open(lunbf,file=file,form='unformatted')
73  call openbf(lunbf,'IN',lunbf)
74  call readmg(lunbf,subset,idate,iret)
75  call codflg('Y')
76 
77  ! make a table of sat ids and sat instruments
78 
79  do n=1,max(nret,nrex)
80  i = nint(said(n))
81  j = nint(siid(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 
87  ! print the summary of satid and sat inst combinations
88 
89  write(*,*)
90  write(*,'(a14,12x,a14,4x,a10)') 'id satellite', 'subsets id ', 'instrument'
91  write(*,*)
92  do i=0,1000
93  do j=0,1000
94  if(isat(i,j)>0) then
95  jsat=jsat+isat(i,j)
96  call satcode(lunbf,i,ci,j,cj)
97  write(*,'(i3.3,2x,a,2x,i10,2x,i3.3,6x,a)')i,ci,isat(i,j),j,trim(adjustl(cj))
98  endif
99  enddo
100  enddo
101 
102  write(*,'(/23x,i10/)') jsat
103 
104 end program sinv
105 
116 
117 subroutine satcode(lunit,icode,csad,jcode,csid)
118 
119  character(16) :: csad
120  character(80) :: csid
121  character(255) :: str
122 
123  csad(1:16)=' '; csid(1:80)=' '
124 
125  ! call routines to look up the said and siid
126 
127  if(icode>0) then
128  str=repeat(' ',255)
129  call getcfmng(lunit,'SAID',icode,' ',-1,str,len,iret); csad=str(1:16)
130  endif
131  if(jcode>0) then
132  str=repeat(' ',255)
133  call getcfmng(lunit,'SIID',jcode,' ',-1,str,len,iret); csid=str(1:80)
134  endif
135 
136 end subroutine satcode
subroutine bort(str)
Log an error message, then 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...
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:118
program sinv
Usage: sinv satbufrfile <tabledir> will print an inventory of satellites in the satbufrfile by platfo...
Definition: sinv.F90:13