C**********************************************************                  LTIDT.2     
C             SUBROUTINE LTIDT                                               LTIDT.3     
C**********************************************************                  LTIDT.4     
      SUBROUTINE LTIDT                                                       LTIDT.5     
C                                                                            LTIDT.6     
C     Inverse Legendre transform, from spectral to Fourier space             LTIDT.7     
C     for the derivatives of temperature required to calculate PV.           LTIDT.8     
C     HEXP transforms fields having the same symmetry and type of            LTIDT.9     
C     Legendre function.                                                     LTIDT.10    
C                                                                            LTIDT.11    
C                                                                            PARAM1.2     
C     Determines model resolution                                            PARAM1.3     
C                                                                            PARAM1.4     
      PARAMETER(NN=21,MM=21,NHEM=2,NL=5,MOCT=1,MG=64,JG=16,NWJ2=121          NETCDF.35    
     P         ,NCRAY=64,JGL=JG,NTRAC=1,NLEVRF=1)                            NETCDF.36    
                                                                             PARAM1.7     
C                                                                            PARAM1.8     
C                                                                            PARAM2.2     
C     Sets basic constants, especially those needed for array dimensions     PARAM2.3     
C                                                                            PARAM2.4     
      PARAMETER(MH=2,PI=3.14159265359,PI2=2.0*PI                             PARAM2.5     
     +,NNP=NN+1,MGPP=MG+2,JGP=JG+1,JGG=JG*NHEM,JGGP=JGG+1,MJP=NWJ2+NWJ2      PARAM2.6     
     +,NLM=NL-1,NLP=NL+1,NLPP=NL+2,NLA=NL+3,NLB=NL+4,NL2=NL*NL               PARAM2.7     
     +,IDA=(MG+MG+MG)/2+1,IDB=NWJ2*NL,IDC=IDB+IDB,IDD=MGPP*NL                PARAM2.8     
     +,IDE=NL2*NN,IDF=NCRAY*(MG+1),IDG=JG*NL,IDH=JG*MG                       PARAM2.9     
     +,IDI=NNP/2,IDJ=IDI*IDI,IDK=NL*IDI,IDL=MGPP/2,IDM=NNP/2,IDN=IDM*NL      PARAM2.10    
     +,NWW=1+(MM-1)/MOCT)                                                    PARAM2.11    
      PARAMETER(IGA=NWJ2*NHEM,IGB=IDB*NHEM,IGC=MGPP*NHEM,IGD=IDD*NHEM        PARAM2.12    
     +,IGG=IDG*NHEM,IGL=IDL*NHEM,IGM=IDM*NHEM,IGN=IDN*NHEM                   PARAM2.13    
     +,IGO=IGA+IGA,IGP=IGB+IGB,NFTWG=(5+NTRAC)*NL+3                          PARAM2.14    
     +,NFTGW=(6+3*NTRAC)*NL+2,NFTGD=(3+NTRAC)*NL,NLTR=NL*NTRAC)              PARAM2.15    
C     Number of 2D (surface) output fields. This value is                    PARAM2.16    
C     Doubled due to averaged and instantaneous fields.                      PARAM2.17    
      PARAMETER (N2DFLD=21,NGRPAD=N2DFLD*2*IGC)                              PARAM2.18    
C                                                                            PARAM2.19    
C                                                                            BLANK.2     
C     Basic planetary parameters for run plus information about              BLANK.3     
C     vertical grid structure                                                BLANK.4     
C                                                                            BLANK.5     
C     Note that RD and GASCON are identical and CPD is set from RD,AKAP.     BLANK.6     
      COMMON        SQ(NNP),RSQ(NNP),SIGMAH(NLM),SIGMA(NL)                   BLANK.7     
     +              ,T01S2(NLM),T0(NL),ALPHA(NL),DSIGMA(NL),RDSIG(NL)        BLANK.8     
     +              ,TKP(NL),C(NL2),SQH(NNP)                                 BLANK.9     
     +              ,MF,MFP,JZF,NF,NFP                                       BLANK.10    
     +              ,AKAP,GA,GASCON,RADEA,WW,P0,PFAC,EZ,AIOCT                BLANK.11    
     +              ,RD,RV,CPD,CLATNT                                        BLANK.12    
     +              ,LRSTRT,LSHORT,LTVEC,LSTRETCH                            BLANK.13    
     +              ,LFLUX                                                   BLANK.14    
     +              ,LBALAN,LRESTIJ                                          BLANK.15    
     +              ,LCLIM, LPERPET, L22L,LOROG ,LCSFCT                      BLANK.16    
     +              ,LNOISE                                                  BLANK.17    
      COMPLEX EZ,AIOCT                                                       BLANK.18    
      LOGICAL LRSTRT,LSHORT,LTVEC,LSTRETCH,LBALAN,LRESTIJ                    BLANK.19    
     +       ,LFLUX,LNOISE                                                   BLANK.20    
     +       ,LCLIM, LPERPET, L22L,LOROG,LCSFCT                              BLANK.21    
