-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_index.f90
95 lines (87 loc) · 3.31 KB
/
test_index.f90
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
! This is file : test_index
! Author= zaikunzhang
! Started at: 14.06.2022
! Last Modified: Tuesday, June 14, 2022 PM02:51:07
! Absoft 64-bit Pro Fortran 22.0.2 on Ubuntu 20.04 raises the following errors
!
! $ af95 test_index.f90 && ./a.out
! 3 4 5 2 4
! 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 -1.00000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000
! 4 3184652083503114539 2 3184370608526404667 2
! Erreur de segmentation (core dumped)
!
! $ af95 -Rc test_index.f90 && ./a.out # The result of the second printed line is wrong.
! 3 4 5 2 4
! 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.00000000000000
! 4 3184652083503114539 2 3184370608526404667 2
! Erreur de segmentation (core dumped)
program test_index
use, intrinsic :: iso_fortran_env, only : INT64
implicit none
real(kind(0.0D0)), parameter :: a(56) = [0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&1.00000000000000, &
&-1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&-1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&-1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&-1.00000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000, &
&0.000000000000000]
real(kind(0.0D0)) :: b(4, 14) = reshape(a, [4, 14])
integer(INT64), parameter :: k(10) = [1, 2, 2, 3, 3, 4, 4, 1, 1, 3]
integer(INT64) :: ij1(2, 5) = reshape(k, [2, 5])
integer(INT64) :: ij2(2, 5)
ij2(1, :) = [1, 2, 3, 4, 1]
ij2(2, :) = [2, 3, 4, 1, 3]
write (*, *) ij2(2, :) + 1
write (*, *) b(:, ij2(1, :) + 1) ! The result of this line is wrong
write (*, *) ij1(2, :) + 1 ! The result of this line is wrong
write (*, *) b(:, ij1(1, :) + 1) ! This line causes a SEGFAULT due to the result of last line
end program test_index