dtimer.f90

来自「shpf 1.9一个并行编译器」· F90 代码 · 共 38 行

F90
38
字号
SUBROUTINE timer (t)
!---------------------------------------------------------------
! Returns the elapsed time in seconds since the first call to
! 'ftimer ()'.
!
! N.B. The 'SYSTEM_CLOCK ()' intrinsic is dangerous in an HPF
! program, as it violates HPF semantics by potentially returning
! a  different value on each processor.  Do not use the result 't'
! in any expression that governs the program's control flow
! (e.g. an IF or WHILE condition)!
!	We plan to provide a 'safe' version of 'SYSTEM_CLOCK ()'
! (e.g. one that returns the time as measured on a particular
! processor) in a future release of 'shpf'.
!---------------------------------------------------------------
  DOUBLE PRECISION, INTENT (OUT) ::  t
  INTEGER :: cnt0, cnt, rate, max
  SAVE       cnt0          ! its initial value should be 0!

  CALL SYSTEM_CLOCK (cnt, rate, max)

  IF (cnt0 == 0) THEN
    cnt0 = cnt
    cnt  = 0
  ELSE IF (cnt >= cnt0) THEN
    cnt = cnt - cnt0
  ELSE
    cnt = max - (cnt0 - cnt) + 1
  ENDIF

  IF (rate > 0) THEN
    t = DBLE (cnt) / DBLE (rate)
  ELSE
    t = 0.0    !! no clock !!
  ENDIF

  RETURN
END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?