For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2006 > g77 double precision data initialization problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author g77 double precision data initialization problem
mvuk

2006-03-21, 10:05 pm

Hello, I've got a rather obvious looking problem that seems to elude
me. Using g77 (3.4.2 in mingw on windows) I don't seem to be able to
initialize double variables properly. I'm trying to set a variable X to
a value of 1.0 and depending on how I specify 1.0 I get either 1.0 or
0.0 as a result: /1.0D0/ gives me a result of 0 while /1.0/ works fine.
The work-around seems to be to compile with the -fzeros flag (ie. "g77
-fzeros try_this.f" rather than just "g77 try_this.f") but I don't
understand why this is necessary and g77 documentation even suggests
this is a deprecated option. I've also tried this with the Watcom
compiler and not had any trouble. Here's the simple program:

PROGRAM TRY_THIS

DOUBLE PRECISION X

DATA X
C + /1.0/
+ /1.0D0/
C + /1.0D+00/
C + /0.1D+01/
C + /0.213D+00/

WRITE (6,1000) X
1000 FORMAT ('X = ',D12.5)

END

Joe Krahn

2006-03-21, 10:05 pm

mvuk wrote:
> Hello, I've got a rather obvious looking problem that seems to elude
> me. Using g77 (3.4.2 in mingw on windows) I don't seem to be able to
> initialize double variables properly. I'm trying to set a variable X to
> a value of 1.0 and depending on how I specify 1.0 I get either 1.0 or
> 0.0 as a result: /1.0D0/ gives me a result of 0 while /1.0/ works fine.
> The work-around seems to be to compile with the -fzeros flag (ie. "g77
> -fzeros try_this.f" rather than just "g77 try_this.f") but I don't
> understand why this is necessary and g77 documentation even suggests
> this is a deprecated option. I've also tried this with the Watcom
> compiler and not had any trouble. Here's the simple program:
>
> PROGRAM TRY_THIS
>
> DOUBLE PRECISION X
>
> DATA X
> C + /1.0/
> + /1.0D0/
> C + /1.0D+00/
> C + /0.1D+01/
> C + /0.213D+00/
>
> WRITE (6,1000) X
> 1000 FORMAT ('X = ',D12.5)
>
> END
>


Looks like a bug in that version/build of g77. g77 in Linux compiles
this OK. Using -fzeros should not make a difference. If that is the
latest MinGW-g77, try an earlier one, and maybe send in a bug report.

g77 supports the f90 syntax for initialization. Try the following and
see if you get the same problem:

DOUBLE PRECISION :: X = 1.0

Joe Krahn
e p chandler

2006-03-21, 10:05 pm


Joe Krahn wrote:
> mvuk wrote:
>
> Looks like a bug in that version/build of g77. g77 in Linux compiles
> this OK. Using -fzeros should not make a difference. If that is the
> latest MinGW-g77, try an earlier one, and maybe send in a bug report.
>
> g77 supports the f90 syntax for initialization. Try the following and
> see if you get the same problem:
>
> DOUBLE PRECISION :: X = 1.0
>
> Joe Krahn


Already listed in GCC Bugzilla as Bug 17541 (version 3.4.2)

[3.4 Regression] [g77] data statements with double precision constants
fail

STATUS: FIXED

-- Elliot

Paul Van Delst

2006-03-22, 7:03 pm

Joe Krahn wrote:
> mvuk wrote:
>
>
> Looks like a bug in that version/build of g77. g77 in Linux compiles
> this OK. Using -fzeros should not make a difference. If that is the
> latest MinGW-g77, try an earlier one, and maybe send in a bug report.
>
> g77 supports the f90 syntax for initialization. Try the following and
> see if you get the same problem:
>
> DOUBLE PRECISION :: X = 1.0


Or, in double-precision-ese,

DOUBLE PRECISION :: X = 1.0d0

cheers,

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
mvuk

2006-03-22, 7:03 pm

Thanks for the replies. It is indeed a resolved bug and I was able to
get gcc 3.4.5 and achieve correct results - thanks again!

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com