Silverfrost Forums

Welcome to our forums

help with sleep1@

2 Apr 2015 7:01 #16095

Hi;

I'm trying to get my program to sleep without using CPU time.

Sleep1@ seems to be the answer but adding it to the program does nothing.

Do I have to invoke a library or something? The examples I've found just show the call.

TIA,

Roger

2 Apr 2015 7:51 (Edited: 3 Apr 2015 2:10) #16096
use clrwin
do i=100,1,-1
CALL TEMPORARY_YIELD@
call sleep1@(0.5)
print*,' Ticking. At the count 0 you lose your harddrive ', i
enddo
end
2 Apr 2015 8:17 #16097

That seems to work but isn't it using CPU time between ticks?

I want it to sleep until called by another program.

Roger

2 Apr 2015 9:18 #16099

The call to temporary_yield@ might be useful if this were part of ClearWin+ code where it would allow the Windows message queue to be consumed.

sleep1@ with temporary_yield@ is the same as sleep@.

sleep1@ just calls the Microsoft function Sleep and this is simply a call to wait, allowing other apps to do their own thing.

I think that we need more information about what you want to do. What action would trigger the application to wake up?

2 Apr 2015 9:38 #16102

I'm not sure. It's a program I'm developing for someone else. He has a big Perl program and wants Fortran to speed things up.

I'm supposing that Perl will call this program as and when needed and he doesn't want Fortran to use up CPU time while waiting.

Roger

2 Apr 2015 10:06 #16103

One way would be to get the Perl program to spawn the Fortran program rather than have it waiting around.

If you really want both programs up and running then you could get the Perl program to create a file (containing data) when it wants the Fortran to do something. The Fortran would check if the data file exists on each tick etc..

There are many other possibilities.

2 Apr 2015 10:17 #16104

Is there a source for more information?

The problem I'm having with F95 is the lack of examples.

I'm coming back to fortran after many years of TrueBasic. My first language was fortran IV and versions thereafter until I needed graphics, at which point I switched to TB

Now I need a fast modern language and F95 looks like it. I just wish it wasn't so expensive.

Roger

3 Apr 2015 12:04 #16105

You have not made it clear why you need to call Sleep@ or similar routines.

If you are using a Fortran DLL to speed things up, the caller (Perl?) should defer making the call to the DLL until it has all the needed data to be sent to the Fortran routine. The DLL is then called and will do its assigned task as quickly as possible, and return control to the caller.

What is wrong with this description of what is needed?

3 Apr 2015 3:39 #16106

I can't say for sure at this time. I need to talk to the person I'm writing this for.

Roger

3 Apr 2015 5:02 #16107

Quoted from PaulLaidler

sleep1@ with temporary_yield@ is the same as sleep@.

My damn English...Not quite got what that means. What this program shows you in task manager CPU utilization respect to previous one?

use mswin
do i=1,100
call sleep@(0.5)
print*,' sucking'
enddo
end
3 Apr 2015 8:43 #16108

My apologies Dan. I should have checked the code for sleep@ rather than relying on my memory.

sleep@ does not call Sleep, it just repeatedly calls temporary_yield@.

3 Apr 2015 10:18 (Edited: 3 Apr 2015 2:13) #16110

Welcome to my club, Paul, if you like me also forget your keys, phone, wallet and if you wear then possibly glasses

3 Apr 2015 11:39 #16111

Paul's suggestion to spawn a copy of the Fortran program when it is required is most sensible, but seems to have been lost in the middle of this thread. It would consume no cpu time and no RAM, and the loss would only be the time taken to load and initialise the program when it was spawned.

Communication between the previous 'incarnation' and the new one can be done with disk files, and subject the precise timings delays etc, the info might be still in the disk cache, and therefore speedily accessible.

Eddie

4 Apr 2015 2:02 #16120

Thanks to all who responded.

My client is happy with SLEEP1@

Now he wants chart plotting so I'm off to explore that.

Roger

4 Apr 2015 6:06 #16122