C                                                                            BLANK.22    
C                                                                            GRIDP3.2     
C     Array ordering in GRIDP must correspond to that in SPECTR.             GRIDP3.3     
C     Complex arrays: multi-level arrays are 2-dimensional.                  GRIDP3.4     
C                                                                            GRIDP3.5     
      COMMON/GRIDP/ CHIG(IGL,NL),SFG(IGL,NL),UG(IGL,NL),VG(IGL,NL)           GRIDP3.6     
     :              ,ZG(IGL,NL),DG(IGL,NL),TG(IGL,NL)                        GRIDP3.7     
     :              ,TRAG(IGL,NL,NTRAC)                                      GRIDP3.8     
     :              ,PLG(IGL),PJG(IGL),PMG(IGL)                              GRIDP3.9     
     :              ,SPG(IGL),VPG(IGL),EG(IGL,NL)                            GRIDP3.10    
     :              ,TNLG(IGL,NL),TRANLG(IGL,NL,NTRAC),FUG(IGL,NL)           GRIDP3.11    
     :              ,FVG(IGL,NL),UTG(IGL,NL),UTRAG(IGL,NL,NTRAC)             GRIDP3.12    
     :              ,VTG(IGL,NL),VTRAG(IGL,NL,NTRAC)                         GRIDP3.13    
     :              ,FVGT(IGL,NL),FUGT(IGL,NL)                               GRIDP3.14    
     :              ,GRPAD(NGRPAD)                                           GRIDP3.15    
      COMPLEX CHIG,SFG,UG,VG,ZG,DG,TG,PLG,PJG,PMG                            GRIDP3.16    
     :       ,SPG,VPG,EG,TNLG,FUG,FVG,UTG,VTG,FVGT,FUGT                      GRIDP3.17    
     :       ,TRAG,TRANLG,UTRAG,VTRAG                                        GRIDP3.18    
C                                                                            GRIDP3.19    
C                                                                            LEGAU.2     
C     Legendre polynomials and information about gaussian latitudes          LEGAU.3     
C                                                                            LEGAU.4     
      COMMON/LEGAU/ ALPJ(MJP),DALPJ(MJP)                                     LEGAU.5     
     +              ,ALP(NWJ2,2,JGL),DALP(NWJ2,2,JGL)                        LEGAU.6     
     +              ,RLP(NWJ2,2,JGL),RDLP(NWJ2,2,JGL)                        LEGAU.7     
     +              ,SI(JGG),CS(JGG),SISQ(JGG),CSSQ(JGG),SECSQ(JGG)          LEGAU.8     
     +              ,ALAT(JGG),GWT(JGG),AW(JGG),JH,JL,JINC                   LEGAU.9     
C                                                                            LEGAU.10    
C                                                                            POLYNO.2     
C     Polynomial used to aid vectorization of Legendre transforms            POLYNO.3     
C                                                                            POLYNO.4     
      COMMON/POLYNO/POLY(NWJ2,2,4),CMPA(IGL)                                 POLYNO.5     
      COMPLEX CMPA                                                           POLYNO.6     
C                                                                            POLYNO.7     
C                                                                            SPECTR.2     
C     Array ordering in SPECTR must correspond to that in GRIDP.             SPECTR.3     
C                                                                            SPECTR.4     
      COMMON/SPECTR/Z(IGB),D(IGB),T(IGB),TRA(IGB,NTRAC),SP(IGA),GS(IGA)      SPECTR.5     
     :              ,SPA(IGA),VP(IGA),DTE(IGB),TT(IGB)                       SPECTR.6     
     :              ,TRAT(IGB,NTRAC),DT(IGB),ZT(IGB)                         SPECTR.7     
     :              ,ZMI(IGB),DMI(IGB),TMI(IGB)                              SPECTR.8     
     :              ,TRAMI(IGB,NTRAC),SPMI(IGA)                              SPECTR.9     
      COMPLEX Z,D,T,TRA,SP,GS,SPA,VP,DTE,TT,TRAT,DT,ZT                       SPECTR.10    
     :       ,ZMI,DMI,TMI,TRAMI,SPMI                                         SPECTR.11    
C                                                                            SPECTR.12    
C                                                                            LTIDT.19    
C     Calls to HEXPFL give following Fourier fields :                        LTIDT.20    
C        CHIG :   x-derivative of temperature field                          LTIDT.21    
C        SFG  :   y-derivative of temperature field                          LTIDT.22    
C     These are only the temporary contents for PV calculation.              LTIDT.23    
C                                                                            LTIDT.24    
      DO 10 L=1,NL                                                           LTIDT.25    
         DO 20 I=1,IGL                                                       LTIDT.26    
            CHIG(I,L)=0.                                                     LTIDT.27    
            SFG(I,L)=0.                                                      LTIDT.28    
 20      CONTINUE                                                            LTIDT.29    
 10   CONTINUE                                                               LTIDT.30    
      CALL HEXP(T,CHIG,NL,2)                                                 LTIDT.31    
      CALL HEXP(T,SFG,NL,4)                                                  LTIDT.32    
      DO 30 L=1,NL                                                           LTIDT.33    
         DO 40 I=1,IGL                                                       LTIDT.34    
            CHIG(I,L)=CMPA(I)*CHIG(I,L)                                      LTIDT.35    
 40      CONTINUE                                                            LTIDT.36    
 30   CONTINUE                                                               LTIDT.37    
C                                                                            LTIDT.38    
      RETURN                                                                 LTIDT.39    
      END                                                                    LTIDT.40    
