I'm far from an expert, but what you're doing seems fine.
I do the same type of thing all the time myself (using SGI's
F90 compilers) and never had it balk on me.
However, you do have to use explicit interfaces (either by
typing up an extra interface file or by putting mysub into
a module and then "using" that module. You have to do this
every time you pass in a F90 construct (derived type, pointer, etc)
into a subroutine as an argument. It's generally a good idea
to get into the habit of using explicit interfaces for every
subroutine you write. This allows you to pass F90 derived
types back and forth, as well as allowing the compiler to check
for type-matching in the subroutine call.
For example try this:
program test
use my_mod, only: mysub
call mysub(mylist%freq1)
end program test
module my_mod
contains
subroutine mysub(freq1)
return
end subroutine mysub
end module my_mod
Apologies if I'm repeating stuff that you already know.
You didn't mention the explicit interface in the code
that you posted so it's the first logical thing to think of.
Is the compiler actually giving you an error, or just a
warning? What is the text of the error/warning?
Catherine
--
-------------------------------------------------------------------------
Catherine Moroney phone : (818) 393-3392
Jet Propulsion Laboratory fax : (818) 393-4802
MailStop 169-315 email : [log in to unmask]
4800 Oak Grove Drive
Pasadena, CA 91109-8099
John Vaul wrote:
> Hi,
>
> The IBM compiler I am using complains when I pass as an argument to a
> subroutine
> an item of a derived type which is itself a derived type. Is it right
> to complain?
>
> An example of what I am doing follows:
>
> type freq
> real :: start
> real :: stop
> real :: step
> end type freq
>
> type list
> type(freq) :: freq1
> type(freq) :: freq2
> end type list
>
> type( list ) :: mylist
> .
> .
> .
> call mysub( mylist%freq1 )
> .
> .
> .
> .
> subroutine mysub( freq1 )
>
> type(freq) , intent(inout) :: freq1
> .
> .
> .
>
> end subroutine mysub
|