Skip to content

Commit

Permalink
Merge pull request ESCOMP#814 from ekluzek/relfixesfor5028
Browse files Browse the repository at this point in the history
A few fixes and extend mksurfdata to set PFT/CFT fractions but use veg-cover from dataset
  • Loading branch information
ekluzek authored Nov 15, 2019
2 parents b2122b3 + 92dae2e commit eb94339
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 94 deletions.
15 changes: 12 additions & 3 deletions src/biogeochem/CNFireBaseMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ subroutine hdm_init( this, bounds, NLFilename )
type(mct_ggrid) :: dom_clm ! domain information
character(len=CL) :: stream_fldFileName_popdens ! population density streams filename
character(len=CL) :: popdensmapalgo = 'bilinear' ! mapping alogrithm for population density
character(len=CL) :: popdens_tintalgo = 'nearest'! time interpolation alogrithm for population density
character(*), parameter :: subName = "('hdmdyn_init')"
character(*), parameter :: F00 = "('(hdmdyn_init) ',4a)"
!-----------------------------------------------------------------------
Expand All @@ -992,7 +993,8 @@ subroutine hdm_init( this, bounds, NLFilename )
stream_year_last_popdens, &
model_year_align_popdens, &
popdensmapalgo, &
stream_fldFileName_popdens
stream_fldFileName_popdens, &
popdens_tintalgo

! Default values for namelist
stream_year_first_popdens = 1 ! first year in stream to use
Expand All @@ -1019,6 +1021,7 @@ subroutine hdm_init( this, bounds, NLFilename )
call shr_mpi_bcast(stream_year_last_popdens, mpicom)
call shr_mpi_bcast(model_year_align_popdens, mpicom)
call shr_mpi_bcast(stream_fldFileName_popdens, mpicom)
call shr_mpi_bcast(popdens_tintalgo, mpicom)

if (masterproc) then
write(iulog,*) ' '
Expand All @@ -1027,6 +1030,7 @@ subroutine hdm_init( this, bounds, NLFilename )
write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens
write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens
write(iulog,*) ' stream_fldFileName_popdens = ',stream_fldFileName_popdens
write(iulog,*) ' popdens_tintalgo = ',popdens_tintalgo
write(iulog,*) ' '
endif

Expand Down Expand Up @@ -1056,7 +1060,7 @@ subroutine hdm_init( this, bounds, NLFilename )
fillalgo='none', &
mapalgo=popdensmapalgo, &
calendar=get_calendar(), &
tintalgo='nearest', &
tintalgo=popdens_tintalgo, &
taxmode='extend' )

if (masterproc) then
Expand Down Expand Up @@ -1135,6 +1139,7 @@ subroutine lnfm_init( this, bounds, NLFilename )
integer :: nml_error ! namelist i/o error flag
type(mct_ggrid) :: dom_clm ! domain information
character(len=CL) :: stream_fldFileName_lightng ! lightning stream filename to read
character(len=CL) :: lightng_tintalgo = 'linear'! time interpolation alogrithm
character(len=CL) :: lightngmapalgo = 'bilinear'! Mapping alogrithm
character(*), parameter :: subName = "('lnfmdyn_init')"
character(*), parameter :: F00 = "('(lnfmdyn_init) ',4a)"
Expand All @@ -1145,7 +1150,8 @@ subroutine lnfm_init( this, bounds, NLFilename )
stream_year_last_lightng, &
model_year_align_lightng, &
lightngmapalgo, &
stream_fldFileName_lightng
stream_fldFileName_lightng, &
lightng_tintalgo

! Default values for namelist
stream_year_first_lightng = 1 ! first year in stream to use
Expand All @@ -1172,6 +1178,7 @@ subroutine lnfm_init( this, bounds, NLFilename )
call shr_mpi_bcast(stream_year_last_lightng, mpicom)
call shr_mpi_bcast(model_year_align_lightng, mpicom)
call shr_mpi_bcast(stream_fldFileName_lightng, mpicom)
call shr_mpi_bcast(lightng_tintalgo, mpicom)

