LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Difficulty with gfortran compile error. (https://www.linuxquestions.org/questions/linux-newbie-8/difficulty-with-gfortran-compile-error-4175528707/)

AlexBB 12-18-2014 07:21 PM

Difficulty with gfortran compile error.
 
I have this code:

Code:

program main
  integer*4 :: N
  double precision :: work(2310)
  N = 2310
  call triangularWindow ( N, work )
end program main

and a subroutine:

Code:

subroutine triangularWindow ( N, work )
    integer*4, intent (in) :: N
    integer*4 :: counter
    real ( kind = 8), intent (out) :: work(N)
    real ( kind = 8) fact1,fact2
    allocate ( work(1:N) )     
    fact1 = DBLE(N)/2.0D0
    fact2 = fact1 - 0.5D0
    counter = 0
    do while (counter .le. N-1)
      counter = counter + 1
      work(counter) = 1.0D0 - DABS ( (counter - fact2 ) / fact1 )
    enddo
    deallocate ( work )
  end subroutine triangularWindow

On compilation I get two errors:

Quote:

fft_select.f08:107.15:

allocate ( work(1:N) )
1
Error: Allocate-object at (1) must be ALLOCATABLE or a POINTER
fft_select.f08:115.16:

deallocate ( work )
1
Error: Allocate-object at (1) must be ALLOCATABLE or a POINTER
What is the problem?

Thanks, - A.

suicidaleggroll 12-18-2014 07:57 PM

Pretty straight forward, and the compiler is telling you the exact problem, you're trying to allocate a non-allocatable array.

Choose one or the other...
Code:

real (kind = 8) :: work(N)
or
Code:

real (kind = 8), dimension(:), allocatable :: work
allocate(work(1:N))
deallocate(work)


AlexBB 12-19-2014 09:46 AM

Suicidaleggroll, thank you again. I know I could have excluded this allocation business altogether but I dug in my heels because of future concerns. At this point is is all debugging and "measurements" but at production time much more memory blocks could be needed. Will try it later tonight. Thanks.

AlexBB 12-20-2014 11:54 AM

Well, as always, Suicidaleggroll, your suggestion worked, however, it does not mean I understand everything I am doing :-). I am ready to drop a new post though.


All times are GMT -5. The time now is 03:52 PM.