Skip to content

Commit

Permalink
Merge branch 'kaizhangpnl/atm/ieflx_cleanup' (PR #1498)
Browse files Browse the repository at this point in the history
Further modifications to check_energy.F90

Further modifications to check_energy.F90 to address the need from the
coupled team. Cleaned up the IEFLX code and added more comments.
Please note that the namelist variable l_ieflx_fix was removed and the
fixer can be switched on if ieflx_opt is 1 or 2 (recommended value is
2).

The problem associated with #1479 went away with those changes.

SHFLXFIX was removed. Instead, we output SHFLXORI (SHFLX before
applying the IEFLX fixer).

IEFLX is now a constant field (global mean IEFLX) and default output.

Also removed the pbuf variable for IEFLX, since it is not used at this
time.

[BFB] for prognostic fields, but IEFLX and SHFLXFIX are changed/removed.

Fixes #1479

* kaizhangpnl/atm/ieflx_cleanup:
  Further modifications to check_energy.F90 to address the need from the coupled team.
  minor comment
  Bugfix for the IEFLX fixer

Conflicts:
	components/cam/src/physics/cam/phys_control.F90
  • Loading branch information
singhbalwinder committed Jun 6, 2017
2 parents b72e8a1 + 920864c commit 8abf0b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 44 deletions.
6 changes: 0 additions & 6 deletions components/cam/bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,6 @@ IEFLX fixer options
Default: 0
</entry>

<entry id="l_ieflx_fix" type="logical" category="fixers"
group="phys_ctl_nl" valid_values="" >
Whether or not to fix ieflx
Default: .false.
</entry>

<!-- Gravity Wave Drag -->

<entry id="use_gw_oro" type="logical" category="gw_drag"
Expand Down
3 changes: 0 additions & 3 deletions components/cam/src/physics/cam/cam_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,6 @@ subroutine diag_surf (cam_in, cam_out, ps, trefmxav, trefmnav )
use time_manager, only: is_end_curr_day
use co2_cycle, only: c_i, co2_transport
use constituents, only: sflxnam
use phys_control, only: ieflx_opt, l_ieflx_fix

!-----------------------------------------------------------------------
!
Expand All @@ -1527,8 +1526,6 @@ subroutine diag_surf (cam_in, cam_out, ps, trefmxav, trefmnav )
lchnk = cam_in%lchnk
ncol = cam_in%ncol

!! if l_ieflx_fix = true, SHFLX will be output in physpkg.F90

call outfld('SHFLX', cam_in%shf, pcols, lchnk)
call outfld('LHFLX', cam_in%lhf, pcols, lchnk)
call outfld('QFLX', cam_in%cflx(1,1), pcols, lchnk)
Expand Down
61 changes: 29 additions & 32 deletions components/cam/src/physics/cam/check_energy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module check_energy
use time_manager, only: is_first_step
use cam_logfile, only: iulog
use cam_abortutils, only: endrun
use phys_control, only: ieflx_opt !!l_ieflx_fix
use phys_control, only: ieflx_opt

implicit none
private
Expand Down Expand Up @@ -78,7 +78,6 @@ module check_energy

! Physics buffer indices

integer :: ieflx_idx = 0 ! teout index in physics buffer
integer :: teout_idx = 0 ! teout index in physics buffer
integer :: dtcore_idx = 0 ! dtcore index in physics buffer

Expand Down Expand Up @@ -146,17 +145,9 @@ subroutine check_energy_register()

if(is_subcol_on()) then
call pbuf_register_subcol('TEOUT', 'phys_register', teout_idx)
call pbuf_register_subcol('IEFLX', 'phys_register', ieflx_idx)
call pbuf_register_subcol('DTCORE', 'phys_register', dtcore_idx)
end if

if(ieflx_opt>0) then
call pbuf_add_field('IEFLX', 'global',dtype_r8 , (/pcols,dyn_time_lvls/), ieflx_idx)
if(is_subcol_on()) then
call pbuf_register_subcol('IEFLX', 'phys_register', ieflx_idx)
end if
end if

end subroutine check_energy_register

!===============================================================================
Expand Down Expand Up @@ -237,8 +228,8 @@ subroutine check_energy_init()

if(ieflx_opt>0) then
call addfld('IEFLX', horiz_only, 'A', 'W/m2', 'Implied internal energy flux')
call addfld('SHFLXFIX', horiz_only, 'A', 'W/m2', 'SHFLX after adding IEFLX')
call add_default ('SHFLXFIX', 1, ' ')
call addfld('SHFLXORI', horiz_only, 'A', 'W/m2', 'SHFLX before adding IEFLX')
call add_default ('IEFLX', 1, ' ')
end if

end subroutine check_energy_init
Expand All @@ -265,8 +256,6 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type)
real(r8) :: wl(state%ncol) ! vertical integral of water (liquid)
real(r8) :: wi(state%ncol) ! vertical integral of water (ice)

real(r8) :: ieflx(pcols) ! vertical integral of kinetic energy

real(r8),allocatable :: cpairv_loc(:,:,:)

integer lchnk ! chunk identifier
Expand Down Expand Up @@ -309,8 +298,6 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type)
wr = 0._r8
ws = 0._r8

ieflx(1:ncol) = 0._r8