if (masterproc) then
write(iulog,*) ' '
Expand All @@ -1180,6 +1187,7 @@ subroutine lnfm_init( this, bounds, NLFilename )
write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng
write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng
write(iulog,*) ' stream_fldFileName_lightng = ',stream_fldFileName_lightng
write(iulog,*) ' lightng_tintalgo = ',lightng_tintalgo
write(iulog,*) ' '
endif

Expand Down Expand Up @@ -1207,6 +1215,7 @@ subroutine lnfm_init( this, bounds, NLFilename )
fldListFile='lnfm', &
fldListModel='lnfm', &
fillalgo='none', &
tintalgo=lightng_tintalgo, &
mapalgo=lightngmapalgo, &
calendar=get_calendar(), &
taxmode='cycle' )
Expand Down
76 changes: 55 additions & 21 deletions src/biogeochem/SatellitePhenologyMod.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module SatellitePhenologyMod

#include "shr_assert.h"

!-----------------------------------------------------------------------
! !DESCRIPTION:
! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation).
Expand Down Expand Up @@ -39,16 +41,18 @@ module SatellitePhenologyMod
public :: SatellitePhenologyInit ! Dynamically allocate memory
public :: interpMonthlyVeg ! interpolate monthly vegetation data
public :: readAnnualVegetation ! Read in annual vegetation (needed for Dry-deposition)
public :: lai_advance ! Advance the LAI streams (outside of a Open-MP threading loop)
!
! !PRIVATE MEMBER FUNCTIONS:
private :: readMonthlyVegetation ! read monthly vegetation data for two months
private :: lai_init ! position datasets for LAI
private :: lai_interp ! interpolates between two years of LAI data
private :: lai_init ! position datasets for LAI
private :: lai_interp ! interpolates between two years of LAI data (when LAI streams are being used)

! !PRIVATE MEMBER DATA:
type(shr_strdata_type) :: sdat_lai ! LAI input data stream
!
! !PRIVATE TYPES:
integer, allocatable :: g_to_ig(:) ! Array matching gridcell index to data index
integer , private :: InterpMonths1 ! saved month index
real(r8), private :: timwt(2) ! time weights for month 1 and month 2
real(r8), private, allocatable :: mlai2t(:,:) ! lai for interpolation (2 months)
Expand Down Expand Up @@ -97,6 +101,7 @@ subroutine lai_init(bounds)
type(mct_ggrid) :: dom_clm ! domain information
character(len=CL) :: stream_fldFileName_lai ! lai stream filename to read
character(len=CL) :: lai_mapalgo = 'bilinear' ! Mapping alogrithm
character(len=CL) :: lai_tintalgo = 'linear' ! Time interpolation alogrithm

character(*), parameter :: subName = "('laidyn_init')"
character(*), parameter :: F00 = "('(laidyn_init) ',4a)"
Expand All @@ -112,7 +117,8 @@ subroutine lai_init(bounds)
stream_year_last_lai, &
model_year_align_lai, &
lai_mapalgo, &
stream_fldFileName_lai
stream_fldFileName_lai, &
lai_tintalgo

! Default values for namelist
stream_year_first_lai = 1 ! first year in stream to use
Expand Down Expand Up @@ -141,6 +147,7 @@ subroutine lai_init(bounds)
call shr_mpi_bcast(stream_year_last_lai, mpicom)
call shr_mpi_bcast(model_year_align_lai, mpicom)
call shr_mpi_bcast(stream_fldFileName_lai, mpicom)
call shr_mpi_bcast(lai_tintalgo, mpicom)

if (masterproc) then

Expand All @@ -150,6 +157,7 @@ subroutine lai_init(bounds)
write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai
write(iulog,*) ' model_year_align_lai = ',model_year_align_lai
write(iulog,*) ' stream_fldFileName_lai = ',trim(stream_fldFileName_lai)
write(iulog,*) ' lai_tintalgo = ',trim(lai_tintalgo)

endif

Expand Down Expand Up @@ -183,6 +191,7 @@ subroutine lai_init(bounds)
fldListModel=fldList, &
fillalgo='none', &
mapalgo=lai_mapalgo, &
tintalgo=lai_tintalgo, &
calendar=get_calendar(), &
taxmode='cycle' )

Expand All @@ -194,55 +203,79 @@ end subroutine lai_init

!-----------------------------------------------------------------------
!
! lai_interp
! lai_advance
!
!-----------------------------------------------------------------------
subroutine lai_interp(bounds, canopystate_inst)
subroutine lai_advance( bounds )
!
! Interpolate data stream information for Lai.
! Advance LAI streams
!
! !USES:
use clm_time_manager, only : get_curr_date
use pftconMod , only : noveg
!
! !ARGUMENTS:
implicit none
type(bounds_type) , intent(in) :: bounds
type(canopystate_type) , intent(inout) :: canopystate_inst
!
! !LOCAL VARIABLES:
integer :: ivt, p, g, ip, ig, gpft
integer :: g, ig ! Indices
integer :: year ! year (0, ...) for nstep+1
integer :: mon ! month (1, ..., 12) for nstep+1
integer :: day ! day of month (1, ..., 31) for nstep+1
integer :: sec ! seconds into current date for nstep+1
integer :: mcdate ! Current model date (yyyymmdd)
character(len=CL) :: stream_var_name
!-----------------------------------------------------------------------

call get_curr_date(year, mon, day, sec)
mcdate = year*10000 + mon*100 + day

call shr_strdata_advance(sdat_lai, mcdate, sec, mpicom, 'laidyn')
if ( .not. allocated(g_to_ig) )then
allocate (g_to_ig(bounds%begg:bounds%endg) )

ig = 0
do g = bounds%begg,bounds%endg
ig = ig+1
g_to_ig(g) = ig
end do
end if

end subroutine lai_advance


!-----------------------------------------------------------------------
!
! lai_interp
!
!-----------------------------------------------------------------------
subroutine lai_interp(bounds, canopystate_inst)
!
! Interpolate data stream information for Lai.
!
! !USES:
use pftconMod , only : noveg
!
! !ARGUMENTS:
implicit none
type(bounds_type) , intent(in) :: bounds
type(canopystate_type) , intent(inout) :: canopystate_inst
!
! !LOCAL VARIABLES:
integer :: ivt, p, ip, ig
character(len=CL) :: stream_var_name
!-----------------------------------------------------------------------
SHR_ASSERT_FL( (lbound(g_to_ig,1) <= bounds%begg ), sourcefile, __LINE__)
SHR_ASSERT_FL( (ubound(g_to_ig,1) >= bounds%endg ), sourcefile, __LINE__)
SHR_ASSERT_FL( (lbound(sdat_lai%avs(1)%rAttr,2) <= g_to_ig(bounds%begg) ), sourcefile, __LINE__)
SHR_ASSERT_FL( (ubound(sdat_lai%avs(1)%rAttr,2) >= g_to_ig(bounds%endg) ), sourcefile, __LINE__)
do p = bounds%begp, bounds%endp
ivt = patch%itype(p)
if (ivt /= noveg) then ! vegetated pft
write(stream_var_name,"(i6)") ivt
stream_var_name = 'LAI_'//trim(adjustl(stream_var_name))
ip = mct_aVect_indexRA(sdat_lai%avs(1),trim(stream_var_name))
endif
gpft = patch%gridcell(p)

!
! Determine vector index corresponding to gpft
!
ig = 0
do g = bounds%begg,bounds%endg
ig = ig+1
if (g == gpft) exit
end do

ig = g_to_ig(patch%gridcell(p))
!
! Set lai for each gridcell/patch combination
!
Expand Down Expand Up @@ -336,6 +369,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, &
call lai_interp(bounds, canopystate_inst)
endif


do fp = 1, num_nolakep
p = filter_nolakep(fp)
c = patch%column(p)
Expand Down
Loading

0 comments on commit eb94339

Please sign in to comment.