File: declaration_01.f90

package info (click to toggle)
lfortran 0.59.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 56,736 kB
  • sloc: cpp: 168,052; f90: 74,272; python: 17,537; ansic: 7,705; yacc: 2,345; sh: 1,334; fortran: 895; makefile: 37; javascript: 15
file content (27 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (4)
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
program declaration_01
    implicit none
    integer, parameter :: xi = 2
    real, parameter :: xr = 2.0
    ! real array initialized with integer constant value
    real, parameter :: x_real_3(3) = xi

    ! complex array initialized with integer constant value
    complex, parameter :: x_cmplx_3(3) = xi

    ! integer array initialized with real constant value
    integer, parameter :: x_int_3(3) = xr
    real :: y(2) = real([2, 3])

    print *, x_real_3
    if (any(x_real_3 /= xi)) error stop

    print *, x_cmplx_3
    if (any(x_cmplx_3 /= (xi, 0))) error stop

    print *, x_int_3
    if (any(x_int_3 /= xr)) error stop

    print *, y
    if (abs(y(1) - 2.0) > 1e-7) error stop
    if (abs(y(2) - 3.0) > 1e-7) error stop
end program declaration_01