Skip to content

Commit aba90e4

Browse files
committed
Read gradz from surfdata file when polygonal tundra is turned on.
Adds logic to read gradz from surfdata file when NGEE Arctic polygonal tundra is turned on. There are already topo_slope variables so should make sure that this additional variable is actually needed.
1 parent 496931b commit aba90e4

File tree

1 file changed

+50
-36
lines changed

1 file changed

+50
-36
lines changed

components/elm/src/main/initVerticalMod.F90

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ module initVerticalMod
1414
use spmdMod , only : masterproc
1515
use elm_varpar , only : more_vertlayers, nlevsno, nlevgrnd, nlevlak
1616
use elm_varpar , only : toplev_equalspace, nlev_equalspace
17-
use elm_varpar , only : nlevsoi, nlevsoifl, nlevurb, nlevslp
17+
use elm_varpar , only : nlevsoi, nlevsoifl, nlevurb, nlevslp
1818
use elm_varctl , only : fsurdat, iulog, use_var_soil_thick
1919
use elm_varctl , only : use_vancouver, use_mexicocity, use_vertsoilc, use_extralakelayers, use_extrasnowlayers
20-
use elm_varctl , only : use_erosion
21-
use elm_varcon , only : zlak, dzlak, zsoi, dzsoi, zisoi, dzsoi_decomp, spval, grlnd
20+
use elm_varctl , only : use_erosion, use_polygonal_tundra
21+
use elm_varcon , only : zlak, dzlak, zsoi, dzsoi, zisoi, dzsoi_decomp, spval, grlnd
2222
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall, icol_road_perv, icol_road_imperv
2323
use landunit_varcon, only : istdlak, istice_mec
2424
use fileutils , only : getfil
25-
use LandunitType , only : lun_pp
26-
use ColumnType , only : col_pp
25+
use LandunitType , only : lun_pp
26+
use ColumnType , only : col_pp
2727
use SnowHydrologyMod, only : InitSnowLayers
2828
use ncdio_pio
2929
use topounit_varcon , only : max_topounits
@@ -50,13 +50,14 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
5050
real(r8) , intent(in) :: thick_roof(bounds%begl:)
5151
!
5252
! LOCAL VARAIBLES:
53-
integer :: c,l,t,ti,topi,g,i,j,lev ! indices
53+
integer :: c,l,t,ti,topi,g,i,j,lev ! indices
5454
type(file_desc_t) :: ncid ! netcdf id
55-
logical :: readvar
55+
logical :: readvar
5656
integer :: dimid ! dimension id
5757
character(len=256) :: locfn ! local filename
58-
real(r8) ,pointer :: std (:) ! read in - topo_std
59-
real(r8) ,pointer :: tslope (:) ! read in - topo_slope
58+
real(r8) ,pointer :: std (:) ! read in - topo_std
59+
real(r8) ,pointer :: tslope (:) ! read in - topo_slope
60+
real(r8) ,pointer :: gradz(:) ! read in - gradz (polygonal tundra only)
6061
real(r8) ,pointer :: hslp_p10 (:,:,:) ! read in - hillslope slope percentiles
6162
real(r8) ,pointer :: dtb (:,:) ! read in - DTB
6263
real(r8) :: beddep ! temporary
@@ -68,14 +69,14 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
6869
integer :: ier ! error status
6970
real(r8) :: scalez = 0.025_r8 ! Soil layer thickness discretization (m)
7071
real(r8) :: thick_equal = 0.2
71-
real(r8) ,pointer :: lakedepth_in(:,:) ! read in - lakedepth
72+
real(r8) ,pointer :: lakedepth_in(:,:) ! read in - lakedepth
7273
real(r8), allocatable :: zurb_wall(:,:) ! wall (layer node depth)
7374
real(r8), allocatable :: zurb_roof(:,:) ! roof (layer node depth)
7475
real(r8), allocatable :: dzurb_wall(:,:) ! wall (layer thickness)
7576
real(r8), allocatable :: dzurb_roof(:,:) ! roof (layer thickness)
7677
real(r8), allocatable :: ziurb_wall(:,:) ! wall (layer interface)
7778
real(r8), allocatable :: ziurb_roof(:,:) ! roof (layer interface)
78-
real(r8) :: depthratio ! ratio of lake depth to standard deep lake depth
79+
real(r8) :: depthratio ! ratio of lake depth to standard deep lake depth
7980
integer :: begc, endc
8081
integer :: begl, endl
8182
!------------------------------------------------------------------------
@@ -87,7 +88,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
8788
SHR_ASSERT_ALL((ubound(thick_wall) == (/endl/)), errMsg(__FILE__, __LINE__))
8889
SHR_ASSERT_ALL((ubound(thick_roof) == (/endl/)), errMsg(__FILE__, __LINE__))
8990

