From 0c3cb73b2af25136eed116ceb8d6f7e2d7bbb119 Mon Sep 17 00:00:00 2001 From: Niels Claes Date: Thu, 11 May 2023 16:15:24 +0200 Subject: [PATCH] better logging if user-defined H gets overridden --- src/mod_equilibrium.f08 | 3 --- src/mod_inspections.f08 | 5 ++++- src/mod_version.f08 | 2 +- src/physics/mod_heatloss.f08 | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/mod_equilibrium.f08 b/src/mod_equilibrium.f08 index 95ff51533..c425a16b3 100644 --- a/src/mod_equilibrium.f08 +++ b/src/mod_equilibrium.f08 @@ -236,9 +236,6 @@ subroutine set_equilibrium(settings, grid, background, physics) if (settings%physics%cooling%is_enabled()) then call physics%heatloss%cooling%initialise() end if - call physics%heatloss%check_if_thermal_balance_needs_enforcing( & - physics%conduction, grid & - ) call physics%hall%validate_scale_ratio(grid%gaussian_grid) end subroutine set_equilibrium diff --git a/src/mod_inspections.f08 b/src/mod_inspections.f08 index bf8ca5666..b291142cf 100644 --- a/src/mod_inspections.f08 +++ b/src/mod_inspections.f08 @@ -33,8 +33,11 @@ subroutine do_equilibrium_inspections(settings, grid, background, physics) type(settings_t), intent(in) :: settings type(grid_t), intent(in) :: grid type(background_t), intent(in) :: background - type(physics_t), intent(in) :: physics + type(physics_t), intent(inout) :: physics + call physics%heatloss%check_if_thermal_balance_needs_enforcing( & + physics%conduction, grid & + ) if (nan_values_present(background, physics, grid)) return if (negative_values_present(background, grid)) return if (.not. wave_numbers_are_valid(geometry=settings%grid%get_geometry())) return diff --git a/src/mod_version.f08 b/src/mod_version.f08 index 8a7eccfbf..b1873124a 100644 --- a/src/mod_version.f08 +++ b/src/mod_version.f08 @@ -14,6 +14,6 @@ module mod_version implicit none !> legolas version number - character(len=10), parameter :: LEGOLAS_VERSION = "2.0.2" + character(len=10), parameter :: LEGOLAS_VERSION = "2.0.3" end module mod_version diff --git a/src/physics/mod_heatloss.f08 b/src/physics/mod_heatloss.f08 index 4561aa803..35e3f6a87 100644 --- a/src/physics/mod_heatloss.f08 +++ b/src/physics/mod_heatloss.f08 @@ -80,6 +80,8 @@ end subroutine set_module_pointers subroutine check_if_thermal_balance_needs_enforcing(this, conduction_tgt, grid_tgt) + use mod_function_utils, only: zero_func + class(heatloss_t), intent(inout) :: this type(conduction_t), intent(in) :: conduction_tgt type(grid_t), intent(in) :: grid_tgt @@ -87,6 +89,8 @@ subroutine check_if_thermal_balance_needs_enforcing(this, conduction_tgt, grid_t if (.not. settings%physics%heating%is_enabled()) return if (.not. settings%physics%heating%force_thermal_balance) return + if (.not. associated(this%heating%H, zero_func)) call log_usr_H_func_warning() + call set_module_pointers(conduction_tgt, grid_tgt, this%cooling) call logger%info("enforcing thermal balance by setting a constant heating term") this%heating%H => H_for_thermal_balance @@ -126,6 +130,21 @@ real(dp) function H_for_thermal_balance(x) end function H_for_thermal_balance + subroutine log_usr_H_func_warning() ! LCOV_EXCL_START + call logger%warning( & + "found user-defined heating function but forced thermal balance enabled!" & + ) + call logger%disable_prefix() + call logger%warning( & + "The provided function will be ignored and thermal balance will be enforced." & + ) + call logger%warning( & + "To disable this behaviour, set force_thermal_balance = .false. in the parfile" & + ) + call logger%enable_prefix() + end subroutine log_usr_H_func_warning ! LCOV_EXCL_STOP + + subroutine delete(this) class(heatloss_t), intent(inout) :: this nullify(settings)