Software Archive
Read-only legacy content
17060 Discussions

integer / integer warning possible?

Intel_C_Intel
Employee
1,927 Views
Hi

Is it possible to get a warning from the compiler in the cases

a) Integer division, eg

nRealVar = iInteger1/iInteger2;

or more generally when mixing types in algebraic expressions??

b) Complex assigned to real, eg

real nR
complex nQ
...
nR = nQ;

I have tried to redefine the division operator /, but it seems
that '/' is too intrinsic to be redefined via INTERFACE ...

Any hints are welcome

Regards
Gunnar Taraldsen
SINTEF Telecom and Informatics
0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,927 Views
No, the compiler does not implement a warning for this. These operations are allowed under the Fortran standard and might be used in valid programs.

I'll add to our wish list an optional warning for mixed-mode arithmetic. I could see that this might be useful to some people.

Steve
0 Kudos
sabalan
New Contributor I
1,927 Views
Fortran Check Does warn for such kinds of type mixings and much more.

Regards,

Sabalan

0 Kudos
Intel_C_Intel
Employee
1,927 Views
... but, it doesn't do f90 (or f95) outside of implicit none, do...end do, end subroutine, select case, and maybe a few minor others. Quite the drawback, imo. (an almost universal drawback among third party Fortran static analyzers.)

-John
0 Kudos
sabalan
New Contributor I
1,927 Views
John, I have not tested the latest version but this is what they promis:

Status as of 4 February 2001

ftnchek is now at version 3.0.2

Some new features in version 3.0:

1. Statement labels are now processed, instead of being
ignored as formerly. Tables of label definitions and
cross-references can be printed, and warnings about
incorrect or suspicious label usage are produced.
This new feature was added by Heba Elsayed.

2. The SELECT CASE construct is now accepted. The syntax
is as defined in Fortran 90. This new feature was
added by John Bollinger.

3. The END PROGRAM, END FUNCTION, END SUBROUTINE and END
BLOCKDATA statements are accepted. No checking for
balance is done.

4. Source code can be in Fortran 90 free format or tradi-
tional fixed format. Also, a semicolon is allowed as
a statement separator.

5. The ftnpp program has been unbundled from the distri-
bution. It is available from the same places as
ftnchek.

Regards,
Sabalan.
0 Kudos
Reply