F90 compiler and user defined types

  • Thread starter Thread starter santanaa
  • Start date Start date
  • Tags Tags
    Compiler
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 replies · 3K views
santanaa
Messages
3
Reaction score
0
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 won't 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?
 
on Phys.org
I believe f90 already have a intrinsic print function.