This is my program:
program ejercicio8
implicit none
real(kind=8) :: i, k, pi
integer, allocatable :: n
integer :: j
real, dimension(:),allocatable :: array
pi= 4*atan(1.0_8)
!----------------------------------------------------------------
print*, "enter dimension n"
read(*,*) n
allocate(array(n))
j=0
do while (j <= n)
array(j) = pi+(j/n)*pi
write(*,*) array(j)
j = j + 1
enddo
end program ejercicio8
The objective is to generate a vector of dimension variable n and assign each component a value of a range (pi, 2pi) , dividing that interval into n parts. For example: if n = 4, the vector would result (pi, 5/4 pi, 3/2 pi, 2pi)
My code compiles but when I start the program I get this:
Program received signal SIGSEGV: Segmentation fault - invalid memory reference