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

Changes to incorporate into ESCOMP/CTSM branch master #1

Open
wants to merge 5 commits into
base: clm_tag_release-clm5.0.25
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions src/cpl/clm_cpl_indices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ module clm_cpl_indices
integer, public ::index_l2x_Sl_snowh ! snow height
integer, public ::index_l2x_Sl_u10 ! 10m wind
integer, public ::index_l2x_Sl_ddvel ! dry deposition velocities (optional)
integer, public ::index_l2x_Sl_lwtgcell ! landunit areas
integer, public ::index_l2x_Sl_pwtgcell ! patch areas
integer, public ::index_l2x_Sl_lai ! leaf area indices
integer, public ::index_l2x_Sl_fv ! friction velocity
integer, public ::index_l2x_Sl_ram1 ! aerodynamical resistance
integer, public ::index_l2x_Sl_soilw ! volumetric soil water
Expand Down Expand Up @@ -137,6 +140,8 @@ subroutine clm_cpl_indices_set( )
use mct_mod , only: mct_aVect, mct_aVect_init, mct_avect_indexra
use mct_mod , only: mct_aVect_clean, mct_avect_nRattr
use seq_drydep_mod , only: drydep_fields_token, lnd_drydep
use seq_drydep_mod , only: luse_fields_token, patch_fields_token
use seq_drydep_mod , only: lai_fields_token
use shr_megan_mod , only: shr_megan_fields_token, shr_megan_mechcomps_n
use shr_fire_emis_mod,only: shr_fire_emis_fields_token, shr_fire_emis_ztop_token, shr_fire_emis_mechcomps_n
use clm_varctl , only: ndep_from_cpl
Expand Down Expand Up @@ -191,9 +196,15 @@ subroutine clm_cpl_indices_set( )
index_l2x_Sl_soilw = mct_avect_indexra(l2x,'Sl_soilw',perrwith='quiet')

if ( lnd_drydep )then
index_l2x_Sl_ddvel = mct_avect_indexra(l2x, trim(drydep_fields_token))
index_l2x_Sl_ddvel = mct_avect_indexra(l2x, trim(drydep_fields_token))
index_l2x_Sl_lwtgcell = mct_avect_indexra(l2x, trim(luse_fields_token))
index_l2x_Sl_pwtgcell = mct_avect_indexra(l2x, trim(patch_fields_token))
index_l2x_Sl_lai = mct_avect_indexra(l2x, trim(lai_fields_token))
else
index_l2x_Sl_ddvel = 0
index_l2x_Sl_ddvel = 0
index_l2x_Sl_lwtgcell = 0
index_l2x_Sl_pwtgcell = 0
index_l2x_Sl_lai = 0
end if

index_l2x_Fall_taux = mct_avect_indexra(l2x,'Fall_taux')
Expand Down
19 changes: 19 additions & 0 deletions src/cpl/lnd_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ subroutine lnd_export( bounds, lnd2atm_inst, lnd2glc_inst, l2x)
use clm_varctl , only : iulog
use clm_time_manager , only : get_nstep, get_step_size
use seq_drydep_mod , only : n_drydep
use seq_drydep_mod , only : NLUse, NPatch
use shr_megan_mod , only : shr_megan_mechcomps_n
use shr_fire_emis_mod , only : shr_fire_emis_mechcomps_n
use domainMod , only : ldomain
Expand Down Expand Up @@ -359,6 +360,24 @@ subroutine lnd_export( bounds, lnd2atm_inst, lnd2glc_inst, l2x)
lnd2atm_inst%ddvel_grc(g,:n_drydep)
end if

! for landunit weights
if (index_l2x_Sl_lwtgcell /= 0 ) then
l2x(index_l2x_Sl_lwtgcell:index_l2x_Sl_lwtgcell+NLUse-1,i) = &
lnd2atm_inst%lwtgcell_grc(g,:NLUse)
end if

! for patch weights
if (index_l2x_Sl_pwtgcell /= 0 ) then
l2x(index_l2x_Sl_pwtgcell:index_l2x_Sl_pwtgcell+NPatch-1,i) = &
lnd2atm_inst%pwtgcell_grc(g,:NPatch)
end if

