LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2014, 08:21 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
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.
 
Old 12-18-2014, 08:57 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
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)
 
1 members found this post helpful.
Old 12-19-2014, 10:46 AM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
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.
 
Old 12-20-2014, 12:54 PM   #4
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Gfortran statement does not compile AlexBB Linux - Newbie 38 12-05-2016 08:19 PM
mingw cross compile gfortran for windows uchiha_itachi Linux - Newbie 2 12-14-2014 07:52 PM
[SOLVED] A compile time error in GFortran I don't understand AlexBB Linux - Newbie 16 12-13-2014 11:46 AM
Can't compile f77 code using gfortran or g77 GradientDrift Programming 2 11-18-2009 11:18 PM
Gfortran compile error aukuntin Linux From Scratch 2 01-28-2007 09:08 PM


All times are GMT -5. The time now is 05:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration