Re: import selected module variables within that module's procedures
- From: "highegg" <highegg@xxxxxxxxx>
- Date: 31 Oct 2006 00:59:29 -0800
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).
.
- References:
- import selected module variables within that module's procedures
- From: beliavsky
- import selected module variables within that module's procedures
- Prev by Date: Unhandled exception in SWilk.exe (SWilk2.dll) (0 xC0000005) : Access violation error in Fortran dll.
- Next by Date: Re: Why these original FORTRAN quirks?
- Previous by thread: import selected module variables within that module's procedures
- Next by thread: make i:j equivalent to [(k,k=i,j)]?
- Index(es):
Relevant Pages
|