Failure to Export Overloaded Assignment

| SimCon Home | fpt Reference Manual Home |

The Special Case of Overloaded Assignment

All arithmetic and relational operators may be overloaded so that they operate on variables of derived types. A function is written to specify the action to be performed and is associated with the operator in an INTERFACE OPERATOR block. The overload must be visible in the scope in which it is used. If it is not, the compiler has no information to indicate how the operator is to be interpreted and an error occurs. There is no risk of confusion.

The assignment operator may also be overloaded for derived types. A subroutine is written to specify the action to be taken when variables of the derived type are assigned. The subroutine is associated with the assignment operator in an INTERFACE ASSIGNMENT block.

However, if no overload is visible, the assignment statement simply copies the right-hand-side variable to the left-hand-side. If any error has occurred in setting up or exporting the overload, the overload fails silently. We have only observed three falures of this type (Hardly a systematic error!). But the situation is so difficult to detect that a special handler was written for it.

Detecting Failed Overloaded Assignments

fpt can search for the situation where an overloaded assignment has been defined for a derived type but assignments occur where the assignment is not overloaded and a simple copy operation takes place. The command is:

CHECK OVERLOADED ASSIGNMENTS

In the "Earth System Modeling Framework", ESMF, used in WRF, an overloaded assignment is defined for a derived type which holds a time. The overload is not declared to be public, and is not exported from the module in which it is defined. An error therefore occurs. The report is shown below:

Check of Overloaded Assignments =============================== ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9648 Line 515 File: ..._re-eng/publication/test/UCAR_clean_build_WRFV3.6.1/WRFV3/share/dfi.F grid%stop_subtime = domain_get_stop_time(grid) ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9649 Line 402 File: ..._re-eng/publication/test/UCAR_clean_build_WRFV3.6.1/WRFV3/share/dfi.F grid%stop_subtime = domain_get_stop_time(head_grid) ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9650 Line 514 File: ..._re-eng/publication/test/UCAR_clean_build_WRFV3.6.1/WRFV3/share/dfi.F grid%start_subtime = domain_get_start_time(grid) ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9651 Line 401 File: ..._re-eng/publication/test/UCAR_clean_build_WRFV3.6.1/WRFV3/share/dfi.F grid%start_subtime = domain_get_start_time(head_grid) ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9652 Line 438 File: ...CAR_clean_build_WRFV3.6.1/WRFV3/external/esmf_time_f90/ESMF_Alarm.F90 prevringtime = alarm%alarmint%prevringtime ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9653 Line 205 File: ...CAR_clean_build_WRFV3.6.1/WRFV3/external/esmf_time_f90/ESMF_Alarm.F90 alarm%alarmint%stoptime = stoptime ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9654 Line 198 File: ...CAR_clean_build_WRFV3.6.1/WRFV3/external/esmf_time_f90/ESMF_Alarm.F90 alarm%alarmint%prevringtime = prevringtime ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ !!! WARNING !!! Number 3513 Severity 1 (Worst 2) Count 9655 Line 201 File: ...CAR_clean_build_WRFV3.6.1/WRFV3/external/esmf_time_f90/ESMF_Alarm.F90 alarm%alarmint%ringtime = ringtime ^ INTERFACE ASSIGNMENT(=) exists but assignment not overloaded ------------------------------------------------------------------------------ 8 inconsistencies detected where variables of derived types for which INTERFACE ASSIGNMENT(=) is specified are copied without overloading.

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