forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SLEEP SUBROUTINE

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Thu Dec 20, 2007 10:07 pm    Post subject: SLEEP SUBROUTINE Reply with quote

Hello,

I'm just a fortran beginner; after some days using f77, I've downloaded the Silverfrost FTN95 software including Plato IDE 3.50.

I'd like to ask you a solution to my problem; I want to know how to use Sleep Subroutine because I'm using it as G95 MANUAL says and it doesn't work.

I'm doing something wrong:

Program Sleep

Integer Year
Year = 2007

Print *, 'YEAR IS ', Year
Call sleep(100)

Print *, '100 seconds later YEAR IS ', Year

END

SUBROUTINE sleep(seconds)
INTEGER, INTENT(IN) :: seconds
END SUBROUTINE sleep


Do you know what is wrong with this code? thanks

F77
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Fri Dec 21, 2007 8:48 am    Post subject: Reply with quote

There is no sleep function in standard Fortran nor in the Salford/Silverfrost Fortran library (that I can think of).

I could point you to a solution but, as a beginner, I do not think that it would help. This would involve calling the sleep function in the Microsoft API.

I am puzzled as to why you would want to use a sleep function in a Fortran program. A sleep function is not provided because there is no obvious reason to need one.
Back to top
View user's profile Send private message AIM Address
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Fri Dec 21, 2007 1:09 pm    Post subject: Reply with quote

Thanks Paul.

I need it because the program I'm coding lasts a lot of time and my computer heats up a lot.

The Sleep Subroutine I posted has been copied from the G95 manual (www.g95.org) as others existing there:

"...
SIGNAL
SUBROUTINE signal(signal, handler, status)
INTEGER, INTENT(IN) :: signal
PROCEDURE, INTENT(IN) :: handler
INTEGER, INTENT(OUT) :: status
END SUBROUTINE signal
Interface to the unix signal system call. Sets status to nonzero on error.

SLEEP
SUBROUTINE sleep(seconds)
INTEGER, INTENT(IN) :: seconds
END SUBROUTINE sleep
Causes the process to pause for seconds seconds.

SRAND
SUBROUTINE srand(seed)
INTEGER, INTENT(IN) :: seed
END SUBROUTINE srand
Re-initializes the random number generator. See the srand() function for details. (page21)"

Even in comp.lang.fortran news, I found a Subroutine Sleep@(time) but yet it doesn't function; perhaps it's for another plataform.

Indeed, I need to put my program "sleeping" and if you could tell me how, don't be scared with my ignorance, I'm dealing with it a long ago Wink and *she* is a good girl.

Thank you Paul.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Dec 21, 2007 1:16 pm    Post subject: Reply with quote

Since your SLEEP subroutine contains no code, it shold certainly execute much faster than 100 seconds! If you want to put code into it in the form of a loop, you could repeatedly call one of the FTN95 time-and-date routines (there are many of them - see the help file) and check if 100 seconds have elapsed. Store the first time you get, and compare the new time to that. RETURN when the 100 seconds have elapsed.

However, you will still be disappointed, as there is no way that your code changes the year, which will always report 2007 - even if you run this in 2008.

If you don't want your SLEEP routine to fail if called around midnight, then you have to watch for that case and adjust accordingly.

Turning now to the code you posted, if you run it through FTN95, you will see that your program and the subroutine are both named SLEEP - something FTN95 doesn't think much of. Correct (say) the program name to SLEEPER and it runs.

Just what did you expect to happen?

E
Back to top
View user's profile Send private message
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Fri Dec 21, 2007 2:23 pm    Post subject: Re: Reply with quote

LitusSaxonicum wrote:
Since your SLEEP subroutine contains no code, it shold certainly execute much faster than 100 seconds!


Thanks LitusSaxonicum. My intention is to stop the processing of data during a small time, so that the processor stops the full-time usage (100% usage).

Quote:
If you want to put code into it in the form of a loop, you could repeatedly call one of the FTN95 time-and-date routines (there are many of them - see the help file) and check if 100 seconds have elapsed. Store the first time you get, and compare the new time to that. RETURN when the 100 seconds have elapsed.

However, you will still be disappointed, as there is no way that your code changes the year, which will always report 2007 - even if you run this in 2008.

If you don't want your SLEEP routine to fail if called around midnight, then you have to watch for that case and adjust accordingly.


May be this subroutine makes that:

Program asd
INTEGER SECONDS

....
CALL CPU_TIME(TIME1)
....
CALL CPU_TIME(TIME2)
SECONDS = TIME2 - TIME1
IF SECONDS > 100 THEN
???
???
END IF
...
...
...
....
END

SUBROUTINE CPU_TIME(TIME)
REAL,INTENT(OUT)::TIME
END SUBROUTINE


After knowing that seconds is > 100 how do I stop the processing?


Quote:
Turning now to the code you posted, if you run it through FTN95, you will see that your program and the subroutine are both named SLEEP - something FTN95 doesn't think much of. Correct (say) the program name to SLEEPER and it runs.

