Skip to content

Commit f90c05c

Browse files
committed
wip - Allow polygonal landunits to be initiated from surface file
Updates initialization routines to allow for polygonal landunits to be created from namelist option and from polygon type percentages specified on input file. In particular, it allows for four landunits to be created with istsoil ltype on each topounit so that the ice wedge polygons can have their own soil columns as well as be vegetated. The fourth landunit is for non-polygonal natural vegetated ground on the same topounit.
1 parent 4a88a2d commit f90c05c

File tree

3 files changed

+200
-125
lines changed

3 files changed

+200
-125
lines changed

components/elm/src/main/elm_varsur.F90

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module elm_varsur
22

33
!-----------------------------------------------------------------------
44
! Module containing 2-d surface boundary data information
5-
! surface boundary data, these are all "gdc" local
5+
! surface boundary data, these are all "gdc" local
66
! Note that some of these need to be pointers (as opposed to just allocatable arrays) to
77
! match the ncd_io interface; for consistency, we make them all pointers
88
!
@@ -14,20 +14,26 @@ module elm_varsur
1414
save
1515
!
1616
! weight of each landunit on the topounit in the grid cell
17-
real(r8), pointer :: wt_lunit(:,:,:)
17+
real(r8), pointer :: wt_lunit(:,:,:)
1818

1919
! whether we have valid urban data in each grid cell or (in each topounit)
2020
logical , pointer :: urban_valid(:,:)
2121

2222
! for natural veg landunit, weight of each pft on the landunit (adds to 1.0 on the
2323
! landunit for all all grid cells, even! those without any natural pft)
2424
! (second dimension goes natpft_lb:natpft_ub)
25-
real(r8), pointer :: wt_nat_patch(:,:,:)
25+
real(r8), pointer :: wt_nat_patch(:,:,:)
26+
27+
! for polygonal tundra special case of natural veg landunit, weight of polygon type
28+
! with respect to the natural vegetation landunit (NOT the grid cell). these do
29+
! not need to sum to 1 to preserve possibility of polygonal tundra and non-polygonal
30+
! ground on the same grid cell, on the vegetated landunit.
31+
real(r8), pointer :: wt_polygon(:,:,:) ! dims: clump, topounit, polygon type
2632

2733
! for crop landunit, weight of each cft on the landunit (adds to 1.0 on the
2834
! landunit for all all grid cells, even those without any crop)
2935
! (second dimension goes cft_lb:cft_ub)
30-
real(r8), pointer :: wt_cft(:,:,:)
36+
real(r8), pointer :: wt_cft(:,:,:)
3137

3238
! for each cft on the crop landunit prescribe annual fertilizer
3339
! landunit for all all grid cells, even those without any crop)
@@ -37,19 +43,19 @@ module elm_varsur
3743

3844
! for glc_mec landunits, weight of glacier in each elevation class (adds to 1.0 on the
3945
! landunit for all grid cells, even those without any glacier)
40-
real(r8), pointer :: wt_glc_mec(:,:,:)
46+
real(r8), pointer :: wt_glc_mec(:,:,:)
4147

4248
! subgrid glacier_mec sfc elevation
43-
real(r8), pointer :: topo_glc_mec(:,:,:)
44-
49+
real(r8), pointer :: topo_glc_mec(:,:,:)
50+
4551
! Topounit related poiters
4652
real(r8), pointer :: num_tunit_per_grd(:) ! Topounit area fraction
4753
real(r8), pointer :: wt_tunit(:,:) ! Topounit area fraction
48-
real(r8), pointer :: elv_tunit(:,:) ! Topounit elevation
49-
real(r8), pointer :: slp_tunit(:,:) ! Topounit slope
54+
real(r8), pointer :: elv_tunit(:,:) ! Topounit elevation
55+
real(r8), pointer :: slp_tunit(:,:) ! Topounit slope
5056
integer, pointer :: asp_tunit(:,:) ! Topounit aspect
51-
52-
real(r8),pointer :: firrig(:,:)
57+
58+
real(r8),pointer :: firrig(:,:)
5359
real(r8),pointer :: f_surf(:,:) ! fraction of water withdraws from surfacewater
5460
real(r8),pointer :: f_grd(:,:) ! fraction of water withdraws from groundwater
5561
!-----------------------------------------------------------------------

