F90 compiler and user defined types

  • Thread starter Thread starter santanaa
  • Start date Start date
  • Tags Tags
    Compiler
AI Thread Summary
The discussion centers on a Fortran 90 (f90) issue related to defining methods with the same name for different user-defined types. The user, a C++ programmer, is trying to create two types, "Box" and "Other," each with a method named "Print." However, the f90 compiler raises an error indicating that the procedure 'Print' is already defined, preventing the user from having both methods coexist. The user seeks a solution to allow both types to have a method named "Print," acknowledging that Fortran already includes an intrinsic print function. The challenge lies in the compiler's inability to distinguish between the two user-defined methods due to the same name, leading to the need for a workaround or alternative naming convention to resolve the conflict.
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?
 
Technology news on Phys.org
I believe f90 already have a intrinsic print function.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top