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...

--
.



Relevant Pages

  • Re: Polymorphic TBP PASS arguments
    ... END TYPE mytype ... SUBROUTINE foo ... END SUBROUTINE foo ... The call could be done with an implicit ...
    (comp.lang.fortran)
  • Advice on polymorphic arguments
    ... implicit none ... subroutine print_data_i ...
    (comp.lang.fortran)
  • Derived type in main
    ... implicit none ... subroutine some_subroutine ... end type myType ...
    (comp.lang.fortran)
  • Re: Derived type in main
    ... implicit none ... subroutine some_subroutine ... end type myType ... I suspect the type definition must be in a module or the subroutine ...
    (comp.lang.fortran)
  • Question about use and host association
    ... IMPLICIT NONE ... PRIVATE ... SUBROUTINE mytype_Write ... Is this compiler message bogus, or am I misunderstanding something about use and/or host ...
    (comp.lang.fortran)