Compute scaling factors of real normalized spherical harmonics
Output values of scaling factors of \f$ Y_\ell^m \f$ harmonics are filled only for non-negative \f$ m \f$ since scaling factor of \f$ Y_\ell^{-m} \f$ is the same as scaling factor of \f$ Y_\ell^m \f$.
@param[in] p: Maximal degree of spherical harmonics. p
>= 0
@param[out] vscales: Array of scaling factors. Dimension is (p+1)**2
@param[out] vscales: Array of values 4pi/(2l+1). Dimension is p+1
@param[out] vscales_rel: Array of relative scaling factors.
Dimension is (p+1)**, vscales2
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | p |
subroutine make_vscales(p)
! Input
integer, intent(in) :: p
real(rp) :: tmp, twolp1, tmp2
integer :: l, ind, m
if(p <= vscales_p) then
! Job is already done
return
end if
if(allocated(vscales)) then
! vscales is allocated but it should be expanded.
! Just remove everything and restart from scratch
deallocate(vscales)
end if
if(allocated(vscales_rel)) then
deallocate(vscales_rel)
end if
vscales_p = p
allocate(vscales((vscales_p+1)**2))
allocate(vscales_rel((vscales_p+1)**2))
twolp1 = 1.0_rp
do l = 0, p
! m = 0
ind = l*l + l + 1
tmp = 4.0*pi / twolp1
tmp2 = tmp
tmp = sqrt(tmp)
vscales_rel(ind) = tmp
vscales(ind) = 1.0_rp / tmp
twolp1 = twolp1 + 2.0_rp
tmp = vscales(ind) * sqrt(2.0)
! m != 0
do m = 1, l
tmp = -tmp / sqrt(dble((l-m+1)*(l+m)))
vscales(ind+m) = tmp
vscales(ind-m) = tmp
vscales_rel(ind+m) = tmp * tmp2
vscales_rel(ind-m) = vscales_rel(ind+m)
end do
end do
end subroutine make_vscales