C*************************************************************               INISET.2     
C                   SUBROUTINE INISET                                        INISET.3     
C*************************************************************               INISET.4     
      SUBROUTINE INISET                                                      INISET.5     
C                                                                            INISET.6     
C     Sets up various variables and arrays. Sets NAMELIST variables          INISET.7     
C     to their default settings, then reads NAMELIST                         INISET.8     
C                                                                            INISET.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                                                                            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                                                                            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    
C                                                                            OUTCON.2     
C     Switches counters and constants controlling type and frequency of      OUTCON.3     
C     model output                                                           OUTCON.4     
C                                                                            OUTCON.5     
      COMMON/OUTCON/RNTAPE,NCOEFF,NLAT,INLAT,INSPC                           OUTCON.6     
     +              ,RNTAPO                                                  OUTCON.7     
     +              ,KOUNTP,KOUNTE,KOUNTH,KOUNTR                             OUTCON.8     
     +              ,KOUTP,KOUTE,KOUTH,KOUTR,DAY                             OUTCON.9     
     +              ,SQR2,RSQR2,EAM1,EAM2,TOUT1,TOUT2,RMG                    OUTCON.10    
     +              ,LSPO(NL),LGPO(NL)                                       OUTCON.11    
     $              ,LSHIST,LMINIH                                           OUTCON.12    
      LOGICAL LSHIST,LMINIH                                                  OUTCON.13    
      LOGICAL LSPO,LGPO                                                      OUTCON.14    
C                                                                            OUTCON.15    
C                                                                            COMFFT.2     
C     Constants and arrays needed for the fast Fourier transforms            COMFFT.3     
C                                                                            COMFFT.4     
      COMMON/COMFFT/NTGW,NRSTGW,NTWG,NRSTWG,NTGD,NRSTGD                      COMFFT.5     
     +              ,TRIG(IDA),WORK(IDF),IFAX(10)                            COMFFT.6     
C                                                                            COMFFT.7     
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                                                                            RESTOR.2     
C     Restoration fields and timescale                                       RESTOR.3     
C                                                                            RESTOR.4     
      COMMON/RESTOR/ZRES(IGN),DRES(IGN),TRES(IGN),SPRES(IGM),DAMP            RESTOR.5     
C                                                                            RESTOR.6     
      COMMON/STATS/GMSP0,GMSPMI,LMASCOR,LMASOLD,LMASPRT                      STATS.2     
      LOGICAL LMASCOR,LMASOLD,LMASPRT                                        STATS.3     
C                                                                            STATS.4     
C-----------------------------------------------------------------------     STATS.5     
C                                                                            INISET.20    
      REAL*8 AKK1                                                            NETCDF.39    
      NAMELIST/INPPL/ GA,GASCON,RADEA,AKAP,WW,P0,RV,CPD,CLATNT               INISET.21    
      NAMELIST/INPRN/ KRUN,BEGDAY,TSPD,KITS,PNU,TDISS                        INISET.22    
     +         ,LFLUX, BEGDOY                                                INISET.23    
     + ,NDEL,T0,LRSTRT,LSTRETCH,LSHORT,LTVEC,LBALAN,LRESTIJ                  INISET.24    
     +   ,LCLIM, LPERPET, L22L,LOROG,LCSFCT                                  INISET.25    
     + ,KOLOUR,LNOISE,LMASCOR,LMASOLD,LMASPRT                                INISET.26    
      NAMELIST/INPOP/RNTAPE,KOUNTH,KOUNTR,KOUNTP,KOUNTE                      INISET.27    
     + ,NCOEFF,NLAT,LGPO,LSPO                                                INISET.28    
     + ,RNTAPO,NTRACO                                                        INISET.29    
     $     ,LSHIST,LMINIH                                                    INISET.30    
