Skip to content

Commit

Permalink
Add a gw_final() subroutine to destroy NN instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jatkinson1000 committed Aug 19, 2024
1 parent 7968fa9 commit b3ac3e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/physics/cam/gw_drag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module gw_drag
public :: gw_drag_readnl ! Read namelist
public :: gw_init ! Initialization
public :: gw_tend ! interface to actual parameterization
public :: gw_final ! Finalization

!
! PRIVATE: Rest of the data and interfaces are private to this module
Expand Down Expand Up @@ -1249,6 +1250,15 @@ 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_module_delete(gw_convect_dp_nn)
endif
end subroutine gw_final

!==========================================================================

subroutine gw_tend(state, pbuf, dt, ptend, cam_in, flx_heat)
!-----------------------------------------------------------------------
! Interface for multiple gravity wave drag parameterization.
Expand Down
3 changes: 3 additions & 0 deletions src/physics/cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ subroutine phys_final( phys_state, phys_tend, pbuf2d )
use microp_aero, only : microp_aero_final
use phys_grid_ctem, only : phys_grid_ctem_final
use nudging, only: Nudge_Model, nudging_final
use gw_drag, only: gw_final

!-----------------------------------------------------------------------
!
Expand Down Expand Up @@ -1367,6 +1368,8 @@ subroutine phys_final( phys_state, phys_tend, pbuf2d )
call HCOI_Chunk_Final
endif

call gw_final()

end subroutine phys_final


Expand Down

0 comments on commit b3ac3e9

Please sign in to comment.