c----------------------------- 
         program DST
c-----------------------------
cPROGRAM TO PLOT DST HOURLY VALUES


         real v(10000),idt(10000),day_avg(1000)
         real hr(400,10000),idn(1000),x_val(400,10000)
         real x_val1(10000)
c        integer dst_val1(10000),dst_val(400,10000)
         real dst_val1(10000),dst_val(400,10000)
         common /data_pts/ v(10000),dst_val(400,10000),idt(10000)
         common /data_pts/ x_val(400,10000),isdt,iedt
         character*40 dstfile

         call pgbegin(0,'?',1,1)
         call pgask(.true.)
         call pgadvance


c        write(*,*)'ENTER START MONTH,DATE,HOUR'
c        read(*,*)ismnth,isdt,ishr
c        write(*,*)'ENTER END MONTH,DATE,HOUR'
c        read(*,*)iemnth,iedt,iehr

         ismnth = 07
         isdt = 25
         ishr = 0

         iemnth = 07
         iedt = 31
         ihr = 24

         open(2, file = 'dtfile.dat', status = 'old')
         write(2,*)'START MONTH,DATE,HOUR:',ismnth,isdt,ishr
         write(2,*)'END MONTH,DATE,HOUR  :',iemnth,iedt,iehr
         write(2,*)''

         st = float(isdt)*24.0*3600. + float(ishr) * 3600.
         et = float(iedt)*24.0*3600. + float(iehr) * 3600.

         xmin = st 
         xmax = et
         ymin = -20.0
         ymax = 25.0
     
         call pgsvp(0.15,0.90,0.15,0.85)
         call pgwindow(xmin,xmax,ymin,ymax)
         call pgtbox('bcnstzhx',0.0,0,'bcvnst',0.0,0) 

         dstfile = 'dst1989'

         l = 0
         open(1, file = dstfile, status = 'old')
         do i = 1, 365
            read(1,10)a,iyear,imnth,idate,(v(j),j = 1,26)
            if (imnth .ge. ismnth .and. idate .ge. isdt)then
             if (imnth .le. iemnth .and. idate .le. iedt)then
                l = l+1
                dst1 = a
                iyr = iyear
                imth = imnth
                idt(i) = idate
                idn(l) = i                      !day number
                k = 0
                do j = 2, 25
                k = k+1
                   hr(i,k) = j-1
                   x_val(idt(i),k) = float(idt(i)) *24.*3600. 
     1                                        + hr(i,k)*3600.
                   dst_val(idt(i),k) = v(j)         
                enddo
                day_avg(idt(i)) = v(26)         !day average
                write(2,11)dst1,iyr,imth,idt(i),
     1                  (dst_val(idt(i),j),j = 1,24),day_avg(idt(i))
10              format(a3,i2,i2,1x,i2,6x,i4,24(i4),i4)            
11              format(a3,i2,i2,1x,f3.0,3x,i4,24(i4),f5.0)            
             endif
            endif
          enddo

          npt = k  

          k = 0
          do i = isdt, iedt
           do j = 1,24
              k = k+1
              x_val1(j) = x_val(i,j)
              dst_val1(j) = dst_val(i,j)
           call pgdraw(x_val1(j),dst_val1(j))
           enddo
c          call pgline(k, x_val1,dst_val1)
c          call pgpoint(k-1, x_val1,dst_val1,17)
              write(*,'(f11.3,2x,i5)')(x_val1(j),dst_val1(j),j = 1,24)
          enddo
          write(*,*)'k',k
          
         call pgend
         stop
         end

