LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 01-22-2015, 08:56 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
Gfortran: attribute that requires explicit interface ???


Hi there,

Trying to compile a few Gfortran lines in Ubuntu 12.04 I get this error:

Quote:
lun = newunit(unit)
1
Error: Dummy argument 'unit' of procedure 'newunit' at (1) has an attribute that requires an explicit interface for this procedure
The number one in fact points to the word "unit" not "lun" in the terminal. It got left-shifted when posted.

The code itself:

Code:
program main
  INTEGER*4 counter,lun,unit
  REAL*8, parameter :: pi = 3.141592653589793
  unit = 10
  lun = newunit(unit)
  ...................  
end program main
What does it all mean and how shall I change the code to compile it without an error?

Thanks, - A.

Last edited by AlexBB; 01-23-2015 at 02:39 PM.
 
Old 01-22-2015, 09:30 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
What is the definition of the newunit function? Is it even defined anywhere?
 
Old 01-23-2015, 09:37 AM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
It is not an intrinsic function but is based on an intrinsic function INQUIRE. So, there is a code in the program for that. I copied it from here.

Last edited by AlexBB; 01-24-2015 at 11:11 AM.
 
Old 01-24-2015, 11:35 AM   #4
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Well, it wanted an interface for this function. In turn an interface needs to be in a module and the module has to be in a separate file too. Otherwise nothing works.

Code:
module sph_persp_mod
  INTERFACE 
    integer function newunit(unit1)
      integer, intent(out), optional :: unit1
    end function newunit
  END INTERFACE
end module
The meaning of all this still eludes me. Whatever works!!!
 
Old 01-25-2015, 01:50 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
It's just one of the rules of Fortran syntax ... modules should be in their own files.
 
  


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
Need an explanation for gfortran interface code. AlexBB Linux - Newbie 0 12-21-2014 09:44 PM
Global symbol "$psid" requires explicit package name at admin.pl line 16. james2009 Programming 1 07-04-2011 05:43 PM
update problem "Attribute error object has no attribute 'rsplit' ruse Linux - Newbie 0 08-28-2009 02:46 AM
Adobe Acrobate Reader Requires A Plugin-That Requires Open LDAP That Requires Berkely Old_Fogie Slackware 10 05-08-2006 06:04 AM
Module usage :Global symbol "$ref" requires explicit package name rajatgarg Programming 2 12-17-2003 02:55 AM


All times are GMT -5. The time now is 08:47 AM.

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