components/elm/src/main/initSubgridMod.F90

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module initSubgridMod
1313
use elm_varctl , only : iulog
1414
use elm_varcon , only : namep, namec, namel, namet
1515
use decompMod , only : bounds_type
16-
use GridcellType , only : grc_pp
16+
use GridcellType , only : grc_pp
1717
Use TopounitType , only : top_pp
18-
use LandunitType , only : lun_pp
19-
use ColumnType , only : col_pp
20-
use VegetationType , only : veg_pp
18+
use LandunitType , only : lun_pp
19+
use ColumnType , only : col_pp
20+
use VegetationType , only : veg_pp
2121
!
2222
! !PUBLIC TYPES:
2323
implicit none
@@ -29,33 +29,34 @@ module initSubgridMod
2929
public :: elm_ptrs_check ! checks and writes out a summary of subgrid data
3030
public :: add_topounit ! add an entry in the topounit-level arrays
3131
public :: add_landunit ! add an entry in the landunit-level arrays
32+
public :: add_polygon_landunit ! adds an entry in the landunit-level arrays for the special type of polygonal ground.
3233
public :: add_column ! add an entry in the column-level arrays
3334
public :: add_patch ! add an entry in the patch-level arrays
3435
!
3536
!-----------------------------------------------------------------------
3637

3738
contains
38-
39+
3940
!------------------------------------------------------------------------------
4041
subroutine elm_ptrs_compdown(bounds)
4142
!
4243
! !DESCRIPTION:
43-
! Assumes the part of the subgrid pointing up has been set. Fills
44+
! Assumes the part of the subgrid pointing up has been set. Fills
4445
! in the data pointing down. Up is p_c, p_l, p_g, c_l, c_g, and l_g.
4546
!
4647
! This algorithm assumes all indices besides grid cell are monotonically
4748
! increasing. (Note that grid cell index is NOT monotonically increasing,
48-
! hence we cannot set initial & final indices at the grid cell level -
49+
! hence we cannot set initial & final indices at the grid cell level -
4950
! grc_pp%luni, grc_pp%lunf, etc.)
5051
!
5152
! Algorithm works as follows. The p, c, and l loops march through
5253
! the full arrays (nump, numc, and numl) checking the "up" indexes.
53-
! As soon as the "up" index of the current (p,c,l) cell changes relative
54-
! to the previous (p,c,l) cell, the *i array will be set to point down
54+
! As soon as the "up" index of the current (p,c,l) cell changes relative
55+
! to the previous (p,c,l) cell, the *i array will be set to point down
5556
! to that cell. The *f array follows the same logic, so it's always the
5657
! last "up" index from the previous cell when an "up" index changes.
5758
!
58-
! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This
59+
! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This
5960
! subroutine will set c_pi(1) = 1, c_pf(1) = 4, c_pi(2) = 5, c_pf(2) = 12.
6061
!
6162
! !USES
@@ -78,7 +79,7 @@ subroutine elm_ptrs_compdown(bounds)
7879
!--- Loop p through full local begp:endp length
7980
!--- Separately check the p_c, p_l, and p_g indexes for a change in
8081
!--- the "up" index.
81-
!--- If there is a change, verify that the current c,l,g is within the
82+
!--- If there is a change, verify that the current c,l,g is within the
8283
!--- valid range, and set c_pi, l_pi, or g_pi to that current c,l,g
8384
!--- Constantly update the c_pf, l_pf, and g_pf array. When the
8485
!--- g, l, c index changes, the *_pf array will be set correctly
@@ -123,8 +124,8 @@ subroutine elm_ptrs_compdown(bounds)
123124
lun_pp%colf(curl) = c
124125
lun_pp%ncolumns(curl) = lun_pp%colf(curl) - lun_pp%coli(curl) + 1
125126
enddo
126-
127-
! Gridcell down pointers to topounits are monotonic, so those can be done like the
127+
128+
! Gridcell down pointers to topounits are monotonic, so those can be done like the
128129
! previous monotonic down pointers
129130
curg = 0
130131
do t = bounds%begt,bounds%endt
@@ -142,7 +143,7 @@ subroutine elm_ptrs_compdown(bounds)
142143

