- #1
Antonija
- 18
- 0
Homework Statement
I have character array in fortran which is defined as allocatable. When program runs, user inputs something like: [1,2,3,4...], and then program reads it and counts the particles, and then allocate array with dimension it just read.
Thats' how I understood it. This program compiles ok, but when it runs I get segmantation fault:
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7F55CA614667
#1 0x7F55CA614C34
#2 0x7F55C9BD21DF
#3 0x7F55C9CC3844
#4 0x7F55CA6CE7A8
#5 0x400CA1 in MAIN__ at ekstremi.f90:0
I thought the problem is in that 'red line' down...
However, when I replace allocate(character(len(interval))::interval with something like this:allocate(character(20))::interval , or this:allocate(character(len=50))::interval, I get the same error...
Also, please tell me what's the difference between this two:
character(len..), dimension(), allocatable:: array
character(len...), allocatable:: array
Homework Equations
The Attempt at a Solution
program first
character(len=*), allocatable::interval
print*,'input the interval'
read(*,*)interval
allocate(character(len(interval))::interval
.
.
.
.
.
deallocate (interval)
end program