FUNCTION gettime(t2,t1) ! ! Function for getting elapsed time between 2 time ! stamps ! ! Liberally lifted from the Octave Etime function ! ! Does not work if you cross a year boundary ! It should work if you cross a leap year day USE const IMPLICIT NONE INTEGER, INTENT(IN) :: t1(8),t2(8) REAL(kind=dp) :: gettime INTEGER, EXTERNAL :: leapyear INTEGER :: days1(12),days2(12) INTEGER :: ly1, ly2, d1, d2 REAL(kind=dp) :: s2,s1 days1 = (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /) days2 = days1 ly1 = leapyear(t1(1)) ly2 = leapyear(t2(1)) if(ly1 == 1) days1(2) = days1(2) + 1 if(ly2 == 1) days2(2) = days2(2) + 1 d1 = sum(days1(1:(t1(2)-1))) + t1(3) d2 = sum(days2(1:(t2(2)-1))) + t2(3) s1 = 86400.0d0 * d1 + 3600.0d0 * t1 (5) + 60.0d0 * t1 (6) + t1 (7) + t1(8)/1000.0d0 s2 = 86400.0d0 * d2 + 3600.0d0 * t2 (5) + 60.0d0 * t2 (6) + t2 (7) + t2(8)/1000.0d0 gettime = s2-s1 RETURN END FUNCTION gettime !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FUNCTION leapyear(year) ! ! Function to determine if the input year is a leap year ! ! Liberally lifted from Octave is_leap_year function ! USE const IMPLICIT NONE INTEGER,INTENT(IN) :: year INTEGER :: leapyear leapyear = 0 IF((year/4 == 0 .AND. year/100 /= 0) .OR. (year/400 == 0)) leapyear = 1 RETURN END FUNCTION leapyear !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE currtime(i) ! ! This subroutine just makes the call to DATE_AND_TIME ! f90 intrinsic function more user friendly ! USE const IMPLICIT NONE INTEGER :: i(8) CALL DATE_AND_TIME(values=i) RETURN END SUBROUTINE currtime