That is easy and not that easy in the same time. In Clearwin+ you can do everything from ground zero with its powerful graphics libraries capable of plotting any thickness and color lines for curves and axis, any backgrounds, take any ourt of hundreds of modern fonts which exist in your computer (and all the utilities to know their height and length to place them ideally on the plotting board). This way you create your own completely controllable plotting utilities and can tune them up eventually to reach super quality and usability for decades since they will be always needed till your last days. And all that in Fortran and hence simple. 2D and 3D plots are also doable, also all in Fortran (and OpenGL). I have done all that. But that will take time initially, may be a month total or more depending on quality needed. But you will be happy. You will never happy with 3rd party software and it always die, so no one supports it. I used 3-4 of them, they disappeared or close to go to oblivion. All look primitive.

If you need your single plot with 1-3 curves in 3 minute then Simpleplot %pl is OK. Look at this forum's discussions on Simpleplot during last year.

4 Apr 2015 7:39 #16123

Thanks but I haven't found easy and fortran to coincide much. Plato catches my syntax errors and tells me what line but why is another matter. Sample code is REALLY needed for novices like me.

Run errors, forget it. The messages tell me nothing.

Clearwin+ will probably do the job from what little I've seen but may be overkill.

Roger

5 Apr 2015 9:21 #16127

Quoted from rogerh Thanks but I haven't found easy and fortran to coincide much. Roger

OK, i am in total Zeitnot lately but give me 10 examples of what you consider simple in programming outside Fortran and me or others here will show you that in 9 out of 10 cases Fortran will beat them in

  • simplicity (more natural, intuitive syntax, smaller code size, availability of legacy math, natural sciences and engineering libraries and examples),
  • quality (code reliability, depth of error diagnostics, debugging efficiency) and
  • final code speed.
5 Apr 2015 1:39 #16128

Quoted from John-Silver maybe if you posted an example of the type of typical plot complexity you'll be trying to generate we could give you a 5-min opinions of if it's feasible with the %pl which Dan mentioned, or whether you should go from basics. Just post an example of the most complex plot you would be generating (post one from the existing program generates and then if you think you'll need to improve it then do one in Excel for example so we can see what you're looking to achieve). Best approach if you don't want to waste too much time cause as Dan says, there are a few mines out there in 'Simpleplot' to be avoided.

Thanks but I've tabled the plotting for now. I'm leaving it up to the client as to how to proceed.

If he wants fortran to do it, I'll be back.

5 Apr 2015 2:04 #16129

OK, i am in total Zeitnot lately but give me 10 examples of what you consider simple in programming outside Fortran and me or others here will show you that in 9 out of 10 cases Fortran will beat them in

  • simplicity (more natural, intuitive syntax, smaller code size, availability of legacy math, natural sciences and engineering libraries and examples),
  • quality (code reliability, depth of error diagnostics, debugging efficiency) and
  • final code speed.

Whoa! I have no doubt you are correct for the most part. Remember, I'm switching to fortran for those very reasons. The only point I would argue is syntax. I've programmed in TrueBasic for many years (I'm 80 now) so it's syntax reads like english to me. Fortran is more terse in comparison.

For example in TB it's FOR i = 1 to 200. F95 doesn't have that. It uses DO i = 1,200. A minor difference but less readable. The IF statements are similar but fortran insists on logical comparisons while TB accepts math comparisons. Types are a particular sore point; TB doesn't require them while fortran is fanatical about it.

These are all differences of approach and no doubt fortran is superior. I'm not saying otherwise, I'm just commenting as a novice on things which make converting difficult.

Roger

5 Apr 2015 6:20 #16130

[quote='rogerh']

[quote:5185671b2b] For example in TB it's FOR i = 1 to 200. F95 doesn't have that. It uses DO i = 1,200. A minor difference but less readable.

Well, to my eye it does not look more readable then Fortran because FOR and equal sign still are keywords and despite very small they meed clarification. I understand if it was

Do from 1 to 200

it would be indeed purely humanly readable. We would probably ask Paul to include that as an extension to lead this Fortran to be eventually almost humanly readable. Will be good marketing point by the way

Please login to reply.