Skip to content

Commit 16121e1

Browse files
Merge branch 'fm/bugfix/UNST-8433_only_update_valobs_when_needed' into 'all/release/2025.01'
UNST-8433: Only update valobs when needed See merge request oss/delft3d!1440
2 parents 26da027 + 6932e54 commit 16121e1

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/engines_gpl/dflowfm/packages/dflowfm_kernel/src/dflowfm_data/fm_statistical_output.f90

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ module fm_statistical_output
3232
real(dp), dimension(:), allocatable, target :: SBCX, SBCY, SBWX, SBWY, SSWX, SSWY, SSCX, SSCY
3333
real(dp), dimension(:), allocatable, target :: qplat_data
3434

35+
logical, public :: apply_statistics_on_output
36+
3537
contains
3638

3739
subroutine close_fm_statistical_output()
@@ -2469,7 +2471,7 @@ subroutine flow_init_statistical_output_his(output_config_set, output_set)
24692471
call add_stat_output_items(output_set, output_config_set%configs(IDX_HIS_DISCHARGE_MAGNITUDE), valobs(:, IPNT_QMAG))
24702472
end if
24712473
end if
2472-
2474+
24732475
! Turbulence model
24742476
if (jahistur > 0) then
24752477
if (model_is_3D()) then
@@ -2953,6 +2955,7 @@ subroutine flow_init_statistical_output_his(output_config_set, output_set)
29532955
call process_output_quantity_configs(output_set)
29542956
call realloc(output_set, .true.) ! set size to count
29552957
call initialize_statistical_output(output_set%statout)
2958+
apply_statistics_on_output = any(station_statistics_requested(output_set%statout))
29562959

29572960
end subroutine flow_init_statistical_output_his
29582961

@@ -2971,6 +2974,21 @@ subroutine process_output_quantity_configs(output_set)
29712974

29722975
end subroutine process_output_quantity_configs
29732976

2977+
!> return whether the output variable item is a station where the requested operation type is a statistical one
2978+
elemental function station_statistics_requested(item) result(res)
2979+
use m_statistical_output_types, only: SO_CURRENT, SO_NONE, SO_UNKNOWN
2980+
2981+
type(t_output_variable_item), intent(in) :: item !< output variable item to check
2982+
logical :: res !< Return value
2983+
2984+
if (allocated(item%output_config)) then
2985+
res = (.not. any(item%operation_type == [SO_CURRENT, SO_NONE, SO_UNKNOWN])) .and. item%output_config%location_specifier == UNC_LOC_STATION
2986+
else
2987+
res = .false.
2988+
end if
2989+
2990+
end function station_statistics_requested
2991+
29742992
!> Deactivate invalid dimension IDs depending on model parameters
29752993
subroutine process_nc_dim_ids(nc_dim_ids)
29762994
use m_sediment, only: stm_included

src/engines_gpl/dflowfm/packages/dflowfm_kernel/src/dflowfm_kernel/main/flow_finalize_single_timestep.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,15 @@ subroutine flow_finalize_single_timestep(iresult)
8585
call timstrt('update HIS data DtUser', handle_extra(75))
8686
if (ti_his > 0) then
8787

88-
call updateValuesOnObservationStations()
88+
if (apply_statistics_on_output) then ! update every numerical timestep if statistics requested
89+
call updateValuesOnObservationStations()
90+
end if
8991

9092
if (comparereal(time1, time_his, eps10) >= 0) then
93+
if (.not. apply_statistics_on_output) then
94+
call updateValuesOnObservationStations()
95+
end if
96+
9197
!do_fourier = do_fourier .or. (md_fou_step == 2)
9298
if (jampi == 1) then
9399
call updateValuesOnRunupGauges_mpi()

0 commit comments

Comments
 (0)