History of Idiom 45 > diff from v48 to v49
Edit summary for version 49 by jupiter:
[Fortran] usleep is a nicer example than sleep
[Fortran] usleep is a nicer example than sleep
↷
Version 48
2019-09-27, 00:19:18
Version 49
2019-09-27, 00:27:09
Idiom #45 Pause execution for 5 seconds
Sleep for 5 seconds in current thread, before proceeding with next instructions.
Idiom #45 Pause execution for 5 seconds
Sleep for 5 seconds in current thread, before proceeding with next instructions.
Code
module M_time
contains
subroutine system_sleep(wait)
use,intrinsic :: iso_c_binding, only: c_int
integer,intent(in) :: wait
integer(kind=c_int) :: waited
interface
function c_usleep(msecs) bind (C,name="usleep")
import
integer(c_int) :: c_usleep
integer(c_int), intent(in), VALUE :: msecs
end function c_usleep
end interface
if(wait.gt.0)then
waited=c_usleep(int(wait,kind=c_int))
endif
end subroutine system_sleep
end module M_time
program demo_M_time
u
Code
module M_time
contains
subroutine system_sleep(wait)
use,intrinsic :: iso_c_binding, only: c_int
integer,intent(in) :: wait
integer(kind=c_int):: waited
interface
function c_usleep(msecs) bind (C,name="usleep")
import
integer(c_int) :: c_usleep
integer(c_int),intent(in),VALUE :: msecs
end function c_usleep
end interface
if(wait.gt.0)then
waited=c_usleep(int(wait,kind=c_int))
endif
end subroutine system_sleep
end module M_time
program x
use M_time
call system_sleep(5000000)
end
Comments bubble
Comments bubble