!-------------------------------------- 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 reespe_la 2,1
#if defined (DOC)
*
***s/r reespe_la  - Spectral Transform all assumed SCALAR fields in global array sp.
*
*Author  : L. Fillion -ARMA/MSC - 1 oct 2005.
*
*     Revision:
* L. Fillion -ARMA/EC - 24 Feb 2010 - Reduce memory requirements.
*
#endif
*
      IMPLICIT NONE
*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
!
!      real*8 zfmla(ni,nksdim,nj)  ! if NCAR fft used
      real*8 zsp(nla,2)
      real*8 zgdxy(ni,nj)
!     
!!
      do jk = 1, nksdim
        do jlat = 1, nj
          do jlon = 1, ni
!            zfmla(jlon,jk,jlat) = gd(jlon,jk,jlat)
            zgdxy(jlon,jlat) = gd(jlon,jk,jlat)
          end do
        end do
        if(lrpnfft) then
          call dft2dr(zsp,zgdxy)
        else
!          call dft2d(zsp,zfmla,sdft2d,nindxy,mlen2d,
!     &               jk,nla,ni,nj,nksdim)
        endif
        do jla = 1, nla
          sp(jla,1,jk) = zsp(jla,1)
          sp(jla,2,jk) = zsp(jla,2)
        enddo
      enddo
!
      return
      end