! Not really cpu time but wallclock time.
! Should work with all Fortran90 systems.
! Note that TIME has to be default real kind (F95 standard allows any kind).

      SUBROUTINE CPU_TIME(TIME)
      REAL, INTENT(OUT) :: TIME

      INTEGER :: COUNT, COUNT_RATE

      CALL SYSTEM_CLOCK(COUNT,COUNT_RATE)
      IF (COUNT_RATE /= 0) THEN
        TIME = REAL(COUNT)/COUNT_RATE
      ELSE
        TIME = -1
      END IF
      END SUBROUTINE CPU_TIME
