fpt and WinFPT Reference Manual - Command-line Commands
| SimCon Home | Ref Manual Home |
CHECK WHOLE ARRAY ASSIGNMENTS
Syntax:
[DO NOT] CHECK WHOLE ARRAY ASSIGNMENTS CHECK WHOLE ARRAY ASSIGNMENTS FROM [ALL] SCALARS CHECK WHOLE ARRAY ASSIGNMENTS FROM VARIABLE SCALARS CHECK WHOLE ARRAY ASSIGNMENTS FROM SCALAR VARIABLES
Function:
fpt checks situations where an unsubscripted array is assigned across an equals sign. There are three situations as shown below:
REAL(KIND=8) :: r REAL(KIND=8) :: a(3),b(3) : 1 a = b : 2 a = 0.0D0 : 3 a = r
These commands were created because the authors have encountered an alarming number of errors similar to that shown below:
REAL*8 r_shtpwr(3) ! Power at rotor REAL*8 e_pwr(3) ! Power from engines : ! Transfer engine powers DO i = 1, 3 r_shtpwr = e_pwr(i) !--------------------^--------------------------------------------------------- !!! fpt - 3409 Un-subscripted whole array assignment from variable scalar !------------------------------------------------------------------------------ ENDDO
This code was part of a medium lift helicopter simulation. The intention was to copy the power output from the three engines to the handler for the rotor shafts. The programmer missed out the subscript for the rotor shaft powers. The code is still legal and syntactically correct. The effect was to write the power for the firat engine to all three elements of the rotor shaft power, then immediately to overwrite these values with the power from the second engine and then with the powers from the third engine. The problem was that the second, middle, engine generated a lower power than the outboard engines, so the total power was overestimated. The helicopter could not lift as much as the simulation predicted.
The command CHECK WHOLE ARRAY ASSIGNMENTS FROM VARIABLE SCALARS or CHECK WHOLE ARRAY ASSIGNMENTS FROM SCALAR VARIABLES commands fpt to report the third class of whole array assignments only.
The command CHECK WHOLE ARRAY ASSIGNMENTS FROM ALL SCALARS or CHECK WHOLE ARRAY ASSIGNMENTS FROM SCALARS commands fpt to report the second and third classes of whole array assignments.
The command CHECK WHOLE ARRAY ASSIGNMENTS commands fpt to report all whole array assignments. This may be useful in migrating code to FORTRAN 77 systems.
When the selected whole array assignments are detected, a diagnostic is inserted into the code, and is written to the list (fpl) file.
Note that it is not necessary to write whole array assignments without subscripts in Fortran 90. The assignment a = b above may be written a(:) = b(:) or a(1:3) = b(1:3).
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
The check is not carried out by default (Note that defaults may be changed in the configuration file).
Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.