Re: once again: where to declare what
- From: Michael Trover <mtrover@xxxxxxxxxxxxx>
- Date: Tue, 18 Oct 2011 11:50:32 -0400
On 10/18/2011 3:50 AM, Phillip Helbig---undress to reply wrote:
Maybe a better approach would be to have the declarations in a file.
This makes it even easier for the user, and if desired he could use
INCLUDE to use them directly, perhaps after changing some names.
(Theoretically, the subroutine in my module could use the same include
file, but I would prefer to have the declarations directly in the
subroutine; exporting these to a(n INCLUDE) file for the benefit of the
user is a one-time cut-and-paste operation.)
Modules can be used to encapsulate type definitions. This seems to be what you are looking for.
Program main
use routines
type(XType):: X
! Do something with X
X%r = 2.0
call sub(X)
end program
module routines
type XType
real:: r
end type
contains
subroutine sub(X)
type(XType):: X
! Do something with X
end subroutine
end module
The declaration is still in the main program but the type is defined in the module. The subroutine sub cannot be used at all without the type definition.
.
- References:
- once again: where to declare what
- From: Phillip Helbig---undress to reply
- Re: once again: where to declare what
- From: Michael Trover
- Re: once again: where to declare what
- From: Phillip Helbig---undress to reply
- Re: once again: where to declare what
- From: Richard Maine
- Re: once again: where to declare what
- From: Phillip Helbig---undress to reply
- once again: where to declare what
- Prev by Date: Re: once again: where to declare what
- Next by Date: Re: Recommend an ODE integrator?
- Previous by thread: Re: once again: where to declare what
- Next by thread: Re: once again: where to declare what
- Index(es):
Relevant Pages
|