File: array_concat.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 (46 lines) | stat: -rw-r--r-- 997 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
43
44
45
46
program array_concat
integer :: A = 2
integer :: B(3) = [1,2,3]
real :: x(4) = [1.0, 2.0, -3.0, 4.0]
integer, allocatable :: B2(:)
integer :: C(4) 
logical :: D(4)

C = [B, A]
print *, C
if( C(1) /= 1 .or. C(2) /= 2 .or. C(3) /= 3 .or. C(4) /= 2 ) error stop
print *, B(1:3)

D = [B, A] > 1
print *, D
if( any(D .neqv. [.false., .true., .true., .true.]) ) error stop

allocate(B2(size(B)))
B2 = B
D = [B2, A] > 1
print *, D
if( any(D .neqv. [.false., .true., .true., .true.]) ) error stop

D = [B([3,2,1]), A] > 1
print *, D
if( any(D .neqv. [.true., .true., .false., .true.]) ) error stop

D = [B2(2:3), A, A] > 1
print *, D
if( any(D .neqv. [.true., .true., .true., .true.]) ) error stop

call temp(x)
contains
subroutine temp(x)
     real, intent(in) :: x(:)
     real :: xx(size(x)) 
     real :: tn(size(x) - 1) 
    logical :: y
     tn = x(1:size(x)-1)
     xx = x
    y = any(xx <= 0 .and. abs([tn, 0.0]) > 0)
    print *, y 
    if( y .neqv. .true.) error stop
end subroutine

end program