Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Sleep Routine

reneeculver
Beginner
4,075 Views
I need a Sleep function.

It should have one Argument which is the number of seconds to sleep for. Any maximum in seconds is not important as long as the maximum is greater is greater than 60 seconds.

It shoulld be simple...

I wish I had some documentation. Can anyone recommend a good reference book?

Renee
0 Kudos
22 Replies
Paul_Curtis
Valued Contributor I
3,722 Views
This would be for Win32 systems only (not portable).
[bash]RECURSIVE SUBROUTINE delay_ms (howmany)
	USE kernel32, ONLY: sleep
	IMPLICIT NONE
	INTEGER,INTENT(IN)	:: howmany

	!	Win32 suspend function, allows the timeslice to be
	!	used by other threads until the timeout elapses
	IF (howmany > 0) CALL sleep (howmany)
END SUBROUTINE delay_ms
[/bash]
0 Kudos
psantos
Beginner
3,722 Views
Perhaps you should consider SLEEPQQ declared in IFPORT. Citing the Composer XE documentation (which by the way a recommend to you):

SLEEPQQ

Portability Subroutine: Delays execution of the program for a specified duration.

Module

USE IFPORT

Syntax

CALL SLEEPQQ (duration)

duration

(Input) INTEGER(4). Number of milliseconds the program is to sleep (delay program execution).

Example:
[fortran] USE IFPORT
 INTEGER(4) delay
 delay    = 2000
 CALL SLEEPQQ(delay)

[/fortran]
Pedro
0 Kudos
reneeculver
Beginner
3,722 Views
Paul,Is that in C?

It doesn't compile.

Pedro, I"ll try yours.

Renee
0 Kudos
Paul_Curtis
Valued Contributor I
3,722 Views
My routine compiles just fine, has worked for at least 10 years now. Note that this forum's stupid editor software has interpreted the greater-than symbol as html. USEing the Win32 API module Kernal32 is much more secure than IFPORT; obviously both are invoking the same API function -- how many layers of screen door do you want to kiss through?
0 Kudos
Steven_L_Intel1
Employee
3,722 Views
"much more secure"? Using a Win32 API call certainly is less portable (Intel Fortran supports SLEEPQQ on all three operating systems.)
0 Kudos
reneeculver
Beginner
3,722 Views
Pedro got it.

Sleep is synchronous and perfect here.

Renee
0 Kudos
reneeculver
Beginner
3,722 Views

"(Intel Fortran supports SLEEPQQ on all three operating systems.)"

I'm afraid that under NO circumstances do I write code for any of the Unix series.

Renee

0 Kudos
Steven_L_Intel1
Employee
3,722 Views
Renee,

You had LIB$SLEEP - which I wrote. It used $HIBER and $SCHDWK (without the latter you'd never wake up.)
0 Kudos
reneeculver
Beginner
3,722 Views
Steve,

I didn't know - Do you have a recommendation for a book I can read?

Where do I find the Lib$ routines? Help is still useless with VS and so this messes up Intel help.

Renee
0 Kudos
Steven_L_Intel1
Employee
3,722 Views
Were you really a VMS developer and you don't remember the LIB$ routines? Those were VMS Run-Time Library routines. I was a developer for the VMS OS from 1978-1988 and wrote the LIB$SLEEP routine in 1979. As has been said in this thread, use SLEEPQQ.

If you are having trouble with the help, please explain. I don't know what you mean by "messes up Intel help". You could have typed "sleep" into the Index tab and found the entry. There is also a handy table, though well buried in the documentation. Language Reference > A to Z Reference > Language Summary Tables. This lists groups of library routines by type.
0 Kudos
reneeculver
Beginner
3,722 Views
Yes I was a VMS developer and DO remember the Lib$ routines BUT I can't find them in theIntel Documentation I have for them.

For that matter I cant find Lib$ in Google....

Renee
0 Kudos
reneeculver
Beginner
3,722 Views
I feel that Microsoft has messed up it's Help in VS version 10 and VS SP1. Obviously SP1 is an improvement,but one can no longer copy from it therefore is largely useless.

For Intel, it found sleep when I searched for it as a pdf file. Since I had what I needed I did not persist in search. I got a .PDF Intel Users and reference guide on the net and that works. The help doesn't as the Find doesn't work at allin VS, with Intel material.

I find that I like books with pages. By the the way, the Unix information is useless and is noise as far as I'm concerned.

Renee
0 Kudos
reneeculver
Beginner
3,722 Views
Hmmmm, After applying the latest set of patches, Find works OK on the PDF file I also have the latest PDF patches.

Renee
0 Kudos
psantos
Beginner
3,722 Views
reneeculver,

You probably have some problem with VS10. I'm using VS10 and I have access to Composer XE documentation using the help tab. I see the doc's through Microsoft help viewer. I also have a search tab.

Pedro
0 Kudos
mecej4
Honored Contributor III
3,722 Views
> Lib$ routines BUT I can't find them in theIntel Documentation

For a good reason. In all probability, they do not exist and will not exist on any OS other than VMS.

Functional equivalents for some LIB$ functions may exist, but these are not part of the Fortran language and portable code will not reference them. As the years pass, it will get harder to dig up even information on what those routines were supposed to do, let alone working ports.
0 Kudos
reneeculver
Beginner
3,722 Views
AMEN.... I have been having trouble with the documentation! I use a PDF I found on the net.

Thanks you.

Renee
0 Kudos
reneeculver
Beginner
3,722 Views
AMEN.... I have been having trouble with the documentation! I use a PDF I found on the net.

Thanks you.

Renee
0 Kudos
reneeculver
Beginner
3,722 Views
"For a good reason. In all probability, they do not exist and will not exist on any OS other than VMS.

Functional equivalents for some LIB$ functions may exist, but these are not part of the Fortran language and portable code will not reference them. As the years pass, it will get harder to dig up even information on what those routines were supposed to do, let alone working ports"

VMS was the best OS ever made, bar none. It's a shame the we are going backwards in the OS world.

Renee

0 Kudos
Steven_L_Intel1
Employee
3,722 Views
Renee,

I was not implying that Intel Fortran had LIB$ routines. I was commenting on your remark about VMS $HIBER and not having "sleep" on VMS, pointing out that yes indeed you did.
0 Kudos
reneeculver
Beginner
3,556 Views
Sleep should not be confused with $hiber. With $hiber, a thread was subject to asynchronous wakeup. Nothing will wake up Sleep because it is purely synchronous where $hiber was asynchronous. There is a day and night difference between Lib$sleep and $hiber. If I'm not mistaken, the wakeup to $hiber was delivered at ASTDEL (IPL 2) and was relatively fast.

Sleep is clumsy; $hiber was refined. Unix was largely a synchronous operating system, which is why Unix programmers do not understand what we're talking about and people think Sleep or Lib$sleep is OK. It's not.

I used $Hiber in the Shadow Serverfora reason which was that it was asynchronous. I never used Lib$sleep because of it's synchronicity.

Renee
0 Kudos
Reply