!
Subroutine Multiplication(nmn, nmx, e1, e2, o1, o2)
use Advertisement
implicit none
integer*4, intent(in) :: nmx, nmn
complex*16, intent(out) :: e1(n_max+terms-1), e2(n_max+terms-1), &
                                       o1(n_max+terms-1), o2(n_max+terms-1)
integer*4 nn, ll
complex*16 factor
e1=(0.d00,0.d00); e2=(0.d00,0.d00)
o1=(0.d00,0.d00); o2=(0.d00,0.d00)
if (m.ne.0) then
  do n=nmn, nmx
    do l=1, l_max
      e1(n)=e1(n)+M11(n, l)*c_e1( l)+M12(n, l)*c_o2(l)
      o2(n)=o2(n)+M21(n, l)*c_e1(l)+M22(n, l)*c_o2(l)
      o1(n)=o1(n)+M11(n, l)*c_o1(l)-M12(n, l)*c_e2(l)
      e2(n)=e2(n)-M21(n, l)*c_o1(l)+M22(n, l)*c_e2(l)
    end do
  end do 
else
  do n=nmn, nmx
    do l=1, l_max
      e1(n)=e1(n)+M11(n, l)*c_e1(l)
      e2(n)=e2(n)+M22(n, l)*c_e2(l)
    end do
  end do 
end if 
factor=-(0.d00,1.d00)/pi !!!
e1=e1*factor; e2=e2*factor
o1=o1*factor; o2=o2*factor
End Subroutine Multiplication
!
Subroutine InnerHuygens(nmx, er, zet, fi, key, huygens) 
use Advertisement
implicit none
integer*4, intent(in) :: nmx, key
real*8, intent(in) :: er, zet, fi
complex*16, intent(inout) :: huygens(3)
integer*4 i
complex*16 ev(3)
call oMatrix_Making(nmx, key) ! key=3 - inner field; key=2 - outer field  !
call Multiplication(m_min, nmx, b_e1, b_e2, b_o1, b_o2) !
if (key.eq.3) call oComponents(er, zet, m_min, nmx, 1, n_M, n_N) !
if (key.eq.2) call oComponents(er, zet, m_min, nmx, 3, n_M, n_N) !
call TE_TM(fi, m_min, nmx, b_e1, b_e2, b_o1, b_o2, pe, pm)
huygens=huygens+et*pe+ef*pm
End Subroutine InnerHuygens
!
Subroutine InnerHuygensCheck(key)
use Advertisement
implicit none
real*8 fl
integer*4, intent(in) :: key
complex*16 in_huygens(3)
call Preparations
call Nodes
pr=dreal(Et); pz=dimag(Et); pf=dreal(Ef)
m=m_max 
m_min=m; if (m.eq.0) m_min=1
b_e1(1:l_max)=(1.d00,0.d00); b_e2(1:l_max)=(1.d00,0.d00)
b_o1(1:l_max)=(1.d00,0.d00); b_o2(1:l_max)=(1.d00,0.d00)
call Normalization(terms)
call Components(pr, pz, 1, l_max, key, lPole, n_M, n_N)
call TE_TM(pf, 1, l_max, b_e1, b_e2, b_o1, b_o2, pe, pm)
pm=pe+pm
fl=cdabs(pm(1)**2)+cdabs(pm(2)**2)+cdabs(pm(3)**2)
print *, pm(1)
print *, pm(2)
print *, pm(3)
print *, fl
write(*,*) '**************************'
in_huygens=(0.d00, 0.d00)
call InnerHuygens(n_max, pr, pz, pf, 3, in_huygens)
rs=cdabs(in_huygens(1)**2)+cdabs(in_huygens(2)**2)+cdabs(in_huygens(3)**2)
print *, in_huygens(1)
print *, in_huygens(2)
print *, in_huygens(3)
print *, dabs(rs-fl)
End Subroutine InnerHuygensCheck