fv3atm icon indicating copy to clipboard operation
fv3atm copied to clipboard

cpl/module_block_data.F90 is getting extremely complex

Open SamuelTrahanNOAA opened this issue 2 years ago • 0 comments

Description

As noted in https://github.com/NOAA-EMC/fv3atm/pull/534, the cpl/module_block_data.F90 data conversion logic, the code is getting complicated and repetitive, which results in error-prone development.

Solution

There is probably a cleaner way to implement this, such as a mix of polymorphic classes and select statements (as suggested by Jun), cpp (# lines) tricks, or a preprocessor such as what FMS uses.

@SamuelTrahanNOAA For the overloading capability, would you like to try the Fortran polymorphic class? Please see example: https://github.com/NOAA-GFDL/FMS/pull/962/files#diff-e76bad5442df93e413ddc44d0e23dd628f667843a955bb471d5ff5ea036cd944

I think the resulting code would be just as complex, and would use features many developers don't know. If Fortran had templates or generics, I would use that, but it doesn't.

Alternatives

None of the proposed solutions are ideal. Does anyone have better ideas?

SamuelTrahanNOAA avatar Jun 29 '22 16:06 SamuelTrahanNOAA