File: fma.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (30 lines) | stat: -rw-r--r-- 617 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
program fma

    implicit none
    real :: x = 4.0
    real, parameter :: pi = 3.14
    real(8) :: S1 = 1.0, S2 = 2.0
    real(8) :: z = 1.0

    integer ::b(10)
    real :: r

    
    x = (x * 4 + 0.5_4*sign(1._4, x)) - x * pi
    z = S1+z*S2
    if( abs(x - 3.94) > 1e-6 ) error stop
    if( abs(z - 3.0) > 1e-6 ) error stop



    b = 1
    r = 1
    b(1) = nint(sign(1.0,r +r*r), 4) ! Test FMA opt. with `--fast` (functioncall with fma nested)
    print *, b(1)   
    if(b(1) /= 1) error stop
    b(1) = r -r*r ! Test FMA opt. with `--fast` (sub op)
    print *, b(1)
    if(b(1) /= 0) error stop

end program