!
Subroutine Field(fi, min, max, e1, e2, o1, o2, E)
use Advertisement
implicit none
real*8, intent(in) :: fi
integer*4, intent(in) :: min, max
complex*16, intent(in) :: e1(n_max+terms-1), e2(n_max+terms-1), &
                                     o1(n_max+terms-1), o2(n_max+terms-1)
complex*16, intent(out), dimension(1:3) :: E
real*8 c,s
integer*4 k
E=(0.d00,0.d00)
c=dcos(m*fi); s=dsin(m*fi)
do k=min, max
 E(1)=E(1)+n_M(1,k)*(-e1(k)*s+o1(k)*c)+&
                  n_N(1,k)*(e2(k)*c+o2(k)*s)
 E(2)=E(2)+n_M(2,k)*(-e1(k)*s+o1(k)*c)+&
                  n_N(2,k)*(e2(k)*c+o2(k)*s)
 E(3)=E(3)+n_M(3,k)*(e1(k)*c+o1(k)*s)+&
                  n_N(3,k)*(-e2(k)*s+o2(k)*c)
end do
End Subroutine Field
!
Subroutine TE_TM(fi, min, max, e1, e2, o1, o2, TE, TM)
use Advertisement
implicit none
real*8, intent(in) :: fi
complex*16, intent(in) :: e1(n_max+terms-1), e2(n_max+terms-1), &
                                     o1(n_max+terms-1), o2(n_max+terms-1)
integer*4, intent(in) :: min, max
complex*16, intent(out) :: TE(3), TM(3)
integer*4 k
real*8 c,s
complex*16 v(3)
TE=(0.d00,0.d00); TM=(0.d00,0.d00)
c=dcos(m*fi); s=dsin(m*fi)
do k=min, max
 TE(1)=TE(1)+(n_M(1,k)*o1(k)+n_N(1,k)*e2(k))*c
 TE(2)=TE(2)+(n_M(2,k)*o1(k)+n_N(2,k)*e2(k))*c
 TE(3)=TE(3)+(n_M(3,k)*o1(k)-n_N(3,k)*e2(k))*s
 TM(1)=TM(1)+(-n_M(1,k)*e1(k)+n_N(1,k)*o2(k))*s
 TM(2)=TM(2)+(-n_M(2,k)*e1(k)+n_N(2,k)*o2(k))*s
 TM(3)=TM(3)+(n_M(3,k)*e1(k)+n_N(3,k)*o2(k))*c
end do
End Subroutine TE_TM
!
Subroutine Plain_Wave(er, zet, fi, el, mag)
use Advertisement
implicit none
real*8, intent(in) :: er, zet, fi
complex*16, intent(out) :: el(3), mag(3)
real*8 c_s(3,3), sz, sf, cf, sz0
complex*16 v(3)
sz0=dsqrt(1.d00-z0*z0)
el(1)=et*z0;    mag(1)=-ef*z0
el(2)=ef;         mag(2)=et
el(3)=-et*sz0; mag(3)=ef*sz0
sf=dsin(fi); cf=dcos(fi); sz=dsqrt(1.d00-zet*zet)
c_s(1,1)=sz*cf;  c_s(1,2)=sz*sf;  c_s(1,3)=zet
c_s(2,1)=zet*cf; c_s(2,2)=zet*sf; c_s(2,3)=-sz
c_s(3,1)=-sf;      c_s(3,2)=cf;       c_s(3,3)=0.d00
v=matmul(c_s, el); el=v
v=matmul(c_s, mag); mag=v
v(1)=cdexp((0.d00,1.d00)*(er*sz*cf*sz0+er*zet*z0))
el=el*v(1); mag=mag*v(1)
End Subroutine Plain_Wave