From 15f16bb857d1dc5929b586f2e4c8c6e91ee70c25 Mon Sep 17 00:00:00 2001 From: William Xu Date: Thu, 5 Sep 2024 21:09:29 -0300 Subject: [PATCH] Inline harmonic analysis Set default HAready = False Also made additional adjustment to ensure harmonic analysis is not activated if tide is not used in the model. --- src/core/MOM_barotropic.F90 | 4 +--- src/core/MOM_dynamics_split_RK2.F90 | 2 +- src/core/MOM_dynamics_split_RK2b.F90 | 2 +- src/diagnostics/MOM_harmonic_analysis.F90 | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index eef142702f..fb2b133f0a 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -4504,9 +4504,6 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS, if (present(SAL_CSp)) then CS%SAL_CSp => SAL_CSp endif - if (present(HA_CSp)) then - CS%HA_CSp => HA_CSp - endif ! Read all relevant parameters and write them to the model log. call get_param(param_file, mdl, "SPLIT", CS%split, default=.true., do_not_log=.true.) @@ -4639,6 +4636,7 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS, default=.not.visc_rem_bug) call get_param(param_file, mdl, "TIDES", use_tides, & "If true, apply tidal momentum forcing.", default=.false.) + if (use_tides .and. present(HA_CSp)) CS%HA_CSp => HA_CSp call get_param(param_file, mdl, "CALCULATE_SAL", CS%calculate_SAL, & "If true, calculate self-attraction and loading.", default=use_tides) det_de = 0.0 diff --git a/src/core/MOM_dynamics_split_RK2.F90 b/src/core/MOM_dynamics_split_RK2.F90 index 11c3ff1873..addfb0e212 100644 --- a/src/core/MOM_dynamics_split_RK2.F90 +++ b/src/core/MOM_dynamics_split_RK2.F90 @@ -1547,7 +1547,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, tv, uh, vh, eta, Time, G, GV, US, p do j=js,je ; do i=is,ie ; eta(i,j) = CS%eta(i,j) ; enddo ; enddo call barotropic_init(u, v, h, CS%eta, Time, G, GV, US, param_file, diag, & - CS%barotropic_CSp, restart_CS, calc_dtbt, CS%BT_cont, CS%SAL_CSp, CS%HA_CSp) + CS%barotropic_CSp, restart_CS, calc_dtbt, CS%BT_cont, CS%SAL_CSp, HA_CSp) if (.not. query_initialized(CS%diffu, "diffu", restart_CS) .or. & .not. query_initialized(CS%diffv, "diffv", restart_CS)) then diff --git a/src/core/MOM_dynamics_split_RK2b.F90 b/src/core/MOM_dynamics_split_RK2b.F90 index 0220db7993..9227ea57ed 100644 --- a/src/core/MOM_dynamics_split_RK2b.F90 +++ b/src/core/MOM_dynamics_split_RK2b.F90 @@ -1463,7 +1463,7 @@ subroutine initialize_dyn_split_RK2b(u, v, h, tv, uh, vh, eta, Time, G, GV, US, call barotropic_init(u, v, h, CS%eta, Time, G, GV, US, param_file, diag, & CS%barotropic_CSp, restart_CS, calc_dtbt, CS%BT_cont, & - CS%SAL_CSp, CS%HA_CSp) + CS%SAL_CSp, HA_CSp) flux_units = get_flux_units(GV) thickness_units = get_thickness_units(GV) diff --git a/src/diagnostics/MOM_harmonic_analysis.F90 b/src/diagnostics/MOM_harmonic_analysis.F90 index 76adad5c8e..1e3b9895cb 100644 --- a/src/diagnostics/MOM_harmonic_analysis.F90 +++ b/src/diagnostics/MOM_harmonic_analysis.F90 @@ -39,7 +39,7 @@ module MOM_harmonic_analysis !> The public control structure of the MOM_harmonic_analysis module type, public :: harmonic_analysis_CS ; private - logical :: HAready = .true. !< If true, perform harmonic analysis + logical :: HAready = .false. !< If true, perform harmonic analysis type(time_type) :: & time_start, & !< Start time of harmonic analysis time_end, & !< End time of harmonic analysis @@ -107,6 +107,8 @@ subroutine HA_init(Time, US, param_file, time_ref, nc, freq, phase0, const_name, CS%HAready = .false. ; return endif + CS%HAready = .true. + if (HA_start_time < 0.0) then HA_start_time = HA_end_time + HA_start_time if (HA_start_time <= 0.0) HA_start_time = 0.0