C                                                                            INISET.31    
  205 FORMAT(/' *****RNTAPE*****',F12.3)                                     INISET.32    
  207 FORMAT(' PRINTED OUTPUT EVERY ',I3,' TIMESTEPS'/                       INISET.33    
     +       ' RMS QUANTITIES OUTPUT EVERY ',I3,' TIMESTEPS'/                INISET.34    
     +       ' HISTORY RECORD WRITTEN EVERY ',I3,' TIMESTEPS'/               INISET.35    
     +       ' RESTART RECORD WRITTEN EVERY ',I3,' TIMESTEPS')               INISET.36    
  209 FORMAT(' INTEGRATION WITH',I3,                                         INISET.37    
     +' LEVELS IN THE VERTICAL (NL=',I3,')'/                                 INISET.38    
     +' JAGGED TRIANGULAR/TRAPEZOIDAL TRUNCATION AT TOTAL WAVENO. ',I3/      INISET.39    
     +' AND ZONAL WAVENO. ',I3,' (NN=',I3,' MM=',I3,')')                     INISET.40    
  221 FORMAT(' NO LATERAL DISSIPATION')                                      INISET.41    
  222 FORMAT(' DEL',I2,' LATERAL DISSIPATION ON VORTICITY, DIVERGENCE'/      INISET.42    
     + ' AND TEMPERATURE WITH DIFFUSION COEFFICIENT  ',E10.4,                INISET.43    
     + ' m**',I1,'/s'/' THE E-FOLDING TIME FOR SMALLEST RESOLVED',           INISET.44    
     + ' SCALE IS ',F5.3,' DAYS')                                            INISET.45    
  223 FORMAT(' NO TIME FILTER')                                              INISET.46    
  224 FORMAT(' ROBERT TIME FILTER WITH PARAMETER PNU ',F5.2)                 INISET.47    
  280 FORMAT(' GLOBAL DOMAIN: BOTH EVEN AND ODD COEFFICIENTS INCLUDED',      INISET.48    
     +' (NHEM=',I1,')')                                                      INISET.49    
  281 FORMAT(' HEMISPHERIC DOMAIN: ONLY EVEN DIVERGENCE TEMPERATURE'/        INISET.50    
     +' SURFACE PRESSURE AND ODD VORTICITY COEFFICIENTS INCLUDED',           INISET.51    
     +' (NHEM=',I1,')')                                                      INISET.52    
  210 FORMAT(' ',I2,'-FOLD SYMMETRY IN LONGITUDE IMPOSED AND ONLY'/          INISET.53    
     +' 1 /',I2,' OF THE DOMAIN USED (MOCT=',I2,')')                         INISET.54    
  211 FORMAT(' NON LINEAR TERMS EVALUATED ON GRID OF ',I3,                   INISET.55    
     +' GAUSSIAN LATITUDES '/' AND ',I3,                                     INISET.56    
     +' EVENLY SPACED LONGITUDES (JG=',I3,' MG=',I3,')')                     INISET.57    
  212 FORMAT(' ECMWF ANGULAR MOMENTUM CONSERVING VERTICAL SCHEME')           INISET.58    
  213 FORMAT(' GLOBAL MASS CORRECTION SWITCHED ON')                          INISET.59    
  214 FORMAT(' GLOBAL MASS CORRECTION SWITCHED OFF')                         INISET.60    
  225 FORMAT(/' ***ABORT*** CORRECT VALUE OF NWJ2',I5,' VALUE GIVEN',I5)     INISET.61    
  232 FORMAT(/' ***ABORT***  NLAT IS GREATER THAN JG*NHEM')                  INISET.62    
  233 FORMAT(/' ***ABORT***NCOEFF IS GREATER THAN NN')                       INISET.63    
  240 FORMAT(/' ***ABORT*** NTRACO IS GREATER THAN NTRAC')                   INISET.64    