90-
! Open surface dataset to read in data below
91+
! Open surface dataset to read in data below
9192

9293
call getfil (fsurdat, locfn, 0)
9394
call ncd_pio_openfile (ncid, locfn, 0)
@@ -103,19 +104,19 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
103104
end if
104105

105106
! --------------------------------------------------------------------
106-
! Define layer structure for soil, lakes, urban walls and roof
107+
! Define layer structure for soil, lakes, urban walls and roof
107108
! Vertical profile of snow is not initialized here - but below
108109
! --------------------------------------------------------------------
109-
110+
110111
! Soil layers and interfaces (assumed same for all non-lake patches)
111112
! "0" refers to soil surface and "nlevsoi" refers to the bottom of model soil
112-
113+
113114
if ( more_vertlayers )then
114-
! replace standard exponential grid with a grid that starts out exponential,
115-
! then has several evenly spaced layers, then finishes off exponential.
116-
! this allows the upper soil to behave as standard, but then continues
115+
! replace standard exponential grid with a grid that starts out exponential,
116+
! then has several evenly spaced layers, then finishes off exponential.
117+
! this allows the upper soil to behave as standard, but then continues
117118
! with higher resolution to a deeper depth, so that, for example, permafrost
118-
! dynamics are not lost due to an inability to resolve temperature, moisture,
119+
! dynamics are not lost due to an inability to resolve temperature, moisture,
119120
! and biogeochemical dynamics at the base of the active layer
120121
do j = 1, toplev_equalspace
121122
zsoi(j) = scalez*(exp(0.5_r8*(j-0.5_r8))-1._r8) !node depths
@@ -148,7 +149,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
148149
zisoi(nlevgrnd) = zsoi(nlevgrnd) + 0.5_r8*dzsoi(nlevgrnd)
149150

150151
if (masterproc) then
151-
write(iulog, *) 'zsoi', zsoi(:)
152+
write(iulog, *) 'zsoi', zsoi(:)
152153
write(iulog, *) 'zisoi: ', zisoi(:)
153154
write(iulog, *) 'dzsoi: ', dzsoi(:)
154155
end if
@@ -164,7 +165,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
164165
dzsoi_decomp(1) = 1.
165166
end if
166167
if (masterproc) then
167-
write(iulog, *) 'dzsoi_decomp', dzsoi_decomp(:)
168+
write(iulog, *) 'dzsoi_decomp', dzsoi_decomp(:)
168169
end if
169170

170171
if (nlevurb > 0) then
@@ -187,7 +188,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
187188

188189
! "0" refers to urban wall/roof surface and "nlevsoi" refers to urban wall/roof bottom
189190
if (lun_pp%urbpoi(l)) then
190-
if (use_vancouver) then
191+
if (use_vancouver) then
191192
zurb_wall(l,1) = 0.010_r8/2._r8
192193
zurb_wall(l,2) = zurb_wall(l,1) + 0.010_r8/2._r8 + 0.020_r8/2._r8
193194
zurb_wall(l,3) = zurb_wall(l,2) + 0.020_r8/2._r8 + 0.070_r8/2._r8
@@ -281,13 +282,13 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
281282

282283
dzurb_roof(l,1) = 0.5*(zurb_roof(l,1)+zurb_roof(l,2)) !thickness b/n two interfaces
283284
do j = 2,nlevurb-1
284-
dzurb_roof(l,j)= 0.5*(zurb_roof(l,j+1)-zurb_roof(l,j-1))
285+
dzurb_roof(l,j)= 0.5*(zurb_roof(l,j+1)-zurb_roof(l,j-1))
285286
enddo
286287
dzurb_roof(l,nlevurb) = zurb_roof(l,nlevurb)-zurb_roof(l,nlevurb-1)
287288

288289
dzurb_wall(l,1) = 0.5*(zurb_wall(l,1)+zurb_wall(l,2)) !thickness b/n two interfaces
289290
do j = 2,nlevurb-1
290-
dzurb_wall(l,j)= 0.5*(zurb_wall(l,j+1)-zurb_wall(l,j-1))
291+
dzurb_wall(l,j)= 0.5*(zurb_wall(l,j+1)-zurb_wall(l,j-1))
291292
enddo
292293
dzurb_wall(l,nlevurb) = zurb_wall(l,nlevurb)-zurb_wall(l,nlevurb-1)
293294

