DDX_ASSOC_LEGENDRE_ALL_DP Subroutine

private subroutine DDX_ASSOC_LEGENDRE_ALL_DP(DP_OUT, P, LMAX, X)

All derivatives for , reusing a precomputed ASSOC_LEGENDRE_ALL table rather than recomputing from scratch.

Warning

Inherits ASSOC_LEGENDRE_ALL's stability limit (safe for at any ) -- see STABILITY_FINDINGS.md at the repo root, Part 2.

by PLM_INDEX(l,m); 0 at the poles (). ASSOC_LEGENDRE_ALL, same size/indexing. P).

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(out) :: DP_OUT((LMAX+1)*(LMAX+2)/2)
real(kind=dp), intent(in) :: P((LMAX+1)*(LMAX+2)/2)
integer(kind=i4), intent(in) :: LMAX

Maximum degree, (must match P's).

real(kind=dp), intent(in) :: X

Argument, (must match the X used to build


Calls

proc~~ddx_assoc_legendre_all_dp~~CallsGraph proc~ddx_assoc_legendre_all_dp DDX_ASSOC_LEGENDRE_ALL_DP proc~plm_index PLM_INDEX proc~ddx_assoc_legendre_all_dp->proc~plm_index

Called by

proc~~ddx_assoc_legendre_all_dp~~CalledByGraph proc~ddx_assoc_legendre_all_dp DDX_ASSOC_LEGENDRE_ALL_DP interface~ddx_assoc_legendre_all DDX_ASSOC_LEGENDRE_ALL interface~ddx_assoc_legendre_all->proc~ddx_assoc_legendre_all_dp proc~batch_dalm_cons BATCH_DALM_CONS proc~batch_dalm_cons->interface~ddx_assoc_legendre_all program~main MAIN program~main->proc~batch_dalm_cons

Source Code

  SUBROUTINE DDX_ASSOC_LEGENDRE_ALL_DP(DP_OUT, P, LMAX, X)
  IMPLICIT NONE
  INTEGER(KIND=i4), INTENT(IN) :: LMAX
  REAL(KIND=dp), INTENT(IN) :: X
  REAL(KIND=dp), INTENT(IN) :: P((LMAX+1)*(LMAX+2)/2)
  REAL(KIND=dp), INTENT(OUT) :: DP_OUT((LMAX+1)*(LMAX+2)/2)
  INTEGER(KIND=i4) :: L, M
  REAL(KIND=dp) :: DOM

  DOM = 1.0_dp - X**2

  DO M = 0, LMAX
    DO L = M, LMAX
      IF (ABS(X) .GE. 1.0_dp .OR. L .EQ. 0) THEN
        DP_OUT(PLM_INDEX(L, M)) = 0.0_dp
      ELSE IF (L .EQ. M) THEN
        DP_OUT(PLM_INDEX(L, M)) = &
            -L * X * P(PLM_INDEX(L, M)) / DOM
      ELSE
        DP_OUT(PLM_INDEX(L, M)) = &
            ((L+M)*P(PLM_INDEX(L-1, M)) - &
            L*X*P(PLM_INDEX(L, M))) / DOM
      END IF
    END DO
  END DO
  END SUBROUTINE DDX_ASSOC_LEGENDRE_ALL_DP