-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathy_l.f90
76 lines (76 loc) · 2.09 KB
/
y_l.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
!
!
!
!
SUBROUTINE HARMO_Y_L (LMAX, LON, LAT, Y_L)
USE SHTOOLS
IMPLICIT NONE
INTEGER, PARAMETER :: LLMAX=512, JJMAX=(LLMAX+1)*(LLMAX+2)/2
INTEGER J, MJ, J_INDEX, LMAX
COMPLEX*16, PARAMETER :: I = CMPLX(0.,1.)
COMPLEX*16 Y_L(*)
REAL*8 LON, LAT
REAL*8, ALLOCATABLE :: PLM(:)
REAL*8 COSDD, SINDD
INTEGER :: JMAX
!
!
! Given longitude LON and latitude LAT - in degrees - this routine computes
! the lambda-component of the gradient of *all* the 4-pi normalized complex
! harmonics $\cal Y_{lm}(\theta,\lambda)$, with \theta=colatitude and \lambda=
! longitude, to degree LMAX given. Uses the (modified) SHTOOLS Legendre
! functions by PlmBar (see Sbr PLMBAR_MOD_D1). - Created by GS August 8, 2008 -
!
! - Modified by GS Apr 2020 -- dynamically allocate PLM
!
!*********************************************************************
! Modified GS on MAy 1, 2020
!
! The routine computes "y_l = (1/sin theta)(d/dlambda) y"
!*********************************************************************
!
!
! ---- Tests the longitude and latitude bounds
If(abs(lat)>90.) then
Write(* ,*) "Error in Sbr. GRAD_LAMBDA_HARMO: Latitude is out of range"
Write(* ,*) "The program will STOP ----------------"
call stop_config
Stop 1
elseif (lon<0.or.lon>360.) then
Write(* ,*) "Error in Sbr. GRAD_LAMBDA_HARMO: Longitude is out of range"
Write(* ,*) "The program will STOP ----------------"
call stop_config
Stop 2
Endif
!
!
! ---- Allocate temporary arrays
!
JMAX=(LMAX+1)*(LMAX+2)/2
ALLOCATE( PLM(JMAX) )
!
! ---- Builds the SHTOOLS Legendre functions, with Condon-Shortley phase
!
CALL PLMBAR_MOD (LMAX, LAT, PLM)
!
!
! ---- Computes the 4-pi normalized Spherical Harmonics up to degree LMAX
!
do j=1, j_index(lmax,lmax)
!
y_l(j) = &
PLM(j)*I*mj(j)* &
cmplx(cosdd(float(mj(j))*lon),sindd(float(mj(j))*lon))/ &
sindd(90.-lat)
!
enddo
!
!
! ---- Release memory
!
DEALLOCATE( PLM )
!
END SUBROUTINE HARMO_Y_L
!
!
!