      PROGRAM etorp
*************************************************************************
* Conversion of dielectric functions to p-reflectivity.                 *
* from standard input it reads 
* input file name for epsilon for the ordinary and extraordinary directions.
* angle of incidence in degree
* the  input files must have the format x eps1o eps2o eps1e,eps2e       *
* The output comes as: x  rp                                            *
*************************************************************************
      REAL X(100000),e1,e2,e3,e4,angle,cst,snt2
      complex epsile(100000),epsilo(100000),cn,cb,cr
      INTEGER I,mm
      character*40 flin
      read(*,'(a40)') flin
      open(23,file=flin)
      read(*,*) angle
      angle=angle*3.14159265/180 
      cst=cos(angle)
      snt2=1-cst*cst   
      mm=100000 
      do 10 i=1,mm                                                  
       READ(23,*,END=11) X(i),e1,e2,e3,e4
       epsilo(i)=cmplx(e1,e2)
       epsile(i)=cmplx(e3,e4)
10    continue
      close(23)   
11    mm=i-1
      do 25 i=1,mm
       cn=csqrt(epsile(i)-snt2)
       cb=csqrt(epsile(i))*csqrt(epsilo(i))*cst
       cr=(cb-cn)/(cb+cn)
       write(*,*) x(i),cabs(cr)**2
25    continue
      END  

