Skip to content

Commit

Permalink
remove useless variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tgastine committed Jul 30, 2024
1 parent 555c3a2 commit 7fc8962
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 deletions.
19 changes: 9 additions & 10 deletions src/horizontal.f90
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ subroutine horizontal()

!-- Calculate grid points and weights for the
! Gauss-Legendre integration of the plms:
call gauleg(-one,one,theta_ord,tmp_gauss,n_theta_max)
call gauleg(-one,one,theta_ord,tmp_gauss)

! Get dP for all degrees and order m=0 at the equator only
! Usefull to estimate the flow velocity at the equator
call plm_theta(half*pi,l_max,0,0,minc,Pl0Eq,dPl0Eq,l_max+1,norm)
call plm_theta(half*pi,l_max,0,0,minc,Pl0Eq,dPl0Eq,norm)

!-- Legendre polynomials and cos(theta) derivative:
do n_theta=1,n_theta_max/2 ! Loop over colat in NHS
Expand Down Expand Up @@ -192,9 +192,7 @@ subroutine horizontal()

!----- Same for longitude output grid:
fac=two*pi/real(n_phi_max*minc,cp)
do n_phi=1,n_phi_max
phi(n_phi)=fac*real(n_phi-1,cp)
end do
phi(:)=[((n_phi-1)*fac, n_phi=1,n_phi_max)]

!-- Initialize fast fourier transform for phis:
if ( .not. l_axi ) call init_fft(n_phi_max)
Expand Down Expand Up @@ -278,7 +276,7 @@ subroutine horizontal()

end subroutine horizontal
!------------------------------------------------------------------------------
subroutine gauleg(sinThMin,sinThMax,theta_ord,gauss,n_th_max)
subroutine gauleg(sinThMin,sinThMax,theta_ord,gauss)
!
! Subroutine is based on a NR code.
! Calculates N zeros of legendre polynomial P(l=N) in
Expand All @@ -290,17 +288,18 @@ subroutine gauleg(sinThMin,sinThMax,theta_ord,gauss,n_th_max)
!-- Input variables:
real(cp), intent(in) :: sinThMin ! lower bound in radiants
real(cp), intent(in) :: sinThMax ! upper bound in radiants
integer, intent(in) :: n_th_max ! desired maximum degree

!-- Output variables:
real(cp), intent(out) :: theta_ord(n_th_max) ! zeros cos(theta)
real(cp), intent(out) :: gauss(n_th_max) ! associated Gauss-Legendre weights
real(cp), intent(out) :: theta_ord(:) ! zeros cos(theta)
real(cp), intent(out) :: gauss(:) ! associated Gauss-Legendre weights

!-- Local variables:
integer :: m,i,j
integer :: m,i,j,n_th_max
real(cp) :: sinThMean,sinThDiff,p1,p2,p3,pp,z,z1
real(cp), parameter :: eps = 10.0_cp*epsilon(one)

n_th_max=size(theta_ord)

! use symmetry
m=(n_th_max+1)/2

Expand Down
2 changes: 1 addition & 1 deletion src/magnetic_energy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ subroutine initialize_magnetic_energy
theta = pi*(nTheta-half)/real(n_theta_max_comp,cp)
!-- Schmidt normalisation --!
call plm_theta(theta, l_max_comp, 0, l_max_comp, minc, &
& plma, dtheta_plma, lm_max_comp, 1)
& plma, dtheta_plma, 1)
lm = 1
do m=0,l_max_comp,minc
do l=m,l_max_comp
Expand Down
20 changes: 3 additions & 17 deletions src/plms.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module plms_theta

use precision_mod
use constants, only: osq4pi, one, two
use useful, only: abortRun

implicit none

Expand All @@ -13,7 +12,7 @@ module plms_theta
contains

subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &
& plma,dtheta_plma,ndim_plma,norm)
& plma,dtheta_plma,norm)
!
! This produces the :math:`P_{\ell}^m` for all degrees :math:`\ell` and
! orders :math:`m` for a given colatitude. :math:`\theta`, as well as
Expand All @@ -33,13 +32,12 @@ subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &
integer, intent(in) :: min_order ! required min order of plm
integer, intent(in) :: max_order ! required max order of plm
integer, intent(in) :: m0 ! basic wave number
integer, intent(in) :: ndim_plma ! dimension of plma and dtheta_plma
integer, intent(in) :: norm ! =0 fully normalised
! =1 Schmidt normalised

