CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

a strange question about Fortran

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2004, 20:10
Default a strange question about Fortran
  #1
Hall
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!
  Reply With Quote

Old   April 29, 2004, 19:33
Default Re: a strange question about Fortran
  #2
agg
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.
  Reply With Quote

Old   May 3, 2004, 19:38
Default Re: a strange question about Fortran
  #3
hall
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.
  Reply With Quote

Old   May 4, 2004, 03:59
Default Re: a strange question about Fortran
  #4
matej
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
  Reply With Quote

Old   May 6, 2004, 21:34
Default Re: a strange question about Fortran
  #5
hall
Guest
 
Posts: n/a
thanks a lot! I just figureed out the problem.
  Reply With Quote

Old   May 7, 2004, 20:13
Default Re: a strange question about Fortran
  #6
subhra
Guest
 
Posts: n/a
Can you tell me : What was the problem??? Your discovery might help me a lot.
  Reply With Quote

Old   May 16, 2004, 19:56
Default Re: a strange question about Fortran
  #7
Hall
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 ......
  Reply With Quote

Old   May 17, 2004, 07:54
Default Re: a strange question about Fortran
  #8
matej
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
  Reply With Quote

Old   May 17, 2004, 15:54
Default Re: a strange question about Fortran
  #9
Hall
Guest
 
Posts: n/a
thank you very much! learned another skill
  Reply With Quote

Old   May 18, 2004, 03:48
Default Re: a strange question about Fortran
  #10
Rami
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.
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 17:24.