NOAA-GFDL / FMS

GFDL's Flexible Modeling System
Other
87 stars 128 forks source link

Modern diag_manager: The `weight` argument is not passed into reduction method functions #1512

Closed uramirez8707 closed 2 months ago

uramirez8707 commented 2 months ago

Describe the bug The weight optional argument is passed into accept_data from send_data and it is copied into the field_weight (field_weight will be 1 if weight was not passed in) https://github.com/NOAA-GFDL/FMS/blob/d42f8aca45bfefaaa45295888a36548b9a9b5a29/diag_manager/fms_diag_object.F90#L575

The field_weight is then passed into fms_diag_do_reduction https://github.com/NOAA-GFDL/FMS/blob/d42f8aca45bfefaaa45295888a36548b9a9b5a29/diag_manager/fms_diag_object.F90#L696-L697 and it is then not used at all

To Reproduce Add an a time varying weight to a send_data call and you will see that answers are not correct

This is what was causing small answer changes between the old and new diag manager in fields where the "weight" was passed in and it was constant.

The old diag was doing

(x(t1)*weight + x(t2)*weight) / 2*(weight)

The new diag was doing

(x(t1)+x(t2))/2 

overtime the differences accumulated!

Expected behavior The weight should be passed in to the do_time_sum_wrapper subroutines. https://github.com/NOAA-GFDL/FMS/blob/d42f8aca45bfefaaa45295888a36548b9a9b5a29/diag_manager/fms_diag_object.F90#L1051-L1086

System Environment This happens in any system

Additional context N/A