Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

module procedures
Is it legal Fortran to have an interface where some of the module
procedures (MP) are functions and others are subroutines?

The following code, where y and z are both MP's of x but y is a
subroutine and z is a function, is disallowed by Lahey/Fujitsu, allowed
by g95, and triggers an internal compiler error with CVF 6.6c. I can't
see any use for such code, but I wonder if the compiler is required to
complain about it.

module xx
implicit none
public  :: x
private :: y,z
interface x
module procedure y,z
end interface x
contains
!
subroutine y()
end subroutine y
!
real function z()
z = 0.0
end function z
end module xx


Report this thread to moderator Post Follow-up to this message
Old Post
beliavsky@aol.com
12-14-04 02:01 AM


Re: module procedures
beliavsky@aol.com writes:

> Is it legal Fortran to have an interface where some of the module
> procedures (MP) are functions and others are subroutines?

No.  From 16.2.3 of f2003 (and probably almost the same words in f90/f95)

"Within a scoping unit, two procedures that have the same generic
name shall both be subroutines or both be funcctions..."

> I wonder if the compiler is required to complain about it.

Nope. It isn't a constraint or any of the other things that trigger
such a requirement in the standard.  (But I'd say that a "good"
compiler ought to.)

--
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain

Report this thread to moderator Post Follow-up to this message
Old Post
Richard E Maine
12-14-04 02:01 AM


Re: module procedures
<beliavsky@aol.com> wrote in message
news:1102971633.736334.135950@c13g2000cwb.googlegroups.com...

> Is it legal Fortran to have an interface where some of the module
> procedures (MP) are functions and others are subroutines?

ISO/IEC 1539-1:1997(E), section 14.1.2.3 says:
"Within a scoping unit, two procedures that have the same generic name
shall both be subroutines or both be functions, and..."

You may interpret the quoted passage as you wish.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end



Report this thread to moderator Post Follow-up to this message
Old Post
James Van Buskirk
12-14-04 02:01 AM


Re: module procedures
beliavsky@aol.com wrote:
> Is it legal Fortran to have an interface where some of the module
> procedures (MP) are functions and others are subroutines?
>
> The following code, where y and z are both MP's of x but y is a
> subroutine and z is a function, is disallowed by Lahey/Fujitsu, allowed
> by g95, and triggers an internal compiler error with CVF 6.6c. I can't
> see any use for such code, but I wonder if the compiler is required to
> complain about it.
>
> module xx
> implicit none
> public  :: x
> private :: y,z
> interface x
> module procedure y,z
> end interface x
> contains
> !
> subroutine y()
> end subroutine y
> !
> real function z()
> z = 0.0
> end function z
> end module xx
>

Nope, this is illegal; when an interface block is used to group
procedures together under the same generic name, they must all be
functions or all be subroutines (see, e.g., p. 93 of Fortran 95/2003
Explained).

cheers,

Rich

--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware

[ Delete VOID for valid email address ]

Report this thread to moderator Post Follow-up to this message
Old Post
Rich Townsend
12-14-04 02:01 AM


Re: module procedures
On 13 Dec 2004 13:00:33 -0800, beliavsky@aol.com wrote:

>The following code, where y and z are both MP's of x but y is a
>subroutine and z is a function, is disallowed by Lahey/Fujitsu, allowed
>by g95, and triggers an internal compiler error with CVF 6.6c.

Intel Fortran gets an internal compiler error too with this - we'll fix it.


Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Lionel
12-15-04 02:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:40 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.