How is CONTAINS supposed to work legally. There is no full explanation
in my help or manuals.
If I have the situation where SUBROUTINE A calls SUBROUTINE B, and
SUBROUTINE B calls subs C and D, since CONTAINS cannot be nested , can I
write:
SUBROUTINE A
CALL B
CONTAINS
SUBROUTINE B
CALL C
CALL C
CALL D
END SUBROUTINE
SUBROUTINE C
END SUBROUTINE
SUBROUTINE D
END SUBROUTINE
END
Before I contact the vendor, I would like to know the legality of this
sequence. It compiles but gives me incorrect results. I also found
that if C and D were functions I would get a compilation warning that
one of them had been completely wiped out by the compiler.
A debug session shows me that it enters routine C, but seems not to have
inherited variables from B. Therefore, a secondary question, should all
contained routines only inherit from A, or if called from B do they
inherit B's variables too? I get a compilation warning that a variable
that I assumed was inherited from B in C is used before a value is set.
B always sets the variable before the call.
These warnings tend to give me the impression that CONTAINS can only go
down one level unless the compiler totally in-lines the code. My
compiler inlines B into A and also declares that it has in-lined D into
A, but no mention of C, wherein lies my failures.
Regards, Paddy
***********************************************************************
"This electronic message and any attachments may contain privileged
and confidential information intended only for the use of the
addressees named above. If you are not the intended recipient of
this email, please delete the message and any attachment and advise
the sender. You are hereby notified that any use, dissemination,
distribution, reproduction of this email is prohibited.
If you have received the email in error, please notify TransGrid
immediately. Any views expressed in this email are those of the
individual sender except where the sender expressly and with
authority states them to be the views of TransGrid. TransGrid uses
virus scanning software but excludes any liability for viruses
contained in any attachment.
Please note the email address for TransGrid personnel is now
[log in to unmask]"
***********************************************************************
|