!-------------------------------------- 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 GDSPA 2,2
#if defined (DOC)
*
C**s/r GDSPA - Adjoint of spectral transform
*
*
*Author : P.Gauthier/P.Koclas - *ARMA and CMC Nov 1997
* . Complete rewriting of the transform for a parallel treatment
* . based on having the outer loop on the zonal wavenumber
*
* Purpose: builds the grid point model state from the spectral
* state.
* revision 001:
* P. Koclas Apr 2003
* -removed commulti
*
*Arguments
*
** Method: The adjoint calculation is done by latitude bands and the
* result is put in comgd0.cdk
*
#endif
IMPLICIT NONE
*implicits
#include "pardim.cdk"
#include "comdim.cdk"
#include "comgem.cdk"
#include "comleg.cdk"
#include "comgd0.cdk"
*
C
INTEGER JGL, JK, JLON, ILONMAX
REAL*8 ZCONV
C
C
C* 1. Inverse Legendre transform
C --------------------------
200 CONTINUE
CALL GDSPAPAR
C
C 2.1 Reset to zero the modes that are not part of the truncation
C -----------------------------------------------------------
C
ILONMAX = NIEND
DO JGL = 1, NJ
DO JLON = 2*(NTRUNC+1)+1, ILONMAX
DO JK = 1, NKGDIM
GD(JLON,JK,JGL) = 0.
END DO
END DO
END DO
C
DO JGL =1,NJ
DO JK = 1, NKGDIM
GD(0,JK,JGL) = 0.
END DO
END DO
C
C 2.2 Apply the FFT
C -------------
C
CALL FFT3DVAR
(GD,NIBEG,NIEND,NKGDIM,NJBEG,NJEND,NKSDIM,+1)
C
C 3. Renormalize the dual winds
C
DO JGL = 1, NJ
ZCONV = R1MUI(JGL)
ILONMAX = NILON(JGL)
DO JK = 1, 2*NFLEV
DO JLON = 1, ILONMAX
GD(JLON,JK,JGL) = GD(JLON,JK,JGL)*ZCONV
END DO
END DO
END DO
C
RETURN
END