Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26750 Discussions

A vestige of default variable naming, even with IMPLICIT NONE?

Mike_M_1
New Contributor I
145 Views

FORTRAN 17.0.-1695 can generate a 6415 naming error in the presence of IMPLICIT NONE, depending on the order of the dummy arguments and type declarations.  The attachment provides an example.  RISK has HMAX, an intended INTEGER, as one of its indexes.  If the declaration of HMAX appears in the interface block before RISK, even if it is after RISK in the argument list, no error is generated.  However, if HMAX follows RISK in the interface block, the 6415 duplicate declaration error is generated, even in the presence of IMPLICIT NONE.  My personal hypothesis is that HMAX is being implicitly defined as REAL (rather than "undefined") in the latter case, causing the type conflict when the INTEGER HMAX is encountered.

0 Kudos
2 Replies
Steve_Lionel
Black Belt Retired Employee
145 Views

The code as presented is not legal Fortran (I ignored the USE of a module not supplied - commented that out). Yeah, the error messages could have been a bit better in this case; if you omit the declaration of HMAX entirely you then get an error saying it has no type.

I don't think the compiler is assuming that HMAX is REAL - rather, it is noting that it has no type because of IMPLICIT NONE. The "conflicts with prior uses" is technically correct, but certainly can be confusing. You do get the same error if you leave off IMPLICIT NONE (since in that case HMAX is implicitly REAL.)

When a variable is used in a specification expression, its type must have been "previously specified". Some compilers will allow you to get away with a later declaration as an extension, but not Intel's. (The development team had long discussions about this and I was on the side of keeping it disallowed.)

mecej4
Black Belt
145 Views

I have occasionally run into such problems with older code. In Fortran 77, you could specify the attributes of a variable in more than one declaration; sometimes you had no way of specifying all the attributes in a single declaration. I like it that F95 and later are designed to make declarations more readable by including all relevant attributes (separated by commas). I took your code and ran it through the old Lahey/Fujitsu Fortran 95 compiler, with and without its -v95s option. Without the option, there were no warnings, which indicates that the compiler made more than one pass through the declarations -- first collect the type information, then the dimensions, etc. With -v95s (issues diagnostic messages if the source code contains any nonstandard features), I found:

  jwd3139i-w  "calc_esc_etc.for", line 8, column 30: Type declaration for 'HMAX' which appeared in previous specification expression is not standard-conforming.
  jwd3139i-w  "calc_esc_etc.for", line 9, column 30: Type declaration for 'MMAX' which appeared in previous specification expression is not standard-conforming.
  jwd3139i-w  "calc_esc_etc.for", line 10, column 30: Type declaration for 'N_DERIVS' which appeared in previous specification expression is not standard-conforming.

 

Reply