143144
! Determine landunit_indices: indices into landunit-level arrays for each grid cell.
144145
! Note that landunits not present in a given grid cell are set to ispval.
145-
! Preliminary implementation of topounits: leave this unchanged, but will only work
146+
! Preliminary implementation of topounits: leave this unchanged, but will only work
146147
! for max_topounits = 1
147148
grc_pp%landunit_indices(:,bounds%begg:bounds%endg) = ispval
148149
do l = bounds%begl,bounds%endl
@@ -184,7 +185,7 @@ subroutine elm_ptrs_compdown(bounds)
184185
call endrun(decomp_index=l, elmlevel=namel, msg=errMsg(__FILE__, __LINE__))
185186
end if
186187
end do
187-
188+
188189
end subroutine elm_ptrs_compdown
189190

190191
!------------------------------------------------------------------------------
@@ -221,7 +222,7 @@ subroutine elm_ptrs_check(bounds)
221222
begp => bounds%begp, &
222223
endp => bounds%endp &
223224
)
224-
225+
225226
if (masterproc) write(iulog,*) ' '
226227
if (masterproc) write(iulog,*) '---elm_ptrs_check:'
227228

@@ -383,7 +384,7 @@ subroutine elm_ptrs_check(bounds)
383384
if (masterproc) write(iulog,*) ' '
384385

385386
end associate
386-
387+
387388
end subroutine elm_ptrs_check
388389

389390
!-----------------------------------------------------------------------
@@ -396,7 +397,7 @@ subroutine add_topounit(ti, gi, wtgcell,elv, slp, asp,topo_ind,is_tpu_active)
396397
!
397398
! !ARGUMENTS:
398399
integer , intent(inout) :: ti ! input value is index of last topounit added; output value is index of this newly-added topounit
399-
integer , intent(in) :: gi ! gridcell index on which this topounit should be placed
400+
integer , intent(in) :: gi ! gridcell index on which this topounit should be placed
400401
real(r8) , intent(in) :: wtgcell ! weight of the topounit relative to the gridcell
401402
real(r8) , intent(in) :: elv ! topounit elevation
402403
real(r8) , intent(in) :: slp ! topounit slope
@@ -415,9 +416,9 @@ subroutine add_topounit(ti, gi, wtgcell,elv, slp, asp,topo_ind,is_tpu_active)
415416
top_pp%elevation(ti) = elv
416417
top_pp%slope(ti) = slp
417418
top_pp%aspect(ti) = asp
418-
top_pp%topo_grc_ind(ti) = topo_ind
419+
top_pp%topo_grc_ind(ti) = topo_ind
419420
top_pp%active(ti) = is_tpu_active
420-
421+
421422
end subroutine add_topounit
422423

423424
!-----------------------------------------------------------------------
@@ -438,18 +439,18 @@ subroutine add_landunit(li, ti, ltype, wttopounit)
438439
real(r8) , intent(in) :: wttopounit ! weight of the landunit relative to the topounit
439440
!
440441
! !LOCAL VARIABLES:
441-
442+
442443
character(len=*), parameter :: subname = 'add_landunit'
443444
!-----------------------------------------------------------------------
444-
445+
445446
li = li + 1
446447

