C THE SPHERICAL HARMONICS OF DEGREE LESS THAN OR EQUAL TO NDEG C ARE NUMBERED FROM 1 TO (NDEG+1)**2. THIS PROGRAM PRODUCES C THE USUAL PARAMETERS ASSOCIATED WITH SUCH INDICES. FOR ALL C INDICES K=1,2,...,(NDEG+1)**2, THIS PRODUCES THE CORRESPONDING C PARAMETERS (N,M,L) FOR THE SPHERICAL HARMONICS. FOR THE MEANING C OF THESE PARAMETERS, SEE THE SUBROUTINE LOCATN GIVEN BELOW. C PARAMETER(MAXDEG=10,MAX_NB=(MAXDEG+1)**2) DIMENSION N(MAX_NB),M(MAX_NB),L(MAX_NB) C OPEN(8,FILE='basis_num.output') PRINT *,'WHAT IS THE DESIRED DEGREE?' READ *,NDEG IF(NDEG .GT. MAXDEG) THEN PRINT *,'THE GIVEN DEGREE IS TOO LARGE.' PRINT *,'USE A LARGER VALUE OF MAXDEG IN THE PROGRAM.' CLOSE(8) END IF NB=(NDEG+1)**2 DO 10 I=1,NB CALL INDX(I,NDEG,N(I),M(I),L(I)) 10 CONTINUE WRITE(8,1000) NDEG 1000 FORMAT(' DEGREE=',I2) WRITE(8,1001) 1001 FORMAT(/,4X,'K',4X,'N',4X,'M',4X,'L') 1002 FORMAT(I5,I5,I5,I5) WRITE(8,1002)(I,N(I),M(I),L(I),I=1,NB) CLOSE(8) STOP END FUNCTION LOCATN(N,M,L,NDEG) C --------------- C C GIVES THE INDEX OF THE SPHERICAL HARMONIC BASIS FUNCTION C WITH INDICES (N,M,L). FOR Q=(X,Y,Z) ON THE UNIT SPHERE, WRITE C Q = (SIN(THETA)*COS(PHI),SIN(THETA)*SIN(PHI),COS(THETA)) C FOR M=0, THE SPHERICAL HARMONIC CORRESPONDING TO (N,M,L) IS C C H(Q) = P (Z). C N C C FOR M>0 AND L=0, THE SPHERICAL HARMONIC IS C C M C H(Q) = P (Z)*COS(M*PHI) C N C C FOR M>0 AND L=1, THE SPHERICAL HARMONIC IS C C M C H(Q) = P (Z)*SIN(M*PHI) C N C C M C THE FUNCTIONS P (Z) AND P (Z) ARE THE LEGENDRE POLYNOMIALS AND C N N C THE ASSOCIATED LEGENDRE FUNCTIONS, DEFINED IN SUBROUTINE 'LEGEND'. C IF(M .EQ. 0) THEN LOCATN=N+1 ELSE LOCATN=NDEG*(2*M-1)-M*(M-3)+2*(N-M)+L END IF RETURN END SUBROUTINE INDX(I,NDEG,N,M,L) C --------------- C C THIS PROGRAM TAKES THE INDEX I OF A SPHERICAL HARMONIC, C 1 .LE. I .LE. (NDEG+1)**2, C AND IT FINDS THE INDICES (N,M,L) TO WHICH I CORRESPONDS. C SEE FUNCTION 'INDX' FOR THE DEFINITION OF (N,M,L). C KOL(MM)=NDEG*(MM-1)-(MM*(MM-3))/2-1 C IF(I .LE. NDEG+1) THEN N=I-1 M=0 L=0 RETURN END IF C J=I-NDEG-2 IF(J .EQ. 2*(J/2)) THEN L=0 ELSE L=1 END IF J=(J-L)/2 DO 40 M=1,NDEG IF(J .LT. KOL(M+1)) THEN N=J-KOL(M)+M RETURN END IF 40 CONTINUE END