File: complex_33.f90

package info (click to toggle)
lfortran 0.61.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 61,892 kB
  • sloc: cpp: 181,767; f90: 92,175; python: 17,616; ansic: 10,170; yacc: 2,377; sh: 1,444; fortran: 892; makefile: 38; javascript: 15
file content (42 lines) | stat: -rw-r--r-- 984 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
31
32
33
34
35
36
37
38
39
40
41
42
program complex_33
    implicit none
    complex, allocatable :: z(:)
    complex :: w(3)
    real :: re_vals(3), im_vals(3)
    real :: zero = 0.0
    integer :: i
    character(len=9) :: buf

    allocate(z(3))
    z = cmplx(1.0/zero, 1.0/zero)
    do i = 1, 3
        write(buf, "(F9.0)") z(i)%im
        if (adjustl(buf) /= "Infinity") error stop
    end do

    w = (1.0, 2.0)
    re_vals = w%re
    im_vals = w%im
    do i = 1, 3
        if (abs(re_vals(i) - 1.0) > 1e-6) error stop
        if (abs(im_vals(i) - 2.0) > 1e-6) error stop
    end do

    z(1) = cmplx(1.0, 4.0)
    z(2) = cmplx(2.0, 5.0)
    z(3) = cmplx(3.0, 6.0)

    re_vals = z%re
    im_vals = z%im

    do i = 1, 3
        if (abs(re_vals(i) - real(i)) > 1e-6) error stop
        if (abs(im_vals(i) - real(i + 3)) > 1e-6) error stop
    end do

    do i = 1, 3
        if (abs(z(i)%re - real(i)) > 1e-6) error stop
        if (abs(z(i)%im - real(i + 3)) > 1e-6) error stop
    end do

end program complex_33