Skip to content

Commit

Permalink
First draft: soil layer definition clean-up and user-defined option
Browse files Browse the repository at this point in the history
1) Clean-up following @swensosc and @billsacks suggestions in issue ESCOMP#279
2) Initial proposal for user-defined option of soil layer structure:
- Use existing namelist variable soil_layerstruct
- Instead of setting to an existing option (e.g. '5SL_3m', etc.),
  set soil_layerstruct = 'user:aa,bb,cc,dd,ee,ff,gg,...'
  where the string is declared of len=256 and
        'user:' tells the code to expect a user defined structure,
        aa gets assigned to nlevsoi and nlevgrnd in the code,
        bb gets assigned to dzsoi(1) in the code,
        cc gets assigned to dzsoi(2) in the code,
        and so on to dzsoi(nlevgrnd).
  • Loading branch information
Samuel Levis committed Jul 5, 2019
1 parent 57adf1e commit cd05cc7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module clm_varctl
!----------------------------------------------------------

logical, public :: use_bedrock = .false. ! true => use spatially variable soil depth
character(len=16), public :: soil_layerstruct = '10SL_3.5m'
character(len=256), public :: soil_layerstruct = '10SL_3.5m'

!----------------------------------------------------------
! plant hydraulic stress switch
Expand Down
3 changes: 3 additions & 0 deletions src/main/clm_varpar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ subroutine clm_varpar_init(actual_maxsoil_patches, actual_numcft)
else if ( soil_layerstruct == '5SL_3m' ) then
nlevsoi = 5
nlevgrnd = 5
else if (soil_layerstruct(1:5) == 'user:') then
read(soil_layerstruct(6:7),*) nlevsoi
nlevgrnd = nlevsoi
else
write(iulog,*) subname//' ERROR: Unrecognized soil layer structure: ', trim(soil_layerstruct)
call shr_sys_abort(subname//' ERROR: Unrecognized soil layer structure')
Expand Down
154 changes: 67 additions & 87 deletions src/main/initVerticalMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ subroutine initVertical(bounds, glc_behavior, snow_depth, thick_wall, thick_roof
integer :: ier ! error status
real(r8) :: scalez = 0.025_r8 ! Soil layer thickness discretization (m)
real(r8) :: thick_equal = 0.2
character(len=20) :: calc_method ! soil layer calculation method
real(r8) ,pointer :: zbedrock_in(:) ! read in - z_bedrock
real(r8) ,pointer :: lakedepth_in(:) ! read in - lakedepth
real(r8), allocatable :: zurb_wall(:,:) ! wall (layer node depth)
Expand Down Expand Up @@ -213,41 +214,34 @@ subroutine initVertical(bounds, glc_behavior, snow_depth, thick_wall, thick_roof
! Soil layers and interfaces (assumed same for all non-lake patches)
! "0" refers to soil surface and "nlevsoi" refers to the bottom of model soil

if ( soil_layerstruct == '10SL_3.5m' ) then
do j = 1, nlevgrnd
zsoi(j) = scalez*(exp(0.5_r8*(j-0.5_r8))-1._r8) !node depths
enddo

dzsoi(1) = 0.5_r8*(zsoi(1)+zsoi(2)) !thickness b/n two interfaces
do j = 2,nlevgrnd-1
dzsoi(j)= 0.5_r8*(zsoi(j+1)-zsoi(j-1))
enddo
dzsoi(nlevgrnd) = zsoi(nlevgrnd)-zsoi(nlevgrnd-1)

zisoi(0) = 0._r8
do j = 1, nlevgrnd-1
zisoi(j) = 0.5_r8*(zsoi(j)+zsoi(j+1)) !interface depths
enddo
zisoi(nlevgrnd) = zsoi(nlevgrnd) + 0.5_r8*dzsoi(nlevgrnd)
if (soil_layerstruct == '10SL_3.5m' .or. soil_layerstruct == '23SL_3.5m') then
calc_method = 'node-based'
else if (soil_layerstruct == '49SL_10m' .or. soil_layerstruct == '20SL_8.5m' .or. soil_layerstruct == '5SL_3m' .or. soil_layerstruct(1:5) == 'user:') then
calc_method = 'thickness-based'
else
write(iulog,*) subname//' ERROR: Unrecognized soil layer structure: ', trim(soil_layerstruct)
call endrun(subname//' ERROR: Unrecognized soil layer structure')
end if

else if ( soil_layerstruct == '23SL_3.5m' )then
! Soil layer structure that starts with standard exponential
! and then has several evenly spaced layers, then finishes off exponential.
! this allows the upper soil to behave as standard, but then continues
! with higher resolution to a deeper depth, so that, for example, permafrost
! dynamics are not lost due to an inability to resolve temperature, moisture,
! and biogeochemical dynamics at the base of the active layer
do j = 1, toplev_equalspace
if (calc_method == 'node-based') then
do j = 1, nlevgrnd
zsoi(j) = scalez*(exp(0.5_r8*(j-0.5_r8))-1._r8) !node depths
enddo

do j = toplev_equalspace+1,toplev_equalspace + nlev_equalspace
zsoi(j) = zsoi(j-1) + thick_equal
enddo

do j = toplev_equalspace + nlev_equalspace +1, nlevgrnd
zsoi(j) = scalez*(exp(0.5_r8*((j - nlev_equalspace)-0.5_r8))-1._r8) + nlev_equalspace * thick_equal
enddo
if (soil_layerstruct == '23SL_3.5m') then
! Soil layer structure that starts with standard exponential,
! then has several evenly spaced layers and finishes off exponential.
! This allows the upper soil to behave as standard, but then continues
! with higher resolution to a deeper depth, so that, e.g., permafrost
! dynamics are not lost due to an inability to resolve temperature,
! moisture, and biogeochemical dynamics at the base of the active layer
do j = toplev_equalspace + 1, toplev_equalspace + nlev_equalspace
zsoi(j) = zsoi(j-1) + thick_equal
enddo
do j = toplev_equalspace + nlev_equalspace + 1, nlevgrnd
zsoi(j) = scalez * (exp(0.5_r8 * (j - nlev_equalspace - 0.5_r8)) - 1._r8) + nlev_equalspace * thick_equal
enddo
end if ! soil_layerstruct == '23SL_3.5m'

dzsoi(1) = 0.5_r8*(zsoi(1)+zsoi(2)) !thickness b/n two interfaces
do j = 2,nlevgrnd-1
Expand All @@ -257,24 +251,50 @@ subroutine initVertical(bounds, glc_behavior, snow_depth, thick_wall, thick_roof

zisoi(0) = 0._r8
do j = 1, nlevgrnd-1
zisoi(j) = 0.5_r8*(zsoi(j)+zsoi(j+1)) !interface depths
zisoi(j) = 0.5_r8*(zsoi(j)+zsoi(j+1)) !interface depths
enddo
zisoi(nlevgrnd) = zsoi(nlevgrnd) + 0.5_r8*dzsoi(nlevgrnd)

else if ( soil_layerstruct == '49SL_10m' ) then
!scs: 10 meter soil column, nlevsoi set to 49 in clm_varpar
do j = 1,10
dzsoi(j)= 1.e-2_r8 !10mm layers
enddo
do j = 11,19
dzsoi(j)= 1.e-1_r8 !100 mm layers
enddo
do j = 20,nlevsoi+1 !300 mm layers
dzsoi(j)= 3.e-1_r8
enddo
do j = nlevsoi+2,nlevgrnd !10 meter bedrock layers
dzsoi(j)= 10._r8
enddo
else if (calc_method == 'thickness-based') then
if (soil_layerstruct == '49SL_10m') then
!scs: 10 meter soil column, nlevsoi set to 49 in clm_varpar
do j = 1, 10
dzsoi(j) = 1.e-2_r8 ! 10-mm layers
enddo
do j = 11, 19
dzsoi(j) = 1.e-1_r8 ! 100-mm layers
enddo
do j = 20, nlevsoi+1 ! 300-mm layers
dzsoi(j) = 3.e-1_r8
enddo
do j = nlevsoi+2,nlevgrnd ! 10-m bedrock layers
dzsoi(j) = 10._r8
enddo
else if (soil_layerstruct == '20SL_8.5m') then
do j = 1, 4 ! linear increase in layer thickness of...
dzsoi(j) = j * 0.02_r8 ! ...2 cm each layer
enddo
do j = 5, 13
dzsoi(j) = dzsoi(4) + (j - 4) * 0.04_r8 ! ...4 cm each layer
enddo
do j = 14, nlevsoi
dzsoi(j) = dzsoi(13) + (j - 13) * 0.10_r8 ! ...10 cm each layer
enddo
do j = nlevsoi + 1, nlevgrnd ! bedrock layers
dzsoi(j) = dzsoi(nlevsoi) + (((j - nlevsoi) * 25._r8)**1.5_r8) / 100._r8
enddo
else if (soil_layerstruct == '5SL_3m') then
dzsoi(1) = 0.1_r8
dzsoi(2) = 0.3_r8
dzsoi(3) = 0.6_r8
dzsoi(4) = 1.0_r8
dzsoi(5) = 1.0_r8
else if (soil_layerstruct(1:5) == 'user:') then
do j = 1, nlevgrnd
! read string indices 8 to 9, 11 to 12, 14 to 15, and so on
read(soil_layerstruct(3*(j+2)-1:3*(j+2)),*) dzsoi(j)
end do
end if ! soil_layerstruct options

zisoi(0) = 0._r8
do j = 1,nlevgrnd
Expand All @@ -285,54 +305,14 @@ subroutine initVertical(bounds, glc_behavior, snow_depth, thick_wall, thick_roof
zsoi(j) = 0.5*(zisoi(j-1) + zisoi(j))
enddo

else if ( soil_layerstruct == '20SL_8.5m' ) then
do j = 1,4
dzsoi(j)= j*0.02_r8 ! linear increase in layer thickness of 2cm each layer
enddo
do j = 5,13
dzsoi(j)= dzsoi(4)+(j-4)*0.04_r8 ! linear increase in layer thickness of 2cm each layer
enddo
do j = 14,nlevsoi
dzsoi(j)= dzsoi(13)+(j-13)*0.10_r8 ! linear increase in layer thickness of 2cm each layer
enddo
do j = nlevsoi+1,nlevgrnd !bedrock layers
dzsoi(j)= dzsoi(nlevsoi)+(((j-nlevsoi)*25._r8)**1.5_r8)/100._r8 ! bedrock layers
enddo

zisoi(0) = 0._r8
do j = 1,nlevgrnd
zisoi(j)= sum(dzsoi(1:j))
enddo

do j = 1, nlevgrnd
zsoi(j) = 0.5*(zisoi(j-1) + zisoi(j))
enddo
else if ( soil_layerstruct == '5SL_3m' ) then
dzsoi(1)= 0.1_r8
dzsoi(2)= 0.3_r8
dzsoi(3)= 0.6_r8
dzsoi(4)= 1.0_r8
dzsoi(5)= 1.0_r8

zisoi(0) = 0._r8
do j = 1,nlevgrnd
zisoi(j)= sum(dzsoi(1:j))
enddo

do j = 1, nlevgrnd
zsoi(j) = 0.5*(zisoi(j-1) + zisoi(j))
enddo
else
write(iulog,*) subname//' ERROR: Unrecognized soil layer structure: ', trim(soil_layerstruct)
call endrun(subname//' ERROR: Unrecognized soil layer structure')
end if

! define a vertical grid spacing such that it is the normal dzsoi if
! nlevdecomp =nlevgrnd, or else 1 meter
if (use_vertsoilc) then
dzsoi_decomp = dzsoi !thickness b/n two interfaces
else
dzsoi_decomp(1) = 1.
dzsoi_decomp(1) = 1._r8
end if

if (masterproc) then
Expand Down

0 comments on commit cd05cc7

Please sign in to comment.