Redundant specification of a variable

In a Fortran program, I have the variable “count” declared and used in the main program. I also have a Subroutine, contained by the main, in which one of the formal parameters also is named “count” (it corresponds to the actual parameter “count” passed by the main). In this function I declare “count” as an integer variable as it takes,


Subroutine assign(tally,count,activCount,actCount,prodCount,
&activData,actData,prodData,zonstart)
IMPLICIT NONE
Integer count,activCount,actCount,zonstart,zoncount,prodCount
Remainder of declaration
.
Body of the Subroutine


but I got from the pgf90 compiler:

PGF90-W-0119-Redundant specification for count (service.f: 392)
0 inform, 1 warnings, 0 severes, 0 fatal for service

Note that line 392 is the line wherein I declare “count” in the subroutine.
Nevertheless the compiler mentions the name of the main (service).

If I don’t declare “count” in the subroutine the compiler complains that:

PGF90-S-0038-Symbol, count, has not been explicitly declared (service.f)
0 inform, 0 warnings, 1 severes, 0 fatal for assign

mentioning correctly the name of the subroutine.
This formal parameter has the same name as the original actual parameter in the main, but this shouldn’t be a problem.
In any case if I change the actual parameter’s name, then it works.
And if I keep the formal parameter named “count”, but I initialize in a “Data” statement in the main the value of the original variable and (actual parameter) “count”, it works too !! This last fact is the most uncomprehensible.
Any explanation ?

Hi,


Fortunately, this is just a warning and will not interfere with the compilation of the program. The compiler is actually not getting the two “count” variables confused, rather your colliding with the intrinsic function “count”. When you declare a subroutine or function with the same name as an intrinsic function, the user’s subroutine, or function will take precedence.

In your case, the variable ‘count’ also overrides the meaning of the intrinsic function. While a varaible’s scope is limited to a particular scoping unit, the intrinsic function’s scope is visible to the parent and the internal subroutine. So the compiler is simply warning you that you’ve already redefined the intrinsic function within this scope. This warning is extaneous and can be ignored.

  • Mat

Clear.

Thank you very much.