      SUBROUTINE INI_GRAPHICS                                                GRAPHICS.2     
c                                                                            GRAPHICS.3     
      rar=0.45                                                               GRAPHICS.4     
c                                                                            GRAPHICS.5     
      call disset(23)                                                        GRAPHICS.6     
      call winini1                                                           GRAPHICS.7     
      call xdevic                                                            GRAPHICS.8     
      call xdspac(1.0)                                                       GRAPHICS.9     
      call xpspac(0.0,1.9/1.5,0.0,1.0)                                       GRAPHICS.10    
      call xspace(2,3,0.0,xlim,ylim)                                         GRAPHICS.11    
      call xpscal(1.0,1.0)                                                   GRAPHICS.12    
      call zjinit                                                            GRAPHICS.13    
      call zstret(2.*rar,rar)                                                GRAPHICS.14    
      call zstmol(rar)                                                       GRAPHICS.15    
      call zstamp(2.*rar)                                                    GRAPHICS.16    
      call zstlnt(30.,30.,80.)                                               GRAPHICS.17    
      call xpages(-1,0)                                                      GRAPHICS.18    
c                                                                            GRAPHICS.19    
      call ini_coast                                                         GRAPHICS.20    
c                                                                            GRAPHICS.21    
      return                                                                 GRAPHICS.22    
      end                                                                    GRAPHICS.23    
c                                                                            GRAPHICS.24    
      subroutine ini_coast                                                   GRAPHICS.25    
      parameter(idt1=1290,idt2=176000)                                       COASTS.2     
      integer inseg                                                          COASTS.3     
      real cstpnt                                                            COASTS.4     
      common /coasts/ inseg(idt1),cstpnt(idt2,2)                             COASTS.5     
c                                                                            GRAPHICS.27    
      print*,' Reading coastline data '                                      GRAPHICS.28    
      open(unit=10,file='/home/swsvalde/qplot/zjmap.dat')                    GRAPHICS.29    
      call zcstrd(10,inseg,idt1,cstpnt,idt2)                                 GRAPHICS.30    
      close(unit=10)                                                         GRAPHICS.31    
c                                                                            GRAPHICS.32    
      return                                                                 GRAPHICS.33    
      end                                                                    GRAPHICS.34    
c                                                                            GRAPHICS.35    
      subroutine plotfields(ipage)                                           GRAPHICS.36    
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    
      PARAMETER(RAD=180./PI)                                                 GRAPHICS.39    
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                                                                            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    
      COMMON/GRIDSS/ZG1(IGD,JG),DG1(IGD,JG),UG1(IGD,JG),VG1(IGD,JG),         GRIDSS.2     
     :              TG1(IGD,JG),SPG1(IGC,JG)                                 GRIDSS.3     
C                                                                            GRIDSS.4     
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                                                                            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    
      INTEGER LU(JGG,NL),LT(JGG,NL),LVT(JGG,NL)                              GRAPHICS.45    
      REAL LUG(MG+1,JGG),LTG(MG+1,JGG)                                       GRAPHICS.46    
      REAL LZUG(JGG,NL),LZTG(JGG,NL)                                         GRAPHICS.47    
      CHARACTER*14 TEXT1                                                     GRAPHICS.48    
