Skip to content

Commit

Permalink
first stage of clean up for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioTBacmeister committed Jan 29, 2025
1 parent 1825587 commit ea056d2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 35 deletions.
2 changes: 1 addition & 1 deletion bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -3912,7 +3912,7 @@ if ($do_gw_rdg_beta) {
}

if ($do_gw_rdg_resid) {
add_default($nl, 'effgw_rdg_resid', 'val'=>'1.0D0');
add_default($nl, 'effgw_rdg_resid' );
}

if ($do_gw_rdg_gamma) {
Expand Down
2 changes: 2 additions & 0 deletions bld/namelist_files/namelist_defaults_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@

<effgw_oro nlev="60" >0.0625D0</effgw_oro>

<effgw_rdg_resid >1.0D0</effgw_rdg_resid>

<effgw_rdg_beta >1.0D0</effgw_rdg_beta>
<effgw_rdg_beta model_top="lt" >0.5D0</effgw_rdg_beta>
<effgw_rdg_beta model_top="mt" >0.5D0</effgw_rdg_beta>
Expand Down
5 changes: 3 additions & 2 deletions bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1325,8 +1325,9 @@ Default: .false.

<entry id="use_gw_rdg_resid" type="logical" category="gw_drag"
group="gw_drag_nl" valid_values="" >
JULIO - need to add comment
Default: .false.
Whether or not to enable gravity waves from residual(non-ridge)
orography
Default: set by build-namelist.
</entry>

<entry id="pgwv" type="integer" category="gw_drag"
Expand Down
16 changes: 2 additions & 14 deletions src/dynamics/se/gravity_waves_sources.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module gravity_waves_sources
use element_mod, only: element_t
use hybrid_mod, only: hybrid_t
use shr_kind_mod, only: r8 => shr_kind_r8

!++ jtb (added for now, while debugging)
use cam_logfile, only: iulog

implicit none
Expand Down Expand Up @@ -105,8 +103,6 @@ subroutine gws_src_fnct(elem, tl, tlq, frontgf, frontga, nphys)

end subroutine gws_src_fnct

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!+++ jtb (01/20/24)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine gws_src_vort(elem, tl, tlq, vort4gw, nphys)
use derivative_mod, only : derivinit
Expand All @@ -133,8 +129,7 @@ subroutine gws_src_vort(elem, tl, tlq, vort4gw, nphys)

! This does not need to be a thread private data-structure
call derivinit(deriv)
!!$OMP PARALLEL NUM_THREADS(horz_num_threads), DEFAULT(SHARED), PRIVATE(nets,nete,hybrid,ie,ncols,frontgf_thr,frontga_thr)
! hybrid = config_thread_region(par,'horizontal')
!!$OMP PARALLEL NUM_THREADS(horz_num_threads), DEFAULT(SHARED), PRIVATE(nets,nete,hybrid,ie,ncols,vort4gw_thr)
hybrid = config_thread_region(par,'serial')
call get_loop_ranges(hybrid,ibeg=nets,iend=nete)

Expand All @@ -158,11 +153,6 @@ subroutine gws_src_vort(elem, tl, tlq, vort4gw, nphys)

end subroutine gws_src_vort





!++jtb (12/31/24)
subroutine compute_vorticity_4gw(vort4gw,tl,tlq,elem,ederiv,hybrid,nets,nete,nphys)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! compute vorticity for use in gw params
Expand Down Expand Up @@ -205,7 +195,7 @@ subroutine compute_vorticity_4gw(vort4gw,tl,tlq,elem,ederiv,hybrid,nets,nete,nph
do k=1,nlev
vort_gll(:,:,k,ie) = vort_gll(:,:,k,ie)*elem(ie)%spheremp(:,:)
end do
! pack ++jtb no idea what these routines are doing
! pack
call edgeVpack(edge1, vort_gll(:,:,:,ie),nlev,0,ie)
enddo
call bndry_exchange(hybrid,edge1,location='compute_vorticity_4gw')
Expand Down Expand Up @@ -315,8 +305,6 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,tlq,elem,ederiv,hybrid,nets,
enddo
! pack
call edgeVpack(edge3, frontgf_gll(:,:,:,ie),nlev,0,ie)
!++jtb:
! Why are dims 2*nlev,nlev, not 2*nlev,2*nlev, or nlev,nlev, ????
call edgeVpack(edge3, gradth(:,:,:,:,ie),2*nlev,nlev,ie)
enddo
call bndry_exchange(hybrid,edge3,location='compute_frontogenesis')
Expand Down
14 changes: 2 additions & 12 deletions src/physics/cam/gw_drag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module gw_drag
integer :: ttend_sh_idx = -1
integer :: frontgf_idx = -1
integer :: frontga_idx = -1
!++jtb
!
integer :: vort4gw_idx = -1

integer :: sgh_idx = -1
Expand Down Expand Up @@ -385,12 +385,6 @@ subroutine gw_drag_readnl(nlfile)
call mpi_bcast(effgw_rdg_resid, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: effgw_rdg_resid")

!++ jtb (12/24/2024)
! This is confusing. Not sure when if ever this was needed.
! Check if fcrit2 was set.
!call shr_assert(fcrit2 /= unset_r8, &
! "gw_drag_readnl: fcrit2 must be set via the namelist."// &
! errMsg(__FILE__, __LINE__))

! Check if pgwv was set.
call shr_assert(pgwv >= 0, &
Expand Down Expand Up @@ -1647,7 +1641,7 @@ subroutine gw_tend(state, pbuf, dt, ptend, cam_in, flx_heat)
! Frontogenesis
real(r8), pointer :: frontgf(:,:)
real(r8), pointer :: frontga(:,:)
!++jtb 12/31/24
! Vorticity source
real(r8), pointer :: vort4gw(:,:)

! Temperature change due to deep convection.
Expand Down Expand Up @@ -1838,7 +1832,6 @@ subroutine gw_tend(state, pbuf, dt, ptend, cam_in, flx_heat)
call pbuf_get_field(pbuf, upwp_clubb_gw_idx, upwp_clubb_gw)
call pbuf_get_field(pbuf, vpwp_clubb_gw_idx, vpwp_clubb_gw)

!++jtb 01/03/25
! Vorticity from SE dycore. This needs to be either
! generalized to other dycores or protected with some
! endrun if dycore != SE
Expand Down Expand Up @@ -1911,8 +1904,6 @@ subroutine gw_tend(state, pbuf, dt, ptend, cam_in, flx_heat)
call outfld('WPTHLP_CLUBB_GW', wpthlp_clubb_gw, pcols, lchnk)
call outfld('UPWP_CLUBB_GW', upwp_clubb_gw, pcols, lchnk)
call outfld('VPWP_CLUBB_GW', vpwp_clubb_gw, pcols, lchnk)

!++jtb 01/03/25 (see comment above)
call outfld ('VORT4GW', vort4gw, pcols, lchnk)

!Deallocate variables that are no longer used:
Expand Down Expand Up @@ -2756,7 +2747,6 @@ subroutine gw_rdg_calc( &

if (luse_gw_rdg_resid == .true.) then
! Add additional GW from residual variance. Assumed isotropic
!kwvrdg = 0.001_r8 / ( hwdth(:,nn) + 0.001_r8 ) ! this cant be done every time step !!!
kwvrdg = 0.001_r8 / ( 100._r8 )
effgw = effgw_rdg_resid * isowgt !1.0_r8 * isowgt
tauoro = 0._r8
Expand Down
9 changes: 3 additions & 6 deletions src/physics/cam/gw_movmtn.F90
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ subroutine gw_movmtn_src(ncol,lchnk, band, desc, u, v, &
! Calculate flux source from vorticity
!----------------------------------------------------------------------
call vorticity_flux_src( vorticity, ncol, pver , alpha_gw_movmtn, xpwp_src, Steer_k, Launch_k )
end if
if ( source_type==2 ) then
else if ( source_type==2 ) then
!----------------------------------------------------------------------
! Calculate flux source from ShCu/PBL and set Steering level
!----------------------------------------------------------------------
Expand Down Expand Up @@ -446,7 +445,6 @@ end function index_of_nearest

!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine shcu_flux_src (xpwp_shcu , ncol, pverx, alpha_gw_movmtn, xpwp_src, steering_level, launch_level ) !! result(xpwp_src)
!!! use gw_common, only: pver
integer, intent(in) :: ncol,pverx
real(r8), intent(in) :: xpwp_shcu (ncol,pverx)
real(r8), intent(in) :: alpha_gw_movmtn
Expand Down Expand Up @@ -474,7 +472,6 @@ end subroutine shcu_flux_src

!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine vorticity_flux_src (vorticity , ncol, pverx, alpha_gw_movmtn, vort_src, steering_level, launch_level ) !! result(xpwp_src)
!!! use gw_common, only: pver
integer, intent(in) :: ncol,pverx
real(r8), intent(in) :: vorticity (ncol,pverx)
real(r8), intent(in) :: alpha_gw_movmtn
Expand All @@ -485,8 +482,8 @@ subroutine vorticity_flux_src (vorticity , ncol, pverx, alpha_gw_movmtn, vort_sr
real(r8) :: scale_factor
integer :: k, nlayers

steering_level(:ncol) = pverx - 20 !++ ?????
launch_level(:ncol) = steering_level -10 !++ tuning test 01/05/25
steering_level(:ncol) = pverx - 20
launch_level(:ncol) = steering_level -10

scale_factor = 1.e4 ! scales vorticity amp to u'w' in CLUBB
!-----------------------------------
Expand Down

0 comments on commit ea056d2

Please sign in to comment.