Re: import selected module variables within that module's procedures




beliavsky@xxxxxxx wrote:
I wish there were a way to import only a few module variables, derived
types, and procedures into a procedure of the module, for example

module foo_mod
integer :: i,j
contains
subroutine sub()
use foo_mod, only: i ! NOT a legal Fortran 95 statement
end subroutine sub
end module foo_mod

but one cannot write "use foo_mod" within module foo_mod. Is there a
way to get this effect in Fortran 95? Fortran 2003? Could the
"submodule" of TR 19767 accomplish this?

you can simply modularize more:

module foo_mod_h
integer:: i,j
end module

module foo_mod_sub
contains
subroutine sub()
use foo_mod_h,only: i
end subroutine
end module

module foo_mod
use foo_mod_h
use foo_mod_sub
end module

another alternative, is making all the subroutines external,
let them USE the module and provide interfaces within the module.
This approach requires extracting and updating of interfaces
appropriately (similar to C headers, but other module advantages
remain).

.



Relevant Pages

  • Re: Memory problem with XML::DOM::Parser???
    ... >> # Die Anfrage ist Teil der neuen EPA ... # Modul für die XML-Funktionen des Clients ... # Subroutine, um die XML-Struktur aus dem XML-Rootfile und den ... sub construct_xml { ...
    (comp.lang.perl.misc)
  • Re: passing database data to a sub
    ... > I'm not sure of the difference, why isn't it a subroutine? ... > sure about this 'shift' thing anyway :-) ... > sub teardown ... > # Setup the template to use for the output. ...
    (perl.beginners)
  • Re: import selected module variables within that modules procedures
    ... NOT a legal Fortran 95 statement ... end subroutine sub ... Isn't this something along the lines of the proposed control of host association that has been suggested previously in this group? ...
    (comp.lang.fortran)
  • Re: Shared Method Problem With "Global" Storage
    ... Shared Method Problem With "Global" Storage ... declare the Sub as Shared. ... What I don't get is that if I refer to ButtonHasBeenClicked in a subroutine ... code which is unique to mining web site B. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Proper class setup?
    ... > sub init { ... here: AUTOLOAD and lvalue subroutines. ... if a subroutine named AUTOLOAD exists then it will be called whenever ...
    (perl.beginners)