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