14  use, 
intrinsic :: iso_fortran_env
 
   38    real(real64),   
intent(inout) :: ylm(nr)
 
   39    integer, 
intent(in)    :: l, mr, nr
 
   40    real(real64),   
intent(inout) :: rr(nr), xx(3, nr)
 
   46    real(real64) :: cost, phi
 
   48    real(real64) :: bs2, bs3, bs6, bs12
 
   54    if (l > 3 .or. l < -5) stop 
'ylm_wannier l out of range ' 
   56      if (mr < 1 .or. mr > 2*l + 1) stop 
'ylm_wannier mr out of range' 
   58      if (mr < 1 .or. mr > abs(l) + 1) stop 
'ylm_wannier mr out of range' 
   63      if (rr(ir) < 1e-12_real64) 
then 
   72      cost =  xx(3, ir) / rr(ir)
 
   76      if (xx(1, ir) > 1e-12_real64) 
then 
   77        phi = 
atan(xx(2, ir) / xx(1, ir))
 
   78      else if (xx(1,ir) < -1e-12_real64) 
then 
   79        phi = 
atan(xx(2, ir) / xx(1, ir)) + 
m_pi 
   88        if (mr == 1) ylm(ir) = 
pz(cost)
 
   89        if (mr == 2) ylm(ir) = 
px(cost, phi)
 
   90        if (mr == 3) ylm(ir) = 
py(cost, phi)
 
   92        if (mr == 1) ylm(ir) = 
dz2(cost)
 
   93        if (mr == 2) ylm(ir) = 
dxz(cost, phi)
 
   94        if (mr == 3) ylm(ir) = 
dyz(cost, phi)
 
   95        if (mr == 4) ylm(ir) = 
dx2my2(cost, phi)
 
   96        if (mr == 5) ylm(ir) = 
dxy(cost, phi)
 
   98        if (mr == 1) ylm(ir) = 
fz3(cost)
 
   99        if (mr == 2) ylm(ir) = 
fxz2(cost, phi)
 
  100        if (mr == 3) ylm(ir) = 
fyz2(cost, phi)
 
  101        if (mr == 4) ylm(ir) = 
fzx2my2(cost, phi)
 
  102        if (mr == 5) ylm(ir) = 
fxyz(cost, phi)
 
  103        if (mr == 6) ylm(ir) = 
fxx2m3y2(cost, phi)
 
  104        if (mr == 7) ylm(ir) = 
fy3x2my2(cost, phi)
 
  106        if (mr == 1) ylm(ir) = bs2 * (
s() + 
px(cost, phi))
 
  107        if (mr == 2) ylm(ir) = bs2 * (
s() - 
px(cost, phi))
 
  109        if (mr == 1) ylm(ir) = bs3 * 
s() - bs6 * 
px(cost, phi) + bs2 * 
py(cost, phi)
 
  110        if (mr == 2) ylm(ir) = bs3 * 
s() - bs6 * 
px(cost, phi) - bs2 * 
py(cost, phi)
 
  111        if (mr == 3) ylm(ir) = bs3 * 
s() + 
m_two * bs6 * 
px(cost, phi)
 
  113        if (mr == 1) ylm(ir) = 
m_half*(
s() + 
px(cost, phi) + 
py(cost, phi) + 
pz(cost))
 
  114        if (mr == 2) ylm(ir) = 
m_half*(
s() + 
px(cost, phi) - 
py(cost, phi) - 
pz(cost))
 
  115        if (mr == 3) ylm(ir) = 
m_half*(
s() - 
px(cost, phi) + 
py(cost, phi) - 
pz(cost))
 
  116        if (mr == 4) ylm(ir) = 
m_half*(
s() - 
px(cost, phi) - 
py(cost, phi) + 
pz(cost))
 
  118        if (mr == 1) ylm(ir) = bs3 * 
s() - bs6 * 
px(cost, phi) + bs2 * 
py(cost, phi)
 
  119        if (mr == 2) ylm(ir) = bs3 * 
s() - bs6 * 
px(cost, phi) - bs2 * 
py(cost, phi)
 
  120        if (mr == 3) ylm(ir) = bs3 * 
s() + 
m_two * bs6 * 
px(cost, phi)
 
  121        if (mr == 4) ylm(ir) = bs2 * 
pz(cost) + bs2 * 
dz2(cost)
 
  122        if (mr == 5) ylm(ir) =-bs2 * 
