I have problems in passing integer variables through several subroutines in a specific system of subroutines. The integer variables are part of a module, are defined and are used in several subroutines that use the module. The reason why these integer variables are passed through some subroutines as arguments is that this is an independent system of subroutines where I cannot use the module. The rules for the INTENT attribute are
INTENT(IN) The procedure must not change the argument. INTENT(OUT) The argument is undefined on entry and may be given a value in the procedure. INTENT(INOUT) The argument may be given a value in the procedure.
Metcalf et al. adds that a dummy argument with INTENT(IN) must not be redefined by the procedure or by being passed on as an actual argument to a procedure that redefines it. So the rules are pretty clear.
I have tried several variants: first without the INTENT attribute, then with other settings. Always an error is reported. Are there further rules for such a situation?
Two results:
If I set in the last subroutine to which the variables are passed
Subroutine c ( … , istop)
Integer , Intent (out) :: istop
….
Istop = 0
I get the error message
Error 15, Attempt to access undefined argument to routine.
If I set
Subroutine c ( … , istop)
Integer , Intent (inout) :: istop
….
Istop = 0
I get the message
Error 14, Attempt to alter an actual argument that is a constant, an expression, an INTENT(IN) argument, or a DO variable.
Of course, all settings of the INTENT attribute in the subroutines that passed the variables where set consistently and according to the rules.
Has anybody experienced a similar problem? Or is this programming already too complex and produces unwanted side-effects?
Thank you in advance for your help,
Klaus Lassmann