C                                                                            INISET.65    
C     Set default values and override as desired through NAMELIST input      INISET.66    
C      Mass correction namelist defaults                                     INISET.67    
                                                                             INISET.68    
      LMASCOR=.TRUE.  ! mass correction switched on                          INISET.69    
      LMASOLD=.TRUE.  ! masses read from restart file                        INISET.70    
      LMASPRT=.FALSE. ! mass correction printed every KOUNTP steps           INISET.71    
C                                                                            INISET.72    
C                                                                            INISET.73    
      GA=9.80665                                                             INISET.74    
      GASCON=287.0                                                           INISET.75    
      RADEA=6371000.0                                                        INISET.76    
      AKAP=0.286                                                             INISET.77    
      WW=7.292E-5                                                            INISET.78    
      P0=100000.0                                                            INISET.79    
      RV=461.51                                                              INISET.80    
      CLATNT=2.5E6                                                           INISET.81    
      CPD=GASCON/AKAP                                                        INISET.82    
C                                                                            INISET.83    
      KRUN=0                                                                 INISET.84    
      BEGDAY=0.0                                                             INISET.85    
      BEGDOY=0.0                                                             INISET.86    
      TSPD=24.0                                                              INISET.87    
      KITS=3                                                                 INISET.88    
      PNU=0.02                                                               INISET.89    
      TDISS=0.25                                                             INISET.90    
      NDEL=6                                                                 INISET.91    
      DO 17 L=1,NL                                                           INISET.92    
         T0(L)=250.0                                                         INISET.93    
   17 CONTINUE                                                               INISET.94    
      LRSTRT=.FALSE.                                                         INISET.95    
      LSTRETCH =.FALSE.                                                      INISET.96    
      LPERPET=.TRUE.                                                         INISET.97    
      LCLIM=.FALSE.                                                          INISET.98    
      L22L=.TRUE.                                                            INISET.99    
      LOROG=.FALSE.                                                          INISET.100   
      LCSFCT=.TRUE.                                                          INISET.101   
      LSHORT=.FALSE.                                                         INISET.102   
      LTVEC =.TRUE.                                                          INISET.103   
      LFLUX=.TRUE.                                                           INISET.104   
      LBALAN=.FALSE.                                                         INISET.105   
      LRESTIJ=.FALSE.                                                        INISET.106   
      LNOISE=.FALSE.                                                         INISET.107   
C                                                                            INISET.108   
      RNTAPE=0.0                                                             INISET.109   
      RNTAPO=-999.0                                                          INISET.110   
      NTRACO=0                                                               INISET.111   
      KOUNTH=0                                                               INISET.112   
      KOUNTR=0                                                               INISET.113   
      KOUNTP=0                                                               INISET.114   
      KOUNTE=0                                                               INISET.115   
      NCOEFF=0                                                               INISET.116   
      NLAT=MIN(16,JGG)                                                       INISET.117   
      LSHIST=.TRUE.                                                          INISET.118   
      LMINIH=.TRUE.                                                          INISET.119   
      DO 18 I=1,NL                                                           INISET.120   
         LSPO(I)=.FALSE.                                                     INISET.121   
         LGPO(I)=.FALSE.                                                     INISET.122   
   18 CONTINUE                                                               INISET.123   
C                                                                            INISET.124   
C     Read NAMELISTs, overwrite defaults and write them out                  INISET.125   
C                                                                            INISET.126   
      READ(7,INPPL)                                                          INISET.127   
      WRITE(2,INPPL)                                                         INISET.128   
      READ(7,INPRN)                                                          INISET.129   
      WRITE(2,INPRN)                                                         INISET.130   
      READ(7,INPOP)                                                          INISET.131   
      IF (RNTAPO.EQ.-999.0) RNTAPO=RNTAPE                                    INISET.132   
      WRITE(2,INPOP)                                                         INISET.133   
C                                                                            INISET.134   
C     Set remaining physical constants.                                      INISET.135   
C                                                                            INISET.136   
      RD=GASCON                                                              INISET.137   
