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

Phase 2 of GW development #1117

Draft
wants to merge 7 commits into
base: cam_development
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -3832,6 +3832,7 @@ my $do_gw_convect_sh = ($nl->get_value('use_gw_convect_sh') =~ /$TRUE/io);
my $do_gw_movmtn_pbl = ($nl->get_value('use_gw_movmtn_pbl') =~ /$TRUE/io);
my $do_gw_rdg_beta = ($nl->get_value('use_gw_rdg_beta') =~ /$TRUE/io);
my $do_gw_rdg_gamma = ($nl->get_value('use_gw_rdg_gamma') =~ /$TRUE/io);
my $do_gw_rdg_resid = ($nl->get_value('use_gw_rdg_resid') =~ /$TRUE/io);

my $do_divstream = ($nl->get_value('gw_rdg_do_divstream') =~ /$TRUE/io);

Expand Down Expand Up @@ -3905,6 +3906,10 @@ if ($do_gw_rdg_beta) {
add_default($nl, 'gw_prndl');
}

if ($do_gw_rdg_resid) {
add_default($nl, 'effgw_rdg_resid');
}

if ($do_gw_rdg_gamma) {
add_default($nl, 'n_rdg_gamma', 'val'=>'-1');
add_default($nl, 'effgw_rdg_gamma', 'val'=>'1.0D0');
Expand Down
4 changes: 4 additions & 0 deletions bld/namelist_files/namelist_defaults_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,10 @@
<effgw_rdg_beta_max model_top="lt" >0.5D0</effgw_rdg_beta_max>
<effgw_rdg_beta_max model_top="mt" >0.5D0</effgw_rdg_beta_max>

<effgw_rdg_beta_max >JULIO</effgw_rdg_beta_max>
<effgw_rdg_beta_max model_top="lt" >JULIO</effgw_rdg_beta_max>
<effgw_rdg_beta_max model_top="mt" >JULIO</effgw_rdg_beta_max>

<!-- setting for gravity waves from shallow convection. -->
<effgw_beres_sh>0.03D0</effgw_beres_sh>

Expand Down
12 changes: 12 additions & 0 deletions bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,12 @@ Whether or not to enable gravity waves from PBL moving mountains source.
Default: .false.
</entry>

<entry id="use_gw_rdg_resid" type="logical" category="gw_drag"
group="gw_drag_nl" valid_values="" >
JULIO - need to add comment
Default: .false.
</entry>

<entry id="pgwv" type="integer" category="gw_drag"
group="gw_drag_nl" valid_values="" >
Gravity wave spectrum dimension (wave numbers are from -pgwv to pgwv).
Expand Down Expand Up @@ -1426,6 +1432,12 @@ Max efficiency associated with anisotropic OGW.
Default: 1.0
</entry>

<entry id="effgw_rdg_resid" type="real" category="gw_drag"
group="gw_drag_nl" valid_values="" >
JULIO - need to add comment and appropriate default
Default: ?????? JULIO
</entry>

<entry id="rdg_beta_cd_llb" type="real" category="gw_drag"
group="gw_drag_nl" valid_values="" >
Drag coefficient for obstacles in low-level flow.
Expand Down
57 changes: 52 additions & 5 deletions src/dynamics/se/dp_coupling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
! dry air mass.

use gravity_waves_sources, only: gws_src_fnct
use dyn_comp, only: frontgf_idx, frontga_idx
use phys_control, only: use_gw_front, use_gw_front_igw
use dyn_comp, only: frontgf_idx, frontga_idx, vort4gw_idx
use phys_control, only: use_gw_front, use_gw_front_igw, use_gw_movmtn_pbl
use hycoef, only: hyai, ps0
use fvm_mapping, only: dyn2phys_vector, dyn2phys_all_vars
use se_dyn_time_mod, only: timelevel_qdp
Expand Down Expand Up @@ -84,9 +84,18 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
real (kind=r8), allocatable :: frontga(:,:,:) ! function (frontgf) and angle (frontga)
real (kind=r8), allocatable :: frontgf_phys(:,:,:)
real (kind=r8), allocatable :: frontga_phys(:,:,:)

!++jtb 01/14/25
! Vorticity
real (kind=r8), allocatable :: vort4gw(:,:,:) ! temp arrays to hold vorticity
real (kind=r8), allocatable :: vort4gw_phys(:,:,:)


! Pointers to pbuf
real (kind=r8), pointer :: pbuf_frontgf(:,:)
real (kind=r8), pointer :: pbuf_frontga(:,:)
!++jtb 12/31/24
real (kind=r8), pointer :: pbuf_vort4gw(:,:)

integer :: ncols, ierr
integer :: col_ind, blk_ind(1), m
Expand All @@ -110,6 +119,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
nullify(pbuf_chnk)
nullify(pbuf_frontgf)
nullify(pbuf_frontga)
!++jtb
nullify(pbuf_vort4gw)



if (fv_nphys > 0) then
nphys = fv_nphys
Expand All @@ -136,10 +149,16 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
allocate(frontga(nphys_pts,pver,nelemd), stat=ierr)
if (ierr /= 0) call endrun("dp_coupling: Allocate of frontga failed.")
end if
if (use_gw_movmtn_pbl) then
!++jtb 01/14/25
allocate(vort4gw(nphys_pts,pver,nelemd), stat=ierr)
if (ierr /= 0) call endrun("dp_coupling: Allocate of vort4gw failed.")
end if

!++jtb 01/14/25
if (iam < par%nprocs) then
if (use_gw_front .or. use_gw_front_igw) then
call gws_src_fnct(elem, tl_f, tl_qdp_np0, frontgf, frontga, nphys)
if (use_gw_front .or. use_gw_front_igw .or. use_gw_movmtn_pbl ) then
call gws_src_fnct(elem, tl_f, tl_qdp_np0, frontgf, frontga, vort4gw, nphys)
end if

if (fv_nphys > 0) then
Expand Down Expand Up @@ -205,6 +224,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
frontgf(:,:,:) = 0._r8
frontga(:,:,:) = 0._r8
end if
if (use_gw_movmtn_pbl) then
!++jtb 01/14/25
vort4gw(:,:,:) = 0._r8
end if

endif ! iam < par%nprocs

Expand All @@ -223,6 +246,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
allocate(frontgf_phys(pcols, pver, begchunk:endchunk))
allocate(frontga_phys(pcols, pver, begchunk:endchunk))
end if
if (use_gw_movmtn_pbl) then
!++jtb 01/14/25
allocate(vort4gw_phys(pcols, pver, begchunk:endchunk))
end if
!$omp parallel do num_threads(max_num_threads) private (col_ind, lchnk, icol, ie, blk_ind, ilyr, m)
do col_ind = 1, phys_columns_on_task
call get_dyn_col_p(col_ind, ie, blk_ind)
Expand All @@ -240,6 +267,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
frontgf_phys(icol, ilyr, lchnk) = frontgf(blk_ind(1), ilyr, ie)
frontga_phys(icol, ilyr, lchnk) = frontga(blk_ind(1), ilyr, ie)
end if
if (use_gw_movmtn_pbl) then
!++jtb 01/14/25
vort4gw_phys(icol, ilyr, lchnk) = vort4gw(blk_ind(1), ilyr, ie)
end if
end do

do m = 1, pcnst
Expand All @@ -249,7 +280,7 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
end do
end do
if (use_gw_front .or. use_gw_front_igw) then
!$omp parallel do num_threads(max_num_threads) private (lchnk, ncols, icol, ilyr, pbuf_chnk, pbuf_frontgf, pbuf_frontga)
!$omp parallel do num_threads(max_num_threads) private (lchnk, ncols, icol, ilyr, pbuf_chnk, pbuf_frontgf, pbuf_frontga, pbuf_vort4gw)
do lchnk = begchunk, endchunk
ncols = get_ncols_p(lchnk)
pbuf_chnk => pbuf_get_chunk(pbuf2d, lchnk)
Expand All @@ -265,6 +296,22 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out)
deallocate(frontgf_phys)
deallocate(frontga_phys)
end if
!++jtb 01/14/25
if (use_gw_movmtn_pbl) then
!$omp parallel do num_threads(max_num_threads) private (lchnk, ncols, icol, ilyr, pbuf_chnk, pbuf_frontgf, pbuf_frontga, pbuf_vort4gw)
do lchnk = begchunk, endchunk
ncols = get_ncols_p(lchnk)
pbuf_chnk => pbuf_get_chunk(pbuf2d, lchnk)
call pbuf_get_field(pbuf_chnk, vort4gw_idx, pbuf_vort4gw)
do icol = 1, ncols
do ilyr = 1, pver
pbuf_vort4gw(icol, ilyr) = vort4gw_phys(icol, ilyr, lchnk)
end do
end do
end do
!++jtb 01/14/25
deallocate(vort4gw_phys)
end if