do k = 1, pver
do i = 1, ncol
ke(i) = ke(i) + 0.5_r8*(state%u(i,k)**2 + state%v(i,k)**2)*state%pdel(i,k)/gravit
Expand Down Expand Up @@ -362,9 +349,6 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type)
! initialize physics buffer
if (is_first_step()) then
call pbuf_set_field(pbuf, teout_idx, state%te_ini, col_type=col_type)
if(ieflx_opt>0) then
call pbuf_set_field(pbuf, ieflx_idx, ieflx, col_type=col_type)
end if
end if

deallocate(cpairv_loc)
Expand Down Expand Up @@ -650,6 +634,8 @@ subroutine ieflx_gmean(state, tend, pbuf2d, cam_in, cam_out, nstep)
!!...................................................................
!! Calculate global mean of the implied internal energy flux
!!
!! This subroutien is called only when ieflx_opt > 0
!!
!! Author: Kai Zhang
!!...................................................................

Expand All @@ -658,8 +644,6 @@ subroutine ieflx_gmean(state, tend, pbuf2d, cam_in, cam_out, nstep)
use cam_history, only: outfld
use phys_control, only: ieflx_opt

! Compute global mean qflx

integer , intent(in) :: nstep ! current timestep number
type(physics_state), intent(in ), dimension(begchunk:endchunk) :: state
type(physics_tend ), intent(in ), dimension(begchunk:endchunk) :: tend
Expand All @@ -673,7 +657,7 @@ subroutine ieflx_gmean(state, tend, pbuf2d, cam_in, cam_out, nstep)
integer :: ncol ! number of active columns
integer :: lchnk ! chunk index

real(r8), pointer :: ieflx(:)
real(r8) :: ieflx(pcols)

real(r8) :: qflx(pcols,begchunk:endchunk) !qflx [kg/m2/s]
real(r8) :: rain(pcols,begchunk:endchunk) !rain [m/s]
Expand All @@ -696,10 +680,19 @@ subroutine ieflx_gmean(state, tend, pbuf2d, cam_in, cam_out, nstep)
snow(:ncol,lchnk) = cam_out(lchnk)%precsc(:ncol) + cam_out(lchnk)%precsl(:ncol)
rain(:ncol,lchnk) = cam_out(lchnk)%precc(:ncol) + cam_out(lchnk)%precl(:ncol) - snow(:ncol,lchnk)

!! the calculation below (rhow*) converts the unit of precipitation from m/s to kg/m2/s

select case (ieflx_opt)

!!.....................................................................................
!! Calculate the internal energy flux at surface (imitate what is considered in the ocean model)
!!
!! ieflx_opt = 1 : air temperature in the lowest model layer will be used
!! ieflx_opt = 2 : skin temperature (from lnd/ocn/ice components) will be used
!!
!! ieflx_opt = 2 is recommended for now.
!!
!! (rhow*) converts the unit of precipitation from m/s to kg/m2/s
!!.....................................................................................

case(1)
ienet(:ncol,lchnk) = cpsw * qflx(:ncol,lchnk) * cam_in(lchnk)%ts(:ncol) - &
cpsw * rhow * ( rain(:ncol,lchnk) + snow(:ncol,lchnk) ) * cam_out(lchnk)%tbot(:ncol)
Expand All @@ -710,18 +703,20 @@ subroutine ieflx_gmean(state, tend, pbuf2d, cam_in, cam_out, nstep)
call endrun('*** incorrect ieflx_opt ***')
end select

!! put it to pbuf for more comprehensive treatment in the future

call pbuf_get_field(pbuf_get_chunk(pbuf2d,lchnk),ieflx_idx, ieflx)
end do

call gmean(ienet, ieflx_glob)

!DIR$ CONCURRENT
do lchnk = begchunk, endchunk

ieflx(:ncol) = ienet(:ncol,lchnk)
ieflx(:ncol) = ieflx_glob

call outfld('IEFLX', ieflx(:ncol), pcols, lchnk)

end do

call gmean(ienet, ieflx_glob)

!!! if (begchunk .le. endchunk) then
!!! if (masterproc) then
!!! write(iulog,'(1x,a12,1x,i8,4(1x,e25.17))') "nstep, ieflx, ieup, iedn ", nstep, ieflx_glob, ieup_glob, iedn_glob
Expand All @@ -735,8 +730,10 @@ end subroutine ieflx_gmean
subroutine check_ieflx_fix(lchnk, ncol, nstep, shflx)

!!
!! Add implied internal energy flux to the sensible heat flux
!! Add the global mean internal energy flux to the sensible heat flux
!!
!! This subroutien is called only when ieflx_opt > 0
!!
!! Called by typhsac
!!

Expand All @@ -749,14 +746,14 @@ subroutine check_ieflx_fix(lchnk, ncol, nstep, shflx)

integer :: i

call outfld('SHFLXORI', shflx, pcols, lchnk)

if(nstep>1) then
do i = 1, ncol
shflx(i) = shflx(i) + ieflx_glob
end do
end if

call outfld('SHFLXFIX', shflx, pcols, lchnk)

return
end subroutine check_ieflx_fix

Expand Down
5 changes: 2 additions & 3 deletions components/cam/src/physics/cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,8 @@ subroutine phys_run2(phys_state, ztodt, phys_tend, pbuf2d, cam_out, &
use metdata, only: get_met_srf2
#endif
use time_manager, only: get_nstep
use check_energy, only: ieflx_gmean
use check_energy, only: check_ieflx_fix
use phys_control, only: ieflx_opt !!l_ieflx_fix
use check_energy, only: ieflx_gmean, check_ieflx_fix
use phys_control, only: ieflx_opt
!
! Input arguments
!
Expand Down

0 comments on commit 8abf0b8

Please sign in to comment.