Skip to content

Commit

Permalink
Add finalisation routine to gw_ml to destroy the net.
Browse files Browse the repository at this point in the history
  • Loading branch information
jatkinson1000 committed Aug 19, 2024
1 parent ab846d3 commit aa106e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/physics/cam/gw_drag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/physics/cam/gw_ml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa106e6

Please sign in to comment.