call t_stopf('dpcopy')

Expand Down
12 changes: 9 additions & 3 deletions src/dynamics/se/dyn_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module dyn_comp
cnst_is_a_water_species
use cam_control_mod, only: initial_run
use cam_initfiles, only: initial_file_get_id, topo_file_get_id, pertlim
use phys_control, only: use_gw_front, use_gw_front_igw
use phys_control, only: use_gw_front, use_gw_front_igw, use_gw_movmtn_pbl
use dyn_grid, only: ini_grid_name, timelevel, hvcoord, edgebuf, &
ini_grid_hdim_name

Expand Down Expand Up @@ -79,6 +79,8 @@ module dyn_comp
! Frontogenesis indices
integer, public :: frontgf_idx = -1
integer, public :: frontga_idx = -1
!++jtb
integer, public :: vort4gw_idx = -1

interface read_dyn_var
module procedure read_dyn_field_2d
Expand Down Expand Up @@ -572,6 +574,10 @@ subroutine dyn_register()
call pbuf_add_field("FRONTGA", "global", dtype_r8, (/pcols,pver/), &
frontga_idx)
end if
if (use_gw_movmtn_pbl) then
call pbuf_add_field("VORT4GW", "global", dtype_r8, (/pcols,pver/), &
vort4gw_idx)
end if

end subroutine dyn_register

Expand Down Expand Up @@ -875,8 +881,8 @@ subroutine dyn_init(dyn_in, dyn_out)
call get_loop_ranges(hybrid, ibeg=nets, iend=nete)
call prim_init2(elem, fvm, hybrid, nets, nete, TimeLevel, hvcoord)
!$OMP END PARALLEL

if (use_gw_front .or. use_gw_front_igw) call gws_init(elem)
!++jtb 01/14/25
if (use_gw_front .or. use_gw_front_igw .or. use_gw_movmtn_pbl) call gws_init(elem)
end if ! iam < par%nprocs

call addfld ('nu_kmvis', (/ 'lev' /), 'A', '', 'Molecular viscosity Laplacian coefficient' , gridname='GLL')
Expand Down
Loading
Loading