fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

CHECK DATA TYPE COERCION

Syntax:

[DO NOT] CHECK DATA TYPE [COERCION]

Function:

fpt checks all expressions for data type and data size (or kind) coercions which could lead to errors. It reports, for example:

Mixed real sizes in expressions are a common source of error. For example:

! Emulation of VMS intrinsic dsind - R*8 sin in degrees REAL*8 FUNCTION dsind(theta) REAL*8 theta dsind = sin(theta*3.1415926535897932/180) END FUNCTION dsind

The problem here is not with the integer value 180. This will be promoted accurately to a REAL*8 value. The problem is PI. This is written with plenty of digits after the decimal point, but is a default REAL value, which on most systems is a REAL*4. The REAL*4 value of PI is then promoted to a REAL*8 value to be multiplied by theta, but the precision is already lost. The return from dsind occupies 8 bytes, but only has 4 bytes of precision. fpt traps the problem.

The use of integers in logical IF statements is common practice under VAX/VMS, and this causes problems when the software is ported to Unix or Windows. This command reports occurrences. The use of integers in logical IF statements is corrected automatically by the command CORRECT USE OF INTEGER FOR LOGICAL.

Where to Use this Command

Operating system command line Yes
Configuration file, config.fsp Yes
Specification (fsp) files, *.fsp Yes
Interactively, to FPT> prompt Yes
Interactive command files Yes
Embedded in the Fortran code Yes

Default

A limited check of data type coercion is made by default. The full check is mode in response to this command (Note that defaults may be changed in the configuration file).

Examples

The user makes the interactive command:

FPT> check data type

fpt reports:

-------------------------------------------------------------- ERROR Number 1429 Severity 2 (Worst 1) Count 4 Line 32 File: D:\JOHN\FPT\FPTTEST\OPENFILE.FOR IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) ^ Inappropriate operand for .NOT. -------------------------------------------------------------- -------------------------------------------------------------- ERROR Number 2533 Severity 2 (Worst 2) Count 5 Line 32 File: D:\JOHN\FPT\FPTTEST\OPENFILE.FOR IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) ^ Incorrect data type for this IF statement --------------------------------------------------------------

and the subroutine code is marked:

STATUS=LIB$GET_LUN(ICH) IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) ! ------^------^------------------------------------------------ !!! fpt - 2533 Incorrect data type for this IF statement !!! fpt - 1429 Inappropriate operand for .NOT. !---------------------------------------------------------------

where STATUS is found to be an integer variable.

See Also

CORRECT USE OF INTEGER FOR LOGICAL

Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.