      real (kind=8) function timer()
      integer it,count_rate, IM
      real (kind=8) second

      logical first
      real (kind=8) tick_period
      data first/.true./
      save first,tick_period

      include       'mpif.h'
      timer = mpi_wtime()

      call system_clock(it,count_rate, IM)
      if (first) then
        tick_period = 1./count_rate
        first = .false.
      end if
      timer = it*tick_period

!      timer = second()

!      timer = 0.001*timef()

      return
      end
