public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-51268-4-OI5QhzVIY3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51268-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51268

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 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.


  parent reply	other threads:[~2011-11-23 10:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 13:32 [Bug fortran/51268] New: " bardeau at iram dot fr
2011-11-22 16:42 ` [Bug fortran/51268] " burnus at gcc dot gnu.org
2011-11-23  9:34 ` bardeau at iram dot fr
2011-11-23 10:54 ` burnus at gcc dot gnu.org [this message]
2011-11-23 14:20 ` bardeau at iram dot fr
2011-11-23 17:17 ` burnus at gcc dot gnu.org
2011-11-24 14:14 ` bardeau at iram dot fr
2011-11-24 14:45 ` burnus at gcc dot gnu.org
2011-11-24 16:35 ` bardeau at iram dot fr
2011-11-29 14:29 ` burnus at gcc dot gnu.org
2011-11-29 14:48 ` bardeau at iram dot fr
2011-11-29 15:24 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51268-4-OI5QhzVIY3@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).