Re: Derived type in main



Ralf Schaa wrote:
People,

an example that does not seem to work:

Module some_module

implicit none
private
public :: some_subroutine


contains

subroutine some_subroutine(t_test)
use some_types
type(myType), intent(in) :: t_test
print*, t_test%test
end subroutine some_subroutine
end Module some_module

Module some_types

implicit none
type myType
real :: test
end type myType
end Module some_types


program main

use some_module, only: some_subroutine
use some_types
implicit none


type( myType ) :: t_test

call some_subroutine( t_test )
end program main

I suspect the type definition must be in a module or the subroutine
'some_subroutine' must be contained in the main program (and not in
the module 'some_module').

I was just hoping that a derived type in the *main* program could be
passed like this ... or am I doing something wrong here?

Only that -- the definition of the structure must be available to the subroutine(s) where it is used as well as in the main program.

As you say, it could be at a module level or in a module of data to be USEd...


It's late but I _think_ what I munged on yours above is one way...

--
.