Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get time in nanoseconds with Fortran code??? 1

Status
Not open for further replies.

onk

Nuclear
Jan 31, 2003
1
For my class I need to find Fortran function that will give me time in nanoseconds.
With date_and_time I can get only milliseconds.

Is there a way to do it?

thanks.
 
Replies continue below

Recommended for you

you can calculate it by multiplying ms with 1,000,000
but you can measure it only at clk resolution subject
to your clock accuracy.
<nbucska@pcperipherals.com>
 
What you want is not really controlled by Fortran. It is more a function of the operating system you are working on and the efficiency of the computer you are working with ( as nbucska suggests ).

If you are using MS Windows... I &quot;think&quot; that the best you can probably hope for is 3 digits behind the decimal point. On my Windows/Fortran system... the tightest timing I ever get back is either to 0.05 or 0.06 seconds... and those are probably only accurate to within 0.1 seconds or something.

Keep in mind.... just because you may get lots of digits back, it doesn't actually mean they are accurate. My guess is there is not a system that you are likely to be working on that is going to give you anything close to nanosecond accuracy ( no matter how many digits you are given ).

Dan :)
 
There is no FORTRAN function which could give ns accuracy
unless you have several GHz clock and welldesigned special
hardware. <nbucska@pcperipherals.com>
 
ONK,

If you look up &quot;timer&quot; code through google maybe adding Borland, they have a true microsecond routine and can't remember but I think also nanosecond timer in C code. Looking though these functions, you will be able to see how the code works down at the hardware level and actually changes a few things around to make the ubiquotous PC offhand clock rate work precisely. If you are still in need of the source code email me at: wswain@hippag.com and when I get to work I can send you the C code files. Unfortunately, we have been off fortran for quite some time now so porting the code back may be left to you.

Another thought, look up IRIG time generator on Google as there may be some Fortran code out there for free (maybe?) that meets the IRIG time standard. This may be only to the 10th of a milllisecond or 100 nanosecond resolution.

Good Luck,
Bill
 
In DOS you can use the internal timer running at 1.1938 MHz


<nbucska@pcperipherals.com>
 
You can't get nanosec. accuracy with PC for the refresh.

<nbucska@pcperipherals.com>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor