NCEPLIBS-bufr  12.0.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,tbldir
17  CHARACTER(240) cmtdir
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 bmiss /10e10/
25  DATA lunbf /20/
26 
27  !-----------------------------------------------------------------------
28  !-----------------------------------------------------------------------
29 
30  isat=0
31  jsat=0
32  said=0
33  ssid=0
34 
35  ! get filename argument
36 
37  narg=iargc()
38  IF(narg<1) THEN
39  write(*,*)'Usage: sinv <satbufrfile> will print inventory of satellites by platform and instrument'
40  CALL exit(2)
41  ENDIF
42  call getarg(1,file)
43  file = trim(adjustl(file))
44  inquire(file=file,exist=exist)
45  if (.not.exist) call bort(trim(file)//' does not exist')
46 
47  ! define master table directory
48 
49  call openbf(lunbf,'FIRST',lunbf) ! need to call openbf prior to calling mtinfo
50  IF(narg==2) THEN ! arg 2 would be a user defined table dir
51  call getarg(2,tbldir)
52  call mtinfo(tbldir,3,4)
53  else ! otherwise default table dir is used
54  cmtdir = '/home/runner/work/NCEPLIBS-bufr/NCEPLIBS-bufr/bufr/build/ins' // &
55 'tall/tables'
56  call mtinfo(cmtdir,3,4)
57  endif
58 
59  ! read through the file and collect counts of satid and sat inst combinations
60 
61  open(lunbf,file=file,form='unformatted')
62  call ufbtab(lunbf,said,1,maxa,nret,'SAID')
63  call ufbtab(lunbf,siid,1,maxa,nrex,'SIID')
64 
65  ! need to open the bufrfile with the satellites of interest
66 
67  open(lunbf,file=file,form='unformatted')
68  CALL openbf(lunbf,'IN',lunbf)
69  call readmg(lunbf,subset,idate,iret)
70  call codflg('Y')
71 
72  ! make a table of sat ids and sat instruments
73 
74  do n=1,max(nret,nrex)
75  i = nint(said(n))
76  j = nint(siid(n))
77  if(i>maxs.or.i<0) i=0
78  if(j>maxs.or.j<0) j=0
79  isat(i,j) = isat(i,j)+1
80  enddo
81 
82  ! print the summary of satid and sat inst combinations
83 
84  write(*,*)
85  write(*,'(a14,12x,a14,4x,a10)') 'id satellite', 'subsets id ', 'instrument'
86  write(*,*)
87  do i=0,1000
88  do j=0,1000
89  if(isat(i,j).gt.0) then
90  jsat=jsat+isat(i,j)
91  call satcode(lunbf,i,ci,j,cj)
92  write(*,'(i3.3,2x,a,2x,i10,2x,i3.3,6x,a)')i,ci,isat(i,j),j,trim(adjustl(cj))
93  endif
94  enddo
95  enddo
96 
97  write(*,'(/23x,i10/)') jsat
98 
99 end program sinv
104 
115 
116 subroutine satcode(lunit,icode,csad,jcode,csid)
117 
118  character(16) :: csad
119  character(80) :: csid
120  character(255) :: str
121 
122  csad(1:16)=' '; csid(1:80)=' '
123 
124  ! call routines to look up the said and siid
125 
126  if(icode>0) then
127  str=repeat(' ',255)
128  call getcfmng(lunit,'SAID',icode,' ',-1,str,len,iret); csad=str(1:16)
129  endif
130  if(jcode>0) then
131  str=repeat(' ',255)
132  call getcfmng(lunit,'SIID',jcode,' ',-1,str,len,iret); csid=str(1:80)
133  endif
134 
135 end subroutine satcode
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine codflg(CF)
This subroutine is used to specify whether or not code and flag table information should be included ...
Definition: codflg.f:41
recursive subroutine getcfmng(LUNIT, NEMOI, IVALI, NEMOD, IVALD, CMEANG, LNMNG, IRET)
This subroutine searches for a specified Table B mnemonic and associated value (code figure or bit nu...
Definition: getcfmng.f:105
recursive subroutine mtinfo(CMTDIR, LUNMT1, LUNMT2)
Specify the directory location and Fortran logical unit numbers to be used when reading master BUFR t...
Definition: mtinfo.f:39
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
recursive subroutine readmg(LUNXX, SUBSET, JDATE, IRET)
Reads the next BUFR message from logical unit ABS(LUNXX) into internal arrays.
Definition: readmg.f:52
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:117
program sinv
Usage: sinv <satbufrfile> will print inventory of satellites by platform and instrument.
Definition: sinv.f90:11
recursive subroutine ufbtab(LUNIN, TAB, I1, I2, IRET, STR)
This subroutine reads through every data subset in a BUFR file and returns one or more specified data...
Definition: ufbtab.f:72