Sleep in Fortran

后端 未结 3 1317
长情又很酷
长情又很酷 2021-02-12 23:27

Does anyone know of an way to sleep for a given number of milliseconds in Fortran? I do not want to use non-portable system calls so anything intrinsic to Fortran or C librarie

3条回答
  •  一生所求
    2021-02-12 23:45

          ! This is another option of making your fortran code to wait for x seconds
           Integer :: iStart, iNew
           Real*8 :: rWait, rDT
          ! rWait: seconds that you want to wait for; you can also set this as an (IN)
          ! variable if this code goes into a subroutine that is developed to be called 
          ! from any part of the program.
          rWait = 1.d0; rDT = 0.d0
          call system_clock (iStart)
          do while (rDT <= rWait)
              call system_clock (iNew)
              rDT = floatj (iNew - iStart) / 10000.d0
          enddo
    

提交回复
热议问题