@@ -13,11 +13,11 @@ module initSubgridMod
13
13
use elm_varctl , only : iulog
14
14
use elm_varcon , only : namep, namec, namel, namet
15
15
use decompMod , only : bounds_type
16
- use GridcellType , only : grc_pp
16
+ use GridcellType , only : grc_pp
17
17
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
21
21
!
22
22
! !PUBLIC TYPES:
23
23
implicit none
@@ -29,33 +29,34 @@ module initSubgridMod
29
29
public :: elm_ptrs_check ! checks and writes out a summary of subgrid data
30
30
public :: add_topounit ! add an entry in the topounit-level arrays
31
31
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.
32
33
public :: add_column ! add an entry in the column-level arrays
33
34
public :: add_patch ! add an entry in the patch-level arrays
34
35
!
35
36
!- ----------------------------------------------------------------------
36
37
37
38
contains
38
-
39
+
39
40
!- -----------------------------------------------------------------------------
40
41
subroutine elm_ptrs_compdown (bounds )
41
42
!
42
43
! !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
44
45
! in the data pointing down. Up is p_c, p_l, p_g, c_l, c_g, and l_g.
45
46
!
46
47
! This algorithm assumes all indices besides grid cell are monotonically
47
48
! 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 -
49
50
! grc_pp%luni, grc_pp%lunf, etc.)
50
51
!
51
52
! Algorithm works as follows. The p, c, and l loops march through
52
53
! 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
55
56
! to that cell. The *f array follows the same logic, so it's always the
56
57
! last "up" index from the previous cell when an "up" index changes.
57
58
!
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
59
60
! subroutine will set c_pi(1) = 1, c_pf(1) = 4, c_pi(2) = 5, c_pf(2) = 12.
60
61
!
61
62
! !USES
@@ -78,7 +79,7 @@ subroutine elm_ptrs_compdown(bounds)
78
79
!- -- Loop p through full local begp:endp length
79
80
!- -- Separately check the p_c, p_l, and p_g indexes for a change in
80
81
!- -- 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
82
83
!- -- valid range, and set c_pi, l_pi, or g_pi to that current c,l,g
83
84
!- -- Constantly update the c_pf, l_pf, and g_pf array. When the
84
85
!- -- g, l, c index changes, the *_pf array will be set correctly
@@ -123,8 +124,8 @@ subroutine elm_ptrs_compdown(bounds)
123
124
lun_pp% colf(curl) = c
124
125
lun_pp% ncolumns(curl) = lun_pp% colf(curl) - lun_pp% coli(curl) + 1
125
126
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
128
129
! previous monotonic down pointers
129
130
curg = 0
130
131
do t = bounds% begt,bounds% endt
@@ -142,7 +143,7 @@ subroutine elm_ptrs_compdown(bounds)
142
143
143
144
! Determine landunit_indices: indices into landunit-level arrays for each grid cell.
144
145
! 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
146
147
! for max_topounits = 1
147
148
grc_pp% landunit_indices(:,bounds% begg:bounds% endg) = ispval
148
149
do l = bounds% begl,bounds% endl
@@ -184,7 +185,7 @@ subroutine elm_ptrs_compdown(bounds)
184
185
call endrun(decomp_index= l, elmlevel= namel, msg= errMsg(__FILE__, __LINE__))
185
186
end if
186
187
end do
187
-
188
+
188
189
end subroutine elm_ptrs_compdown
189
190
190
191
!- -----------------------------------------------------------------------------
@@ -221,7 +222,7 @@ subroutine elm_ptrs_check(bounds)
221
222
begp = > bounds% begp, &
222
223
endp = > bounds% endp &
223
224
)
224
-
225
+
225
226
if (masterproc) write (iulog,* ) ' '
226
227
if (masterproc) write (iulog,* ) ' ---elm_ptrs_check:'
227
228
@@ -383,7 +384,7 @@ subroutine elm_ptrs_check(bounds)
383
384
if (masterproc) write (iulog,* ) ' '
384
385
385
386
end associate
386
-
387
+
387
388
end subroutine elm_ptrs_check
388
389
389
390
!- ----------------------------------------------------------------------
@@ -396,7 +397,7 @@ subroutine add_topounit(ti, gi, wtgcell,elv, slp, asp,topo_ind,is_tpu_active)
396
397
!
397
398
! !ARGUMENTS:
398
399
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
400
401
real (r8 ) , intent (in ) :: wtgcell ! weight of the topounit relative to the gridcell
401
402
real (r8 ) , intent (in ) :: elv ! topounit elevation
402
403
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)
415
416
top_pp% elevation(ti) = elv
416
417
top_pp% slope(ti) = slp
417
418
top_pp% aspect(ti) = asp
418
- top_pp% topo_grc_ind(ti) = topo_ind
419
+ top_pp% topo_grc_ind(ti) = topo_ind
419
420
top_pp% active(ti) = is_tpu_active
420
-
421
+
421
422
end subroutine add_topounit
422
423
423
424
!- ----------------------------------------------------------------------
@@ -438,18 +439,18 @@ subroutine add_landunit(li, ti, ltype, wttopounit)
438
439
real (r8 ) , intent (in ) :: wttopounit ! weight of the landunit relative to the topounit
439
440
!
440
441
! !LOCAL VARIABLES:
441
-
442
+
442
443
character (len=* ), parameter :: subname = ' add_landunit'
443
444
!- ----------------------------------------------------------------------
444
-
445
+
445
446
li = li + 1
446
447
447
448
lun_pp% topounit(li) = ti
448
449
lun_pp% gridcell(li) = top_pp% gridcell(ti)
449
-
450
+
450
451
lun_pp% wttopounit(li) = wttopounit
451
452
lun_pp% itype(li) = ltype
452
-
453
+
453
454
if (ltype == istsoil .or. ltype == istcrop) then
454
455
lun_pp% ifspecial(li) = .false.
455
456
else
@@ -476,6 +477,51 @@ subroutine add_landunit(li, ti, ltype, wttopounit)
476
477
477
478
end subroutine add_landunit
478
479
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
+
479
525
!- ----------------------------------------------------------------------
480
526
subroutine add_column (ci , li , ctype , wtlunit )
481
527
!
@@ -499,10 +545,10 @@ subroutine add_column(ci, li, ctype, wtlunit)
499
545
col_pp% landunit(ci) = li
500
546
col_pp% topounit(ci) = lun_pp% topounit(li)
501
547
col_pp% gridcell(ci) = lun_pp% gridcell(li)
502
-
548
+
503
549
col_pp% wtlunit(ci) = wtlunit
504
550
col_pp% itype(ci) = ctype
505
-
551
+
506
552
end subroutine add_column
507
553
508
554
!- ----------------------------------------------------------------------
@@ -526,17 +572,17 @@ subroutine add_patch(pi, ci, ptype, wtcol)
526
572
! !LOCAL VARIABLES:
527
573
integer :: li ! landunit index, for convenience
528
574
integer :: lb_offset ! offset between natpft_lb and 1
529
-
575
+
530
576
character (len=* ), parameter :: subname = ' add_patch'
531
577
!- ----------------------------------------------------------------------
532
-
578
+
533
579
pi = pi + 1
534
580
535
581
veg_pp% column(pi) = ci
536
582
veg_pp% landunit(pi) = col_pp% landunit(ci)
537
583
veg_pp% topounit(pi) = col_pp% topounit(ci)
538
584
veg_pp% gridcell(pi) = col_pp% gridcell(ci)
539
-
585
+
540
586
veg_pp% wtcol(pi) = wtcol
541
587
veg_pp% itype(pi) = ptype
542
588
0 commit comments