c                                                                            GRAPHICS.49    
      do j=1,jg                                                              GRAPHICS.50    
         sec=alat(j)/rad                                                     GRAPHICS.51    
         sec=cv/cos(sec)                                                     GRAPHICS.52    
         do ihem=1,nhem                                                      GRAPHICS.53    
            iof=(ihem-1)*mgpp                                                GRAPHICS.54    
            if (ihem.eq.1) then                                              GRAPHICS.55    
               jj=j                                                          GRAPHICS.56    
            else                                                             GRAPHICS.57    
               jj=jggp-j                                                     GRAPHICS.58    
            end if                                                           GRAPHICS.59    
            iof1=iof+(nl-1)*igc                                              GRAPHICS.60    
            do i=1,mg                                                        GRAPHICS.61    
               lug(i,jj)=sec*ug1(i+iof1,j)                                   GRAPHICS.62    
            end do                                                           GRAPHICS.63    
            lug(mg+1,jj)=lug(1,jj)                                           GRAPHICS.64    
            do l=1,nl                                                        GRAPHICS.65    
               iof1=iof+(l-1)*igc                                            GRAPHICS.66    
               asum=0.0                                                      GRAPHICS.67    
               do i=1,mg                                                     GRAPHICS.68    
                  asum=asum+ug1(i+iof1,j)                                    GRAPHICS.69    
               end do                                                        GRAPHICS.70    
               lzug(jj,nl+1-l)=sec*asum/real(mg)                             GRAPHICS.71    
            end do                                                           GRAPHICS.72    
            iof1=iof+(nl-1)*igc                                              GRAPHICS.73    
            do i=1,mg                                                        GRAPHICS.74    
               ltg(i,jj)=ct*(tg1(i+iof1,j)+t0(nl))-273.16                    GRAPHICS.75    
            end do                                                           GRAPHICS.76    
            ltg(mg+1,jj)=ltg(1,jj)                                           GRAPHICS.77    
            do l=1,nl                                                        GRAPHICS.78    
               iof1=iof+(l-1)*igc                                            GRAPHICS.79    
               asum=0.0                                                      GRAPHICS.80    
               do i=1,mg                                                     GRAPHICS.81    
                  asum=asum+tg1(i+iof1,j)                                    GRAPHICS.82    
               end do                                                        GRAPHICS.83    
               lztg(jj,nl+1-l)=ct*(asum/real(mg)+t0(l))-273.16               GRAPHICS.84    
            end do                                                           GRAPHICS.85    
         end do                                                              GRAPHICS.86    
      end do                                                                 GRAPHICS.87    
      rewind 24                                                              GRAPHICS.88    
c                                                                            GRAPHICS.89    
      text1='Day= 999999.99'                                                 GRAPHICS.90    
      write(text1(6:14),'(f9.2)')day                                         GRAPHICS.91    
