File: array_concat.f90

package info (click to toggle)
lfortran 0.58.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,512 kB
  • sloc: cpp: 162,179; f90: 68,251; python: 17,476; ansic: 6,278; yacc: 2,334; sh: 1,317; fortran: 892; makefile: 33; javascript: 15
file content (46 lines) | stat: -rw-r--r-- 997 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
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