c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c!     This module is to get current time info 
C!
c!     Xindi Bian
c!     Dept. of Geo. and Atmos. Sci. 
C!     Iowa State University
C!     Ames, IA 50010
C!     xindi.bian@iastate.edu
C!     January 19, 1991
c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c!     edited for PNNL ARM project
c!
c!     Randy X. Bian
c!     Pacific Northwest National Laboratory
c!     P. O. Box 999, K9-30
c!     Richland, WA 99352
c!     (509)372-6141
c!     randy.x.bian@pnl.gov
c!     March 21, 1995
c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c!     edited again for EAMC web update 
c!
c!     Randy X. Bian
c!     USDA Forest Service / NCRS
c!     1407 S. Harrison Rd, Suite 220
c!     East Lansing, MI 48823
c!     (515)-355-7740 ext 104
c!     xbian@fs.fed.us
c!     Feb 17, 2004
c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      character*24 t
      character*8 yyyymmdd
      character*2 uti,utc
      character*4 domn(4)
      parameter(mvar=16)
      character*6 var(mvar)
      logical is_it_there
      uti = '00'
      domn(1)='36km'
      domn(2)='12km'
      domn(3)='4kme'
      domn(4)='4kmw'
      var( 1)='haineh'
      var( 2)='hainel'
      var( 3)='hainem'
      var( 4)='haines'
      var( 5)='fosber'
      var( 6)='ventin'
      var( 7)='pblhgt'
      var( 8)='srfcrh'
      var( 9)='accpre'
      var(10)='3hrpre'
      var(11)='2mtemp'
      var(12)='sealpr'
      var(13)='qva850'
      var(14)='rha850'
      var(15)='uva850'
      var(16)='tkexhi'
      n = time()
      do j = 1,1
        t = ctime(n)
        if(t(5:7).eq.'Jan')imm = 1
        if(t(5:7).eq.'Feb')imm = 2
        if(t(5:7).eq.'Mar')imm = 3
        if(t(5:7).eq.'Apr')imm = 4
        if(t(5:7).eq.'May')imm = 5
        if(t(5:7).eq.'Jun')imm = 6
        if(t(5:7).eq.'Jul')imm = 7
        if(t(5:7).eq.'Aug')imm = 8
        if(t(5:7).eq.'Sep')imm = 9
        if(t(5:7).eq.'Oct')imm =10
        if(t(5:7).eq.'Nov')imm =11
        if(t(5:7).eq.'Dec')imm =12
        read(t(12:13),*)ihr
        read(t(21:24),*)iyy
        read(t(9:10),*)idd
        yyyymmdd(1:4)=t(21:24)
        write(yyyymmdd(5:6),'(i2.2)')imm
        write(yyyymmdd(7:8),'(i2.2)')idd
        n = n - 30*24*3600
      enddo
      status=system( 'rm -rf current.12km.sfc.wind.gif')
      status=system( 'rm -rf future.12km.sfc.wind.gif')
      status=system( 'rm -rf today.18z.12km.wind.watch.gif')
      status=system( 'rm -rf today.21z.12km.wind.watch.gif')
      status=system( 'rm -rf today.18z.12km.rh.watch.gif')
      status=system( 'rm -rf today.21z.12km.rh.watch.gif')
      status=system( 'rm -rf ./current/*')
      ihru = (ihr + 5)/3 * 3
      write(utc(1:2),'(i2.2)')ihru
      is_it_there = .FALSE.
      INQUIRE ( FILE =
     & './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_'//utc//'.gif'
     & , EXIST = is_it_there )
      if ( is_it_there ) then
        do ivar = 1,mvar
        do idom = 1,2
        status=system( 'ln -s '//
     &   '../'//yyyymmdd//uti//'/'//uti//'_'//var(ivar)//
     &   '_'//domn(idom)//'_'//utc//'.gif'//
     &   ' ./current/'//var(ivar)//'_'//domn(idom)//'.gif' )
        enddo
        do idom = 3,4
        status=system( 'ln -s '//
     &   '../'//yyyymmdd//uti//'/'//uti//'_'//var(ivar)//
     &   '_0'//domn(idom)//'_'//utc//'.gif'//
     &   ' ./current/'//var(ivar)//'_'//domn(idom)//'.gif' )
        enddo
        enddo
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_'//utc//'.gif'//
     &   ' current.12km.sfc.wind.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_uwatch_12km_18.gif'//
     &   ' today.18z.12km.wind.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_uwatch_12km_21.gif'//
     &   ' today.21z.12km.wind.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_rhwatc_12km_18.gif'//
     &   ' today.18z.12km.rh.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_rhwatc_12km_21.gif'//
     &   ' today.21z.12km.rh.watch.gif' )
        if( (ihr + 5) .lt .18 ) then
          status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_18.gif'//
     &   ' future.12km.sfc.wind.gif' )
        else
          status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_42.gif'//
     &   ' future.12km.sfc.wind.gif' )
        endif
      else
        call yesterday(iyy,imm,idd,iy2,im2,id2)
        write(yyyymmdd(1:4),'(i4.4)')iy2
        write(yyyymmdd(5:6),'(i2.2)')im2
        write(yyyymmdd(7:8),'(i2.2)')id2
        ihru = (ihr + 5 + 24 ) /3 * 3
        write(utc(1:2),'(i2.2)')ihru
        INQUIRE ( FILE =
     & './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_'//utc//'.gif'
     & , EXIST = is_it_there )
        if ( is_it_there ) then
        do ivar = 1,mvar
        do idom = 1,2
        status=system( 'ln -s '//
     &   '../'//yyyymmdd//uti//'/'//uti//'_'//var(ivar)//
     &   '_'//domn(idom)//'_'//utc//'.gif'//
     &   ' ./current/'//var(ivar)//'_'//domn(idom)//'.gif' )
        enddo
        do idom = 3,4
        status=system( 'ln -s '//
     &   '../'//yyyymmdd//uti//'/'//uti//'_'//var(ivar)//
     &   '_0'//domn(idom)//'_'//utc//'.gif'//
     &   ' ./current/'//var(ivar)//'_'//domn(idom)//'.gif' )
        enddo
        enddo
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_uwatch_12km_42.gif'//
     &   ' today.18z.12km.wind.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_uwatch_12km_45.gif'//
     &   ' today.21z.12km.wind.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_rhwatc_12km_42.gif'//
     &   ' today.18z.12km.rh.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_rhwatc_12km_45.gif'//
     &   ' today.21z.12km.rh.watch.gif' )
        status=system( 'ln -s '//
     &   './'//yyyymmdd//uti//'/'//uti//'_10mwnd_12km_'//utc//'.gif'//
     &   ' current.12km.sfc.wind.gif' )
        endif
      endif
      end
c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      subroutine yesterday(iy1,im1,id1,iy2,im2,id2)
        if(id1.eq.1)then
          if(im1.eq.1)then
             id2 = 31
             im2 = 12
             iy2 = iy1 - 1
          endif
          if(im1.eq.3)then
             if(mod(iy1,4).eq.0)then
               id2 = 29
             else
               id2 = 28
             endif
             im2 = im1 -1
             iy2 = iy1
          endif
          if(im1.eq.5.or.im1.eq.7.or.im1.eq.8
     &               .or.im1.eq.10.or.im1.eq.12)then
             id2 = 30
             im2 = im1 -1
             iy2 = iy1
          endif
          if(im1.eq.2.or.im1.eq.4.or.im1.eq.6
     &               .or.im1.eq.9.or.im1.eq.11)then
             id2 = 31
             im2 = im1 -1
             iy2 = iy1
          endif
        else
          id2 = id1 - 1
          im2 = im1
          iy2 = iy1
        endif
      return
      end
c!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

