	subroutine read_rss_sst(filename,sst_data)

!	This routine reads version-1 RSS OI SST daily files

!	INPUT
!
!	You must UNZIP FILES before reading them
!
! 	filename  with path in form satnames.yyyy.doy.v01
!	 where satname  = name of satellite (tmi_amsre, amsre, or tmi)
!	       yyyy	= year
!		doy	= day of year

!	OUTPUT  
!	sst_data  (a 1440x720 array of data)

!	Longitude  is 0.25*xdim-0.125    degrees east
!	Latitude   is 0.25*ydim-90.125

		character(len=100)				:: filename
		real(4),dimension(1440,720)			:: sst_data
		integer(4)					:: file_exists    

		character(len=1),dimension(1440,720)		:: buffer
		logical exist

		real(4),parameter				:: scale  = 0.15
		real(4),parameter				:: offset = -3.0

	 
! check to see if file exists -- if not return a -1 in file_exists

		file_exists=0
		inquire(file=filename,exist=exist)
		if(.not. exist) then
			file_exists = -1
			return
		endif

! open the file and read in character data

		write(*,*) 'reading sst file: ', filename
		open(unit=3,file=filename,status='OLD',RECL=1036800,access='DIRECT',form='UNFORMATTED')
		read(unit=3,rec=1) buffer

! convert character data to real SSTs using byte scaling and offset parameters

		sst_data = real(ichar(buffer))

		where(sst_data<=250)
			sst_data = (sst_data * scale) + offset
		endwhere
		do i=1,1440
		do j=1,720
!		  print *,i,j,sst_data(i,j),ichar(buffer(i,j))
                enddo
                enddo
		sst_data=sst_data+273.16


! close the file and return

		close(unit=3)
		return
	end


