From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1569 invoked by alias); 23 Nov 2011 10:23:02 -0000 Received: (qmail 1559 invoked by uid 22791); 23 Nov 2011 10:23:01 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Nov 2011 10:22:46 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/51268] [Regression] A subroutine can not know anymore its own interface Date: Wed, 23 Nov 2011 10:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg02298.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51268 --- Comment #3 from Tobias Burnus 2011-11-23 10:22:12 UTC --- (In reply to comment #2) > Well, we are definitely interested in what the standard says exactly. For links to the standards see: http://gcc.gnu.org/wiki/GFortranStandards I think the following of "11.2.2 The USE statement and use association" of Fortran 2008 should capture this: "Two or more accessible entities, other than generic interfaces or defined operators, may have the same local identifier only if the identifier is not used. Generic interfaces and defined operators are handled as described in 12.4.3.4. Except for these cases, the local identifier of any entity given accessibility by a USE statement shall differ from the local identifiers of all other entities accessible to the scoping unit." > Because if this is explicitly forbidden, we are wondering what the Fortran > committee had in mind for programs using thousands of subroutines and where > the programmers want to provide the interfaces for each. I think your idea is to "hide" the implementation (the subroutines) from the interfaces (i.e. the module itself). Well, until Fortran 2003, they had no real solution but then they created the Technical Report (TR) 19767:2005 "Enhanced Module Facilities". This TR is now part of Fortran 2008 and informally known as "submodules": There is only one important downside: So far, almost no compiler supports submodules; http://fortranwiki.org/fortran/show/Fortran+2008+status lists only Cray. With submodules you can create a master module: module master interface MODULE SUBROUTINE sub (a,b) integer, intent(in) a, b end subroutine end interface end module master SUBMODULE (master) implementation contains MODULE SUBROUTINE sub (a,b) integer, intent(in) a, b ! < implementation > end subroutine end module implementation Variant which saves typing by leaving out the repeated variable declaration: SUBMODULE (master) implementation contains MODULE SUBROUTINE sub ! < implementation > end subroutine end module implementation * * * (In reply to comment #2) > I just hope the official recommendation is different from defining all > the subroutines as module procedures in a single 100000-lines long module... Well, you could use multiple modules for the actual implementation and then collect all of them in module master use m1 use m2 ... end module master This will automatically export all (public) procedures from the used modules such that "use master" will work. This is not as flexible as submodules but it valid and works since Fortran 90.