I have been told for my PhD that I have to learn fortran 2003 language. I have never used and OOP program before nor fortran. I am trying to understand what the difference
The keyword type
is used to declare derived types -- best not to get into the habit of thinking, perhaps imported from foreign languages, that type
is used for declaring something called classes
.
The keyword class
is used, in restricted circumstances, to mean of the type specified or any of its extended types
. extended type is Fortran-speak for a type which extends another type, essentially one which specialises or inherits from another type. The restricted circumstances within which class
is used are in procedure dummy-argument lists and in declarations of entities with the attribute allocatable
or the attribute pointer
. A class
entity gets a dynamic type
at run-time, and its dynamic type may vary from run to run, or across a single execution of the program.
If you don't understand the explanation in the previous paragraphs it's possibly because I've explained things poorly, but it's also possibly because you don't yet have enough of a grounding in the basics of Fortran. To acquire the grounding find yourself an up-to-date online tutorial, an online reference guide, and start programming.