diff --git a/src/physics/cam/gw_drag.F90 b/src/physics/cam/gw_drag.F90 index 252e054e01..83e56d898e 100644 --- a/src/physics/cam/gw_drag.F90 +++ b/src/physics/cam/gw_drag.F90 @@ -42,7 +42,8 @@ module gw_drag use gw_common, only: GWBand use gw_convect, only: BeresSourceDesc use gw_front, only: CMSourceDesc - use gw_ml, only: gw_drag_convect_dp_ml_init, gw_drag_convect_dp_ml + use gw_ml, only: gw_drag_convect_dp_ml_init, gw_drag_convect_dp_ml_final, & + gw_drag_convect_dp_ml ! Typical module header implicit none @@ -1259,7 +1260,7 @@ end subroutine handle_pio_error subroutine gw_final() ! Destroy neccessary attributes if using ML scheme for convective drag if ((gw_convect_dp_ml == 'on') .or. (gw_convect_dp_ml == 'bothon')) then - call torch_delete(gw_convect_dp_nn) + call gw_drag_convect_dp_ml_final() endif end subroutine gw_final diff --git a/src/physics/cam/gw_ml.F90 b/src/physics/cam/gw_ml.F90 index 9ec295308a..6ed404f8b7 100644 --- a/src/physics/cam/gw_ml.F90 +++ b/src/physics/cam/gw_ml.F90 @@ -16,7 +16,7 @@ module gw_ml private save -public :: gw_drag_convect_dp_ml, gw_drag_convect_dp_ml_init +public :: gw_drag_convect_dp_ml, gw_drag_convect_dp_ml_init, gw_drag_convect_dp_ml_final ! Neural Net as read in by FTorch type(torch_model) :: convect_net @@ -153,6 +153,14 @@ subroutine gw_drag_convect_dp_ml_init(neural_net_path, norms_path) end subroutine gw_drag_convect_dp_ml_init +subroutine gw_drag_convect_dp_ml_final() + + ! Destroy the convective drag net + call torch_delete(convect_net) + +end subroutine gw_drag_convect_dp_ml_final + + subroutine read_norms(norms_path) use netcdf