!-- Output variables:
real(cp), intent(out) :: plma(ndim_plma) ! associated Legendre polynomials at theta
real(cp), intent(out) :: dtheta_plma(ndim_plma) ! their theta derivative
real(cp), intent(out) :: plma(:) ! associated Legendre polynomials at theta
real(cp), intent(out) :: dtheta_plma(:) ! their theta derivative

!-- Local variables:
real(cp) :: sq2,dnorm,fac,plm,plm1,plm2
Expand Down Expand Up @@ -94,9 +92,6 @@ subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &

!----- Now store it:
pos=pos+1
if ( pos > ndim_plma ) then
call abortRun('! Dimension ndim_plma too small in subroutine plm_theta')
end if
plma(pos) = dnorm*plm

end do
Expand Down Expand Up @@ -129,9 +124,6 @@ subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &
!-------- l=m contribution:
l=m
pos=pos+1
if ( pos > ndim_plma ) then
call abortRun('! Dimension ndim_plma too small in subroutine plm_theta')
end if
if ( m < max_degree ) then
if( norm == 0 .OR. norm == 2 ) then
dtheta_plma(pos)= l/sqrt(real(2*l+3,cp)) * plma(pos+1)
Expand All @@ -150,9 +142,6 @@ subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &
do l=m+1,max_degree-1

pos=pos+1
if ( pos > ndim_plma ) then
call abortRun('! Dimension ndim_plma too small in subroutine plm_theta')
end if
if( norm == 0 .OR. norm == 2 ) then
dtheta_plma(pos)= &
& l*sqrt( real((l+m+1)*(l-m+1),cp) / &
Expand All @@ -177,9 +166,6 @@ subroutine plm_theta(theta,max_degree,min_order,max_order,m0, &
if ( m < max_degree ) then
l=max_degree
pos=pos+1
if ( pos > ndim_plma ) then
call abortRun('! Dimension ndim_plma too small in subroutine plm_theta')
end if
if( norm == 0 .OR. norm == 2 ) then
dtheta_plma(pos)= &
& l*sqrt( real((l+m+1)*(l-m+1),cp) / &
Expand Down
16 changes: 7 additions & 9 deletions src/shtransforms.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subroutine initialize_transforms
!

!-- Local variables
integer :: n_theta, norm, lm, mc, m
integer :: n_theta, norm, mc, m
real(cp) :: colat,theta_ord(n_theta_max), gauss(n_theta_max)
real(cp) :: plma(lm_max), dtheta_plma(lm_max)

Expand All @@ -62,20 +62,18 @@ subroutine initialize_transforms

!-- Calculate grid points and weights for the
!-- Gauss-Legendre integration of the plms:
call gauleg(-one,one,theta_ord,gauss,n_theta_max)
call gauleg(-one,one,theta_ord,gauss)

do n_theta=1,n_theta_max/2 ! Loop over colat in NHS
colat=theta_ord(n_theta)
!----- plmtheta calculates plms and their derivatives
! up to degree and order l_max and m_max at
! the points cos(theta_ord(n_theta)):
call plm_theta(colat,l_max,m_min,m_max,minc,plma,dtheta_plma,lm_max,norm)
do lm=1,lm_max
Plm(lm,n_theta) =plma(lm)
dPlm(lm,n_theta)=dtheta_plma(lm)
wPlm(lm,n_theta) =two*pi*gauss(n_theta)*plma(lm)
wdPlm(lm,n_theta)=two*pi*gauss(n_theta)*dtheta_plma(lm)
end do
call plm_theta(colat,l_max,m_min,m_max,minc,plma,dtheta_plma,norm)
Plm(:,n_theta) =plma(:)
dPlm(:,n_theta)=dtheta_plma(:)
wPlm(:,n_theta) =two*pi*gauss(n_theta)*plma(:)
wdPlm(:,n_theta)=two*pi*gauss(n_theta)*dtheta_plma(:)
end do

!-- Build auxiliary index arrays for Legendre transform:
Expand Down

0 comments on commit 7fc8962

Please sign in to comment.