I am trying to use Dynamic arrays in F95 with gfortran (F95) under Ubuntu 6.10.
What is wrong with this code? I am getting a message:
Syntax error in ALLOCATE statment.
I tried to put the ALLOCATE and DEALLOCATE in the main program, and that prevented the error message, but it still did not work. I got a message:
Segmentation failure: Core Dumped.
Thanks for any help.
----------------------------------------
program CountSpikes
c Opens a text file (of spike times) and counts how many lines it has
REAL*8, ALLOCATABLE :: rgsp) !rank 1
c
open(unit=55,status='old',file='retu160_4.dat')
nspikes=0
do
read(55, *, end=999) rgsp(nspikes)
C print *,rgsp, nspikes
nspikes=nspikes+1
end do
999 print *, nspikes
call testDynamicArray(nspikes, rgsp)
end
subroutine testDynamicArray(nspikes,rgsp)
allocate (rgsp (nspikes) )
do i=1,nspikes
print *,rgsp(i)
end do
deallocate(rgsp)
return
end
What is wrong with this code? I am getting a message:
Syntax error in ALLOCATE statment.
I tried to put the ALLOCATE and DEALLOCATE in the main program, and that prevented the error message, but it still did not work. I got a message:
Segmentation failure: Core Dumped.
Thanks for any help.
----------------------------------------
program CountSpikes
c Opens a text file (of spike times) and counts how many lines it has
REAL*8, ALLOCATABLE :: rgsp) !rank 1
c
open(unit=55,status='old',file='retu160_4.dat')
nspikes=0
do
read(55, *, end=999) rgsp(nspikes)
C print *,rgsp, nspikes
nspikes=nspikes+1
end do
999 print *, nspikes
call testDynamicArray(nspikes, rgsp)
end
subroutine testDynamicArray(nspikes,rgsp)
allocate (rgsp (nspikes) )
do i=1,nspikes
print *,rgsp(i)
end do
deallocate(rgsp)
return
end