Just what did you expect to happen?

E


Yes it runned. However it didn't "sleeped" Confused

Thanks.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Fri Dec 21, 2007 2:31 pm    Post subject: Reply with quote

My apologies there is indeed a FTN95 routine called SLEEP@.

Here is a sample program...

Code:
PRINT*,"This program will terminate in 10 seconds..."
CALL SLEEP@(10.0)
END
Back to top
View user's profile Send private message AIM Address
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Fri Dec 21, 2007 5:25 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
My apologies there is indeed a FTN95 routine called SLEEP@.

Here is a sample program...

Code:
PRINT*,"This program will terminate in 10 seconds..."
CALL SLEEP@(10.0)
END


Great, thanks Paul.

I think that it's called an "intrinsic function", isnīt it?

It really pauses the processing but ... it doesn't stop the processor usage. The program goes on in CPU usage = 100% Sad
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Dec 22, 2007 3:13 pm    Post subject: Reply with quote

I expect that SLEEP@ repeatedly calls the internal clock, and as a result, makes the cpu rather busy. It makes your program "sleep", not the cpu.

As regards the cpu getting hot, have you done anything as mundane as taking the side panel off your computer and checking that the cpu heatsink and fan aren't blocked up with dust? Some cheap coolers have sleeve bearings that wear out: the ball bearing type is better but more expensive. Maybe your cooling fan is running slow? You can buy high-powered replacement coolers from a variety of sources, and if you don't mind the noise, extra cooling fans for the case. (Even a new case, with extra fans, might solve the problem). Your cpu should run too hot to touch, but it shouldn't overheat so that it causes errors, even if it is running continuously at 100%.

You may find in the BIOS settings of your computer that you can set the processor to slow down if the temperature exceeds a threshold. I had this once set so that the computer slowed down at normal running temp - it got as far as booting then ran at half speed!

If it isn't the heat INSIDE the computer that is the problem, but the heat that it kicks out when running, then why not try ducting it to the outside? All the exhausts are on the back, so you can even balance it on a window ledge with its backside out of the window! I find that in the summer my home office (which is a wooden house at the end of the garden) used to get unbearably hot. I put the PC outside on the deck and ran the cables in through the window! Flat screens are so much cooler than CRTs that I didn't have to do this last summer at all however.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Sat Dec 22, 2007 3:47 pm    Post subject: Reply with quote

Yes you are right. SLEEP@ turns out to be yield process and the name is misleading.

There is an alternative (undocumented) SLEEP1@ that appears to be a genuine sleep process so it does not take over the CPU. It has the same argument.
Back to top
View user's profile Send private message AIM Address
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Sat Jan 12, 2008 5:23 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
Yes you are right. SLEEP@ turns out to be yield process and the name is misleading.

There is an alternative (undocumented) SLEEP1@ that appears to be a genuine sleep process so it does not take over the CPU. It has the same argument.


Thank you very much Paul Very Happy It functions very well

Sorry for the delay answering to you Sad
Back to top
View user's profile Send private message
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Sat Jan 12, 2008 5:31 pm    Post subject: Re: Reply with quote

LitusSaxonicum wrote:
I expect that SLEEP@ repeatedly calls the internal clock, and as a result, makes the cpu rather busy. It makes your program "sleep", not the cpu.

As regards the cpu getting hot, have you done anything as mundane as taking the side panel off your computer and checking that the cpu heatsink and fan aren't blocked up with dust? Some cheap coolers have sleeve bearings that wear out: the ball bearing type is better but more expensive. Maybe your cooling fan is running slow? You can buy high-powered replacement coolers from a variety of sources, and if you don't mind the noise, extra cooling fans for the case. (Even a new case, with extra fans, might solve the problem). Your cpu should run too hot to touch, but it shouldn't overheat so that it causes errors, even if it is running continuously at 100%.

You may find in the BIOS settings of your computer that you can set the processor to slow down if the temperature exceeds a threshold. I had this once set so that the computer slowed down at normal running temp - it got as far as booting then ran at half speed!

If it isn't the heat INSIDE the computer that is the problem, but the heat that it kicks out when running, then why not try ducting it to the outside? All the exhausts are on the back, so you can even balance it on a window ledge with its backside out of the window! I find that in the summer my home office (which is a wooden house at the end of the garden) used to get unbearably hot. I put the PC outside on the deck and ran the cables in through the window! Flat screens are so much cooler than CRTs that I didn't have to do this last summer at all however.

Eddie


Yes Eddie you were right. It was the cpu heatsink and fan that were blocked up with dust. I cleaned it as you told me and now no problem with the cpu usage/temp.

Thank you very much Very Happy
Back to top
View user's profile Send private message
Fortran77



Joined: 19 Dec 2007
Posts: 19

PostPosted: Sat Jan 12, 2008 5:32 pm    Post subject: Reply with quote

I forgot to wish you guys, Happy New Year Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group