      implicit none

      integer n
c      parameter(n=36)
      parameter(n=56)
      real*8 lambda(n),val(n)
      real*8 wl,dwl

      real*8 res

      character*128 fn

      integer i

c      fn="g.data"
c      fn="omega.data"
      fn="qext.data"
      open(50,file='./'//fn,status='unknown')
      do i=1,n
         read(50,*) lambda(i),val(i)
         lambda(i)=lambda(i)*1.0d-6
      enddo
      close(50)

      call sort(n,lambda,val)

c      fn="gmod.data"
c      fn="omegamod.data"
      fn="qextmod.data"
      open(50,file='./'//fn,status='unknown')

      dwl=0.1d-6
      wl=5.0d-6
 100  continue
      do i=2,n-1
         if(lambda(i).gt.wl) go to 200
      enddo
 200  continue

      res=(val(i)-val(i-1))/(lambda(i)-lambda(i-1))
     &     *(wl-lambda(i-1))+val(i-1)
      res=max(res,0.0d0)


      write(50,'(4e)') wl,res
      wl=wl+dwl
      if(wl.lt.200.d-6) go to 100

      close(50)

      stop
      end

c******************************************************************************
      real*8 function plfunc(x,t)

      implicit none

      real*8 x,t
      real*8 c,planc,boltz

      c=2.99792458d8
      planc=6.6260755d-34
      boltz=1.380658d-23

      plfunc=2.0d0*planc*c*c*x*x*x
     &     /(dexp(planc*c*x/(boltz*t))-1.0d0)

      return
      end
