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

Feature: Export land types and LAI #1475

Closed
wants to merge 2 commits into from
Closed
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/mct/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
20 changes: 19 additions & 1 deletion src/cpl/mct/lnd_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ subroutine lnd_export( bounds, waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst
use seq_flds_mod , only : seq_flds_l2x_fields
use clm_varctl , only : iulog
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 lnd_import_export_utils, only : check_for_nans
Expand Down Expand Up @@ -293,13 +294,30 @@ subroutine lnd_export( bounds, waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst
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) = &
-lnd2atm_inst%flxvoc_grc(g,:shr_megan_mechcomps_n)
end if


! for fire emis fluxes
if (index_l2x_Fall_flxfire /= 0 ) then
l2x(index_l2x_Fall_flxfire:index_l2x_Fall_flxfire+shr_fire_emis_mechcomps_n-1,i) = &
Expand Down
24 changes: 23 additions & 1 deletion src/cpl/nuopc/lnd_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module lnd_import_export
use glc2lndMod , only : glc2lnd_type
use domainMod , only : ldomain
use spmdMod , only : masterproc
use seq_drydep_mod , only : seq_drydep_readnl, n_drydep
use seq_drydep_mod , only : seq_drydep_readnl, n_drydep, NPatch, NLUse
use shr_megan_mod , only : shr_megan_readnl, shr_megan_mechcomps_n
use nuopc_shr_methods , only : chkerr
use lnd_import_export_utils , only : check_for_errors, check_for_nans
Expand Down Expand Up @@ -127,6 +127,9 @@ module lnd_import_export
character(*), parameter :: Sl_soilw = 'Sl_soilw'
character(*), parameter :: Fall_fco2_lnd = 'Fall_fco2_lnd'
character(*), parameter :: Sl_ddvel = 'Sl_ddvel'
character(*), parameter :: Sl_lwtgcell = 'Sl_lwtgcell'
character(*), parameter :: Sl_pwtgcell = 'Sl_pwtgcell'
character(*), parameter :: Sl_lai = 'Sl_lai'
character(*), parameter :: Fall_voc = 'Fall_voc'
character(*), parameter :: Fall_fire = 'Fall_fire'
character(*), parameter :: Sl_fztop = 'Sl_fztop'
Expand Down Expand Up @@ -273,6 +276,13 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r
if (drydep_nflds > 0) then
call fldlist_add(fldsFrLnd_num, fldsFrLnd, Sl_ddvel, ungridded_lbound=1, ungridded_ubound=drydep_nflds)
end if
if (NLUse > 0) then
call fldlist_add(fldsFrLnd_num, fldsFrLnd, Sl_lwtgcell, ungridded_lbound=1, ungridded_ubound=NLUse)
end if
if (NPatch > 0) then
call fldlist_add(fldsFrLnd_num, fldsFrLnd, Sl_pwtgcell, ungridded_lbound=1, ungridded_ubound=NPatch)
call fldlist_add(fldsFrLnd_num, fldsFrLnd, Sl_lai, ungridded_lbound=1, ungridded_ubound=NPatch)
end if
if (shr_megan_mechcomps_n > 0) then
call fldlist_add(fldsFrLnd_num, fldsFrLnd, Fall_voc, ungridded_lbound=1, ungridded_ubound=megan_nflds)
end if
Expand Down Expand Up @@ -799,6 +809,18 @@ subroutine export_fields( gcomp, bounds, glc_present, rof_prognostic, &
call state_setexport_2d(exportState, Sl_ddvel, lnd2atm_inst%ddvel_grc(begg:,1:drydep_nflds), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (fldchk(exportState, Sl_lwtgcell)) then ! landunit weights
call state_setexport_2d(exportState, Sl_lwtgcell, lnd2atm_inst%lwtgcell_grc(begg:,1:NLUse), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (fldchk(exportState, Sl_pwtgcell)) then ! patch weights
call state_setexport_2d(exportState, Sl_pwtgcell, lnd2atm_inst%pwtgcell_grc(begg:,1:NPatch), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (fldchk(exportState, Sl_lai)) then ! leaf area indices
call state_setexport_2d(exportState, Sl_lai, lnd2atm_inst%lai_grc(begg:,1:NPatch), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (fldchk(exportState, Fall_voc)) then ! megan voc emis fluxes
call state_setexport_2d(exportState, Fall_voc, lnd2atm_inst%flxvoc_grc(begg:,1:shr_megan_mechcomps_n), &
minus = .true., rc=rc)
Expand Down
3 changes: 2 additions & 1 deletion src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
call lnd2atm(bounds_proc, &
atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, &
water_inst, &
energyflux_inst, solarabs_inst, drydepvel_inst, &
energyflux_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
38 changes: 36 additions & 2 deletions src/main/lnd2atmMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ 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, nlevmaxurbgrnd !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 filterColMod , only : filter_col_type, col_filter_from_logical_array
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 @@ -33,6 +34,7 @@ module lnd2atmMod
use WaterType , only : water_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 @@ -150,6 +152,7 @@ subroutine lnd2atm(bounds, &
atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, &
water_inst, &
energyflux_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 @@ -170,6 +173,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 @@ -179,7 +183,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, g, l, p ! indices
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
real(r8), parameter :: amO = 16.0_r8 ! Atomic mass number for Oxygen
Expand Down Expand Up @@ -306,6 +310,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 @@ -54,6 +55,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 @@ -166,6 +170,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