Show Bid Request
Fortrain and C program
Bid Request Id: 8214
|
|
|
Posted by: |
seatiger74 (25 ratings)
(Software buyer rating 10)
|
Posted: |
Jan 31, 2002 12:05:36 AM EDT
|
Bidding Closes: |
Feb 14, 2002 12:06:31 AM EDT
|
Viewed (by coders): |
165 times
|
|
|
|
Description:
Programming Languages Assignment 1 (Write 2 programs, one in Fortran and one in C, both do the same thing as described below)
In this first assignment, since we have been discussing efficiency and FORTRAN, let's run a race between FORTRAN and C on the RS-6000 system. I have made a function to allow you to do CPU timings from FORTRAN (by calling on C), and so what we will do is a long winded series of floating point computations and CPU time the thing. You will simply write a FORTRAN module to do numerical integration and CPU time how long it takes, using 1 million subintervals. I will discuss FORTRAN in class; here I will simply outline the trapezoidal rule, and how to do the CPU timing.
For CPU timing, first get the file getclock.o as with
getfile getclock.o
Then in your FORTRAN code, use
implicit real*8(a-h,o-z) external getclock start = getclock(0) ... elap = (getclock(0) - start) / 1000000.d0
Then, elap is the CPU elapsed time in seconds that ... took to do.
Trapezoidal rule: To integrate a function f(x) over an interval [a,b] with n subintervals, break up [a,b] into n equal subintervals a = x0 < x1 < x2 < ... < xn = b and let h = (b - a) / n = width of each subinterval. Then the integral of f over [a,b] is approximately
h * (f(a)/2 + f(x1) + f(x2) + ... + f(xn-1) + f(b)/2)
Use the following function to integrate :
f(x) = (tan(atan(exp(log(sqrt(x * x)))))) ** 2
To compile your code, use
f77 -O myfile.f getclock.o
which will make executable a.out if it compiles OK.
In the C version, just call clock() to get the start and elapsed time, and then divide the difference by CLOCKS_PER_SEC as a double to get the elapsed time in seconds.
Be sure in both cases to print the approximated integral value! Mathematically you are integrating x^2 over [0,1] so the exact answer is just 1/3 (0.333333...). However due to floating point roundoff, the result will likely be a bit off.
Deliverables: Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased.
Special Conditions / Other:
Mon 2/4/02
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation, you can report it to: abuse@rentacoder.com.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
This bid was accepted by the buyer!
|
$10 (USD)
|
Feb 1, 2002 12:15:12 AM EDT
|
10
(Excellent)
|
|
|
Hello Colleague!
Here in Arkansas, I've just finished testing of both F77 and C code for you project!
Precision is good - at least 12 digits are correct.
Note that in both cases integration results are equal,
that makes me feel that F77 library uses C math libary on my system.
Also note that you are not supposed to compute logarithm of zero, so I've ignored
zero point and used F(0)=0.
On my PC (Pentuim2/500Mhz) the C program runs a few percent faster
than Fortran code. Actually I've excepted F77 code to perform better. I think, it
can be caused by math functions you've selected.
Last year I've done project
involving 2D and 3D computational grids for hyperbolic partial differential
equations. Then C code was REALLY slower.
Well, I'm ready to transfer code at any moment.
I believe it's unfair to ask for bigger money for this.
Expecially if you going to use for educational purpose.
You can pay me after you recieve full package or
wait and ask me to make any updates to computational part.
Note that results can be different when you'll run these tests on your computer.
Best, Paul
|
|
|
|
|
|