integer function convtime(yr,mon,day,hr,min)
      
c Originally written by Shawn Smith (smith@coaps.fsu.edu)
c Updated Spring 1999 for Y2K compliance by Anthony Arguez
c (anthony@coaps.fsu.edu). 
c
c This subroutine will convert a given year, month, day, hour, and
c minutes to a minutes from 1-1-1980 00:00 time stamp.

      integer year(1980:2020), month(12), leap_mon(12), min_day,
     +        min_hr, yr, mon, day, hr, min
     
      data year /0, 527040, 1052640, 1578240, 2103840, 2630880, 3156480,
     +           3682080, 4207680, 4734720, 5260320, 5785920, 6311520,
     +           6838560, 7364160, 7889760,  8415360, 8942400, 9468000,
     +           9993600, 10519200, 11046240, 11571840, 12097440,  
     +		 12623040, 13150080, 13675680, 14201280, 14726880, 
     +		 15253920, 15779520, 16305120, 16830720, 17357760,
     +		 17883360, 18408960, 18934560, 19461600, 19987200,
     +           20512800, 21038400/    
      data month /0, 44640, 84960, 129600, 172800, 217440, 260640,
     +            305280, 349920, 393120, 437760, 480960/
      data leap_mon /0, 44640, 86400, 131040, 174240, 218880, 262080,
     +               306720, 351360, 394560, 439200, 482400/
      data min_day, min_hr /1440, 60/
      
c Test values to see if they fit valid ranges:

      if (yr.lt.1980.or.yr.gt.2020) then
         print*, 'ERROR ---- year out of range (1980-2020)'
         stop
      endif   
      if (mon.lt.1.or.mon.gt.12) then
         print*, 'ERROR ---- month out of range (1-12)'
         stop
      endif   
      if (mon.eq.2) then
         if ((MOD(yr,4).eq.0).and.(day.lt.1.or.day.gt.29)) then
            print*, 'ERROR ---- Feb. day out of range (1-29)'
            stop
         elseif ((MOD(yr,4).ne.0).and.(day.lt.1.or.day.gt.28)) then
            print*, 'ERROR ---- Feb. day out of range (1-28)'
            stop
         endif
      elseif ((mon.eq.4).or.(mon.eq.6).or.(mon.eq.9).or.(mon.eq.11))
     +       then
         if (day.lt.1.or.day.gt.30) then
            print*, 'ERROR ---- day out of range (1-30)'
            stop
         endif
      else   
         if (day.lt.1.or.day.gt.31) then
            print*, 'ERROR ---- day out of range (1-31)'
            stop
         endif  
      endif   
      if (hr.lt.0.or.hr.gt.23) then
         print*, 'ERROR ---- hour out of range (0-23)'
         stop 
      endif  
      if (min.lt.0.or.min.gt.60) then
         print*, 'ERROR ---- minute out of range (0-60)'
         stop
      endif
      
c Convert time:
      
      if (MOD(yr,4).eq.0) then
         convtime=year(yr)+leap_mon(mon)+((day-1)*min_day)+(hr*min_hr)+
     +   min
      else
         convtime=year(yr)+month(mon)+((day-1)*min_day)+(hr*min_hr)+min
      endif   
c      print*, 'convtime=', convtime
      
      return
      end