pz(cost) + bs2 * 
dz2(cost)
 
  124        if (mr == 1) ylm(ir) = bs6 * 
s() - bs2 * 
px(cost, phi) -bs12 * 
dz2(cost) + 
m_half * 
dx2my2(cost, phi)
 
  125        if (mr == 2) ylm(ir) = bs6 * 
s() + bs2 * 
px(cost, phi) -bs12 * 
dz2(cost) + 
m_half * 
dx2my2(cost, phi)
 
  126        if (mr == 3) ylm(ir) = bs6 * 
s() - bs2 * 
py(cost, phi) -bs12 * 
dz2(cost) - 
m_half * 
dx2my2(cost, phi)
 
  127        if (mr == 4) ylm(ir) = bs6 * 
s() + bs2 * 
py(cost, phi) -bs12 * 
dz2(cost) - 
m_half * 
dx2my2(cost, phi)
 
  128        if (mr == 5) ylm(ir) = bs6 * 
s() - bs2 * 
pz(cost) +bs3 * 
dz2(cost)
 
  129        if (mr == 6) ylm(ir) = bs6 * 
s() + bs2 * 
pz(cost) +bs3 * 
dz2(cost)
 
  143    real(real64) ::
pz, cost
 
  147  function px(cost, phi)
 
  148    real(real64) ::
px, cost, phi, sint
 
  153  function py(cost, phi)
 
  154    real(real64) ::
py, cost, phi, sint
 
  161    real(real64) ::
dz2, cost
 
  165  function dxz(cost, phi)
 
  166    real(real64) ::
dxz, cost, phi, sint
 
  171  function dyz(cost, phi)
 
  172    real(real64) ::
dyz, cost, phi, sint
 
  177  function dx2my2(cost, phi)
 
  178    real(real64) ::
dx2my2, cost, phi, sint
 
  183  function dxy(cost, phi)
 
  184    real(real64) ::
dxy, cost, phi, sint
 
  191    real(real64) ::
fz3, cost
 
  192    fz3 =  0.25_real64 * 
sqrt(7.0_real64 / 
m_pi) * (5.0_real64 * cost * cost - 
m_three) * cost
 
  195  function fxz2(cost, phi)
 
  196    real(real64) ::
fxz2, cost, phi, sint
 
  198    fxz2 =  0.25_real64 * 
sqrt(10.5_real64 / 
m_pi) * (5.0_real64 * cost * cost - 
m_one) * sint * 
cos(phi)
 
  201  function fyz2(cost, phi)
 
  202    real(real64) ::
fyz2, cost, phi, sint
 
  204    fyz2 =  0.25_real64 * 
sqrt(10.5_real64 / 
m_pi) * (5.0_real64 * cost * cost - 
m_one) * sint * 
sin(phi)
 
  208    real(real64) ::
fzx2my2, cost, phi, sint
 
  213  function fxyz(cost, phi)
 
  214    real(real64) ::
fxyz, cost, phi, sint
 
  220    real(real64) ::
fxx2m3y2, cost, phi, sint
 
  226    real(real64) ::
fy3x2my2, cost, phi, sint
 
double sin(double __x) __attribute__((__nothrow__
 
double atan(double __x) __attribute__((__nothrow__
 
double sqrt(double __x) __attribute__((__nothrow__
 
double cos(double __x) __attribute__((__nothrow__
 
real(real64), parameter, public m_two
 
real(real64), parameter, public m_zero
 
real(real64), parameter, public m_four
 
real(real64), parameter, public m_pi
some mathematical constants
 
real(real64), parameter, public m_half
 
real(real64), parameter, public m_one
 
real(real64), parameter, public m_three
 
real(real64) function fxx2m3y2(cost, phi)
 
real(real64) function fy3x2my2(cost, phi)
 
real(real64) function py(cost, phi)
 
real(real64) function fxz2(cost, phi)
 
real(real64) function fz3(cost)
 
real(real64) function dz2(cost)
 
real(real64) function dxz(cost, phi)
 
real(real64) function pz(cost)
 
real(real64) function fzx2my2(cost, phi)
 
real(real64) function dxy(cost, phi)
 
real(real64) function fxyz(cost, phi)
 
real(real64) function dyz(cost, phi)
 
real(real64) function dx2my2(cost, phi)
 
real(real64) function px(cost, phi)
 
subroutine, public ylm_wannier(ylm, l, mr, rr, xx, nr)
 
real(real64) function s()
 
real(real64) function fyz2(cost, phi)