Skip to content

Commit 0f321cd

Browse files
authored
Merge pull request #1321 from rgknox/twostream-restart-fixes-v2
restart fixes for two-stream
2 parents b5d3a13 + ad7d84d commit 0f321cd

13 files changed

+378
-370
lines changed

biogeochem/EDCanopyStructureMod.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
14521452
call leaf_area_profile(sites(s))
14531453

14541454
if(hlm_radiation_model.eq.twostr_solver) then
1455-
call FatesConstructRadElements(sites(s),bc_in(s)%fcansno_pa,bc_in(s)%coszen_pa)
1455+
call FatesConstructRadElements(sites(s))
14561456
end if
14571457

14581458
end do ! site loop
@@ -1858,9 +1858,10 @@ subroutine leaf_area_profile( currentSite )
18581858
end if if_any_canopy_area
18591859

18601860
cpatch => cpatch%younger
1861-
18621861
enddo !patch
18631862

1863+
1864+
18641865
return
18651866
end subroutine leaf_area_profile
18661867

biogeochem/EDPatchDynamicsMod.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,6 +3212,8 @@ subroutine fuse_2_patches(csite, dp, rp)
32123212
rp%zstar = (dp%zstar*dp%area + rp%zstar*rp%area) * inv_sum_area
32133213
rp%c_stomata = (dp%c_stomata*dp%area + rp%c_stomata*rp%area) * inv_sum_area
32143214
rp%c_lblayer = (dp%c_lblayer*dp%area + rp%c_lblayer*rp%area) * inv_sum_area
3215+
3216+
! Radiation
32153217
rp%rad_error(1) = (dp%rad_error(1)*dp%area + rp%rad_error(1)*rp%area) * inv_sum_area
32163218
rp%rad_error(2) = (dp%rad_error(2)*dp%area + rp%rad_error(2)*rp%area) * inv_sum_area
32173219

biogeochem/FatesPatchMod.F90

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ module FatesPatchMod
136136
! RADIATION
137137
real(r8) :: rad_error(num_swb) ! radiation consv error by band [W/m2]
138138
real(r8) :: fcansno ! fraction of canopy covered in snow [0-1]
139-
logical :: solar_zenith_flag ! integer flag specifying daylight (based on zenith angle)
140-
real(r8) :: solar_zenith_angle ! solar zenith angle [radians]
141139
real(r8) :: gnd_alb_dif(num_swb) ! ground albedo for diffuse rad, both bands [0-1]
142140
real(r8) :: gnd_alb_dir(num_swb) ! ground albedo for direct rad, both bands [0-1]
143141

@@ -466,8 +464,6 @@ subroutine NanValues(this)
466464
! RADIATION
467465
this%rad_error(:) = nan
468466
this%fcansno = nan
469-
this%solar_zenith_flag = .false.
470-
this%solar_zenith_angle = nan
471467
this%gnd_alb_dif(:) = nan
472468
this%gnd_alb_dir(:) = nan
473469

@@ -565,7 +561,6 @@ subroutine ZeroValues(this)
565561
this%c_stomata = 0.0_r8
566562
this%c_lblayer = 0.0_r8
567563

568-
569564
! RADIATION
570565
this%rad_error(:) = 0.0_r8
571566
this%tr_soil_dir_dif(:) = 0.0_r8
@@ -574,7 +569,7 @@ subroutine ZeroValues(this)
574569
this%fabd(:) = 0.0_r8
575570
this%sabs_dir(:) = 0.0_r8
576571
this%sabs_dif(:) = 0.0_r8
577-
572+
578573
! ROOTS
579574
this%btran_ft(:) = 0.0_r8
580575

@@ -691,7 +686,7 @@ end subroutine InitLitter
691686
!===========================================================================
692687