@@ -362,7 +363,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
362363
t = col_pp%topounit(c)
363364
topi = grc_pp%topi(g)
364365
ti = t - topi + 1
365-
366+
366367
col_pp%lakedepth(c) = lakedepth_in(g,ti)
367368
end do
368369
deallocate(lakedepth_in)
@@ -435,7 +436,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
435436

436437
else if (col_pp%lakedepth(c) > 1._r8 .and. col_pp%lakedepth(c) < 5000._r8) then
437438

438-
depthratio = col_pp%lakedepth(c) / (zlak(nlevlak) + 0.5_r8*dzlak(nlevlak))
439+
depthratio = col_pp%lakedepth(c) / (zlak(nlevlak) + 0.5_r8*dzlak(nlevlak))
439440
col_pp%z_lake(c,1) = zlak(1)
440441
col_pp%dz_lake(c,1) = dzlak(1)
441442
col_pp%dz_lake(c,2:nlevlak-1) = dzlak(2:nlevlak-1)*depthratio
@@ -466,12 +467,12 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
466467
end do
467468

468469
!-----------------------------------------------
469-
! Set cold-start values for snow levels, snow layers and snow interfaces
470+
! Set cold-start values for snow levels, snow layers and snow interfaces
470471
!-----------------------------------------------
471472

472473
if (.not. use_extrasnowlayers) then
473-
474-
associate(snl => col_pp%snl) ! Output: [integer (:) ] number of snow layers
474+
475+
associate(snl => col_pp%snl) ! Output: [integer (:) ] number of snow layers
475476

476477
do c = bounds%begc,bounds%endc
477478
l = col_pp%landunit(c)
@@ -547,12 +548,12 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
547548
col_pp%zi(c,-nlevsno+0:0) = 0._r8
548549
end if
549550
end do
550-
551+
551552
end associate
552-
553+
553554
else ! use extra (16) snow layers, for firn model
554555
call InitSnowLayers(bounds, snow_depth(bounds%begc:bounds%endc))
555-
556+
556557
end if
557558

558559
!-----------------------------------------------
@@ -563,7 +564,7 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
563564
call ncd_io(ncid=ncid, varname='SLOPE', flag='read', data=tslope, dim1name=grlnd, readvar=readvar)
564565
if (.not. readvar) then
565566
call shr_sys_abort(' ERROR: TOPOGRAPHIC SLOPE NOT on surfdata file'//&
566-
errMsg(__FILE__, __LINE__))
567+
errMsg(__FILE__, __LINE__))
567568
end if
568569
do c = begc,endc
569570
g = col_pp%gridcell(c)
@@ -572,11 +573,24 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
572573
end do
573574
deallocate(tslope)
574575

576+
if (use_polygonal_tundra) then
577+
allocate(gradz(bounds%begg:bounds%endg))
578+
call ncd_io(ncid=ncid, varname='GRADZ', flag='read', data=gradz, dim1name=grlnd, readvar=readvar)
579+
if (.not. readvar) then
580+
call shr_sys_abort(' ERROR: polygonal tundra turned on, but GRADZ not on surfdata file'//&
581+
errMsg(__FILE__, __LINE__))
582+
end if
583+
do c = begc,endc
584+
g = col_pp%gridcell(c)
585+
col_pp%meangradz(c) = gradz(g)
586+
end do
587+
end if
588+
575589
allocate(std(bounds%begg:bounds%endg))
576590
call ncd_io(ncid=ncid, varname='STD_ELEV', flag='read', data=std, dim1name=grlnd, readvar=readvar)
577591
if (.not. readvar) then
578592
call shr_sys_abort(' ERROR: TOPOGRAPHIC STDdev (STD_ELEV) NOT on surfdata file'//&
579-
errMsg(__FILE__, __LINE__))
593+
errMsg(__FILE__, __LINE__))
580594
end if
581595
do c = begc,endc
582596
g = col_pp%gridcell(c)
@@ -623,11 +637,11 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
623637
else
624638
do c = begc,endc
625639
g = col_pp%gridcell(c)
626-
l = col_pp%landunit(c)
640+
l = col_pp%landunit(c)
627641
t = col_pp%topounit(c)
628642
topi = grc_pp%topi(g)
629643
ti = t - topi + 1
630-
644+
631645
if (lun_pp%urbpoi(l) .and. col_pp%itype(c) /= icol_road_imperv .and. col_pp%itype(c) /= icol_road_perv) then
632646
col_pp%nlevbed(c) = nlevurb
633647
else if (lun_pp%itype(l) == istdlak) then

0 commit comments

Comments
 (0)