!-------------------------------------- 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 re2spla(psp,pgd,knk) 22,2
#if defined (DOC)
*
***s/r re2sp2dla  - Transform from grid point pgd to Fourier
*                   at a given vertical klev using a DFT2D.
*
*Author  : L. Fillion -ARMA/EC - 23 Apr 2008.
*
*     Revision:
*
#endif
*
      IMPLICIT NONE
      integer klev,knk
      real*8 pgd(ni,knk,nj)
      real*8 psp(nla,2,knk)
*implicits
#include "taglam4d.cdk"
#include "comdim.cdk"
#include "comgrd_param.cdk"
#include "comgrd.cdk"
#include "comgd0.cdk"
#include "comsp.cdk"
#include "comfftla.cdk"
!     
      INTEGER ILEN, JK, JLON, JLAT, INCPU, ISIZ, jla
!
      integer jk,jla
      real*8 zfmla(ni,nj)
      real*8 zgdxy(ni,nj)
      real*8 zsp2d(nla,2)
!     
!!
      do jk = 1,knk
        do jlat = 1, nj
          do jlon = 1, ni
            zfmla(jlon,jlat) = pgd(jlon,jk,jlat)
            zgdxy(jlon,jlat) = pgd(jlon,jk,jlat)
          end do
        end do
        if(lrpnfft) then
          call dft2dr(zsp2d,zgdxy)
        else
          call dft2d(zsp2d,zfmla,sdft2d,nindxy,mlen2d,
     &               jk,nla,ni,nj,1)
        endif
        do jla = 1, nla
          psp(jla,1,jk) = zsp2d(jla,1)
          psp(jla,2,jk) = zsp2d(jla,2)
        enddo
      enddo
!
      return
      end