693688
subroutine Create(this, age, area, land_use_label, nocomp_pft, num_swb, num_pft, &
694-
num_levsoil, current_tod, regeneration_model)
689+
num_levsoil, current_tod, regeneration_model)
695690
!
696691
! DESCRIPTION:
697692
! create a new patch with input and default values
@@ -708,7 +703,7 @@ subroutine Create(this, age, area, land_use_label, nocomp_pft, num_swb, num_pft,
708703
integer, intent(in) :: num_levsoil ! number of soil layers
709704
integer, intent(in) :: current_tod ! time of day [seconds past 0Z]
710705
integer, intent(in) :: regeneration_model ! regeneration model version
711-
706+
712707
! initialize patch
713708
! sets all values to nan, then some values to zero
714709
call this%Init(num_swb, num_levsoil)
@@ -1214,8 +1209,6 @@ subroutine Dump(this)
12141209
write(fates_log(),*) 'pa%total_tree_area = ',this%total_tree_area
12151210
write(fates_log(),*) 'pa%total_grass_area = ',this%total_grass_area
12161211
write(fates_log(),*) 'pa%zstar = ',this%zstar
1217-
write(fates_log(),*) 'pa%solar_zenith_flag = ',this%solar_zenith_flag
1218-
write(fates_log(),*) 'pa%solar_zenith_angle = ',this%solar_zenith_angle
12191212
write(fates_log(),*) 'pa%gnd_alb_dif = ',this%gnd_alb_dif(:)
12201213
write(fates_log(),*) 'pa%gnd_alb_dir = ',this%gnd_alb_dir(:)
12211214
write(fates_log(),*) 'pa%c_stomata = ',this%c_stomata

biogeophys/FatesPlantRespPhotosynthMod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
649649

650650
else ! Two-stream
651651

652-
if(cohort_layer_elai(iv) > nearzero .and. currentPatch%solar_zenith_flag) then
652+
if(cohort_layer_elai(iv) > nearzero .and. sites(s)%coszen>0._r8 ) then
653653

654654
call FatesGetCohortAbsRad(currentPatch, currentCohort, ipar, &
655655
cohort_vaitop(iv), cohort_vaibot(iv), cohort_elai, cohort_esai, &

main/EDInitMod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ subroutine zero_site( site_in )
282282
site_in%smp_memory(:,:) = nan
283283
site_in%vegtemp_memory(:) = nan ! record of last 10 days temperature for senescence model.
284284

285+
site_in%coszen = 0._r8
285286
site_in%phen_model_date = fates_unset_int
286287

287288
! Disturbance rates tracking

main/EDTypesMod.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ module EDTypesMod
357357
! Total area of patches in each age bin [m2]
358358
real(r8), allocatable :: area_by_age(:)
359359

360+
! Cosine of the zenith angle of the sun
361+
real(r8) :: coszen
362+
360363

361364
! Nutrient relevant
362365
real(r8), allocatable :: rec_l2fr(:,:) ! A running mean of the l2fr's for the newly

main/FatesInterfaceMod.F90

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ subroutine zero_bcs(fates,s)
293293
fates%bc_in(s)%watsat_sl(:) = 0.0_r8
294294
fates%bc_in(s)%tempk_sl(:) = 0.0_r8
295295
fates%bc_in(s)%h2o_liqvol_sl(:) = 0.0_r8
296-
fates%bc_in(s)%filter_vegzen_pa(:) = .false.
297-
fates%bc_in(s)%coszen_pa(:) = 0.0_r8
298296
fates%bc_in(s)%fcansno_pa(:) = 0.0_r8
299297
fates%bc_in(s)%albgr_dir_rb(:) = 0.0_r8
300298
fates%bc_in(s)%albgr_dif_rb(:) = 0.0_r8
@@ -375,13 +373,13 @@ subroutine zero_bcs(fates,s)
375373
fates%bc_out(s)%rssun_pa(:) = 0.0_r8
376374
fates%bc_out(s)%rssha_pa(:) = 0.0_r8
377375

378-
fates%bc_out(s)%albd_parb(:,:) = 0.0_r8
379-
fates%bc_out(s)%albi_parb(:,:) = 0.0_r8
380-
fates%bc_out(s)%fabd_parb(:,:) = 0.0_r8
381-
fates%bc_out(s)%fabi_parb(:,:) = 0.0_r8
382-
fates%bc_out(s)%ftdd_parb(:,:) = 0.0_r8
383-
fates%bc_out(s)%ftid_parb(:,:) = 0.0_r8
384-
fates%bc_out(s)%ftii_parb(:,:) = 0.0_r8
376+
fates%bc_out(s)%albd_parb(:,:) = 0.0_r8 ! zero albedo, soil absorbs all rad
377+
fates%bc_out(s)%albi_parb(:,:) = 0.0_r8 ! zero albedo, soil absorbs all rad
378+
fates%bc_out(s)%fabd_parb(:,:) = 0.0_r8 ! no rad absorbed by veg
379+
fates%bc_out(s)%fabi_parb(:,:) = 0.0_r8 ! no rad absorbed by veg
380+
fates%bc_out(s)%ftdd_parb(:,:) = 1.0_r8 ! rad flux to soil at bottom of veg is 100%
381+
fates%bc_out(s)%ftid_parb(:,:) = 1.0_r8 ! rad flux to soil at bottom of veg is 100%
382+
fates%bc_out(s)%ftii_parb(:,:) = 1.0_r8 ! rad flux to soil at bottom of veg is 100%
385383

386384
fates%bc_out(s)%elai_pa(:) = 0.0_r8
387385
fates%bc_out(s)%esai_pa(:) = 0.0_r8
@@ -533,8 +531,7 @@ subroutine allocate_bcin(bc_in, nlevsoil_in, nlevdecomp_in, num_lu_harvest_cats,
533531
allocate(bc_in%t_soisno_sl(nlevsoil_in))
534532

535533
! Canopy Radiation
536-
allocate(bc_in%filter_vegzen_pa(maxpatch_total))
537-
allocate(bc_in%coszen_pa(maxpatch_total))
534+
bc_in%coszen = nan
538535
allocate(bc_in%fcansno_pa(maxpatch_total))
539536
allocate(bc_in%albgr_dir_rb(num_swb))
540537
allocate(bc_in%albgr_dif_rb(num_swb))
@@ -621,13 +618,15 @@ subroutine allocate_bcout(bc_out, nlevsoil_in, nlevdecomp_in)
621618
allocate(bc_out%rssha_pa(maxpatch_total))
622619

623620
! Canopy Radiation
624-
allocate(bc_out%albd_parb(fates_maxPatchesPerSite,num_swb))
625-
allocate(bc_out%albi_parb(fates_maxPatchesPerSite,num_swb))
626-
allocate(bc_out%fabd_parb(fates_maxPatchesPerSite,num_swb))
627-
allocate(bc_out%fabi_parb(fates_maxPatchesPerSite,num_swb))
628-
allocate(bc_out%ftdd_parb(fates_maxPatchesPerSite,num_swb))
629-
allocate(bc_out%ftid_parb(fates_maxPatchesPerSite,num_swb))
630-
allocate(bc_out%ftii_parb(fates_maxPatchesPerSite,num_swb))
621+
622+
623+
allocate(bc_out%albd_parb(maxpatch_total,num_swb))
624+
allocate(bc_out%albi_parb(maxpatch_total,num_swb))
625+
allocate(bc_out%fabd_parb(maxpatch_total,num_swb))
626+
allocate(bc_out%fabi_parb(maxpatch_total,num_swb))
627+
allocate(bc_out%ftdd_parb(maxpatch_total,num_swb))
628+
allocate(bc_out%ftid_parb(maxpatch_total,num_swb))
629+
allocate(bc_out%ftii_parb(maxpatch_total,num_swb))
631630

632631
! We allocate the boundary conditions to the BGC
633632
! model, regardless of what scheme we use. The BGC

main/FatesInterfaceTypesMod.F90

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,17 +522,10 @@ module FatesInterfaceTypesMod
522522

523523
! Canopy Radiation Boundaries
524524
! ---------------------------------------------------------------------------------
525-
526-
! Filter for vegetation patches with a positive zenith angle (daylight)
527-
logical, allocatable :: filter_vegzen_pa(:)
528-
529-
! Cosine of the zenith angle (0-1), by patch
530-
! Note RGK: It does not seem like the code would currently generate
531-
! different zenith angles for different patches (nor should it)
532-
! I am leaving it at this scale for simplicity. Patches should
533-
! have no spacially variable information
534-
real(r8), allocatable :: coszen_pa(:)
535525

526+
! Cosine of the zenith angle (0-1) - site level
527+
real(r8) :: coszen
528+
536529
! fraction of canopy that is covered in snow
537530
real(r8), allocatable :: fcansno_pa(:)
538531

@@ -670,6 +663,9 @@ module FatesInterfaceTypesMod
670663

671664
! Canopy Radiation Boundaries
672665
! ---------------------------------------------------------------------------------
666+
667+
! Note: We initialize and default the radiatioon balance to assume that the
668+
! canopy is invisible, and the soil absorbs all radiation.
673669

674670
! Surface albedo (direct) (HLMs use this for atm coupling and balance checks)
675671
real(r8), allocatable :: albd_parb(:,:)

0 commit comments

Comments
 (0)