JCSDA / CRTMv3

CRTMv3 repository for coordinated development and releases. Code history is not carried in this repository prior to v3, to reduce the cloning overhead. For v2.x history leading up to v3, see JCSDA/crtm repository.
Other
6 stars 6 forks source link

[Feature] Operator Overloading for Assignment (=) between Existing and New/Empty Types in CRTM (Fortran) #81

Open BenjaminTJohnson opened 1 year ago

BenjaminTJohnson commented 1 year ago

Background:

Within the CRTM, there are multiple custom types (e.g., Options_Type) used for various functionalities. Currently, assigning an object of an existing type to an uninitialized or new object of the same type requires explicit member-wise assignment, which can be cumbersome and error-prone.

Feature Description:

Implement operator overloading for the assignment operator = in Fortran to allow for straightforward assignment between existing and new or uninitialized objects of custom types within CRTM. This will enhance code readability and reduce the risk of errors.

Example:

! Current way of doing assignment

newObject%member1 = existingObject%member1
newObject%member2 = existingObject%member2

! ... and so on

! Proposed way

newObject = existingObject

Tasks:

Expected Benefits:

Simplifies code related to object initialization and assignment.

Reduces the risk of bugs due to member-wise copying. This was noticed with Opt = Options assignment. This becomes particularly problematic when there are allocatable optional components of a given type.

Improves maintainability by reducing the amount of code needed for type assignments.

BenjaminTJohnson commented 1 year ago

List of custom types eligible for operator assignment, I think choosing only the operators that have an existing (==) (equal check) operator should have the assignment (=) operator:

Fun.