C                                                                            INISET.138   
C     Write out details of model run                                         INISET.139   
C                                                                            INISET.140   
      WRITE(2,205)RNTAPE                                                     INISET.141   
      WRITE(2,209)NL,NL,NN,MM,NN,MM                                          INISET.142   
      IF(NHEM.EQ.2) WRITE(2,280) NHEM                                        INISET.143   
      IF(NHEM.EQ.1) WRITE(2,281) NHEM                                        INISET.144   
      WRITE(2,210) MOCT,MOCT,MOCT                                            INISET.145   
      WRITE(2,211)JG,MG,JG,MG                                                INISET.146   
      WRITE(2,212)                                                           INISET.147   
      IF (LMASCOR) THEN                                                      INISET.148   
         WRITE(2,213)                                                        INISET.149   
      ELSE                                                                   INISET.150   
         WRITE(2,214)                                                        INISET.151   
      ENDIF                                                                  INISET.152   
C                                                                            INISET.153   
C     Set resolution dependent quantities                                    INISET.154   
C                                                                            INISET.155   
      AMH=MH                                                                 INISET.156   
      MF=MM-1                                                                INISET.157   
      MFP=MF+1                                                               INISET.158   
      MFPP=MFP+1                                                             INISET.159   
      NF=NN-1                                                                INISET.160   
      NFP=NF+1                                                               INISET.161   
      NFPP=NFP+1                                                             INISET.162   
      AIOCT=(0.,1.)*MOCT                                                     INISET.163   
C                                                                            INISET.164   
C     Set various spectral limits and coefficients which                     INISET.165   
C     depend on wavenumber                                                   INISET.166   
C                                                                            INISET.167   
      NW=1+MF/MOCT                                                           INISET.168   
      NWP=NW+1                                                               INISET.169   
      MJPP=MJP+NW                                                            INISET.170   
      MGP=MG+1                                                               INISET.171   
      MG2=MG/2                                                               INISET.172   
      RMG=1./REAL(MG)                                                        INISET.173   
      JZF=MGPP-NW-NW                                                         INISET.174   
      DO 4 NP=1,NFPP                                                         INISET.175   
         SQ(NP)=NP*(NP-1)                                                    INISET.176   
         SQH(NP)=0.5*SQ(NP)                                                  INISET.177   
         IF (NP.GT.1) THEN                                                   INISET.178   
            RSQ(NP)=1./SQ(NP)                                                INISET.179   
         ELSE                                                                INISET.180   
            RSQ(1)=0.                                                        INISET.181   
         ENDIF                                                               INISET.182   
    4 CONTINUE                                                               INISET.183   
C                                                                            INISET.184   
C     Compute internal diffusion parameter                                   INISET.185   
C                                                                            INISET.186   
      IF(TDISS.EQ.0.0) THEN                                                  INISET.187   
         AKK=0.0                                                             INISET.188   
      ELSE                                                                   INISET.189   
c                                                                            NETCDF.40    
c        Slightly more complicated version to cope with r4 precision:        NETCDF.41    
c        AKK=WW*(RADEA**NDEL)/(2.0*PI*TDISS*((NN*(NN+1))**REAL(NDEL/2)))     NETCDF.42    
c        AKK=AKK/(WW*(RADEA**NDEL))                                          NETCDF.43    
c                                                                            NETCDF.44    
         AKK=NN*(NN+1)                                                       NETCDF.45    
         AKK=AKK**REAL(NDEL/2)                                               NETCDF.46    
         AKK=1.0/(2.0*PI*TDISS*AKK)                                          NETCDF.47    
         AKK1=RADEA                                                          NETCDF.48    
         AKK1=WW*AKK1**NDEL                                                  NETCDF.49    
         AKK1=AKK*AKK1                                                       NETCDF.50    
      END IF                                                                 INISET.191   
      IF(AKK.EQ.0.0) WRITE(2,221)                                            INISET.192   
      IF(AKK.NE.0.0) WRITE(2,222) NDEL,AKK,NDEL,TDISS                        INISET.193   
      NDELH=NDEL/2                                                           INISET.195   
      DO 3 NP=1,NNP                                                          INISET.196   
         AK(NP)=AKK*(SQ(NP)**NDELH)                                          INISET.197   
    3 CONTINUE                                                               INISET.198   
