(j3.2006) implicit typing

Bill Long longb
Sun Aug 21 13:14:36 EDT 2016


On Aug 20, 2016, at 8:05 AM, Robert Corbett <robert.corbett at oracle.com> wrote:

> Ian Harvey posted the following program to
> comp.lang.fortran.
> 
>    DIMENSION c(2)
>    PARAMETER(i=SIZE(c))
>    INTEGER c
>    END
> 
> He said none of the compilers he tried would compile
> the program, but that he failed to find s rule in
> the Fortran standard that it violated.  He pointed
> out that the definition of a constant expression does
> not include the restriction regarding agreement of
> implicit and explicit types that is given for
> specification expressions.

I?m not sure why that is relevant. The SIZE(c) reference does not depend on the type of C, only the shape, which was previously declared.  The question is wether the appearance of C as an argument to SIZE is sufficient to cause it to be implicitly typed as REAL,  which is then contradicted by the INTEGER declaration that comes later. As an experiment, try adding implicit none; integer i  at the beginning of the code.   If you still see an error about the type of C not being declared before C appears elsewhere, that is the issue.

I have reduced sympathy for cases like this, since no respectable coding style guide would permit the use of either the DIMENSION or PARAMETER statements. 

Cheers,
Bill

> 
> Bob Corbett
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list