[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-17 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #16 from Bahram.shahrooz at uc dot edu ---
I spent a good chunk of today to debug.  The culprit was two variables that had
not been set equal to 0.  I get the same results with g77 on Windows, GFortran
on Mac Big Sur, & AbsoftTools ( I downloaded a trial version to help me debug)
on Mac Big Sur

You guys are so helpful. I truly appreciate your time and.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-17 Thread tkoenig at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

Thomas Koenig  changed:

   What|Removed |Added

 CC||tkoenig at gcc dot gnu.org

--- Comment #15 from Thomas Koenig  ---
Just one final remark.

Using gfortran -O2 -Wall FiberAnalysis.f

will give you

FiberAnalysis.f:146:72:

  146 |   if(eincr.gt.0) xnumber=(esfinal-estart)/eincr
  |   
^
Warnung: »estart« may be used uninitialized [-Wmaybe-uninitialized]
FiberAnalysis.f:146:44:

  146 |   if(eincr.gt.0) xnumber=(esfinal-estart)/eincr
  |^
Hinweis: »estart« ist hier deklariert
FiberAnalysis.f:148:9:

  148 |   if(xnumber.gt.500) then
  | ^
Warnung: »xnumber« könnte in dieser Funktion uninitialisiert verwendet werden
[-Wmaybe-uninitialized]


which pretty well shows where problems could occur.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-17 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #14 from kargl at gcc dot gnu.org ---
The code uses undefined variables.  With g77, these seem to be initialized to
some value.  If -freal-init=nan is used, the compiled program dies quickly.  In
other words, the bug is in the program not gfortran.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-16 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #13 from Bahram.shahrooz at uc dot edu ---
Thank you for your help.  I really appreciate your time.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-16 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #12 from Steve Kargl  ---
On Sat, Jan 16, 2021 at 11:20:20PM +, Bahram.shahrooz at uc dot edu wrote:
> 
> Do you've any suggestions for how to trace the source
> of error so I can fix the code?
> 

Not really.  I suppose  old fashion debugging is needed
where you put 'print' statements into the code to check
intermediate results. As far as I can tell, you simply
are using undefined variables in the code.  This isn't
a gfortran bug, so the bug report will be closed.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-16 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #11 from Bahram.shahrooz at uc dot edu ---
Thanks!

This is how I compiled: 

gfortran FiberAnalysis.f -finit-real=nan -fcheck=all -ffpe-trap=zero,invalid -o
FiberAnalysis_v2

This what I get after running (the answers are correct):

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic
operation.

Backtrace for this error:
#0  0x105c4ad3d
#1  0x105c4a16d
#2  0x7fff203c4d7c
#3  0x105c34e45
#4  0x105c3c653
#5  0x105c3cae6
zsh: floating point exception  /Users/bahram/FiberAnalysis_v2
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.

Do you've any suggestions for how to trace the source of error so I can fix the
code?

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #10 from Steve Kargl  ---
On Sat, Jan 16, 2021 at 04:48:09AM +, Bahram.shahrooz at uc dot edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701
> 
> --- Comment #9 from Bahram.shahrooz at uc dot edu ---
> Yes, thank you for finding this bug. Things didn't change after changing 
> estart
> to estrt. 
> 
> Sorry, I don't know how to use -freal-init=nan.  I tried to use it like this
> but got an error.
> 
> % gfortran FiberAnalysis.f -freal-init=nan -o FiberAnalysis
> 
> gfortran: error: unrecognized command-line option '-freal-init=nan'
> 

Whoops.  It helps if I spell it right.  -finit-real=nan

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #9 from Bahram.shahrooz at uc dot edu ---
Yes, thank you for finding this bug. Things didn't change after changing estart
to estrt. 

Sorry, I don't know how to use -freal-init=nan.  I tried to use it like this
but got an error.

% gfortran FiberAnalysis.f -freal-init=nan -o FiberAnalysis

gfortran: error: unrecognized command-line option '-freal-init=nan'

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #8 from Steve Kargl  ---
On Fri, Jan 15, 2021 at 05:21:22PM -0800, Steve Kargl wrote:
> 
> You're using undefined variables.
> 

I little more debugging, 

  read(5,*) estrt,esfinal,eincr
  if(eincr.gt.0) xnumber=(esfinal-estart)/eincr

estart is undefined here.  I suspect you want estrt.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #7 from Steve Kargl  ---
On Sat, Jan 16, 2021 at 12:51:38AM +, Bahram.shahrooz at uc dot edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701
> 
> --- Comment #6 from Bahram.shahrooz at uc dot edu ---
> I get wrong answers doing this:
> 
> gfortran FiberAnalysis.f -o FiberAnalysis
> 
> I get correct answers doing this:
> 
> gfortran FiberAnalysis.f -fcheck=all -ffpe-trap=zero,invalid -o FiberAnalysis
> 

Your code is broken.  I added -freal-init=nan to initialize
all variables to an NaN.  The compiled program dies, and the debugger
shows

% gdb ./z z.core
Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x08049476 in fsteel1 (es=nan(0x8), fs=nan(0x8), 
ibuckle=0) at FiberAnalysis.f:387
387   if(es.ge.0.0) go to 10
(gdb) p es
$1 = nan(0x8)

If I reduce the loop 'do 3000 na=1,500' by 1, i.e., I use
'do 3000 na=1,499', then the computation dies at

(gdb) bt
#0  0x0804e323 in fiberanalysis () at FiberAnalysis.f:313
#1  0x0804ed63 in main (argc=1, argv=0xffbfe864) at FiberAnalysis.f:361
#2  0x08048a37 in _start1 ()
#3  0x08048b90 in _start ()

Line 313 is 

  if(xp(k).ne.0.and.xp(k).ge.xpmin) then

and 

(gdb) p xp(500)
$4 = nan(0x8)
(gdb) p xp(499)
$5 = 2425.0013590651233

If I reduce the loop to 498, it then dies at

Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x0804e08b in fiberanalysis () at FiberAnalysis.f:302
302   if(xp(k).lt.xpmin) then
(gdb) p xp(498)
$1 = 2424.590579331998
(gdb) p xp(499)
$2 = nan(0x8)

You're using undefined variables.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #6 from Bahram.shahrooz at uc dot edu ---
I get wrong answers doing this:

gfortran FiberAnalysis.f -o FiberAnalysis

I get correct answers doing this:

gfortran FiberAnalysis.f -fcheck=all -ffpe-trap=zero,invalid -o FiberAnalysis

   Moment  Axial_Load
   3244.08910-215.38970
   3432.22199-190.65966
   3594.93500-168.86785
   3734.50302-149.77519
   3842.77168-134.14558
   3986.24344-114.80934
   4115.25069 -97.21038
   4230.37015 -81.27311
   4323.74191 -67.84354
   4442.09009 -51.57463
   4551.67144 -36.41379
   4653.40529 -22.24901
   4748.46682  -8.91886
   4844.11684   4.77310
   4933.55651  17.64818
   5017.35901  29.77892
   5097.44257  41.41472
   5193.49624  55.17913
   5275.53074  67.17330
   5351.16344  78.34124

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #5 from Steve Kargl  ---
On Sat, Jan 16, 2021 at 12:41:56AM +, Bahram.shahrooz at uc dot edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701
> 
> --- Comment #4 from Bahram.shahrooz at uc dot edu ---
> I compiled with the suggested options (below) and now the code gives the same
> result as g77.
> 
> -fcheck=all -ffpe-trap=zero,invalid
> 
> Things look good now!
> 

Those options should not fix the code.  Those should
find the error.  If you compile without these options,
do you then get wrong results.  Also, what do you 
expect.  On my system, I see

  Moment  Axial_Load
   1470.43183 134.34887
   1564.87796 144.02005
   1643.96121 152.13968
   1708.47908 158.75645
   1749.07356 162.94978

for the first few lines.

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #4 from Bahram.shahrooz at uc dot edu ---
I compiled with the suggested options (below) and now the code gives the same
result as g77.

-fcheck=all -ffpe-trap=zero,invalid

Things look good now!

Sorry for starting this bug report prematurely, and many thanks for your
help!!!

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread Bahram.shahrooz at uc dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

--- Comment #3 from Bahram.shahrooz at uc dot edu ---
Created attachment 49979
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49979&action=edit
source code

Sorry, I had to zip several files. Readme file in Archive.zip explains what the
files are.

Here's how I compiled:

gfortran FiberAnalysis.f -o0 -o FiberAnalysis

g77 -o0 FiberAnalysis.f -o FiberAnalysis

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek  ---
And given the warnings, if the code uses exact floating point comparisons, it
might behave differently if there is even 1 ulp difference (which is quite
possible on a lot of code).

[Bug fortran/98701] I compiled a program with gfortran on Mac (Big Sur, version 11.1) and g77 on Windows 10. I get two very different results for identical input files with the results from the one c

2021-01-15 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
We need
1) Course code and input file
2) Expected output generated by g77 on Windows 10.  Command line used to
   compile code.
3) Output you go on Mac.

With gfortran, try compiling with -fcheck=all -ffpe-trap=zero,invalid