# Strange behavior of \`ifort\`

**URL:** https://fortran-lang.discourse.group/t/strange-behavior-of-ifort/4846
**Category:** Uncategorized
**Created:** [December 2, 2022, 12:58pm UTC](https://fortran-lang.discourse.group/t/strange-behavior-of-ifort/4846 "2022-12-02T12:58:03Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![septc](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/septc/32/77_2.png) [@septc](https://fortran-lang.discourse.group/u/septc)
#### Post date: [December 2, 2022, 3:49pm UTC](https://fortran-lang.discourse.group/t/strange-behavior-of-ifort/4846/8 "2022-12-02T15:49:58Z")

</div>

Hello,  
This is a somewhat simplified version of the code, where I just used `1/real(i)` to generate array elements and made the array `S` symmetric afterward. Then, if I divide `S` by `tmp`, the `S` becomes not symmetric. If I attach the `-fp-model stric` or `-check all` option (in addition to `-O3`), the `S` becomes symmetric again. The result also becomes symmetric if I multiply by `tmp` (rather than division).

```fortran
program test                                                                            
implicit none                                                                                                                                                                                                        
integer :: i                                                                                                                              
real, parameter :: A(25) = [( 1 / real(i), i=1,25 )]
real :: S(5, 5), tmp                                                                                                           
                                                                                                                                     
S = reshape(A, [5, 5])                                                                                                               
S = ( S + transpose(S) ) / 2

print *, "S(before) = "
print *, S
print *, "symmetric? ", all(abs(S - transpose(S)) <= 0)                                                                                         

tmp = 10                                                                                                                                     
S = S / tmp !! not symmetric (-O3), symmetric (-O3 -fp-model strict or -chek all)
!! S = S * tmp !! symmetric (-O3)

print *
print *, "S(after) = "
print *, S                                                                                                                                    
print *, "symmetric? ", all(abs(S - transpose(S)) <= 0)      

print *
print *, "error in symmetry"
print *, abs(S - transpose(S))
                                                                                                                                     
end program

```

I am not familiar with recent ifort options, but apart from the precision stuff, is it possibly related to some optimization that breaks the symmetry of `S`…?

(I tried it with Compiler explorer here. [code + result](https://godbolt.org/z/hba8jMbKv) )

---

_[View the full topic](https://fortran-lang.discourse.group/t/strange-behavior-of-ifort/4846)._
