File: declaration_01.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (27 lines) | stat: -rw-r--r-- 763 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
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