A Fortran example program that performs backward and forward Spherical Harmonic Transforms using SHTns.
A Fortran example program that performs backward and forward Spherical Harmonic Transforms using SHTns. Compile using :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 PROGRAM sht_example
20
21 IMPLICIT NONE
22
23 include 'shtns.f'
24
25 integer*4 lmax, mmax, mres
26 integer*4 nlat, nphi
27 integer*4 nlm
28 integer*4 layout
29 integer*4 norm
30 real*8 eps_polar
31 complex*16, allocatable :: Slm(:), Tlm(:)
32 real*8, allocatable :: sh(:,:), th(:,:)
33
34 integer i,lm, m
35
36
37 lmax = 5
38 mmax = 2
39 mres = 2
40 nphi = 6
41 nlat = 8
42
43
44 call shtns_calc_nlm(nlm, lmax, mmax, mres)
45 print*,'NLM=',nlm
46
47
48 call shtns_verbose(1)
49
50
52
53
54 layout = sht_phi_contiguous
55 call shtns_init_sh_gauss(layout, lmax, mmax, mres, nlat, nphi)
56
57
58
59
60
61
62
63
64
65
66 call shtns_print_cfg()
67
68
69 allocate ( slm(1:nlm), tlm(1:nlm) )
70 allocate ( sh(1:nphi,1:nlat), th(1:nphi,1:nlat) )
71 slm(:) = 0.0
72
73
74 call shtns_lmidx(lm, 1, 0)
75 slm(lm) = 1.0
76 print*
77 print*,slm(:)
78
79 call shtns_sh_to_spat(slm, sh)
80
81
82 print*
83 do i=1,nphi
84 print*,'phi index=',i
85 print*,sh(i,:)
86 enddo
87
88
89 call shtns_spat_to_sh(sh, slm)
90
91 print*
92 print*,slm(:)
93
94
95 print*
96 do m=0, mres*mmax, mres
97 print*,'m=', m
98 call shtns_lmidx(lm,m,m)
99 print*,slm(lm : lm+(lmax-m))
100 enddo
101
102
103
104 nlat = 32
105 call shtns_init_sh_gauss(layout, lmax, mmax, mres, nlat, nphi)
106 m = 1*mres
107 call shtns_lmidx(lm, m, m)
108 slm(lm+1) = 1.0
109 call shtns_sh_to_spat_ml(m/mres, slm(lm), tlm, lmax)
110 print*
111 print*,'spectral m=', m
112 print*,slm(lm : lm+lmax-m+1)
113 print*,'spatial m=', m
114 print*,tlm(1 : nlat)
115
116 stop
117 END
int shtns_use_threads(int num_threads)
Enables multi-thread transform using OpenMP with num_threads (if available). Returns number of thread...
Definition sht_init.c:1605