program read_bufrtovs ! subprogram: read_bufrtovs read bufr tovs 1b data !$$$ use kinds, only: r_kind,r_double,i_kind implicit none ! Declare passed variables character(len=20) :: infile ! Declare local parameters integer(i_kind),parameter:: n1bhdr=13 integer(i_kind),parameter:: n2bhdr=14 ! Declare local variables logical hirs,msu,amsua,amsub,mhs,hirs4,hirs3,hirs2,ssu character(14):: obstype character(14):: infile2 character(8) subset character(80) hdr1b,hdr2b integer(i_kind) ireadsb,ireadmg,next integer(i_kind) i,j,k,llll,llb,lll integer(i_kind) iret,idate,nchanl,n integer(i_kind) lnbufr real(r_double),allocatable,dimension(:):: data1b8 real(r_double),dimension(n1bhdr):: bfr1bhdr real(r_double),dimension(n2bhdr):: bfr2bhdr !************************************************************************** obstype='mhs' infile='bufrtovs' hirs2 = obstype == 'hirs2' hirs3 = obstype == 'hirs3' hirs4 = obstype == 'hirs4' hirs = hirs2 .or. hirs3 .or. hirs4 msu= obstype == 'msu' amsua= obstype == 'amsua' amsub= obstype == 'amsub' mhs = obstype == 'mhs' ssu = obstype == 'ssu' if ( hirs ) then nchanl=19 else if ( msu ) then nchanl=4 else if ( amsua ) then nchanl=15 else if ( amsub ) then nchanl=5 else if ( mhs ) then nchanl=5 else if ( ssu ) then nchanl=3 endif llb=1 lll=1 lnbufr=10 allocate(data1b8(nchanl)) ! Big loop over standard data feed and possible ears data do llll=llb,lll ! Set bufr subset names based on type of data to read ! Open unit to satellite bufr file infile2=infile ! if(llll == 2)then ! infile2=trim(infile)//'ears' ! if(amsua .and. kidsat >= 200 .and. kidsat <= 207)go to 500 ! end if ! Reopen unit to satellite bufr file call closbf(lnbufr) open(lnbufr,file=infile2,form='unformatted',status = 'old',err = 500) call openbf(lnbufr,'IN',lnbufr) ! Loop to read bufr file next=0 read_subset: do while(ireadmg(lnbufr,subset,idate)>=0) next=next+1 write(*,*) subset,idate read_loop: do while (ireadsb(lnbufr)==0) ! Read header record. (llll=1 is normal feed, 2=EARS data) hdr1b ='SAID FOVN YEAR MNTH DAYS HOUR MINU SECO CLAT CLON CLATH CLONH HOLS' call ufbint(lnbufr,bfr1bhdr,n1bhdr,1,iret,hdr1b) write(*,*) (bfr1bhdr(i),i=1,n1bhdr) hdr2b ='SAZA SOZA BEARAZ SOLAZI' call ufbint(lnbufr,bfr2bhdr,n2bhdr,1,iret,hdr2b) write(*,*) (bfr2bhdr(i),i=1,4) ! Read data record. Increment data counter if(llll == 1)then call ufbrep(lnbufr,data1b8,1,nchanl,iret,'TMBR') else call ufbrep(lnbufr,data1b8,1,nchanl,iret,'TMBRST') end if write(*,*) (data1b8(i),i=1,iret) ! End of bufr read loops enddo read_loop enddo read_subset call closbf(lnbufr) 500 continue end do end program read_bufrtovs