forked from JackS9/phatpsy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gennrm.f
39 lines (39 loc) · 1.3 KB
/
gennrm.f
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
SUBROUTINE GENNRM(PLMNRM,FACT,NPLM,NFACT,LMAX,QREALY)
IMPLICIT REAL*8(A-H,O,P,R-Z),LOGICAL*1(Q)
C-----------------------------------------------------------------------
C
C GENNRM...
C
C THIS ROUTINE GENERATES THE NORMALIZATION CONSTANTS FOR THE
C SPHERICAL HARMONICS UP TO A MAXIMUM L-VALUE.
C
C VARIABLE DEFINITIONS:
C
C LMAX......... MAXIMUM L-VALUE.
C PLMNRM(LM)... NORMALIZATION CONSTANT FOR P(L,M), WHERE
C LM = L*(L+1)/2 + ABS(M) + 1.
C NPLM......... =(LMAX+1)*(LMAX+2)/2, DIMENSION OF PLMNRM(*).
C FACT(N)...... =(N-1)-FACTORIAL.
C NFACT........ AT LEAST 2*LMAX+1, DIMENSION OF FACT(*).
C (ASSUMED GENERATED BY GENFAC PREVIOUSLY).
C QREALY....... =T --> REAL SPHERICAL HARMONICS.
C
C ROUTINES CALLED: DATAN2, DSQRT
C
C-----------------------------------------------------------------------
DIMENSION PLMNRM(NPLM),FACT(NFACT)
DATA ZERO/0.0D0/,ONE/1.0D0/,TWO/2.0D0/
PI=TWO*DATAN2(ONE,ZERO)
LMXP1=LMAX+1
DO 20 IL=1,LMXP1
LL=(IL*(IL-1))/2
DO 10 IM=1,IL
M=IM-1
LM=LL+IM
AREA=TWO*PI
IF (.NOT.QREALY.OR.(M.EQ.0)) AREA=TWO*AREA
PLMNRM(LM)=DSQRT((2*IL-1)*FACT(IL-M)/(AREA*FACT(IL+M)))
10 CONTINUE
20 CONTINUE
RETURN
END