Skip to content

Commit 49aa47d

Browse files
authored
Merge pull request #1450 from Hallberg-NOAA/geothermal_cleanup
+Fixed rare issue with MOM_geothermal and cleanup
2 parents 0abf9c2 + 777bd35 commit 49aa47d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/parameterizations/vertical/MOM_geothermal.F90

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module MOM_geothermal
33

44
! This file is part of MOM6. See LICENSE.md for the license.
55

6-
use MOM_diag_mediator, only : post_data, register_diag_field, safe_alloc_ptr
6+
use MOM_diag_mediator, only : post_data, register_diag_field, safe_alloc_alloc
77
use MOM_diag_mediator, only : register_static_field, time_type, diag_ctrl
88
use MOM_domains, only : pass_var
99
use MOM_error_handler, only : MOM_error, FATAL, WARNING
@@ -23,22 +23,21 @@ module MOM_geothermal
2323

2424
!> Control structure for geothermal heating
2525
type, public :: geothermal_CS ; private
26-
real :: dRcv_dT_inplace !< The value of dRcv_dT above which (dRcv_dT is
27-
!! negative) the water is heated in place instead
28-
!! of moving upward between layers [R degC-1 ~> kg m-3 degC-1].
29-
real, pointer :: geo_heat(:,:) => NULL() !< The geothermal heat flux [J m-2 T-1 ~> W m-2].
26+
real :: dRcv_dT_inplace !< The value of dRcv_dT above which (dRcv_dT is negative) the
27+
!! water is heated in place instead of moving upward between
28+
!! layers in non-ALE layered mode [R degC-1 ~> kg m-3 degC-1]
29+
real, allocatable, dimension(:,:) :: geo_heat !< The geothermal heat flux [J m-2 T-1 ~> W m-2]
3030
real :: geothermal_thick !< The thickness over which geothermal heating is
31-
!! applied [H ~> m or kg m-2].
32-
logical :: apply_geothermal !< If true, geothermal heating will be applied
33-
!! otherwise GEOTHERMAL_SCALE has been set to 0 and
34-
!! there is no heat to apply.
35-
36-
type(time_type), pointer :: Time => NULL() !< A pointer to the ocean model's clock.
37-
type(diag_ctrl), pointer :: diag => NULL() !< A structure that is used to
38-
!! regulate the timing of diagnostic output.
39-
integer :: id_internal_heat_heat_tendency = -1 !< ID for diagnostic of heat tendency
40-
integer :: id_internal_heat_temp_tendency = -1 !< ID for diagnostic of temperature tendency
41-
integer :: id_internal_heat_h_tendency = -1 !< ID for diagnostic of thickness tendency
31+
!! applied [H ~> m or kg m-2]
32+
logical :: apply_geothermal !< If true, geothermal heating will be applied. This is false if
33+
!! GEOTHERMAL_SCALE is 0 and there is no heat to apply.
34+
35+
type(time_type), pointer :: Time => NULL() !< A pointer to the ocean model's clock
36+
type(diag_ctrl), pointer :: diag => NULL() !< A structure that is used to regulate the timing
37+
!! timing of diagnostic output
38+
integer :: id_internal_heat_heat_tendency = -1 !< ID for diagnostic of heat tendency
39+
integer :: id_internal_heat_temp_tendency = -1 !< ID for diagnostic of temperature tendency
40+
integer :: id_internal_heat_h_tendency = -1 !< ID for diagnostic of thickness tendency
4241

4342
end type geothermal_CS
4443

@@ -532,7 +531,7 @@ subroutine geothermal_init(Time, G, GV, US, param_file, diag, CS, useALEalgorith
532531
CS%apply_geothermal = .not.(geo_scale == 0.0)
533532
if (.not.CS%apply_geothermal) return
534533

535-
call safe_alloc_ptr(CS%geo_heat, isd, ied, jsd, jed) ; CS%geo_heat(:,:) = 0.0
534+
call safe_alloc_alloc(CS%geo_heat, isd, ied, jsd, jed) ; CS%geo_heat(:,:) = 0.0
536535

537536
call get_param(param_file, mdl, "GEOTHERMAL_FILE", geo_file, &
538537
"The file from which the geothermal heating is to be "//&
@@ -544,7 +543,8 @@ subroutine geothermal_init(Time, G, GV, US, param_file, diag, CS, useALEalgorith
544543
"The value of drho_dT above which geothermal heating "//&
545544
"simply heats water in place instead of moving it between "//&
546545
"isopycnal layers. This must be negative.", &
547-
units="kg m-3 K-1", scale=US%kg_m3_to_R, default=-0.01)
546+
units="kg m-3 K-1", scale=US%kg_m3_to_R, default=-0.01, &
547+
do_not_log=((GV%nk_rho_varies<=0).or.(GV%nk_rho_varies>=GV%ke)) )
548548
if (CS%dRcv_dT_inplace >= 0.0) call MOM_error(FATAL, "geothermal_init: "//&
549549
"GEOTHERMAL_DRHO_DT_INPLACE must be negative.")
550550

@@ -554,8 +554,8 @@ subroutine geothermal_init(Time, G, GV, US, param_file, diag, CS, useALEalgorith
554554
filename = trim(inputdir)//trim(geo_file)
555555
call log_param(param_file, mdl, "INPUTDIR/GEOTHERMAL_FILE", filename)
556556
call get_param(param_file, mdl, "GEOTHERMAL_VARNAME", geotherm_var, &
557-
"The name of the geothermal heating variable in "//&
558-
"GEOTHERMAL_FILE.", default="geo_heat")
557+
"The name of the geothermal heating variable in GEOTHERMAL_FILE.", &
558+
default="geo_heat")
559559
call MOM_read_data(filename, trim(geotherm_var), CS%geo_heat, G%Domain)
560560
do j=jsd,jed ; do i=isd,ied
561561
CS%geo_heat(i,j) = (G%mask2dT(i,j) * geo_scale) * CS%geo_heat(i,j)
@@ -601,7 +601,7 @@ end subroutine geothermal_init
601601
subroutine geothermal_end(CS)
602602
type(geothermal_CS), intent(inout) :: CS !< Geothermal heating control structure that
603603
!! will be deallocated in this subroutine.
604-
deallocate(CS%geo_heat)
604+
if (allocated(CS%geo_heat)) deallocate(CS%geo_heat)
605605
end subroutine geothermal_end
606606

607607
!> \namespace mom_geothermal

0 commit comments

Comments
 (0)