c                                                                            GRAPHICS.92    
      call xnwpic                                                            GRAPHICS.93    
      call frame_graphics(1)                                                 GRAPHICS.94    
      call contour_graphics(ltg,mg+1,jgg,-0.1,1,1,                           GRAPHICS.95    
     :     'Temperature at bottom level '//text1)                            GRAPHICS.96    
      call xnwpic                                                            GRAPHICS.97    
      call frame_graphics(1)                                                 GRAPHICS.98    
      call contour_graphics(lug,mg+1,jgg,-0.1,0,1,                           GRAPHICS.99    
     :     'Zonal Wind at bottom level '//text1)                             GRAPHICS.100   
c                                                                            GRAPHICS.101   
      call xnwpic                                                            GRAPHICS.102   
      call frame_graphics(11)                                                GRAPHICS.103   
      call contour_graphics(lztg,jgg,nl,-0.1,1,11,                           GRAPHICS.104   
     :     'Zonal Cross_Section of Temperature '//text1)                     GRAPHICS.105   
      call xnwpic                                                            GRAPHICS.106   
      call frame_graphics(11)                                                GRAPHICS.107   
      call contour_graphics(lzug,jgg,nl,-0.1,0,11,                           GRAPHICS.108   
     :     'Zonal Cross_Section of Zonal Wind '//text1)                      GRAPHICS.109   
c                                                                            GRAPHICS.110   
      if (ipage.eq.1) call xpages(-1,0)                                      GRAPHICS.111   
c                                                                            GRAPHICS.112   
      return                                                                 GRAPHICS.113   
      end                                                                    GRAPHICS.114   
c                                                                            GRAPHICS.115   
c                                                                            GRAPHICS.116   
      subroutine plotfields2(ipage)                                          GRAPHICS.117   
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    
      PARAMETER(RAD=180./PI)                                                 GRAPHICS.120   
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                                                                            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                                                                            GRIDPP.2     
C     Array ordering in GRIDP must correspond to that in SPECTR.             GRIDPP.3     
C     Real arrays: multi-level arrays are 2-dimensional.                     GRIDPP.4     
C     the variables have been renamed to coincide with                       GRIDPP.5     
C     variable names in bgcm5 DGRMLT                                         GRIDPP.6     
C                                                                            GRIDPP.7     
C swapped round VLNG and UNLG to check                                       GRIDPP.8     
      COMMON/GRIDP/ CHIG(IGC,NL),SFG(IGC,NL),UG(IGC,NL),VG(IGC,NL)           GRIDPP.9     
     :              ,TTVD(IGC,NL),QTVD(IGC,NL),TG(IGC,NL)                    GRIDPP.10    
     :              ,TRAG(IGC,NL,NTRAC)                                      GRIDPP.11    
     :              ,PLG(IGC),TYBL(IGC),TXBL(IGC)                            GRIDPP.12    
     :              ,SPG(IGC),VPG(IGC),TTRD(IGC,NL)                          GRIDPP.13    
     :              ,TNLG(IGC,NL),TRANLG(IGC,NL,NTRAC),UNLG(IGC,NL)          GRIDPP.14    
     :              ,VNLG(IGC,NL),TTLR(IGC,NL),UTRAG(IGC,NL,NTRAC)           GRIDPP.15    
     :              ,TTCR(IGC,NL),VTRAG(IGC,NL,NTRAC)                        GRIDPP.16    
     :              ,UTVD(IGC,NL),VTVD(IGC,NL)                               GRIDPP.17    
     :         ,ASSBL(IGC),ASHBL(IGC),ASLBL(IGC),ARRCR(IGC),ARRLR(IGC)       GRIDPP.18    
     :         ,arflux(igc,6),asfld(igc,6),acld(igc,4)                       GRIDPP.19    
     :         ,SSBL(IGC),SHBL(IGC),SLBL(IGC),RRCR(IGC),RRLR(IGC)            GRIDPP.20    
     :         ,rflux(igc,6),sfld(igc,6),cld(igc,4)                          GRIDPP.21    
C                                                                            GRIDPP.22    
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                                                                            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    
      REAL LUG(MG+1,JGG),LTG(MG+1,JGG)                                       GRAPHICS.126   
      CHARACTER*14 TEXT1                                                     GRAPHICS.127   
c                                                                            GRAPHICS.128   
      rewind 24                                                              GRAPHICS.129   
      do j=1,jg                                                              GRAPHICS.130   
         sec=alat(j)/rad                                                     GRAPHICS.131   
         sec=cv/cos(sec)                                                     GRAPHICS.132   
                                                                             GRAPHICS.133   
         read(24)assbl,ashbl,aslbl,arrcr,arrlr,                              GRAPHICS.134   
     :           arflux,asfld,acld,                                          GRAPHICS.135   
     :           ssbl,shbl,slbl,rrcr,rrlr,                                   GRAPHICS.136   
     :           rflux,sfld,cld                                              GRAPHICS.137   
         do ihem=1,nhem                                                      GRAPHICS.138   
            iof=(ihem-1)*mgpp                                                GRAPHICS.139   
            if (ihem.eq.1) then                                              GRAPHICS.140   
               jj=j                                                          GRAPHICS.141   
            else                                                             GRAPHICS.142   
               jj=jggp-j                                                     GRAPHICS.143   
            end if                                                           GRAPHICS.144   
            do i=1,mg                                                        GRAPHICS.145   
               lug(i,jj)=rrcr(i+iof)                                         GRAPHICS.146   
            end do                                                           GRAPHICS.147   
            lug(mg+1,jj)=lug(1,jj)                                           GRAPHICS.148   
            do i=1,mg                                                        GRAPHICS.149   
               ltg(i,jj)=rrlr(i+iof)                                         GRAPHICS.150   
            end do                                                           GRAPHICS.151   
            ltg(mg+1,jj)=ltg(1,jj)                                           GRAPHICS.152   
         end do                                                              GRAPHICS.153   
      end do                                                                 GRAPHICS.154   
      rewind 24                                                              GRAPHICS.155   
c                                                                            GRAPHICS.156   
      text1='Day= 999999.99'                                                 GRAPHICS.157   
      write(text1(6:14),'(f9.2)')day                                         GRAPHICS.158   
c                                                                            GRAPHICS.159   
      call xnwpic                                                            GRAPHICS.160   
      call frame_graphics(1)                                                 GRAPHICS.161   
      call contour_graphics(ltg,mg+1,jgg,-0.1,1,1,                           GRAPHICS.162   
     :     'Convective Rainfall at bottom level '//text1)                    GRAPHICS.163   
      call xnwpic                                                            GRAPHICS.164   
      call frame_graphics(1)                                                 GRAPHICS.165   
      call contour_graphics(lug,mg+1,jgg,-0.1,0,1,                           GRAPHICS.166   
     :     'Large scale Rainfall '//text1)                                   GRAPHICS.167   
c                                                                            GRAPHICS.168   
      if (ipage.eq.1) call xpages(-1,0)                                      GRAPHICS.169   
c                                                                            GRAPHICS.170   
      return                                                                 GRAPHICS.171   
      end                                                                    GRAPHICS.172   
c                                                                            GRAPHICS.173   
      subroutine frame_graphics(iptyp)                                       GRAPHICS.174   
      parameter(idt1=1290,idt2=176000)                                       COASTS.2     
      integer inseg                                                          COASTS.3     
      real cstpnt                                                            COASTS.4     
      common /coasts/ inseg(idt1),cstpnt(idt2,2)                             COASTS.5     
c                                                                            GRAPHICS.176   
      call drawbox(iptyp,0.45,0)                                             GRAPHICS.177   
c                                                                            GRAPHICS.178   
      if (iptyp.ne.11) then                                                  GRAPHICS.179   
         call xlcol(3,4,4,-8)                                                GRAPHICS.180   
         call zcstpl(inseg,idt1,cstpnt,idt2)                                 GRAPHICS.181   
      end if                                                                 GRAPHICS.182   
c                                                                            GRAPHICS.183   
      call xclear                                                            GRAPHICS.184   
c                                                                            GRAPHICS.185   
      return                                                                 GRAPHICS.186   
      end                                                                    GRAPHICS.187   
c                                                                            GRAPHICS.188   
      subroutine drawbox(iptyp,rar,izoom)                                    GRAPHICS.189   
c                                                                            GRAPHICS.190   
      if (iptyp.eq.0) then                                                   GRAPHICS.191   
         call zststl(0)                                                      GRAPHICS.192   
         call xmap(-0.95,0.95,-1.05,0.45)                                    GRAPHICS.193   
         call zpenup(-2.*rar,-1.0*rar)                                       GRAPHICS.194   
         call zpendn( 2.*rar,-1.0*rar)                                       GRAPHICS.195   
         call zpendn( 2.*rar,     rar)                                       GRAPHICS.196   
         call zpendn(-2.*rar,     rar)                                       GRAPHICS.197   
         call zpendn(-2.*rar,-1.0*rar)                                       GRAPHICS.198   
      else if (iptyp.eq.11) then                                             GRAPHICS.199   
         call zststl(0)                                                      GRAPHICS.200   
         call xmap(-1.5,1.5,-0.4,1.2)                                        GRAPHICS.201   
         call xlcol(8,4,4,0)                                                 GRAPHICS.202   
         do l=1,6                                                            GRAPHICS.203   
            call zpenup(-1.0,0.2*(l-1))                                      GRAPHICS.204   
            call zpendn( 1.0,0.2*(l-1))                                      GRAPHICS.205   
         end do                                                              GRAPHICS.206   
         do j=1,7                                                            GRAPHICS.207   
            call zpenup(-1.0+(j-1)/3.0,0.0)                                  GRAPHICS.208   
            call zpendn(-1.0+(j-1)/3.0,1.0)                                  GRAPHICS.209   
         end do                                                              GRAPHICS.210   
         call xlcol(1,4,4,0)                                                 GRAPHICS.211   
         call zpenup(-1.0,0.0)                                               GRAPHICS.212   
         call zpendn(-1.0,1.0)                                               GRAPHICS.213   
         call zpendn( 1.0,1.0)                                               GRAPHICS.214   
         call zpendn( 1.0,0.0)                                               GRAPHICS.215   
         call zpendn(-1.0,0.0)                                               GRAPHICS.216   
      else                                                                   GRAPHICS.217   
         call xmap(-0.95,0.95,-0.85,0.65)                                    GRAPHICS.218   
         call zststl(iabs(iptyp))                                            GRAPHICS.219   
         if (iptyp.eq.4) then                                                GRAPHICS.220   
            call zstcen(10.0,90.0)                                           GRAPHICS.221   
            call zsthta(30.0)                                                GRAPHICS.222   
         else if (iptyp.eq.-4) then                                          GRAPHICS.223   
            call zstcen(10.0,-90.0)                                          GRAPHICS.224   
            if (izoom.eq.0) then                                             GRAPHICS.225   
               call zsthta(-30.0)                                            GRAPHICS.226   
            else                                                             GRAPHICS.227   
               call zsthta(-15.0)                                            GRAPHICS.228   
            end if                                                           GRAPHICS.229   
         else                                                                GRAPHICS.230   
            call zstcen(0.,0.)                                               GRAPHICS.231   
         end if                                                              GRAPHICS.232   
         call xlcol(8,4,4,0)                                                 GRAPHICS.233   
         call zxyref                                                         GRAPHICS.234   
         call xlcol(1,4,4,0)                                                 GRAPHICS.235   
         call zoutln                                                         GRAPHICS.236   
      end if                                                                 GRAPHICS.237   
c                                                                            GRAPHICS.238   
      return                                                                 GRAPHICS.239   
      end                                                                    GRAPHICS.240   
c                                                                            GRAPHICS.241   
      subroutine contour_graphics(zg,ix,iy,cinc,itype,iptyp,                 GRAPHICS.242   
     :           text1)                                                      GRAPHICS.243   
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                                                                            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======================================================================      GRAPHICS.248   
C                                                                     =      GRAPHICS.249   
C     Do contour plot - line drawing method                           =      GRAPHICS.250   
C                                                                     =      GRAPHICS.251   
C======================================================================      GRAPHICS.252   
      real xcoord(mg+1),ycoord(jgg)                                          GRAPHICS.253   
      real cnt(100)                                                          GRAPHICS.254   
      integer iwk((mg+1)*jgg)                                                GRAPHICS.255   
      character*(*) text1                                                    GRAPHICS.256   
      character*43 text2                                                     GRAPHICS.257   
c                                                                            GRAPHICS.258   
      if (iptyp.eq.1) then                                                   GRAPHICS.259   
         do i=1,ix                                                           GRAPHICS.260   
            xcoord(i)=(i-1)*pi2/real(mg)                                     GRAPHICS.261   
         end do                                                              GRAPHICS.262   
         do j=1,iy                                                           GRAPHICS.263   
            ycoord(j)=pi/180.0*alat(j)                                       GRAPHICS.264   
         end do                                                              GRAPHICS.265   
      else if (iptyp.eq.11) then                                             GRAPHICS.266   
         do i=1,ix                                                           GRAPHICS.267   
            xcoord(i)=alat(i)/90.0                                           GRAPHICS.268   
         end do                                                              GRAPHICS.269   
         do l=1,iy                                                           GRAPHICS.270   
            ycoord(l)=1.0-sigma(iy+1-l)                                      GRAPHICS.271   
         end do                                                              GRAPHICS.272   
      end if                                                                 GRAPHICS.273   
c                                                                            GRAPHICS.274   
      call maxmin(zg,ix,iy,fmin,fmax)                                        GRAPHICS.275   
c                                                                            GRAPHICS.276   
      ncnt=100                                                               GRAPHICS.277   
      call setcv(FMIN,FMAX,CINC,CNT,NCNT,ITYPE,FINC)                         GRAPHICS.278   
      text2='min =  999.999, max=  999.999, ci=  999.999'                    GRAPHICS.279   
      write(text2(7:14),'(f8.3)')fmin                                        GRAPHICS.280   
      write(text2(22:29),'(f8.3)')fmax                                       GRAPHICS.281   
      write(text2(36:43),'(f8.3)')finc                                       GRAPHICS.282   
c                                                                            GRAPHICS.283   
      do ival=1,ncnt                                                         GRAPHICS.284   
        if (cnt(ival).gt.0.1*FINC) then                                      GRAPHICS.285   
            call xlcol(2,4,4,0)                                              GRAPHICS.286   
         else if (cnt(ival).lt.-0.1*FINC) then                               GRAPHICS.287   
            call xlcol(4,4,4,0)                                              GRAPHICS.288   
         else                                                                GRAPHICS.289   
            call xlcol(6,4,4,0)                                              GRAPHICS.290   
         end if                                                              GRAPHICS.291   
         CALL ZGCNTR (ZG,xcoord,ycoord,IWK,IX,IX,IY,CNT(IVAL))               GRAPHICS.292   
      end do                                                                 GRAPHICS.293   
      call xchmag(0.017)                                                     GRAPHICS.294   
      if (iptyp.eq.1) then                                                   GRAPHICS.295   
         xoff=-0.9                                                           GRAPHICS.296   
         yoff=-0.45                                                          GRAPHICS.297   
      else                                                                   GRAPHICS.298   
         xoff=-1.0                                                           GRAPHICS.299   
         yoff=0.0                                                            GRAPHICS.300   
      end if                                                                 GRAPHICS.301   
      ilen=lnsig1(text1)                                                     GRAPHICS.302   
      call xcharl(xoff,yoff-0.06,text1(1:ilen))                              GRAPHICS.303   
      ilen=lnsig1(text2)                                                     GRAPHICS.304   
      call xcharl(xoff,yoff-0.12,text2(1:ilen))                              GRAPHICS.305   
      call xclear                                                            GRAPHICS.306   
c                                                                            GRAPHICS.307   
      return                                                                 GRAPHICS.308   
      end                                                                    GRAPHICS.309   
c                                                                            GRAPHICS.310   
      subroutine maxmin(zg,ix,iy,fmin1,fmax1)                                GRAPHICS.311   
      real zg(ix*iy)                                                         GRAPHICS.312   
c                                                                            GRAPHICS.313   
      fmin1=zg(1)                                                            GRAPHICS.314   
      fmax1=zg(1)                                                            GRAPHICS.315   
      do i=2,ix*iy                                                           GRAPHICS.316   
         if (zg(i).lt.fmin1) fmin1=zg(i)                                     GRAPHICS.317   
         if (zg(i).gt.fmax1) fmax1=zg(i)                                     GRAPHICS.318   
      end do                                                                 GRAPHICS.319   
c                                                                            GRAPHICS.320   
      return                                                                 GRAPHICS.321   
      end                                                                    GRAPHICS.322   
c                                                                            GRAPHICS.323   
      SUBROUTINE SETCV (FMIN,FMAX,CINC,CV,NCNT,ITYPE,FINC)                   GRAPHICS.324   
C======================================================================      GRAPHICS.325   
C                                                                     =      GRAPHICS.326   
C  Set up contour levels for a data array with known min and max      =      GRAPHICS.327   
C  values. Three options, depending on sign and magnitude of input    =      GRAPHICS.328   
C  contour interval, CINC :                                           =      GRAPHICS.329   
C     a) CINC.GT.0.       : Use input contour interval CINC.          =      GRAPHICS.330   
C     b) CINC.LT.-1.      : Contour interval is (-CINC) in normalised =      GRAPHICS.331   
C                           units, defined such that max. abs. value  =      GRAPHICS.332   
C                           is 1000 units.                            =      GRAPHICS.333   
C     c) -1.LT.CINC.LT.0. : Contour interval is (-CINC) in normalised =      GRAPHICS.334   
C                           units, defined such that next power of 10 =      GRAPHICS.335   
C                           greater than max. abs. value is 1 unit.   =      GRAPHICS.336   
C  In (c) the contour interval is halved if the max. abs. value is    =      GRAPHICS.337   
C  less than half the next power of ten, or divided by 5 if less than =      GRAPHICS.338   
C  1/5th of it.                                                       =      GRAPHICS.339   
C                                                                     =      GRAPHICS.340   
C   If itype.eq.0 then (b) and (c) is calculated using maximum value  =      GRAPHICS.341   
C   If itype.eq.1 then (b) and (c) uses range                         =      GRAPHICS.342   
C======================================================================      GRAPHICS.343   
C                                                                            GRAPHICS.344   
      REAL CV(NCNT)                                                          GRAPHICS.345   
C                                                                            GRAPHICS.346   
      FAMAX=AMAX1(ABS(FMAX),ABS(FMIN))                                       GRAPHICS.347   
      FRANGE=FMAX-FMIN                                                       GRAPHICS.348   
      IF (FRANGE.LE.FAMAX*1.E-10) THEN                                       GRAPHICS.349   
         FINC=0.0                                                            GRAPHICS.350   
         NCNT=0                                                              GRAPHICS.351   
         RETURN                                                              GRAPHICS.352   
      END IF                                                                 GRAPHICS.353   
c                                                                            GRAPHICS.354   
      IF (CINC.GT.0.) THEN                                                   GRAPHICS.355   
         FINC=CINC                                                           GRAPHICS.356   
      ELSE IF (CINC.LE.-1.) THEN                                             GRAPHICS.357   
         FINC=-FAMAX*CINC/1000.                                              GRAPHICS.358   
      ELSE IF (CINC.LT.0.) THEN                                              GRAPHICS.359   
         IF (ITYPE.EQ.0) THEN                                                GRAPHICS.360   
            IEXP=NINT(ALOG10(FAMAX)*0.99999)                                 GRAPHICS.361   
            FA10=10.**IEXP                                                   GRAPHICS.362   
            FRACT=FAMAX/FA10                                                 GRAPHICS.363   
         ELSE                                                                GRAPHICS.364   
            IEXP=NINT(ALOG10(FRANGE)*0.99999)                                GRAPHICS.365   
            FA10=10.**IEXP                                                   GRAPHICS.366   
            FRACT=FRANGE/FA10                                                GRAPHICS.367   
         END IF                                                              GRAPHICS.368   
         IF (FRACT.GT.0.5) THEN                                              GRAPHICS.369   
            FINC=-FA10*CINC                                                  GRAPHICS.370   
         ELSE IF (FRACT.GT.0.2) THEN                                         GRAPHICS.371   
            FINC=-FA10*CINC*0.5                                              GRAPHICS.372   
         ELSE                                                                GRAPHICS.373   
            FINC=-FA10*CINC*0.2                                              GRAPHICS.374   
         END IF                                                              GRAPHICS.375   
      END IF                                                                 GRAPHICS.376   
c      print*,cinc,iexp,fmin,fmax,frange,fract,fa10,finc                     GRAPHICS.377   
C                                                                            GRAPHICS.378   
      ILO=INT(FMIN/FINC)                                                     GRAPHICS.379   
      IF (FMIN.GE.0.) ILO=ILO+1                                              GRAPHICS.380   
      CLV=FLOAT(ILO-1)*FINC                                                  GRAPHICS.381   
      I=0                                                                    GRAPHICS.382   
 10   CLV=CLV+FINC                                                           GRAPHICS.383   
      I=I+1                                                                  GRAPHICS.384   
      IF ((I.GT.NCNT).OR.(CLV.GE.FMAX)) GO TO 20                             GRAPHICS.385   
      CV(I)=CLV                                                              GRAPHICS.386   
      GO TO 10                                                               GRAPHICS.387   
 20   NCNT=I-1                                                               GRAPHICS.388   
C                                                                            GRAPHICS.389   
      RETURN                                                                 GRAPHICS.390   
      END                                                                    GRAPHICS.391   
c                                                                            GRAPHICS.392   
      subroutine end_graphics                                                GRAPHICS.393   
c                                                                            GRAPHICS.394   
      call xgrend                                                            GRAPHICS.395   
c                                                                            GRAPHICS.396   
      return                                                                 GRAPHICS.397   
      end                                                                    GRAPHICS.398   
