program read_airs ! . . . . ! subprogram: read_airs read bufr format airs data use kinds, only: r_kind,r_double,i_kind ! Number of channels for sensors in BUFR integer(i_kind),parameter :: n_airschan = 281 !--- 281 subset ch out of 2378 ch for AIRS integer(i_kind),parameter :: n_amsuchan = 15 integer(i_kind),parameter :: n_hsbchan = 4 integer(i_kind),parameter :: n_totchan = n_amsuchan+n_airschan+n_hsbchan+1 ! BUFR file sequencial number character(len=512) :: table_file integer(i_kind) :: lnbufr = 10 integer(i_kind) :: lnbufrtab = 11 integer(i_kind) :: irec,isub,next ! Variables for BUFR IO real(r_double),dimension(2) :: aquaspot real(r_double),dimension(12,3) :: allspot real(r_double),dimension(n_totchan) :: allchan character(len=8) :: subset character(len=80) :: allspotlist integer(i_kind) :: iret, ireadmg,ireadsb logical :: airstab character(len=80) :: infile infile='airsbufr' allspotlist='SIID YEAR MNTH DAYS HOUR MINU SECO CLATH CLONH SAZA BEARAZ FOVN' ! Open BUFR file open(lnbufr,file=infile,form='unformatted') ! Open BUFR table table_file = 'airs_bufr.table' ! make table file name inquire(file=table_file,exist=airstab) if (airstab) then open(lnbufrtab,file=trim(table_file)) call openbf(lnbufr,'IN',lnbufrtab) else call openbf(lnbufr,'IN',lnbufr) endif call datelen(10) ! Big loop to read data file next=0 do while(ireadmg(lnbufr,subset,idate)>=0) next=next+1 read_loop: do while (ireadsb(lnbufr)==0) ! Read AIRSSPOT , AMSUSPOT and HSBSPOT call ufbrep(lnbufr,allspot,12,3,iret,allspotlist) if(iret /= 3) cycle read_loop ! Check that number of airs channel equals n_airschan ! only done until they match for one record and ndata is updated ! Read AIRSCHAN or AMSUCHAN or HSBCHAN call ufbrep(lnbufr,allchan,1,n_totchan,iret,'TMBR') if( iret /= n_totchan)then write(6,*)'READ_AIRS: ### ERROR IN READING ', ' BUFR DATA:', & iret, ' CH DATA IS READ INSTEAD OF ',n_totchan cycle read_loop endif ! Read AQUASPOT call ufbint(lnbufr,aquaspot,2,1,iret,'SOZA SOLAZI') enddo read_loop enddo call closbf(lnbufr) ! Close bufr file end program read_airs