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

fortran bug

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 17, 2008, 22:21
Default fortran bug
  #1
taw
Guest
 
Posts: n/a
I find the following bug in Fortran. Can some one advise why this occur?

What is the best strategy to avoid such possible errors. I appreciate for taking your time to answer me.

the simple code is:

!!!program explain.f

implicit none

double precision a,b

a=5.

b=25.

print*,"this is 'ok'!?",1./(a*b),(a*b)**-1.

print*,"why 'not ok' now?",1./(a*b)/(1.d10)**.2,

> ( a*b)**-1./(1.d10)**.2

stop

end !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

the following is how it is complied and run ~/ifort explain.f ~/./a.out this is 'ok'!? 8.000000000000000E-003 8.000000000000000E-003 why 'not ok' now? 7.999999451020953E-005 0.952863960639244

  Reply With Quote

Old   August 18, 2008, 09:08
Default Re: fortran bug
  #2
jinwon park
Guest
 
Posts: n/a
It is a common error for beginners. Do like this

a=5.d0 b=25.d0

"d0" makes real numbers double-precision. Take care
  Reply With Quote

Old   August 18, 2008, 12:55
Default Re: fortran bug
  #3
underGroundMan
Guest
 
Posts: n/a
Hi

I am using Windows XP on a 32-bit system. I have recently installed "Compaq Visual Fortran 6.1", standard edition on my system. Is this compiler compatible with CFX?

I have tried to compile subroutine in tutorial 9 but I am getting following error:

ERROR CCL parser failed with message: Perl Syntax errors detected: Died at (eval 59) line 12.

How can I get rid of this error? Thanks in advance for your answer.

Regards

  Reply With Quote

Old   August 18, 2008, 20:31
Default Re: fortran bug
  #4
taw
Guest
 
Posts: n/a
Sorry Jinwok,

That does not change the bug yet. Can you copy and paste in your pc and check it yourself.

Regards

Taw
  Reply With Quote

Old   August 19, 2008, 02:20
Default Re: fortran bug
  #5
hadian
Guest
 
Posts: n/a
this is not a bug. it calculates / and * from right to left and can save only 15 meaningful digit (for double precision number.) so digits more than 15 are dropped. if you change 1.d10 to 1.d5 you will see that there is no problem.
  Reply With Quote

Old   August 19, 2008, 02:44
Default Re: fortran bug
  #6
taw
Guest
 
Posts: n/a
Hi Hadian, thanks for the response

I tried what you suggested, but I haven't still got as it should be for me, maybe double exponentiation may not be allowed. But even for these I write numbers like 10.d0, instead of 1.d10 or 1.d5, it didn't remove the bug!

Regards,

Tilek
  Reply With Quote

Old   August 19, 2008, 03:10
Default Re: fortran bug
  #7
hadian
Guest
 
Posts: n/a
change the line: print*,"why 'not ok' now?",1./(a*b)/(1.d10)**.2,(a*b)**-1./(1.d10)**.2 with: print*,"why 'not ok' now?",1./(a*b)/(1.d10)**.2,( a*b)**(-1.)/(1.d10)**.2

(just put -1 in parentheses.)
  Reply With Quote

Old   August 19, 2008, 03:53
Default Re: not a fortran bug
  #8
taw
Guest
 
Posts: n/a
Hi Hadian,

Thank you very much. I have got it to working now. I will in the future give special care when writing routines like this.

Thanks,TAW
  Reply With Quote

Old   August 19, 2008, 05:03
Default Re: Compaq Visual Fortran 6.1-fortran bug
  #9
student
Guest
 
Posts: n/a
Am using the same compiler BUT I can not use files with:

USE file

i.e. I can not compile with the USE statement. I have to go back to the traditional fortran. Do you have any idea how to be able to use this statement and to let the compiler see it.

Thanks.

  Reply With Quote

Old   August 19, 2008, 08:29
Default Re: Compaq Visual Fortran 6.1-fortran bug
  #10
underGroundMan
Guest
 
Posts: n/a
Hi Student

I have just installed compaq compiler. I am not even sure if this compiler is compatible with CFX. Are you using CFX? As I said I could not even compile a subroutine in tutorial 9. Any idea what could be wrong?

Thanks

  Reply With Quote

Old   August 20, 2008, 05:37
Default Re: Compaq Visual Fortran 6.1-fortran bug
  #11
student
Guest
 
Posts: n/a
I did not use it â€" try this one it may work.

http://g95.org/

have a nice journey!

  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 05:37
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 hawk Main CFD Forum 1 April 12, 2005 22:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 20:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 15:16
Why Favoring Fortran over C/C++? Zi-Wei Chiou Main CFD Forum 35 September 26, 2001 09:34


All times are GMT -4. The time now is 15:23.