The Elk Code
 
Loading...
Searching...
No Matches
genshtmat.f90
Go to the documentation of this file.
1
2! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: genshtmat
8! !INTERFACE:
9subroutine genshtmat
10! !USES:
11use modmain
12! !DESCRIPTION:
13! Generates the forward and backward spherical harmonic transformation (SHT)
14! matrices using the spherical covering set produced by the routine
15! {\tt sphcover}. These matrices are used to transform a function between its
16! $(l,m)$-expansion coefficients and its values at the $(\theta,\phi)$ points
17! on the sphere. Both real and complex SHT matrices are calculated and stored
18! in global arrays.
19!
20! !REVISION HISTORY:
21! Created April 2003 (JKD)
22!EOP
23!BOC
24implicit none
25! local variables
26integer itp
27real(8) v(3)
28! automatic arrays
29real(8) tp(2,lmmaxo),vtp(3,lmmaxo),rlm(lmmaxo)
30complex(8) ylm(lmmaxo)
31!--------------------------------!
32! SHT matrices for lmaxi !
33!--------------------------------!
34! allocate real SHT matrices
35if (allocated(rbshti)) deallocate(rbshti)
36allocate(rbshti(lmmaxi,lmmaxi))
37if (allocated(rfshti)) deallocate(rfshti)
38allocate(rfshti(lmmaxi,lmmaxi))
39! allocate complex SHT matrices
40if (allocated(zbshti)) deallocate(zbshti)
41allocate(zbshti(lmmaxi,lmmaxi))
42if (allocated(zfshti)) deallocate(zfshti)
43allocate(zfshti(lmmaxi,lmmaxi))
44! allocate single-precision complex copies
45if (allocated(cbshti)) deallocate(cbshti)
46allocate(cbshti(lmmaxi,lmmaxi))
47if (allocated(cfshti)) deallocate(cfshti)
48allocate(cfshti(lmmaxi,lmmaxi))
49! generate spherical covering set for lmaxi
50call sphcover(lmmaxi,tp)
51! convert (theta, phi) angles to vectors
52do itp=1,lmmaxi
53 call sctovec(tp(:,itp),vtp(:,itp))
54end do
55! rotate the spherical covering set if required
56if (trotsht) then
57 do itp=1,lmmaxi
58 v(1:3)=vtp(1:3,itp)
59 call r3mv(rotsht,v,vtp(:,itp))
60 end do
61end if
62! generate real and complex spherical harmonics and set the backward SHT arrays
63do itp=1,lmmaxi
64 call genrlmv(lmaxi,vtp(:,itp),rlm)
65 rbshti(itp,1:lmmaxi)=rlm(1:lmmaxi)
66 call genylmv(.false.,lmaxi,vtp(:,itp),ylm)
67 zbshti(itp,1:lmmaxi)=ylm(1:lmmaxi)
68end do
69! find the forward SHT arrays
70! real
73! complex
76! make single-precision complex copies
79!--------------------------------!
80! SHT matrices for lmaxo !
81!--------------------------------!
82! allocate real SHT matrices
83if (allocated(rbshto)) deallocate(rbshto)
84allocate(rbshto(lmmaxo,lmmaxo))
85if (allocated(rfshto)) deallocate(rfshto)
86allocate(rfshto(lmmaxo,lmmaxo))
87! allocate complex SHT matrices
88if (allocated(zbshto)) deallocate(zbshto)
89allocate(zbshto(lmmaxo,lmmaxo))
90if (allocated(zfshto)) deallocate(zfshto)
91allocate(zfshto(lmmaxo,lmmaxo))
92! allocate single-precision complex copies
93if (allocated(cbshto)) deallocate(cbshto)
94allocate(cbshto(lmmaxo,lmmaxo))
95if (allocated(cfshto)) deallocate(cfshto)
96allocate(cfshto(lmmaxo,lmmaxo))
97! generate spherical covering set
98call sphcover(lmmaxo,tp)
99! convert (theta, phi) angles to vectors
100do itp=1,lmmaxo
101 call sctovec(tp(:,itp),vtp(:,itp))
102end do
103! rotate the spherical covering set if required
104if (trotsht) then
105 do itp=1,lmmaxo
106 v(1:3)=vtp(1:3,itp)
107 call r3mv(rotsht,v,vtp(:,itp))
108 end do
109end if
110! generate real and complex spherical harmonics and set the backward SHT arrays
111do itp=1,lmmaxo
112 call genrlmv(lmaxo,vtp(:,itp),rlm)
113 rbshto(itp,1:lmmaxo)=rlm(1:lmmaxo)
114 call genylmv(.false.,lmaxo,vtp(:,itp),ylm)
115 zbshto(itp,1:lmmaxo)=ylm(1:lmmaxo)
116end do
117! find the forward SHT arrays
118! real
119rfshto(1:lmmaxo,1:lmmaxo)=rbshto(1:lmmaxo,1:lmmaxo)
120call rminv(lmmaxo,rfshto)
121! complex
122zfshto(1:lmmaxo,1:lmmaxo)=zbshto(1:lmmaxo,1:lmmaxo)
123call zminv(lmmaxo,zfshto)
124! make single-precision complex copies
125cbshto(1:lmmaxo,1:lmmaxo)=zbshto(1:lmmaxo,1:lmmaxo)
126cfshto(1:lmmaxo,1:lmmaxo)=zfshto(1:lmmaxo,1:lmmaxo)
127return
128
129contains
130
131pure subroutine sctovec(tp,v)
132implicit none
133! arguments
134real(8), intent(in) :: tp(2)
135real(8), intent(out) :: v(3)
136! local variables
137real(8) t1
138t1=sin(tp(1))
139v(1)=t1*cos(tp(2))
140v(2)=t1*sin(tp(2))
141v(3)=cos(tp(1))
142end subroutine
143
144end subroutine
145!EOC
146
subroutine genrlmv(lmax, v, rlm)
Definition genrlmv.f90:10
pure subroutine sctovec(tp, v)
subroutine genshtmat
Definition genshtmat.f90:10
pure subroutine genylmv(t4pil, lmax, v, ylm)
Definition genylmv.f90:10
real(8), dimension(:,:), allocatable rfshto
Definition modmain.f90:571
complex(4), dimension(:,:), allocatable cfshti
Definition modmain.f90:581
complex(8), dimension(:,:), allocatable zfshto
Definition modmain.f90:579
integer lmmaxi
Definition modmain.f90:207
real(8), dimension(:,:), allocatable rbshto
Definition modmain.f90:569
real(8), dimension(:,:), allocatable rbshti
Definition modmain.f90:565
logical trotsht
Definition modmain.f90:561
complex(8), dimension(:,:), allocatable zbshto
Definition modmain.f90:577
complex(8), dimension(:,:), allocatable zbshti
Definition modmain.f90:573
real(8), dimension(3, 3) rotsht
Definition modmain.f90:563
complex(4), dimension(:,:), allocatable cbshto
Definition modmain.f90:582
real(8), dimension(:,:), allocatable rfshti
Definition modmain.f90:567
integer lmaxo
Definition modmain.f90:201
integer lmaxi
Definition modmain.f90:205
complex(4), dimension(:,:), allocatable cfshto
Definition modmain.f90:582
complex(8), dimension(:,:), allocatable zfshti
Definition modmain.f90:575
complex(4), dimension(:,:), allocatable cbshti
Definition modmain.f90:581
pure subroutine r3mv(a, x, y)
Definition r3mv.f90:10
subroutine rminv(n, a)
Definition rminv.f90:7
subroutine sphcover(n, tp)
Definition sphcover.f90:10
subroutine zminv(n, a)
Definition zminv.f90:7