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

Soil layer definition clean-up and user-defined option #759

Merged
merged 32 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cd05cc7
First draft: soil layer definition clean-up and user-defined option
slevis-lmwg Jul 5, 2019
68d5e54
Change user-defined option to allow min(dzsoi(j)) = .001 m
slevis-lmwg Jul 6, 2019
048199d
Introducing soil_layerstruct_userdefined and nlevsoinl
slevis-lmwg Jul 12, 2019
ebe5997
Minor update of the wording of an error check in clm_varpar
slevis-lmwg Jul 12, 2019
ecb7d4a
namelist_defaults correction and ChangLog first draft
slevis-lmwg Jul 15, 2019
6c89d29
Merge tag 'ctsm1.0.dev050' into soil_layer_def_cleanup
slevis-lmwg Jul 15, 2019
4d97279
New error checks in CLMBuildNamelist.pm
slevis-lmwg Jul 15, 2019
907432d
Remove UNSET from list of soil_layerstruct_predefined valid_values
slevis-lmwg Jul 15, 2019
bf4a18c
Introduce new test-suite tests
slevis-lmwg Jul 18, 2019
a47e3cb
Changed new test from ERS to ERP_P36x2
slevis-lmwg Jul 18, 2019
f92fcc1
Merge tag 'ctsm1.0.dev051' into soil_layer_def_cleanup
slevis-lmwg Jul 22, 2019
d4ba7f5
Revisions in /bld directory based on @billsacks' comments
slevis-lmwg Jul 22, 2019
63fdbd4
Revisions (part 2) in response to @billsacks review
slevis-lmwg Jul 23, 2019
260e9eb
Change new soil_layerstruct test from ERP to SOILSTRUCTUD
slevis-lmwg Jul 23, 2019
f87837a
Merge tag 'ctsm1.0.dev052' into soil_layer_def_cleanup
slevis-lmwg Jul 23, 2019
1bc0f1d
Repl. soil_layerstruct_predefined /= '10SL_3.5m' w organic_frac_squared
slevis-lmwg Jul 24, 2019
2618b2c
Follow-up to last commit that gives bfb same answers as clm4.5 test
slevis-lmwg Jul 25, 2019
eeead76
Consolidated code that repeated
slevis-lmwg Jul 25, 2019
6b52599
Changed new test to clm-default because its /testmods_dirs was empty
slevis-lmwg Jul 25, 2019
2ce604d
Consilidating repetitive code intended for initializing VIC
slevis-lmwg Jul 25, 2019
506ee20
Clean-up related to the previous commit
slevis-lmwg Jul 25, 2019
938f125
Consolidation of repetitive code
slevis-lmwg Jul 26, 2019
f62c5d0
Improved code organization
slevis-lmwg Jul 26, 2019
094e3be
Revert "Improved code organization"
slevis-lmwg Jul 29, 2019
d3c518f
New test info in config_component.xml to avoid abort
slevis-lmwg Jul 29, 2019
b4e19f9
Updated ChangeLog/ChangeSum
slevis-lmwg Jul 29, 2019
3fffb02
Remove unused if-statement
slevis-lmwg Jul 29, 2019
342207f
Reversing changes made in commits 1bc0f1d and 2618b2c
slevis-lmwg Jul 31, 2019
d1eca83
Minor comment correction
slevis-lmwg Jul 31, 2019
6d2fa76
Minor comment placement correction
slevis-lmwg Aug 1, 2019
f40533c
Silly mistake that justifies the motto: RUN AT LEAST ONE TEST!
slevis-lmwg Aug 1, 2019
72d598b
Update ChangeLog with new date
billsacks Aug 1, 2019
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
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to change this to read 4 characters per dzsoi(j) since the units are meters and 4 characters will allow
min(dzsoi(j)) = .001 m

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