Skip to content

Commit

Permalink
Migrating solve steps to new_decomp.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaxmonsky committed Sep 16, 2024
1 parent d347a39 commit 5ebc048
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 128 deletions.
21 changes: 10 additions & 11 deletions src/physics/cam/diffusion_solver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ subroutine compute_vdiff( lchnk ,
use coords_1d, only: Coords1D
use linear_1d_operators, only : BoundaryType, BoundaryFixedLayer, &
BoundaryData, BoundaryFlux, TriDiagDecomp
use vdiff_lu_solver, only : fin_vol_lu_decomp
use new_decomp, only : fin_vol_solve
use beljaars_drag_cam, only : do_beljaars
! FIXME: This should not be needed
use air_composition, only: rairv

use phys_control, only : phys_getopts
use phys_control, only : phys_getopts
use vdiff_lu_solver, only : fin_vol_lu_decomp

! Modification : Ideally, we should diffuse 'liquid-ice static energy' (sl), not the dry static energy.
! Also, vertical diffusion of cloud droplet number concentration and aerosol number
Expand Down Expand Up @@ -576,10 +577,10 @@ end function vd_lu_qdecomp

du = u(:ncol,:)
dv = v(:ncol,:)
call new_fin_vol_lu_decomp(ztodt, p, u(:ncol,:), du, ncol, pver, &
du = fin_vol_solve(ztodt, p, u(:ncol,:), ncol, pver, &
coef_q=tau_damp_rate, &
coef_q_diff=kvm(:ncol,:)*dpidz_sq)
call new_fin_vol_lu_decomp(ztodt, p, v(:ncol,:), dv, ncol, pver, &
dv = fin_vol_solve(ztodt, p, v(:ncol,:), ncol, pver, &
coef_q=tau_damp_rate, &
coef_q_diff=kvm(:ncol,:)*dpidz_sq)
u(:ncol,:) = u(:ncol,:) + du
Expand Down Expand Up @@ -750,12 +751,12 @@ end function vd_lu_qdecomp
! condition is defined directly on the top interface.
if (.not. use_spcam) then
ddse = dse(:ncol,:)
call new_fin_vol_lu_decomp(ztdot, p, dse(:ncol,:), ddse, &
ddse = fin_vol_solve(ztodt, p, dse(:ncol,:), &
ncol, pver, &
coef_q_diff=kvh(:ncol,:)*dpidz_sq, &
upper_bndry=interface_boundary, &
l_cond=BoundaryData(dse_top(:ncol)))
dse(:nol,:) = dse(:ncol,:) + ddse
dse(:ncol,:) = dse(:ncol,:) + ddse
endif

! Calculate flux at top interface
Expand All @@ -771,13 +772,12 @@ end function vd_lu_qdecomp
! upper boundary is zero flux for extended model
if (.not. use_spcam) then
dttemp = ttemp
call new_fin_vol_lu_decomp(ztdot, p, ttemp, dttemp, ncol, pver, &
coef_q_diff=kvt(:ncol,:)*dpidz_sq &
dttemp = fin_vol_solve(ztodt, p, ttemp, ncol, pver, &
coef_q_diff=kvt(:ncol,:)*dpidz_sq, &
coef_q_weight=cpairv(:ncol,:))
ttemp = ttemp + dttemp
end if

call decomp%finalize()

!-------------------------------------
! Update dry static energy
Expand All @@ -798,8 +798,7 @@ end function vd_lu_qdecomp
! Boundary layer thickness of "0._r8" signifies that the boundary
! condition is defined directly on the top interface.
if (.not. use_spcam) then
ddse = dse(:ncol,:)
call new_fin_vol_lu_decomp(ztdot, p, dse(:ncol,:), ddse, ncol, pver, &
ddse = fin_vol_solve(ztodt, p, dse(:ncol,:), ncol, pver, &
coef_q_diff=kv_total(:ncol,:)*dpidz_sq, &
upper_bndry=interface_boundary, &
l_cond=BoundaryData(dse_top(:ncol)))
Expand Down
4 changes: 2 additions & 2 deletions src/physics/cam/eddy_diff_cam.F90
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
zero , fieldlist_wet, fieldlist_molec, &
ufd , vfd , qtfd , slfd , &
jnk1d , jnk1d , jnk2d , jnk1d , errstring , &
tauresx , tauresy , 0 , cpairv(:,:,lchnk), zero, &
.false., .false. )
tauresx , tauresy , 0 , cpairv(:,:,lchnk), zero, &
.false., .false.)

call handle_errmsg(errstring, subname="compute_vdiff", &
extra_msg="compute_vdiff called from eddy_diff_cam")
Expand Down
Loading

0 comments on commit 5ebc048

Please sign in to comment.