|
From: Arjen Markus on 14 Apr 2008 03:13 On 14 apr, 01:57, har...(a)mcs.vuw.ac.nz (John Harper) wrote: > In article <rl9Mj.175$Jr6...(a)nntpserver.swip.net>, > > > > > > Kurt Kallblad <kurt.kallb...(a)tele2.se> wrote: > > >"Mik" <proxi...(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.har...(a)vuw.ac.nz phone (+64)(4)463 6780 fax (+64)(4)463 5045- Tekst uit oorspronkelijk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven - That is a very CPU-intensive solution! Most compilers I know of have SLEEP in some form or other (the argument may be in seconds or in milliseconds, the name may also be WAIT or it is hidden in some module). Regards, Arjen
From: Mik on 14 Apr 2008 03:38 John Harper �����: > 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 Unfortunately, it takes about 100% of CPU load.
First
|
Prev
|
Pages: 1 2 Prev: Reopening standard input/output Next: Update: Strange behaviour (CVF) |