Here, I know that A is just a 1D array of length 170.
subroutine gonewrong(q,e,A)
implicit none
integer, dimension(:) :: q
integer, dimension(:,:), intent(in) :: e
integer, dimension(size(e,1)*2), intent(out) :: A
print *, A(2)
end subroutine gonewrong
When I try to find A(2), for example, it gives me a segmentation fault! e has dimension (85,2).
Would it be because I declared A as an allocatable array in the program I used to compile it with?
The program I used:
program prog_1
use module_1
implicit none
integer::qm,a,b,c
integer,allocatable,dimension(:)::q
integer,allocatable,dimension(:,:)::e
!integer, dimension(size(e,1)*2) :: A
a = 5
b = 3
c = 10
allocate(q(a+c))
allocate(e(a+b*c,2))
call subr1(a,b,c,qm,q,e) !Outputs are qm,q and e.
call gonewrong(q,e,A) !gonewrong takes q and e as arguments
end program prog_1
Aas a scalar integer in the program and then pass it to the subroutine which expects an array? How can that ever compile? Show the complete code, the whole module, the commands you use. Compile with some debugging flags (-g -fcheck=all -Wall).aandAis the same thing!!!Ais not declared anything, the line is commented out. Or it was just a minute ago. With both declaration foraandAit can't compile. Don't make random changes to the code in the question when people take it as a base for their answers. Make sure the code is exactly the code you tested.