- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I'm looking for a portable way to halt execution of my program for a time shorter than one second. I can't use Fortrans intrinsic sleep() function because it accepts only integer seconds.
I had thought to do this by calling the C function sleep using C binding. However, I keep getting a linker error: "unresolved external symbol _sleep referenced...".
I'm using Intel Visual Fortran Composer XE 2011.
See below for my code.
Thanks in advance for any help.
cheers,
Maarten
I'm looking for a portable way to halt execution of my program for a time shorter than one second. I can't use Fortrans intrinsic sleep() function because it accepts only integer seconds.
I had thought to do this by calling the C function sleep using C binding. However, I keep getting a linker error: "unresolved external symbol _sleep referenced...".
I'm using Intel Visual Fortran Composer XE 2011.
See below for my code.
Thanks in advance for any help.
cheers,
Maarten
[fortran]module sleep_ms interface function sleep_C(ms) bind(c,name="sleep") use iso_c_binding, only : c_int integer(c_int), value :: ms integer(c_int) :: sleep_C end function sleep_C end interface contains function sleep_ms(ms) use iso_c_binding, only: c_int implicit none integer, intent(in), value :: ms integer :: sleep_ms integer(c_int) :: ms_c ms_c = ms sleep_ms = sleep_C(ms_c) end function sleep_ms end module sleep_ms[/fortran]
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might check exactly how the sleep() linker symbol is spelled in the library you are using, by tools such as dumpbin.
There is no standard Fortran sleep function; you might find the ifort sleepqq function more convenient than the other legacy sleep function.
There is no standard Fortran sleep function; you might find the ifort sleepqq function more convenient than the other legacy sleep function.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might check exactly how the sleep() linker symbol is spelled in the library you are using, by tools such as dumpbin.
There is no standard Fortran sleep function; you might find the ifort sleepqq function more convenient than the other legacy sleep function.
There is no standard Fortran sleep function; you might find the ifort sleepqq function more convenient than the other legacy sleep function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
thanks for the fast answer. I had considered sleepqq but dismissed it because I assumed it was not portable to other compilers (specifically PGI Fortran). After some further searching I found that it *is* portable. In PGI Fortran it seems to be part of the module DFLIB, but this module seems also to be available in Intel Fortran.
cheers,
Maarten
thanks for the fast answer. I had considered sleepqq but dismissed it because I assumed it was not portable to other compilers (specifically PGI Fortran). After some further searching I found that it *is* portable. In PGI Fortran it seems to be part of the module DFLIB, but this module seems also to be available in Intel Fortran.
cheers,
Maarten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maarten,
In IFPORT there is the funciton SLEEPQQ(milliseconds)
Jim Dempsey
In IFPORT there is the funciton SLEEPQQ(milliseconds)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see you already found SLEEPQQ...
When you program delays sometimes your interest is in the length of the delay while other times you are intersted in time intervals (IOW ~precisely every n milliseconds). In the latter case you also need to obtain the system time with sufficient resolution such that you can recompute the delay necessary to reach the desired time interval. Lookup SYSTEM_CLOCK as well as WIN32 API's which are also available.
Jim Dempsey
When you program delays sometimes your interest is in the length of the delay while other times you are intersted in time intervals (IOW ~precisely every n milliseconds). In the latter case you also need to obtain the system time with sufficient resolution such that you can recompute the delay necessary to reach the desired time interval. Lookup SYSTEM_CLOCK as well as WIN32 API's which are also available.
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page