Skip to content

Commit

Permalink
read surf and and restric spliting
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdebolskiy committed Aug 5, 2022
1 parent 0b97164 commit 9dea14f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/clm_initializeMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ subroutine initialize2(ni,nj)
use clm_varctl , only : finidat, finidat_interp_source, finidat_interp_dest, fsurdat
use clm_varctl , only : use_cn, use_fates
use clm_varctl , only : use_crop, ndep_from_cpl, fates_spitfire_mode
use clm_varctl , only : use_excess_ice_tiles
use clm_instur , only : exice_tile_mask
use clm_varorb , only : eccen, mvelpp, lambm0, obliqr
use landunit_varcon , only : landunit_varcon_init, max_lunit, numurbl
use pftconMod , only : pftcon
Expand Down Expand Up @@ -229,6 +231,9 @@ subroutine initialize2(ni,nj)
allocate (haslake (begg:endg ))
allocate (pct_urban_max(begg:endg, numurbl ))
allocate (wt_nat_patch (begg:endg, surfpft_lb:surfpft_ub ))
if (use_excess_ice_tiles) then
allocate (exice_tile_mask (begg:endg ))
endif

! Read list of Patches and their corresponding parameter values
! Independent of model resolution, Needs to stay before surfrd_get_data
Expand Down
2 changes: 2 additions & 0 deletions src/main/clm_varsur.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ module clm_instur
! (second dimension goes 1:numurbl)
real(r8), pointer :: pct_urban_max(:,:)
!-----------------------------------------------------------------------
! excess ice tiling mask
integer, pointer :: exice_tile_mask(:)

end module clm_instur
3 changes: 2 additions & 1 deletion src/main/subgridMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ subroutine subgrid_get_info_natveg(gi, npatches, ncols, nlunits)
! !USES
use clm_varpar, only : natpft_lb, natpft_ub
use clm_varctl, only : use_excess_ice_tiles
use clm_instur, only : exice_tile_mask
!
! !ARGUMENTS:
integer, intent(in) :: gi ! grid cell index
Expand All @@ -155,7 +156,7 @@ subroutine subgrid_get_info_natveg(gi, npatches, ncols, nlunits)

if (npatches > 0) then
! Assume that the vegetated landunit has one column
if (use_excess_ice_tiles) then
if (use_excess_ice_tiles .and. exice_tile_mask(gi) == 1) then
ncols = 2
else
ncols = 1
Expand Down
42 changes: 42 additions & 0 deletions src/main/surfrdMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module surfrdMod
private :: surfrd_veg_dgvm ! Read vegetated landunits for DGVM mode
private :: surfrd_pftformat ! Read crop pfts in file format where they are part of the vegetated land unit
private :: surfrd_cftformat ! Read crop pfts in file format where they are on their own landunit
private :: surfrd_exicetiles! Read excess ice tiling mask
!
! !PRIVATE DATA MEMBERS:
character(len=*), parameter, private :: sourcefile = &
Expand Down Expand Up @@ -722,6 +723,7 @@ subroutine surfrd_veg_all(begg, endg, ncid, ns, actual_numcft)
!
! !USES:
use clm_varctl , only : create_crop_landunit, use_fates, n_dom_pfts
use clm_varctl , only : use_excess_ice_tiles
use clm_varpar , only : natpft_lb, natpft_ub, natpft_size, cft_size, cft_lb, cft_ub
use clm_instur , only : wt_lunit, wt_nat_patch, wt_cft, fert_cft
use landunit_varcon , only : istsoil, istcrop
Expand Down Expand Up @@ -853,6 +855,9 @@ subroutine surfrd_veg_all(begg, endg, ncid, ns, actual_numcft)

call collapse_to_dominant(wt_nat_patch(begg:endg,:), natpft_lb, natpft_ub, &
begg, endg, n_dom_pfts)
if (use_excess_ice_tiles) then
call surfrd_exicetiles(begg, endg, ncid, ns)
endif

end subroutine surfrd_veg_all

Expand Down Expand Up @@ -989,5 +994,42 @@ subroutine surfrd_urbanmask(begg, endg)
call ncd_pio_closefile(ncid_dynuse)

end subroutine surfrd_urbanmask

subroutine surfrd_exicetiles(begg, endg, ncid, ns)
!
!
use clm_varctl, only : use_excess_ice_tiles
use clm_instur, only : exice_tile_mask

!
! !ARGUMENTS:
integer, intent(in) :: begg, endg
type(file_desc_t),intent(inout) :: ncid ! netcdf id
integer ,intent(in) :: ns ! domain size

!local variables
integer :: ier ! error status
logical :: readvar ! is variable on dataset
integer,pointer :: arrayl(:) ! local array (needed because ncd_io expects a pointer)
character(len=32) :: subname = 'surfrd_exicetiles' ! subroutine name

! read tile mask
if (use_excess_ice_tiles) then
allocate(arrayl(begg:endg))
call ncd_io(ncid=ncid, varname='TWOTILES', flag='read', data=arrayl, &
dim1name=grlnd, readvar=readvar)
if (.not. readvar) then
call endrun( msg=' ERROR: TWOTILES not on surface data file'//errMsg(sourcefile, __LINE__))
else
exice_tile_mask(begg:endg) = arrayl(begg:endg)

endif
deallocate(arrayl)
endif




end subroutine

end module surfrdMod

0 comments on commit 9dea14f

Please sign in to comment.