C**********************************************************                  DSTEP.2     
C             SUBROUTINE DSTEP                                               DSTEP.3     
C**********************************************************                  DSTEP.4     
      SUBROUTINE DSTEP                                                       DSTEP.5     
C                                                                            DSTEP.6     
C     Diabatic part of timestep. Completion of time-filter.                  DSTEP.7     
C     Note that only Z,D,T have diabatic tendencies at present.              DSTEP.8     
C                                                                            DSTEP.9     
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                                                                            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                                                                            BATS.2     
C     Constant arrays and variables associated with time and vertical        BATS.3     
C     differencing. Also counters.                                           BATS.4     
C                                                                            BATS.5     
      COMMON/BATS/  BM1(IDE),AK(NNP),AQ(NL2),G(NL2),TAU(NL2)                 BATS.6     
     +              ,KOUNT,KITS,KSTART,KTOTAL,KRUN,BEGDAY,ITSPD              BATS.7     
     +              ,DELT,DELT2,CV,CG,CT,CQ,PNU,PNU2,PNU21                   BATS.8     
     +              ,NTRACO,CTRA(NTRAC),KOLOUR(NTRAC),RGG(NL2)               BATS.9     
     +              ,BEGDOY,DOY                                              BATS.10    
C                                                                            BATS.11    
      IF(KOUNT.GT.KITS) THEN                                                 DSTEP.14    
C                                                                            DSTEP.15    
C       Ordinary centred timestep                                            DSTEP.16    
C                                                                            DSTEP.17    
        DO 10 I=1,IGB                                                        DSTEP.18    
           Z(I)=Z(I)+DELT2*ZT(I)                                             DSTEP.19    
           T(I)=T(I)+DELT2*TT(I)                                             DSTEP.20    
           D(I)=D(I)+DELT2*DT(I)                                             DSTEP.21    
           ZMI(I)=ZMI(I)+PNU*Z(I)                                            DSTEP.22    
           TMI(I)=TMI(I)+PNU*T(I)                                            DSTEP.23    
           DMI(I)=DMI(I)+PNU*D(I)                                            DSTEP.24    
   10   CONTINUE                                                             DSTEP.25    
        DO 11 KK=1,NTRAC                                                     DSTEP.26    
           DO 11 I=1,IGB                                                     DSTEP.27    
              TRA(I,KK)=TRA(I,KK)+DELT2*TRAT(I,KK)                           DSTEP.28    
              TRAMI(I,KK)=TRAMI(I,KK)+PNU*TRA(I,KK)                          DSTEP.29    
   11   CONTINUE                                                             DSTEP.30    
        DO 20 I=1,IGA                                                        DSTEP.31    
           SPMI(I)=SPMI(I)+PNU*SP(I)                                         DSTEP.32    
20      CONTINUE                                                             DSTEP.33    
        RETURN                                                               DSTEP.34    
      ELSE                                                                   DSTEP.35    
C                                                                            DSTEP.36    
C       Short initial timestep                                               DSTEP.37    
C                                                                            DSTEP.38    
        DO 60 I=1,IGB                                                        DSTEP.39    
           Z(I)=Z(I)+DELT2*ZT(I)                                             DSTEP.40    
           T(I)=T(I)+DELT2*TT(I)                                             DSTEP.41    
           D(I)=D(I)+DELT2*DT(I)                                             DSTEP.42    
   60   CONTINUE                                                             DSTEP.43    
        DO 61 KK=1,NTRAC                                                     DSTEP.44    
           DO 61 I=1,IGB                                                     DSTEP.45    
             TRA(I,KK)=TRA(I,KK)+DELT2*TRAT(I,KK)                            DSTEP.46    
   61   CONTINUE                                                             DSTEP.47    
        DELT=DELT2                                                           DSTEP.48    
        DELT2=DELT2+DELT2                                                    DSTEP.49    
        RETURN                                                               DSTEP.50    
      ENDIF                                                                  DSTEP.51    
C                                                                            DSTEP.52    
      END                                                                    DSTEP.53    
