NCEPLIBS-bufr 11.7.1
sinv.f90
1!-----------------------------------------------------------------------
2!-----------------------------------------------------------------------
3 PROGRAM sinv
4
5 parameter(maxa=16000000)
6 parameter(maxs=1000)
7
8 CHARACTER(255) FILE,tbldir
9 CHARACTER(100) cmtdir
10 CHARACTER(8) SUBSET
11 CHARACTER ci*16,cj*80
12 dimension isat(0:maxs,0:maxs)
13 real(8) arr(2,maxa),said(maxa),siid(maxa)
14 logical exist
15
16 DATA bmiss /10e10/
17 DATA lunbf /20/
18
19!-----------------------------------------------------------------------
20!-----------------------------------------------------------------------
21
22 isat=0
23 jsat=0
24 said=0
25 ssid=0
26 !!close(6); open(6,recl=130)
27
28! get filename argument
29
30 narg=iargc()
31 IF(narg<1) THEN
32 write(*,*)'Usage: sinv <satbufrfile> will print inventory of satellites by platform and instrument'
33 CALL exit(2)
34 ENDIF
35 call getarg(1,file)
36 file = trim(adjustl(file))
37 inquire(file=file,exist=exist)
38 if (.not.exist) call bort(trim(file)//' does not exist')
39
40
41! define master table directory
42
43 call openbf(lunbf,'FIRST',lunbf) ! need to call openbf prior to calling mtinfo
44 IF(narg==2) THEN ! arg 2 would be a user defined table dir
45 call getarg(2,tbldir)
46 call mtinfo(tbldir,3,4)
47 else ! otherwise default table dir is used
48 call mtinfo( &
49 "/home/jeffa/build/install/tables" &
50 ,3,4)
51 endif
52
53! read through the file and collect counts of satid and sat inst combinations
54
55 open(lunbf,file=file,form='unformatted')
56 call ufbtab(lunbf,said,1,maxa,nret,'SAID')
57 call ufbtab(lunbf,siid,1,maxa,nrex,'SIID')
58
59! need to open the bufrfile with the satellites of interest
60
61 open(lunbf,file=file,form='unformatted')
62 CALL openbf(lunbf,'IN',lunbf)
63 call readmg(lunbf,subset,idate,iret)
64 call codflg('Y')
65
66! make a table of sat ids and sat instruments
67
68 do n=1,max(nret,nrex)
69 i = said(n)
70 j = siid(n)
71 if(i>maxs.or.i<0) i=0
72 if(j>maxs.or.j<0) j=0
73 isat(i,j) = isat(i,j)+1
74 enddo
75
76! print the summary of satid and sat inst combinations
77
78 write(*,*)
791 format(a14,2x,a14,2x,a8)
80 do i=0,1000
81 do j=0,1000
82 if(isat(i,j).gt.0) then
83 jsat=jsat+isat(i,j)
84 call satcode(lunbf,i,ci,j,cj)
85 write(*,'(i3.3,2x,a16,2x,i10,2x,i3.3,a80)')i,ci,isat(i,j),j,trim(cj)
86 endif
87 enddo
88 enddo
89
90 write(*,'(/23x,i10/)') jsat
91
92 end program
93!-----------------------------------------------------------------------
94! looks up BUFR code table values for SAID (said) and SIID (instrument)
95!-----------------------------------------------------------------------
96 subroutine satcode(lunit,icode,csad,jcode,csid)
97
98 character(16) :: csad
99 character(80) :: csid
100 character(255) :: str
101
102 csad(1:16)=' '; csid(1:80)=' '
103
104! call routines to look up the said and siid
105
106 if(icode>0) then
107 str=repeat(' ',255)
108 call getcfmng(lunit,'SAID',icode,' ',-1,str,len,iret); csad=str(1:16)
109 elseif(jcode>0) then
110 str=repeat(' ',255)
111 call getcfmng(lunit,'SIID',jcode,' ',-1,str,len,iret); csid=str(1:80)
112 endif
113
114 end subroutine
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine codflg(CF)
This subroutine is used to specify whether or not code and flag table information should be included ...
Definition: codflg.f:46
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:111
subroutine mtinfo(CMTDIR, LUNMT1, LUNMT2)
This subroutine allows the specification of the directory location and Fortran logical unit numbers t...
Definition: mtinfo.f:47
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
Definition: openbf.f:139
subroutine readmg(LUNXX, SUBSET, JDATE, IRET)
This subroutine reads the next BUFR message from logical unit ABS(LUNXX) into internal arrays.
Definition: readmg.f:74
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:82