F90 compiler and user defined types

  • Thread starter santanaa
  • Start date
  • #1
3
0

Main Question or Discussion Point

Hi I have a little issue with f90.

I am a c++ programmer but I have to use fortran for this project.

f90 the compiler does seem to distinguish between methods from user defined types. I have two types one "has a" instance of the other. Both have a methods named Print (with different typed arguments and in different modules). I want both of my user efined types to have the method named Print. The compiler wont let me define both!

here is an example

Code:
module BoxModule
type Box
...
end type
contains
subroutine Print(b)
type(Box) b
...
end subroutine
end module

module OtherModule
type Other
...
type(Box) b
...
end type
contains
subroutine Print(o) ! <----------------------------- compiler doesn't like this
type(Other) o
...
Print(o%b)
...
end subroutine
end module
here is the error

Code:
subroutine Print(c)
                1
use BoxModule
       2
Error: Procedure 'print' at (1) is already defined at (2)
Howe can I have both user dfeind type have a function named Print?
 

Answers and Replies

  • #2
4
0
I believe f90 already have a intrinsic print function.
 

Related Threads on F90 compiler and user defined types

Replies
1
Views
2K
Replies
1
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
7
Views
2K
  • Last Post
Replies
7
Views
1K
Replies
3
Views
4K
Replies
1
Views
578
Replies
8
Views
41K
Replies
1
Views
3K
Top