I thought you could pass a record in a calling sequence, but here I get an error #6633,even when the types are identical in structure.
Is there a subtlety here? Seems obvious.......
Identical in structure, yes. Same type, no. Put the type in a module and USE the module both places - then it will be the same type.
Let me make an analogy - if you had a twin brother, would he be you?
Is there an article I can refer to?
I need to research this a little further for my own edification.
My twin brother doesn't speak to me anymore
(just kidding) :<)
The Fortran standard, linked to at the top of the main forum page, is the reference, though as is typical for the standard, the words about this are not all in one place.
Referencing Fortran 2008, we can start with paragraph 2 of section 18.104.22.168 ("Ordinary dummy variables") which says, "The dummy argument shall be type compatible with the actual argument."
Ok, so now we need to know what "type compatible" means. The canonical definition is in the "Terms and Definitions" chapter, section 22.214.171.124, which says, "compatibility of the type of one entity with respect to another for purposes such as argument association, pointer association and allocation (4.3.1)". Big help that is, but it does reference 4.3.1.
Section 4.3.1 is "Type specifiers and type compatibility". This describes how you give an object a type, whether it be intrinsic, derived or polymorphic. Buried in the subsection on CLASS, 126.96.36.199, is this: "A nonpolymorphic entity is type compatible only with entities of the same declared type."
There is no exception here for two types that have the same layout - those are different types.
Bill, I have led you astray... - partly.
I missed an important part of the standard, 188.8.131.52, "Determination of derived types". I will quote it here:
3 184.108.40.206 Determination of derived types4 1 Derived-type definitions with the same type name may appear in different scoping units, in which case they might5 be independent and describe different derived types or they might describe the same type.6 2 Two data entities have the same type if they are declared with reference to the same derived-type definition.7 Data entities also have the same type if they are declared with reference to different derived-type definitions8 that specify the same type name, all have the SEQUENCE attribute or all have the BIND attribute, have no9 components with PRIVATE accessibility, and have type parameters and components that agree in order, name,10 and attributes. Otherwise, they are of different derived types. A data entity declared using a type with the11 SEQUENCE attribute or with the BIND attribute is not of the same type as an entity of a type that has any12 components that are PRIVATE
So in your example, if you gave derived type CB the SEQUENCE attribute in both caller and callee, then you would avoid the error.
Thanks for these details Steve. This explains the disconnect I had this past week. In the calling routine I had defined an array with a base index of 0 instead of 1. In the subroutine I defined the dummy argument as X(:) and was surprised when it came through as an undefined pointer.
I've embarrassed my self again. I sent a module that does compile (with typos corrected). Just ignore the previous message.
With apologizes. John Bauer
Glad to hear it.