C                                                                            INISET.199   
C     Set time variables and counters                                        INISET.200   
C                                                                            INISET.201   
      IF(PNU.EQ.0.0)WRITE(2,223)                                             INISET.202   
      IF(PNU.NE.0.0)WRITE(2,224)PNU                                          INISET.203   
      WRITE(2,207)KOUNTP,KOUNTE,KOUNTH,KOUNTR                                INISET.204   
C                                                                            INISET.205   
      IF(KOUNTP.EQ.0) KOUNTP=-999                                            INISET.206   
      IF(KOUNTE.EQ.0) KOUNTE=-999                                            INISET.207   
      IF(KOUNTH.EQ.0) KOUNTH=-999                                            INISET.208   
      IF(KOUNTR.EQ.0) KOUNTR=-999                                            INISET.209   
      DELT=PI2/TSPD                                                          INISET.210   
      PNU2=PNU+PNU                                                           INISET.211   
      PNU21=1.0-PNU2                                                         INISET.212   
      ITSPD=NINT(TSPD)                                                       INISET.213   
C                                                                            INISET.214   
C     Check variables make sense                                             INISET.215   
C                                                                            INISET.216   
      IF (NLAT.GT.JGG) THEN                                                  INISET.217   
         WRITE(2,232)                                                        INISET.218   
         CALL ABORT                                                          INISET.219   
      ENDIF                                                                  INISET.220   
      IF (NCOEFF.GT.NN) THEN                                                 INISET.221   
         WRITE(2,233)                                                        INISET.222   
         CALL ABORT                                                          INISET.223   
      ENDIF                                                                  INISET.224   
      NWJCH=0                                                                INISET.225   
      DO 310 MP=1,MFP,MOCT                                                   INISET.226   
         DO 320 JP=MP,NFP,MH                                                 INISET.227   
            NWJCH=NWJCH+1                                                    INISET.228   
 320     CONTINUE                                                            INISET.229   
 310  CONTINUE                                                               INISET.230   
      IF (NWJ2.NE.NWJCH) THEN                                                INISET.231   
         WRITE(2,225) NWJCH,NWJ2                                             INISET.232   
         CALL ABORT                                                          INISET.233   
      ENDIF                                                                  INISET.234   
      IF (NTRACO.GT.NTRAC) THEN                                              INISET.235   
         WRITE(2,240)                                                        INISET.236   
         CALL ABORT                                                          INISET.237   
      ENDIF                                                                  INISET.238   
C                                                                            INISET.239   
C     Set dimensionalising factors                                           INISET.240   
C                                                                            INISET.241   
      EZ=1.0/SQRT(.375)                                                      INISET.242   
      CV=RADEA*WW                                                            INISET.243   
      CG=CV*CV                                                               INISET.244   
      CT=CG/GASCON                                                           INISET.245   
      CQ=1000.0                                                              INISET.246   
      PFAC=0.5*CV*CV*1.0E5/GA                                                INISET.247   
      SQR2=SQRT(2.0)                                                         INISET.248   
      RSQR2=1.0/SQR2                                                         INISET.249   
      EAM1=SQR2/3.                                                           INISET.250   
      EAM2=SQRT(2./45.)                                                      INISET.251   
C                                                                            INISET.252   
C     Make T0 dimensionless                                                  INISET.253   
C                                                                            INISET.254   
      DO 61 L=1,NL                                                           INISET.255   
        T0(L)=T0(L)/CT                                                       INISET.256   
   61 CONTINUE                                                               INISET.257   
      DO 30 KK=1,NTRAC                                                       INISET.258   