! for leaf area indices
if (index_l2x_Sl_lai /= 0 ) then
l2x(index_l2x_Sl_lai:index_l2x_Sl_lai+NPatch-1,i) = &
lnd2atm_inst%lai_grc(g,:NPatch)
end if

! for MEGAN VOC emis fluxes
if (index_l2x_Fall_flxvoc /= 0 ) then
l2x(index_l2x_Fall_flxvoc:index_l2x_Fall_flxvoc+shr_megan_mechcomps_n-1,i) = &
Expand Down
2 changes: 1 addition & 1 deletion src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
call lnd2atm(bounds_proc, &
atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, &
waterstate_inst, waterflux_inst, irrigation_inst, energyflux_inst, &
solarabs_inst, drydepvel_inst, &
solarabs_inst, drydepvel_inst, canopystate_inst, &
vocemis_inst, fireemis_inst, dust_inst, ch4_inst, glc_behavior, &
lnd2atm_inst, &
net_carbon_exchange_grc = net_carbon_exchange_grc(bounds_proc%begg:bounds_proc%endg))
Expand Down
39 changes: 36 additions & 3 deletions src/main/lnd2atmMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ module lnd2atmMod
use shr_megan_mod , only : shr_megan_mechcomps_n
use shr_fire_emis_mod , only : shr_fire_emis_mechcomps_n
use clm_varpar , only : numrad, ndst, nlevgrnd !ndst = number of dust bins.
use clm_varcon , only : rair, grav, cpair, hfus, tfrz, spval
use clm_varcon , only : rair, grav, cpair, hfus, tfrz, spval, ispval
use clm_varctl , only : iulog, use_lch4
use seq_drydep_mod , only : n_drydep, drydep_method, DD_XLND
use decompMod , only : bounds_type
use subgridAveMod , only : p2g, c2g
use lnd2atmType , only : lnd2atm_type
use atm2lndType , only : atm2lnd_type
use CanopyStateType , only : canopystate_type
use ch4Mod , only : ch4_type
use DUSTMod , only : dust_type
use DryDepVelocity , only : drydepvel_type
Expand All @@ -34,6 +35,7 @@ module lnd2atmMod
use IrrigationMod , only : irrigation_type
use glcBehaviorMod , only : glc_behavior_type
use glc2lndMod , only : glc2lnd_type
use PatchType , only : patch
use ColumnType , only : col
use LandunitType , only : lun
use GridcellType , only : grc
Expand Down Expand Up @@ -124,7 +126,7 @@ end subroutine lnd2atm_minimal
subroutine lnd2atm(bounds, &
atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, &
waterstate_inst, waterflux_inst, irrigation_inst, energyflux_inst, &
solarabs_inst, drydepvel_inst, &
solarabs_inst, drydepvel_inst, canopystate_inst, &
vocemis_inst, fireemis_inst, dust_inst, ch4_inst, glc_behavior, &
lnd2atm_inst, &
net_carbon_exchange_grc)
Expand All @@ -147,6 +149,7 @@ subroutine lnd2atm(bounds, &
type(energyflux_type) , intent(in) :: energyflux_inst
type(solarabs_type) , intent(in) :: solarabs_inst
type(drydepvel_type) , intent(in) :: drydepvel_inst
type(canopystate_type) , intent(in) :: canopystate_inst
type(vocemis_type) , intent(in) :: vocemis_inst
type(fireemis_type) , intent(in) :: fireemis_inst
type(dust_type) , intent(in) :: dust_inst
Expand All @@ -156,7 +159,7 @@ subroutine lnd2atm(bounds, &
real(r8) , intent(in) :: net_carbon_exchange_grc( bounds%begg: ) ! net carbon exchange between land and atmosphere, positive for source (gC/m2/s)
!
! !LOCAL VARIABLES:
integer :: c, g ! indices
integer :: c, p, l, g ! indices
real(r8) :: qflx_ice_runoff_col(bounds%begc:bounds%endc) ! total column-level ice runoff
real(r8) :: eflx_sh_ice_to_liq_grc(bounds%begg:bounds%endg) ! sensible heat flux generated from the ice to liquid conversion, averaged to gridcell
real(r8), parameter :: amC = 12.0_r8 ! Atomic mass number for Carbon
Expand Down Expand Up @@ -279,6 +282,36 @@ subroutine lnd2atm(bounds, &
p2c_scale_type='unity', c2l_scale_type= 'unity', l2g_scale_type='unity')
endif

! Landunit/patch areas
if ( drydep_method == DD_XLND ) then
lnd2atm_inst%pwtgcell_grc(:,:) = 0.0e+00_r8
do p = bounds%begp,bounds%endp
if (patch%itype(p) /= ispval) then
g = patch%gridcell(p)
lnd2atm_inst%pwtgcell_grc(g,patch%itype(p)+1) = patch%wtgcell(p)
end if
end do

lnd2atm_inst%lwtgcell_grc(:,:) = 0.0e+00_r8
do l = bounds%begl,bounds%endl
if (lun%itype(l) /= ispval) then
g = lun%gridcell(l)
lnd2atm_inst%lwtgcell_grc(g,lun%itype(l)) = lun%wtgcell(l)
end if
end do
end if

! Leaf area indices
if ( drydep_method == DD_XLND ) then
! Aggregate sunlit and shaded leaf area index
lnd2atm_inst%lai_grc(:,:) = 0.0e+00_r8
do p = bounds%begp,bounds%endp
g = patch%gridcell(p)
lnd2atm_inst%lai_grc(g,patch%itype(p)+1) = &
canopystate_inst%elai_patch(p)
end do
end if

! voc emission flux
if (shr_megan_mechcomps_n>0) then
call p2g(bounds, shr_megan_mechcomps_n, &
Expand Down
9 changes: 9 additions & 0 deletions src/main/lnd2atmType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module lnd2atmType
use shr_megan_mod , only : shr_megan_mechcomps_n
use shr_fire_emis_mod,only : shr_fire_emis_mechcomps_n
use seq_drydep_mod, only : n_drydep, drydep_method, DD_XLND
use seq_drydep_mod, only : NLUse, NPatch
!
! !PUBLIC TYPES:
implicit none
Expand Down Expand Up @@ -57,6 +58,9 @@ module lnd2atmType
real(r8), pointer :: fv_grc (:) => null() ! friction velocity (m/s) (for dust model)
real(r8), pointer :: flxdst_grc (:,:) => null() ! dust flux (size bins)
real(r8), pointer :: ddvel_grc (:,:) => null() ! dry deposition velocities
real(r8), pointer :: lwtgcell_grc (:,:) => null() ! landunit areas
real(r8), pointer :: pwtgcell_grc (:,:) => null() ! patch areas
real(r8), pointer :: lai_grc (:,:) => null() ! leaf area indices
real(r8), pointer :: flxvoc_grc (:,:) => null() ! VOC flux (size bins)
real(r8), pointer :: fireflx_grc (:,:) => null() ! Wild Fire Emissions
real(r8), pointer :: fireztop_grc (:) => null() ! Wild Fire Emissions vertical distribution top
Expand Down Expand Up @@ -190,6 +194,11 @@ subroutine InitAllocate(this, bounds)
if ( n_drydep > 0 .and. drydep_method == DD_XLND )then
allocate(this%ddvel_grc(begg:endg,1:n_drydep)); this%ddvel_grc(:,:)=ival
end if
if ( drydep_method == DD_XLND ) then
allocate(this%lwtgcell_grc(begg:endg,1:NLUse)); this%lwtgcell_grc(:,:)=spval
allocate(this%pwtgcell_grc(begg:endg,1:NPatch)); this%pwtgcell_grc(:,:)=spval
allocate(this%lai_grc(begg:endg,1:NPatch)); this%lai_grc(:,:) =spval
end if

end subroutine InitAllocate

Expand Down
47 changes: 46 additions & 1 deletion src_clm40/main/clm_atmlnd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ module clm_atmlnd
use decompMod , only : get_proc_bounds
use shr_kind_mod, only : r8 => shr_kind_r8
use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=)
use shr_infnan_mod, only: shr_infnan_isnan
use spmdMod , only : masterproc
use abortutils , only : endrun
use seq_drydep_mod, only : n_drydep, drydep_method, DD_XLND
use seq_drydep_mod, only : NLUse, NPatch
use shr_megan_mod, only : shr_megan_mechcomps_n
!
! !PUBLIC TYPES:
Expand Down Expand Up @@ -124,6 +126,9 @@ module clm_atmlnd
real(r8), pointer :: rofice(:) => null() ! rof ice forcing
real(r8), pointer :: flxdst(:,:) => null() !dust flux (size bins)
real(r8), pointer :: ddvel(:,:) => null() !dry deposition velocities
real(r8), pointer :: lwtgcell(:,:) => null() ! landunit areas
real(r8), pointer :: pwtgcell(:,:) => null() ! patch areas
real(r8), pointer :: lai(:,:) => null() ! leaf area indices
real(r8), pointer :: flxvoc(:,:) => null() ! VOC flux (size bins)
! Needed for backwards compatibility with lnd_comp_mct used in clm4_5
real(r8), pointer :: flux_ch4(:) => null() !net CH4 flux (kg C/m**2/s) [+ to atm]
Expand Down Expand Up @@ -300,6 +305,11 @@ subroutine init_lnd2atm_type(beg, end, l2a)
if ( n_drydep > 0 .and. drydep_method == DD_XLND )then
allocate(l2a%ddvel(beg:end,1:n_drydep))
end if
if ( drydep_method == DD_XLND )then
allocate(l2a%lwtgcell(beg:end,1:NLUse))
allocate(l2a%pwtgcell(beg:end,1:NPatch))
allocate(l2a%lai(beg:end,1:NPatch))
end if

! ival = nan ! causes core dump in map_maparray, tcx fix
ival = 0.0_r8
Expand Down Expand Up @@ -331,6 +341,11 @@ subroutine init_lnd2atm_type(beg, end, l2a)
if ( n_drydep > 0 .and. drydep_method == DD_XLND )then
l2a%ddvel(beg:end, : ) = ival
end if
if ( drydep_method == DD_XLND )then
l2a%lwtgcell(:,:)=ival
l2a%pwtgcell(:,:)=ival
l2a%lai(:,:) =ival
end if

end subroutine init_lnd2atm_type

Expand Down Expand Up @@ -436,7 +451,7 @@ subroutine clm_map2gcell()
integer :: begl, endl ! per-proc beginning and ending landunit indices
integer :: begg, endg ! per-proc gridcell ending gridcell indices

integer :: g ! indices
integer :: g, l, p ! indices
real(r8), parameter :: amC = 12.0_r8 ! Atomic mass number for Carbon
real(r8), parameter :: amO = 16.0_r8 ! Atomic mass number for Oxygen
real(r8), parameter :: amCO2 = amC + 2.0_r8*amO ! Atomic mass number for CO2
Expand Down Expand Up @@ -538,6 +553,36 @@ subroutine clm_map2gcell()
p2c_scale_type='unity', c2l_scale_type= 'unity', l2g_scale_type='unity')
endif

! Landunit/patch indices
if ( drydep_method == DD_XLND ) then
clm_l2a%pwtgcell(:,:) = 0.0e+00_r8
do p = begp,endp
g = pft%gridcell(p)
clm_l2a%pwtgcell(g,pft%itype(p)+1) = pft%wtgcell(p)
end do

clm_l2a%lwtgcell(:,:) = 0.0e+00_r8
do l = begl,endl
if (lun%itype(l) > 0 ) then
g = lun%gridcell(l)
clm_l2a%lwtgcell(g,lun%itype(l)) = lun%wtgcell(l)
end if
end do
endif

! Leaf area indices
if ( drydep_method == DD_XLND ) then
clm_l2a%lai(:,:) = 0.0e+00_r8
do p = begp,endp
g = pft%gridcell(p)
if ( shr_infnan_isnan(pps%elai(p)) ) then
clm_l2a%lai(g,pft%itype(p)+1) = 0.0e+00_r8
else
clm_l2a%lai(g,pft%itype(p)+1) = pps%elai(p)
endif
enddo
endif

! Convert from gC/m2/s to kgCO2/m2/s
do g = begg,endg
clm_l2a%nee(g) = clm_l2a%nee(g)*convertgC2kgCO2
Expand Down
16 changes: 14 additions & 2 deletions src_clm40/main/clm_cpl_indices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module clm_cpl_indices
integer, public ::index_l2x_Sl_snowh ! snow height
integer, public ::index_l2x_Sl_u10 ! 10m wind
integer, public ::index_l2x_Sl_ddvel ! dry deposition velocities (optional)
integer, public ::index_l2x_Sl_lwtgcell ! landunit area weights
integer, public ::index_l2x_Sl_pwtgcell ! patch area weights
integer, public ::index_l2x_Sl_lai ! leaf area indices
integer, public ::index_l2x_Sl_fv ! friction velocity
integer, public ::index_l2x_Sl_ram1 ! aerodynamical resistance
integer, public ::index_l2x_Sl_soilw ! volumetric soil water
Expand Down Expand Up @@ -131,6 +134,8 @@ subroutine clm_cpl_indices_set( )
use mct_mod , only: mct_aVect, mct_aVect_init, mct_avect_indexra
use mct_mod , only: mct_aVect_clean, mct_avect_nRattr
use seq_drydep_mod , only: drydep_fields_token, lnd_drydep
use seq_drydep_mod , only: luse_fields_token, patch_fields_token
use seq_drydep_mod , only: lai_fields_token
use shr_megan_mod , only: shr_megan_fields_token, shr_megan_mechcomps_n
use clm_varctl , only: use_voc
!
Expand Down Expand Up @@ -181,10 +186,17 @@ subroutine clm_cpl_indices_set( )
index_l2x_Sl_ram1 = mct_avect_indexra(l2x,'Sl_ram1')
index_l2x_Sl_fv = mct_avect_indexra(l2x,'Sl_fv')
index_l2x_Sl_soilw = mct_avect_indexra(l2x,'Sl_soilw',perrwith='quiet')

if ( lnd_drydep )then
index_l2x_Sl_ddvel = mct_avect_indexra(l2x, trim(drydep_fields_token))
index_l2x_Sl_ddvel = mct_avect_indexra(l2x, trim(drydep_fields_token))
index_l2x_Sl_lwtgcell = mct_avect_indexra(l2x, trim(luse_fields_token))
index_l2x_Sl_pwtgcell = mct_avect_indexra(l2x, trim(patch_fields_token))
index_l2x_Sl_lai = mct_avect_indexra(l2x, trim(lai_fields_token))
else
index_l2x_Sl_ddvel = 0
index_l2x_Sl_ddvel = 0
index_l2x_Sl_lwtgcell = 0
index_l2x_Sl_pwtgcell = 0
index_l2x_Sl_lai = 0
end if

index_l2x_Fall_taux = mct_avect_indexra(l2x,'Fall_taux')
Expand Down
20 changes: 19 additions & 1 deletion src_clm40/main/lnd_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ subroutine lnd_export( bounds, clm_l2a, clm_s2x, l2x)
use shr_kind_mod , only : r8 => shr_kind_r8
use clm_varctl , only : iulog, create_glacier_mec_landunit
use clm_time_manager , only : get_nstep, get_step_size
use seq_drydep_mod , only : n_drydep
use seq_drydep_mod , only : n_drydep, NLUse, NPatch
use shr_megan_mod , only : shr_megan_mechcomps_n
!
! !ARGUMENTS:
Expand Down Expand Up @@ -298,6 +298,24 @@ subroutine lnd_export( bounds, clm_l2a, clm_s2x, l2x)
clm_l2a%ddvel(g,:n_drydep)
end if

! for landunit weights
if (index_l2x_Sl_lwtgcell /= 0 ) then
l2x(index_l2x_Sl_lwtgcell:index_l2x_Sl_lwtgcell+NLUse-1,i) = &
clm_l2a%lwtgcell(g,:NLUse)
end if

! for patch weights
if (index_l2x_Sl_pwtgcell /= 0 ) then
l2x(index_l2x_Sl_pwtgcell:index_l2x_Sl_pwtgcell+NPatch-1,i) = &
clm_l2a%pwtgcell(g,:NPatch)
end if

! for leaf area indices
if (index_l2x_Sl_lai /= 0 ) then
l2x(index_l2x_Sl_lai:index_l2x_Sl_lai+NPatch-1,i) = &
clm_l2a%lai(g,:NPatch)
end if

! for MEGAN VOC emis fluxes
if (index_l2x_Fall_flxvoc /= 0 ) then
l2x(index_l2x_Fall_flxvoc:index_l2x_Fall_flxvoc+shr_megan_mechcomps_n-1,i) = &
Expand Down