Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add finalize subroutine for stochastic physics #32

Merged
merged 2 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions stochastic_physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module stochastic_physics

public :: init_stochastic_physics
public :: run_stochastic_physics
public :: finalize_stochastic_physics

contains

Expand Down Expand Up @@ -345,4 +346,76 @@ subroutine run_stochastic_physics(levs, kdt, phour, blksz, xlat, xlon, sppt_wts,

end subroutine run_stochastic_physics

subroutine finalize_stochastic_physics()
use stochy_data_mod, only : nshum,rpattern_shum,rpattern_sppt,nsppt,rpattern_skeb,nskeb,&
vfact_sppt,vfact_shum,vfact_skeb, skeb_vwts,skeb_vpts, &
rpattern_sfc, nlndp,gg_lats,gg_lons,sl,skebu_save,skebv_save,gis_stochy
use stochy_gg_def, only : wgt_a,sinlat_a,coslat_a,colrad_a,wgtcs_a,rcs2_a,lats_nodes_h,global_lats_h
use spectral_layout_mod, only : lat1s_a ,lon_dims_a
use stochy_layout_lag, only : lat1s_h
implicit none

if (allocated(gg_lats)) deallocate (gg_lats)
if (allocated(gg_lons)) deallocate (gg_lons)
if (allocated(sl)) deallocate (sl)
if (nsppt > 0) then
if (allocated(rpattern_sppt)) deallocate(rpattern_sppt)
if (allocated(vfact_sppt)) deallocate(vfact_sppt)
endif
if (nshum > 0) then
if (allocated(rpattern_shum)) deallocate(rpattern_shum)
if (allocated(vfact_shum)) deallocate(vfact_shum)
endif
if (nskeb > 0) then
if (allocated(rpattern_skeb)) deallocate(rpattern_skeb)
if (allocated(skeb_vwts)) deallocate (skeb_vwts)
if (allocated(skeb_vpts)) deallocate (skeb_vpts)
if (allocated(skebu_save)) deallocate (skebu_save)
if (allocated(skebv_save)) deallocate (skebv_save)
if (allocated(vfact_skeb)) deallocate(vfact_skeb)
endif
if (nlndp > 0) then
if (allocated(rpattern_sfc)) deallocate(rpattern_sfc)
endif

deallocate(lat1s_a)
deallocate(lon_dims_a)
deallocate(wgt_a)
deallocate(wgtcs_a)
deallocate(rcs2_a)
deallocate(colrad_a)
deallocate(sinlat_a)
deallocate(coslat_a)
deallocate(lat1s_h)
deallocate(gis_stochy%lonsperlat)
deallocate(gis_stochy%ls_node)
deallocate(gis_stochy%ls_nodes)
deallocate(gis_stochy%max_ls_nodes)
deallocate(gis_stochy%lats_nodes_a_fix)
deallocate(gis_stochy%lats_nodes_a)
deallocate(gis_stochy%global_lats_a)
deallocate(gis_stochy%lats_nodes_ext)
deallocate(gis_stochy%TRIE_LS_SIZE)
deallocate(gis_stochy%TRIO_LS_SIZE)
deallocate(gis_stochy%TRIEO_LS_SIZE)
deallocate(gis_stochy%LS_MAX_NODE_GLOBAL)
deallocate(gis_stochy%LS_NODE_GLOBAL)
deallocate(gis_stochy%epse)
deallocate(gis_stochy%epso)
deallocate(gis_stochy%epsedn)
deallocate(gis_stochy%epsodn)
deallocate(gis_stochy%kenorm_e)
deallocate(gis_stochy%kenorm_o)
deallocate(gis_stochy%snnp1ev)
deallocate(gis_stochy%snnp1od)
deallocate(gis_stochy%plnev_a)
deallocate(gis_stochy%plnod_a)
deallocate(gis_stochy%pddev_a)
deallocate(gis_stochy%pddod_a)
deallocate(gis_stochy%plnew_a)
deallocate(gis_stochy%plnow_a)

end subroutine finalize_stochastic_physics


end module stochastic_physics
1 change: 1 addition & 0 deletions stochy_data_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret)
if (is_master() .and. stochini) CLOSE(stochlun)
deallocate(noise_e,noise_o)
end subroutine init_stochdata

!>@brief This subroutine 'read_pattern' will read in the spectral coeffients from a previous run (stored in stoch_ini,
!!turned on by setting STOCHINI=.true.)
!>@details Data read in are flat binary, so the number of stochastic physics patterns running must match previous run
Expand Down