      SUBROUTINE TIME_1970(ITIME,I70)
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine TIME_1970    
C.LIBRARY:        GENERAL
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       1.0 - 27 Aug 92 - Original version
C                 1.1 - 02 Jan 01 - fixed anti-Y2K bug !
C.PURPOSE:        convert time array (y m d h m s f) to sec since 1970
C.METHOD:         arithmetics     
C.SYNTAX:         CALL TIME_1970(ITIME,I70)  
C.PARAMETERS:     INTEGER ITIME(7)   time array (input)               
C                 INTEGER I70        seconds since 1970 (output)
C.RESTRICTIONS:   valid to year 2038 because of INTEGER*4 (signed)   
C.NOTES:          does NOT check legal range of year, month etc.
C                 does NOT consider leap seconds        
C.FILES:          none
C.REFERENCES:     noen
C
C----------------------------------------------------------------------
C
      INTEGER ITIME(7),I70,IJD,MONTHS(12),IYE
      LOGICAL LEAP
C
C     offset for   Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
      DATA MONTHS /  0, 31, 59, 90,120,151,181,212,243,273,304,334/
C
C     compute elapsed years since 1970
      IYE=ITIME(1)-1970
C->   if year is less than 1970 or greater than ???? should give error
C->   also if month is illegal (not 1-12) or day is illegal ...  
C
C     handle elapsed days in entire years since 1970 jan 1 0:0:0
C     correction term is for leap years since 1970 (2000 leap too) 
C     extra correction for years > 2000 : OK up to 2100
      IJD=IYE*365 + (IYE+1)/4
*     IF(ITIME(1).GT.2100)IJD=IJD-1   and so on every century to 2399 
C
C     is it a leap year (every 4 but not 1700. 1800. etc. but 1600 and 2000 yes)
C     LEAP = (MOD(ITIME(1),4).EQ.0.AND.MOD(ITIME(1),100).NE.0).OR.MOD(ITIME(1),400).EQ.0 
C     however in range 1970-2038 all years/4 are leap
      LEAP = MOD(ITIME(1),4).EQ.0            
C
C     compute day of the year and add it
      IJD=IJD+ITIME(3)+MONTHS(ITIME(2))
      IF (LEAP.AND.ITIME(2).GT.2)IJD=IJD+1
C
C     handle elapsed days in the year and convert to seconds
      I70=(IJD-1)*86400
C
C     handle hours minutes seconds (ignore fraction of seconds)
      I70=I70+ITIME(6)+ITIME(5)*60+ITIME(4)*3600
C
C     shall one take into account leap seconds too ?
      RETURN
      END
