I am trying to run a simple code to create arrays. This code was working before. However, now it has somehow stopped working and throws a runtime error. Here is the piece of code that causes the trouble.
call PF33(thetamix,rhodhI,16)
subroutine PF33(thetamix,rhodhI,N)
implicit none
integer*8 N, thetamix,rhodhI
real*8 k1, k2,k4, k2x, k4x
dimension k1(N), k2(N), k4(N), k2x(N), k4x(N), X(N)
do i = 1, N/2
k1(i) = (2 * pi / L) * (i - 1)
enddo
do i = N/2 + 2, N
k1(i) = -((N - i + 1) * (2 * pi / L))
enddo
k1(N/2 + 1) = ((N/2) * (2 * pi / L))
k2=k1*k1
k2(N/2+1)=((N/2)*(2*pi/L))**2
k4=k2*k2
k4(N/2+1)=((N/2)*(2*pi/L))**4
k2x=k2
k4x=k4
return
end
N is a dummy attribute that is taken from the subroutine call. The second k1 loop is the line where I get the error. Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7ffb858b877d in ???
#1 0x7ffb858b7993 in ???
#2 0x7ffb8544251f in ???
#3 0x55741fee21f5 in pf33_
at /home/raghav/Desktop/SeaIce/FeapElement/Andrea-Feap/home/andrea/feap/ver84/user/PF33.f:123
#4 0x55741fed81d3 in uprhoha_as33_
What am I missing? Thanks in advance