- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider the following small piece of code (Fortran77) run on 32bit architecture:
In this case I would assume "C - (A - B)" would give me "zero" (0.0D0), but it doesn't on Linux. If I compile the same piece of code in Windows, it gives me zero. By the way, if I use Absoft ProFortran compiler I also get zero. Why is this happening? Can I do something with compiler flags? I tried "-O1" and "-O2", but they didn't help me. Simple compiler string was
ifort -O -o test test.f
Result from Linux:
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 -3.5527136788005009293556213E-15
Result from Windows:
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 0.0000000000000000000000000E+00
Using the compiler option "-pc64" on Linux did not affect the output. Changing the compiler option to "/Qpc80" on Windows made the output equal the one from Linux. The two physical computers are equal, "only" the operating system differs.
Any idea of what I could do to get consistent results from the two compilers?
Compiler versions:
Windows: 11.0.066
Linux: 11.1.046
I also tried with 10.1.022 for Linux with same result.
Regards
Espen
PROGRAM TEST
C
IMPLICIT NONE
DOUBLE PRECISION A, B, C
C
A = 319.0D0 / DACOS(-1.0D0)
B = 761.0D0 / 93.0D0
C = A - B
C
WRITE(6, '(3EN35.25)') C, A - B, C - (A - B)
C
END
In this case I would assume "C - (A - B)" would give me "zero" (0.0D0), but it doesn't on Linux. If I compile the same piece of code in Windows, it gives me zero. By the way, if I use Absoft ProFortran compiler I also get zero. Why is this happening? Can I do something with compiler flags? I tried "-O1" and "-O2", but they didn't help me. Simple compiler string was
ifort -O -o test test.f
Result from Linux:
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 -3.5527136788005009293556213E-15
Result from Windows:
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 0.0000000000000000000000000E+00
Using the compiler option "-pc64" on Linux did not affect the output. Changing the compiler option to "/Qpc80" on Windows made the output equal the one from Linux. The two physical computers are equal, "only" the operating system differs.
Any idea of what I could do to get consistent results from the two compilers?
Compiler versions:
Windows: 11.0.066
Linux: 11.1.046
I also tried with 10.1.022 for Linux with same result.
Regards
Espen
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compile with: -assume protect-parens (Linux) or /assume:protect-parens (Windows). The default is noprotect-parens.
I see consistent compiler treatment and resultsacross Linux and Windows.
Linux
$ ifort -V u68415.f90 -o u68415
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090827 Package ID: l_cprof_p_11.1.056
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Intel Fortran 11.1-2582
GNU ld version 2.17.50.0.6-5.el5 20061020
$ ./u68415
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 -3.5527136788005009293556213E-15
$ ifort -V u68415.f90 -o u68415 -assume protect-parens
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090827 Package ID: l_cprof_p_11.1.056
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Intel Fortran 11.1-2582
GNU ld version 2.17.50.0.6-5.el5 20061020
$ ./u68415
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 0.0000000000000000000000000E+00
Windows
$ ifort u68415.f90
Intel Visual Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090511 Package ID: w_cprof_p_11.1.035
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
-out: u68415.exe
-subsystem:console
u68415.obj
$ .u68415.exe
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 -3.5527136788005009293556213E-15
$ ifort /assume:protect-parens u68415.f90
Intel Visual Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090511 Package ID: w_cprof_p_11.1.035
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
-out: u68415.exe
-subsystem:console
u68415.obj
$ .u68415.exe
93.3580579937044916505328729E+00 93.3580579937044916505328729E+00 0.0000000000000000000000000E+00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can confirm your results and I now get consistent output from Linux and Windows. It is really possible to get a bit lost in all these compilation options...
Thank you so much for the help. It is highly appreciated.
Thank you so much for the help. It is highly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - espenbe
It is really possible to get a bit lost in all these compilation options...
Thank you so much for the help. It is highly appreciated.
Thank you so much for the help. It is highly appreciated.
Indeed it is. There are a lot of them andI cetainly do not remember them all myself.
Glad I could help.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page