c Hard wires water to Tracer Number 1                                        INISET.259   
C water has "colour" of 3.                                                   INISET.260   
         IF (KK.EQ.1) THEN                                                   INISET.261   
            KOLOUR(KK)=3                                                     INISET.262   
c convert from g/Kg                                                          INISET.263   
            CTRA(KK)=CQ                                                      INISET.264   
C         ELSE                                                               INISET.265   
          IF(KOLOUR(KK).EQ.1)  CTRA(KK)=CT                                   INISET.266   
          IF(KOLOUR(KK).EQ.2)  CTRA(KK)=1.E6*CT*WW*GA/P0                     INISET.267   
         ENDIF                                                               INISET.268   
   30 CONTINUE                                                               INISET.269   
C                                                                            INISET.270   
C     Set up arrays and variables for use in FFT routines                    INISET.271   
C                                                                            INISET.272   
      NTRWG=NFTWG*NHEM                                                       INISET.273   
      NTRGW=NFTGW*NHEM                                                       INISET.274   
      NTRGD=NFTGD*NHEM                                                       INISET.275   
      NTWG=(NTRWG-1)/NCRAY                                                   INISET.276   
      NTGW=(NTRGW-1)/NCRAY                                                   INISET.277   
      NTGD=(NTRGD-1)/NCRAY                                                   INISET.278   
      NRSTWG=NTRWG-NCRAY*NTWG                                                INISET.279   
      NRSTGW=NTRGW-NCRAY*NTGW                                                INISET.280   
      NRSTGD=NTRGD-NCRAY*NTGD                                                INISET.281   
C                                                                            INISET.282   
C     Calculate auxiliary values required by FFT991                          INISET.283   
C                                                                            INISET.284   
      CALL SET99(TRIG,IFAX,MG)                                               INISET.285   
C                                                                            INISET.286   
C     Set output control variables and initialise WRSPS                      INISET.287   
C                                                                            INISET.288   
      INSPC=0                                                                INISET.289   
      DO 28 MP=1,NCOEFF,MOCT                                                 INISET.290   
         DO 27 JP=MP,NCOEFF,MH                                               INISET.291   
            INSPC=INSPC+1                                                    INISET.292   
   27    CONTINUE                                                            INISET.293   
   28 CONTINUE                                                               INISET.294   
      CALL WRSPS(Z(1),1)                                                     INISET.295   
      IF (NLAT.NE.0) THEN                                                    INISET.296   
         INLAT=JGG/NLAT                                                      INISET.297   
      ELSE                                                                   INISET.298   
         INLAT=0                                                             INISET.299   
      ENDIF                                                                  INISET.300   
C                                                                            INISET.301   
C     Set up CMPA array to calculate x-derivative of half transforms         INISET.302   
C                                                                            INISET.303   
      DO 40 I=1,IGL                                                          INISET.304   
         CMPA(I)=0.0                                                         INISET.305   
   40 CONTINUE                                                               INISET.306   
      NROW=0                                                                 INISET.307   
      DO 41 MP=1,MFP,MOCT                                                    INISET.308   
         NROW=NROW+1                                                         INISET.309   
         CMPA(NROW)=CMPLX(0.,REAL(MP-1))                                     INISET.310   
   41 CONTINUE                                                               INISET.311   
      IF(NHEM.EQ.2)THEN                                                      INISET.312   
         NROW=0                                                              INISET.313   
CDIR$    IVDEP                                                               INISET.314   
         DO 42 MP=1,MFP,MOCT                                                 INISET.315   
            NROW=NROW+1                                                      INISET.316   
            CMPA(NROW+IDL)=CMPA(NROW)                                        INISET.317   
   42    CONTINUE                                                            INISET.318   
      END IF                                                                 INISET.319   
C                                                                            INISET.320   
      END                                                                    INISET.321   
