!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!

      SUBROUTINE GETALP(DDALP,DDDALP,KLATH,KTRUNC,KTRUNCDIM ,KM) 11,1
#if defined (DOC)
*
***s/r GETALP  - Retrieve Legendre Polynomials for a fixed
*     .          value of "m"
*
*Author  : P. Koclas  *CMC/AES  - Nov 97
*Revision:
*     . P. Gauthier *ARMA/MSC - June 2003
*     .      Introduction of module MODALP instead of comdeck COMALP
*Arguments:
*     DDALP()              : Legendre function
*     DDDALP()             : pseudo-derivative
*     KLATH                : number of latitude circles on one hemisphere
*     KTRUNC               : truncation order (triangular)
*     KM                   : zonal wavenumber
*     KTRUNCDIM            : dimension needed for argument passing
*
#endif
*
      use modalp, only: dalp, dealp
      IMPLICIT NONE
*implicits
#include "comdim.cdk"
#include "comleg.cdk"
C     
      INTEGER KM,KLATH,KTRUNC, KTRUNCDIM
      INTEGER ILA,IND
      INTEGER JLAT,JN, JLEN
      REAL*8  DDALP(0:KTRUNCDIM,KLATH), DDDALP(0:KTRUNCDIM,KLATH)
C     
C     
C     6. GET Legendre polynomials FOR A GIVEN M
C     
 600  CONTINUE
C     
C     .  Set to zero
C     
      DO JLAT = 1,KLATH
         DO JLEN = 0, KTRUNC
            DDALP(JLEN,JLAT) = 0.D0
            DDDALP(JLEN,JLAT)= 0.D0
         END DO
      END DO
C     
C     .  EXTRACT POLYNOMIALS
C     
      DO JLAT = 1, KLATH
         DO JN = KM, KTRUNC
            ILA = NIND(KM) + JN-KM
            IND=JN-KM
            DDALP(IND,JLAT) =  DALP(ILA,JLAT)
            DDDALP(IND,JLAT) = DEALP(ILA,JLAT)
         END DO
      END DO
C     
      RETURN
      END