LinuxQuestions.org
Visit Jeremy's Blog.
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 11-10-2014, 11:29 AM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
Passing an array into a subroutine in GFortran


Hi there,

I have a large package of subroutines in one of the FORTRAN dialects. In the event it compiles when I placed it in a file with .f08 extension. There is no MAIN module and I am trying to write it. One of the last statements logically should be a call to a subroutine which hopefully will lead to a result. I try to copy the recommendations from this website and my GFortran compiler gives me errors.

This is the code this website recommends:

Code:
integer, parameter :: n=10
real(8), dimension(n)  :: x, y
real(8), dimension(n,n) :: val
This is my code:

Code:
INTEGER, parameter :: nn = 50
    DOUBLE PRECISION, dimension (nn) :: pqa    
    INTEGER, dimension (nn)    :: ipqa
    CALL xdlegf(dnu1, nudiff, MM, LL, THETA, id, pqa, ipqa)
You can see also the subroutine to be called (xdlegf) where two last elements in the calling sequence are in fact dummy arrays. This is the error I am getting:

Code:
alex@alex-VirtualBox:~/LEGENDRE$ gfortran legendre_fun1.f08
legendre_fun1.f08:11.47:

    DOUBLE PRECISION, dimension (nn) :: pqa    
                                               1
Error: Unexpected data declaration statement at (1)
legendre_fun1.f08:12.38:

    INTEGER, dimension (nn)    :: ipqa
                                      1
Error: Unexpected data declaration statement at (1)
Why is it so?

Thanks, - A.
 
Old 11-10-2014, 11:33 AM   #2
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
OK, I solved it. Another lesson for me. I placed those two declarations among the executable statements and they should precede any exec statement as it turns out.
 
  


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] C++ passing 2d array to a function kevinamygrayson Programming 10 10-31-2012 07:00 AM
[SOLVED] passing a 2D array to a function in C++ aihaike Programming 2 03-28-2012 09:14 PM
Passing parameters to bash script function (or subroutine) withanh Linux - Newbie 5 02-19-2012 09:54 AM
perl: Passing arrays to subroutine kenneho Programming 8 07-07-2009 07:14 AM
Simple subroutine being passed an array WorldBuilder Programming 4 11-04-2003 01:02 AM


All times are GMT -5. The time now is 01:34 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