From: Mik on
Hello,
Has Fortran command to suspend program execution (e.g. to 100 ms), like
sleep(100)?
From: tholen on
Mik <proximum(a)none.none> writes:

> Has Fortran command to suspend program execution (e.g. to 100 ms), like
> sleep(100)?

It's not part of the language, but there may be an API provided by the
operating system that can be accessed by Fortran. (I have some Fortran
programs that call DosSleep.)

From: Kurt Kallblad on

"Mik" <proximum(a)none.none> wrote in message
news:ftr346$cpo$1(a)registered.motzarella.org...
> Hello,
> Has Fortran command to suspend program execution (e.g. to
> 100 ms), like sleep(100)?

Not standard but:

MS Win has the API:
VOID Sleep(
DWORD dwMilliseconds // sleep time in milliseconds
);

CVF and I think Intel 's compiler still have it:
CALL SLEEP (time)
time: (Input) INTEGER(4). Length of time, in seconds, to
suspend the calling process

CALL SLEEPQQ (duration)
duration: (Input) INTEGER(4). Number of milliseconds the
program is to sleep

Kurt

From: Gary Scott on
tholen(a)antispam.ham wrote:

> Mik <proximum(a)none.none> writes:
>
>
>>Has Fortran command to suspend program execution (e.g. to 100 ms), like
>>sleep(100)?
>
>
> It's not part of the language, but there may be an API provided by the
> operating system that can be accessed by Fortran. (I have some Fortran
> programs that call DosSleep.)
>
There really is a need for an intrinsic $sleep, $wait, and $delay
equivalent.

--

Gary Scott
mailto:garylscott(a)sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford
From: John Harper on
In article <rl9Mj.175$Jr6.76(a)nntpserver.swip.net>,
Kurt Kallblad <kurt.kallblad(a)tele2.se> wrote:
>
>"Mik" <proximum(a)none.none> wrote in message
>news:ftr346$cpo$1(a)registered.motzarella.org...
>> Hello,
>> Has Fortran command to suspend program execution (e.g. to
>> 100 ms), like sleep(100)?
>
>Not standard but:
>
>MS Win has the API:
> VOID Sleep(
> DWORD dwMilliseconds // sleep time in milliseconds
> );
>
>CVF and I think Intel 's compiler still have it:
> CALL SLEEP (time)
> time: (Input) INTEGER(4). Length of time, in seconds, to
>suspend the calling process
>
> CALL SLEEPQQ (duration)
> duration: (Input) INTEGER(4). Number of milliseconds the
>program is to sleep

You can roll your own. IMHO the following is OK in f95 if cpu_time
is good enough, and it warns you if the processor knows it can't be.
You could do something similar with date_and_time but it would be
more complicated, and I'm not sure what it would do if there was a
leap second while the do loop was executing. I chose the name slumber
because some compilers have an intrinsic subroutine called sleep.

SUBROUTINE slumber(x) ! x = default real number of seconds to "sleep"
REAL,INTENT(IN)::x
REAL cpu1,cpu2
CALL cpu_time(cpu1)
DO
CALL cpu_time(cpu2)
IF (cpu1 < 0. .OR. cpu2 < 0.) THEN
PRINT *,"This processor can't give a useful cpu_time :-("
RETURN
END IF
IF (cpu2-cpu1 > x) RETURN
END DO
END SUBROUTINE slumber

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper(a)vuw.ac.nz phone (+64)(4)463 6780 fax (+64)(4)463 5045