From 9dea14f27c7d20fa04ca255f681ddaf68b72281d Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Fri, 5 Aug 2022 14:12:23 +0200 Subject: [PATCH] read surf and and restric spliting --- src/main/clm_initializeMod.F90 | 5 ++++ src/main/clm_varsur.F90 | 2 ++ src/main/subgridMod.F90 | 3 ++- src/main/surfrdMod.F90 | 42 ++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 1046287cec..0fcb617bac 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -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 @@ -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 diff --git a/src/main/clm_varsur.F90 b/src/main/clm_varsur.F90 index d360941d23..a4bcd47d5c 100644 --- a/src/main/clm_varsur.F90 +++ b/src/main/clm_varsur.F90 @@ -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 diff --git a/src/main/subgridMod.F90 b/src/main/subgridMod.F90 index c44ed9abf1..38d26884ae 100644 --- a/src/main/subgridMod.F90 +++ b/src/main/subgridMod.F90 @@ -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 @@ -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 diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index 78c9d8492e..3215c95adc 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -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 = & @@ -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 @@ -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 @@ -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