Skip to content

Commit

Permalink
Merge remote-tracking branch 'olyson/dynurb_mksurf_ctsm5.2.mksurfdata…
Browse files Browse the repository at this point in the history
…_I1564' into feature/new_mksurfdata

This merge was discussed here:
#1587 (comment)
  • Loading branch information
slevis-lmwg committed Mar 17, 2022
2 parents 8a11384 + 4b3ef5a commit ff4d156
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 257 deletions.
6 changes: 6 additions & 0 deletions tools/mksurfdata_map/mksurfdata.pl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ sub write_transient_timeseries_file {
my $hrvtypyr = `$scrdir/../../bld/queryDefaultNamelist.pl $queryfilopts $resolhrv -options sim_year='$yr',ssp_rcp=${ssp_rcp}${mkcrop} -var mksrf_fvegtyp -namelist clmexp`;
chomp( $hrvtypyr );
printf $fh_landuse_timeseries $dynpft_format, $hrvtypyr, $yr;
my $urbanyr = "/glade/scratch/keerzhang/archive/BNU_NoAdjust/05deg_".$yr."_new_NoAdjust.nc";
chomp( $urbanyr); # !KZ I hard coded this part just to generate a txt file with urban raw data file locations
printf $fh_landuse_timeseries $dynpft_format, $urbanyr, $yr; # And note that I made no change to the "landuse_timeseries_override_$desc.txt" because I am not sure how to deal with the the 'pft_override' option
my $lakeyr = "/glade/work/ivanderk/inputdata/rawdata/timeseries/mksurf_lake_0.05x0.05_hist_clm5_hydrolakes_2017_c20200305.nc";
chomp( $lakeyr);
printf $fh_landuse_timeseries $dynpft_format, $lakeyr, $yr;
if ( $yr % 100 == 0 ) {
print "year: $yr\n";
}
Expand Down
13 changes: 13 additions & 0 deletions tools/mksurfdata_map/src/mkfileMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,20 @@ subroutine mkfile(domain, fname, harvdata, dynlanduse)
deallocate(ind1D, ind2D)

else
call ncd_def_spatial_var(ncid=ncid, varname='PCT_URBAN', xtype=xtype, &
lev1name='numurbl', lev2name='time', &
long_name='percent urban for each density type', units='unitless')

call ncd_def_spatial_var(ncid=ncid, varname='PCT_URBAN_MAX', xtype=xtype, &
lev1name='numurbl', &
long_name='maximum percent urban for each density type', units='unitless')

call ncd_def_spatial_var(ncid=ncid, varname='PCT_LAKE', xtype=xtype, &
lev1name="time", long_name='percent lake', units='unitless')

call ncd_def_spatial_var(ncid=ncid, varname='PCT_LAKE_MAX', xtype=xtype, &
long_name='maximum percent lake', units='unitless')

call harvdata%getFieldsIdx( ind1D, ind2D )
do j = 1, harvdata%num1Dfields()
call ncd_def_spatial_var(ncid=ncid, varname=mkharvest_fieldname(ind1D(j),constant=.false.), xtype=xtype, &
Expand Down
33 changes: 29 additions & 4 deletions tools/mksurfdata_map/src/mklanwatMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ module mklanwatMod
private

! !PUBLIC MEMBER FUNCTIONS:
public mklakwat ! make % lake
public mkwetlnd ! make % wetland
public mklakparams ! make lake parameters

public mklakwat ! make % lake
public mkwetlnd ! make % wetland
public mklakparams ! make lake parameters
public update_max_array_lake ! Update the maximum lake percent
!EOP
!===============================================================
contains
Expand Down Expand Up @@ -499,5 +499,30 @@ subroutine mklakparams(ldomain, mapfname, datfname, ndiag, &
call shr_sys_flush(6)

end subroutine mklakparams
!------------------------------------------------------------------------------

!-----------------------------------------------------------------------
subroutine update_max_array_lake(pct_lakmax_arr,pct_lake_arr)
!
! !DESCRIPTION:
! Update the maximum lake percent for landuse.timeseries file
!
! !ARGUMENTS:
real(r8) , intent(inout):: pct_lakmax_arr(:) ! max lake percent
real(r8) , intent(in):: pct_lake_arr(:) ! lake percent that is used to update the old pct_lakmax_arr
!
! !LOCAL VARIABLES:
integer :: n,ns ! indices

character(len=*), parameter :: subname = 'update_max_array_lake'
!-----------------------------------------------------------------------
ns = size(pct_lake_arr,1)
do n = 1, ns
if (pct_lake_arr(n) > pct_lakmax_arr(n)) then
pct_lakmax_arr(n) = pct_lake_arr(n)
end if
end do

end subroutine update_max_array_lake

end module mklanwatMod
40 changes: 0 additions & 40 deletions tools/mksurfdata_map/src/mkpftUtilsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module mkpftUtilsMod
! !PUBLIC MEMBER FUNCTIONS:
!
public :: convert_from_p2g ! Convert a p2g array into pct_pft_type objects
public :: adjust_total_veg_area ! Adjust the total vegetated area (natural veg & crop) to a new specified total

!
! !PRIVATE MEMBER FUNCTIONS:
Expand Down Expand Up @@ -213,45 +212,6 @@ function get_default_cft() result(default_cft)

end function get_default_cft


!-----------------------------------------------------------------------
subroutine adjust_total_veg_area(new_total_pct, pctnatpft, pctcft)
!
! !DESCRIPTION:
! Adjust the total vegetated area on the grid cell (natural veg & crop) to a new
! specified total.
!
! If the old areas are 0%, then all the new area goes into pctnatpft.
!
! !USES:
use mkpctPftTypeMod, only : pct_pft_type
!
! !ARGUMENTS:
real(r8), intent(in) :: new_total_pct ! new total % of natural veg + crop landunits
class(pct_pft_type), intent(inout) :: pctnatpft ! natural veg cover information
class(pct_pft_type), intent(inout) :: pctcft ! crop cover information
!
! !LOCAL VARIABLES:
real(r8) :: natpft_l2g ! grid cell % cover of nat. veg.
real(r8) :: cft_l2g ! grid cell % cover of crop
real(r8) :: old_total ! old total % cover of natural veg + crop landunits

character(len=*), parameter :: subname = 'adjust_total_veg_area'
!-----------------------------------------------------------------------

natpft_l2g = pctnatpft%get_pct_l2g()
cft_l2g = pctcft%get_pct_l2g()
old_total = natpft_l2g + cft_l2g
if (old_total > 0._r8) then
call pctnatpft%set_pct_l2g(natpft_l2g * new_total_pct / old_total)
call pctcft%set_pct_l2g(cft_l2g * new_total_pct / old_total)
else
call pctnatpft%set_pct_l2g(new_total_pct)
end if

end subroutine adjust_total_veg_area


end module mkpftUtilsMod


Loading

0 comments on commit ff4d156

Please sign in to comment.