|
[Sponsors] |
April 27, 2004, 20:10 |
a strange question about Fortran
|
#1 |
Guest
Posts: n/a
|
Hi, guys:
I got a strange problem which I can't figure out. I use a simple 2nd-order center difference scheme to solve a first order oridinary differential equation. When I use default f77 to compile my code and run, I can get the right results compared with analytical solution. And the result is improved when the number of grids changes from 100 to 1000. But beyond 10000, the results is wrong. when I use f77 -i8 option to compile my code which supposed to give me better solution. But I find this is wrong. The result becomes worse. And when I use different grids, 100, 1000 and 10000, the results are almost the same ... so I didn't know what happened. Is something need to be noticed with the -r8 option? My code seems ok with only 80 lines. anyone can give me some suggestion? Thanks in advance! |
|
April 29, 2004, 19:33 |
Re: a strange question about Fortran
|
#2 |
Guest
Posts: n/a
|
Try to compile the code using all possible debug options (check for array out of bounds...etc) for your compiler (non-optimized) and then run it. You might be able to track some errors.
|
|
May 3, 2004, 19:38 |
Re: a strange question about Fortran
|
#3 |
Guest
Posts: n/a
|
thanks a lot can't log on this forum for two days... can you tell me some details about debugging? or any links? Thank you very much.
|
|
May 4, 2004, 03:59 |
Re: a strange question about Fortran
|
#4 |
Guest
Posts: n/a
|
First, find out where is the manual or user guide coming with the compiler. If it is SGI or GNU or some other compiler, you can google the manuals. have a look for example to http://www.star.le.ac.uk/~cgp/fortran.html
Second, your problem seem pretty much like the misdeclaration or array bounds problem. Try to download and use ftncheck program ( http://www.dsm.fordham.edu/~ftnchek/ ) put the 'implicit none' before the declaration of variables and declare correctly all variables. use compiler switches for checking the code - they're different for different compilers. debugging: find the info on the web. generally, -g switch of the compiler will put the debugging info to the code and you can cosnequently run the program in the debugger (gdb, dbx on SGI, xfx for ABSOFT .....), it can print the variables and other info. good luck matej |
|
May 6, 2004, 21:34 |
Re: a strange question about Fortran
|
#5 |
Guest
Posts: n/a
|
thanks a lot! I just figureed out the problem.
|
|
May 7, 2004, 20:13 |
Re: a strange question about Fortran
|
#6 |
Guest
Posts: n/a
|
Can you tell me : What was the problem??? Your discovery might help me a lot.
|
|
May 16, 2004, 19:56 |
Re: a strange question about Fortran
|
#7 |
Guest
Posts: n/a
|
oh, very sorry, didn't come here for a week
In my code, there is a do loop, the parameter should be 1 (one), but I type a l (letter l) there...... kind of stupid ...... |
|
May 17, 2004, 07:54 |
Re: a strange question about Fortran
|
#8 |
Guest
Posts: n/a
|
to avoid such a stupid typos, put an 'implicit none' statement before declaring variables. It'll give you the error during compilation.
matej |
|
May 17, 2004, 15:54 |
Re: a strange question about Fortran
|
#9 |
Guest
Posts: n/a
|
thank you very much! learned another skill
|
|
May 18, 2004, 03:48 |
Re: a strange question about Fortran
|
#10 |
Guest
Posts: n/a
|
It is a good idea to enforce declaration of all variables. However, in this specific case, if there is a declared integer variable l (l.c. L), this trick won't help.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fortran Compiler-CFX12.1 | Araz | CFX | 13 | March 27, 2017 06:37 |
Fortran question | Noureddine | Main CFD Forum | 12 | October 31, 2007 14:07 |
Question for Fortran experts | jojo | Main CFD Forum | 5 | September 27, 2006 09:30 |
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 | hawk | Main CFD Forum | 1 | April 12, 2005 23:13 |
Stack frame size, Origin 2000, fortran, a question. | Sergei Chernyshenko | Main CFD Forum | 4 | February 22, 1999 15:24 |