447448
lun_pp%topounit(li) = ti
448449
lun_pp%gridcell(li) = top_pp%gridcell(ti)
449-
450+
450451
lun_pp%wttopounit(li) = wttopounit
451452
lun_pp%itype(li) = ltype
452-
453+
453454
if (ltype == istsoil .or. ltype == istcrop) then
454455
lun_pp%ifspecial(li) = .false.
455456
else
@@ -476,6 +477,51 @@ subroutine add_landunit(li, ti, ltype, wttopounit)
476477

477478
end subroutine add_landunit
478479

480+
!-----------------------------------------------------------------------
481+
subroutine add_polygon_landunit(li, ti, ltype, wttopounit, polytype)
482+
!
483+
! !DESCRIPTION:
484+
! Add an entry in the landunit-level arrays. li gives the index of the last landunit
485+
! added; the new landunit is added at li+1, and the li argument is incremented
486+
! accordingly.
487+
!
488+
! This verison of add_landunit is specific to polygonal tundra.
489+
!
490+
! !USES:
491+
use landunit_varcon , only : istsoil, istcrop, istice_mec, istdlak, isturb_MIN, isturb_MAX
492+
!
493+
! !ARGUMENTS:
494+
integer , intent(inout) :: li ! input value is index of last landunit added; output value is index of this newly-added landunit
495+
integer , intent(in) :: ti ! topounit index on which this landunit should be placed
496+
integer , intent(in) :: ltype ! landunit type
497+
real(r8) , intent(in) :: wttopounit ! weight of the landunit relative to the topounit
498+
integer , intent(in) :: polytype ! defines the type of ice wedge polygon this landunit corresponds to
499+
!
500+
! !LOCAL VARIABLES:
501+
502+
character(len=*), parameter :: subname = 'add_polygon_landunit'
503+
!-----------------------------------------------------------------------
504+
505+
li = li + 1
506+
507+
lun_pp%topounit(li) = ti
508+
lun_pp%gridcell(li) = top_pp%gridcell(ti)
509+
510+
lun_pp%wttopounit(li) = wttopounit
511+
lun_pp%itype(li) = ltype
512+
513+
if (ltype == istsoil) then
514+
lun_pp%ifspecial(li) = .false.
515+
lun_pp%ispolygon(li) = .true.
516+
lun_pp%polygontype(li) = polytype
517+
else
518+
write (iulog, *) "ERROR: attempting to assign polygonal tundra landunit to special or crop landunit type"
519+
call endrun(msg=errMsg(__FILE__, __LINE__))
520+
end if
521+
522+
end subroutine add_polygon_landunit
523+
524+
479525
!-----------------------------------------------------------------------
480526
subroutine add_column(ci, li, ctype, wtlunit)
481527
!
@@ -499,10 +545,10 @@ subroutine add_column(ci, li, ctype, wtlunit)
499545
col_pp%landunit(ci) = li
500546
col_pp%topounit(ci) = lun_pp%topounit(li)
501547
col_pp%gridcell(ci) = lun_pp%gridcell(li)
502-
548+
503549
col_pp%wtlunit(ci) = wtlunit
504550
col_pp%itype(ci) = ctype
505-
551+
506552
end subroutine add_column
507553

508554
!-----------------------------------------------------------------------
@@ -526,17 +572,17 @@ subroutine add_patch(pi, ci, ptype, wtcol)
526572
! !LOCAL VARIABLES:
527573
integer :: li ! landunit index, for convenience
528574
integer :: lb_offset ! offset between natpft_lb and 1
529-
575+
530576
character(len=*), parameter :: subname = 'add_patch'
531577
!-----------------------------------------------------------------------
532-
578+
533579
pi = pi + 1
534580

535581
veg_pp%column(pi) = ci
536582
veg_pp%landunit(pi) = col_pp%landunit(ci)
537583
veg_pp%topounit(pi) = col_pp%topounit(ci)
538584
veg_pp%gridcell(pi) = col_pp%gridcell(ci)
539-
585+
540586
veg_pp%wtcol(pi) = wtcol
541587
veg_pp%itype(pi) = ptype
542588

0 commit comments

Comments
 (0)