Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the mksurfdata_map to generate landuse_timeseries for dynamic urban and lake #1579

Merged
merged 18 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading