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

Updates VSFM and adds EMI #1460

Merged
merged 58 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4eb164b
Adds namelist option to specify domain decompisition for ALM.
Nov 10, 2015
cb8c79f
Adds a subroutine in ALM to read grid-to-grid connectivity
Nov 13, 2015
7aaa21a
Adds support for decomposing ALM grid via graph partitioning
Nov 26, 2015
b649382
Consolidates the initialization of PETSc in ALM
Nov 27, 2015
dec015c
Initial implementation of a lateral connectivity framework for ALM
Dec 4, 2015
480f0f5
Adds subroutines to get/set values for ALM subgrid categories
Jan 8, 2016
fe467ce
Adds more functionality for laterally connected ALM domain
Jan 8, 2016
30d898e
Adds update of ALM's ghost subgrid structure
Jan 8, 2016
9f10c65
Fixes preprocessor statement in ALM-VSFM
Jan 8, 2016
e383c89
Adds subroutine to count ALM ghost subgrid hierarchy
Feb 19, 2016
cadd6ae
Adds x/y field for each ALM grid cell
Feb 19, 2016
ee455de
Updates the check for ALM ghost subgrid hierarchy
Feb 19, 2016
c46719c
Adds subroutine to exchange column-level ALM across MPI tasks
Feb 19, 2016
6aa2c7c
Fixes the mapping of neighboring grid cells in ALM
Feb 19, 2016
4995927
Assigns soil properties to ghost/halo colums in ALM
Feb 19, 2016
26eede2
Updates to equation-of-state in ALM for VSFM
Feb 20, 2016
b3df051
Adds initial infrastructre to support lateral subsurface flow in ALM
Feb 20, 2016
fe3c8fa
ALM reads additional data specified in MPAS format
Feb 24, 2016
929e4e7
Updates to ALM suburface mesh for VSFM
Feb 24, 2016
0d8f798
Minor ALM modifications to avoid compiler failures
Mar 8, 2016
4d6f9b9
Adds seepage face BC in ALM VSFM solver
Mar 9, 2016
171a4e9
Turns on lateral subsurface flow in ALM
Mar 24, 2016
b8ea024
Updates VSFM solver in ALM to saves internal/boundary mass flux
Mar 25, 2016
d647435
Adds options to include lateral flows in VSFM
Mar 29, 2016
4c0c545
Updates VSFM solver tolerance after an unacceptable solution
Mar 29, 2016
3e2e061
Restructures VSFM subdirectory in ALM
Apr 13, 2016
86772f2
Fixes the initialization of lateral flux in ALM.
Apr 15, 2016
67b7739
Splits ALM's thermal model for non-urban and urban cols
Apr 12, 2016
c26e2ad
Adds a runtime option to specify ALM thermal model
Apr 13, 2016
4dbff9b
Initial checkin of PETSc-based thermal model for ALM
Apr 26, 2016
3667265
ALM-MPP refactor to reduce dependency on CLM
May 11, 2016
2af72db
Round-2 of ALM-MPP refactor to reduce dependency on CLM
May 12, 2016
c6ca96f
Rename ALM-MPP files
May 12, 2016
44a791e
Round-3 of ALM-MPP refactor to reduce dependency on CLM
May 12, 2016
c1ea2ec
Round-4 of ALM-MPP refactor to reduce dependency on CLM
May 12, 2016
e071169
Minor fixes to the ALM-MPP refactor
May 12, 2016
7600a8f
Major refactor of ALM PETSc-based thermal model
Jun 15, 2016
4b92f6a
Adds a subroutine in VSFM to set MPI rank
Jun 16, 2016
d2fbdae
Major refactor of VSFM
Jun 22, 2016
af6e0c2
Few enhancements and bugfixes in VSFM
Jun 28, 2016
cb9a3c0
Few fixes after rebasing the branch
Oct 13, 2016
9828548
Updates to ALM MPP framework
Oct 14, 2016
697c56e
Removes ALM-MPP dependency on CLM
Oct 14, 2016
fa9c921
Fixes for lateral hydrology in VSFM
Oct 19, 2016
dca1a36
Adds a runtime option to add seepage BC in VSFM
Oct 19, 2016
46bf459
Swaps ALM's VSFM code by git submodule
Nov 3, 2016
21cf1f6
Removes unused arguments in ALM VSFM solver
Nov 10, 2016
87cda08
Updates VSFM initialization
Nov 14, 2016
018ece7
Updates the ALM-MPP submodule
Apr 19, 2017
50d55d0
Initial checkin of ALM's External Model Interface
Nov 10, 2016
bb85c7e
Minor indentation changes
May 11, 2017
a3c7cbc
Removes compilation of deprecated MPP driver
May 11, 2017
7b2232d
Fixes a build failure with debugging turned on
May 17, 2017
f941efb
Fixes VSFM for multi-task simulation
May 17, 2017
0218221
Makes ALM's MPP thread safe
May 4, 2017
2ca6667
Corrects the column level mesh information needed by PTM
May 18, 2017
bc031d0
Fixes for PTM
May 23, 2017
ed969b2
Removes output of x,y location of ALM domain
May 31, 2017
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
path = components/mpas-cice/model
url = git@github.com:ACME-Climate/MPAS.git
branch = cice/develop
[submodule "alm-mpp"]
path = components/clm/src/external_models/mpp
url = git@github.com:ACME-Climate/mpp.git
branch = alm/develop
6 changes: 5 additions & 1 deletion components/clm/bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,14 @@ sub write_filepath_cesmbld
"betr/bgc_century",
"betr/bgc_sminn",
"biogeophys",
"biogeophys/vsfm",
"biogeochem",
"dyn_subgrid",
"ED/main",
"external_models/mpp/src/mpp/dtypes",
"external_models/mpp/src/mpp/thermal",
"external_models/mpp/src/mpp/util",
"external_models/mpp/src/mpp/vsfm",
"external_models/emi/src/",
"utils",
"cpl" );

Expand Down
17 changes: 16 additions & 1 deletion components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,19 @@ attributes from the config_cache.xml file (with keys converted to upper-case).

<glc_snow_persistence_max_days>7300</glc_snow_persistence_max_days>

<!-- VSFM default -->
<!-- ======================================================================================== -->
<!-- VSFM default -->
<!-- ======================================================================================== -->
<use_vsfm>.false.</use_vsfm>
<vsfm_include_seepage_bc>.false.</vsfm_include_seepage_bc>
<vsfm_satfunc_type>smooth_brooks_corey_bz3</vsfm_satfunc_type>
<vsfm_use_dynamic_linesearch>.false.</vsfm_use_dynamic_linesearch>
<vsfm_lateral_model_type>none</vsfm_lateral_model_type>

<!-- ======================================================================================== -->
<!-- PETSc-based thermal model default -->
<!-- ======================================================================================== -->
<use_petsc_thermal_model>.false.</use_petsc_thermal_model>

<!-- ================================================================== -->
<!-- The default filenames are given relative to the root directory
Expand Down Expand Up @@ -1762,6 +1771,12 @@ this mask will have smb calculated over the entire global land surface

<use_aereoxid_prog use_cn=".true.">.true.</use_aereoxid_prog>

<!-- ========================================= -->
<!-- Defaults for lateral grid connectivity -->
<!-- ========================================= -->
<lateral_connectivity>.false.</lateral_connectivity>
<domain_decomposition_method>round_robin</domain_decomposition_method>

<!-- ========================================= -->
<!-- Defaults for clm_pflotran_inparm interface -->
<!-- ========================================= -->
Expand Down
36 changes: 36 additions & 0 deletions components/clm/bld/namelist_files/namelist_definition_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,19 @@ If TRUE (which is the default), check consistency between pct_nat_pft on the fla
and pct_nat_pft read from the surface dataset.
</entry>

<!-- ========================================================================================= -->
<!-- Namelist options related to lateral grid connectivity
<!-- ======================================================================================== -->
<entry id="lateral_connectivity" type="logical" category="clm_initialization"
group="clm_inparm" valid_values="" >
If TRUE setup up lateral grid connectivity in CLM.
</entry>

<entry id="domain_decomp_type" type="char*256" category="clm_initialization"
group="clm_inparm" valid_values="round_robin,graph_partitioning" >
Specifies the method for decomposing CLM grids across processors.
</entry>

<!-- ========================================================================================= -->
<!-- Namelist options related to the bgc & pflotran interface
<!-- ======================================================================================== -->
Expand Down Expand Up @@ -1598,6 +1611,29 @@ Type of saturation function used in VSFM.
<entry id="vsfm_use_dynamic_linesearch" type="logical" category="default_settings"
group="clm_inparm" valid_values="">
Runtime flag to dynamically modify PETSc SNES linesearch option when VSFM fails to converge before cutting the timestep.

<entry id="vsfm_lateral_model_type" type="char*32" category="clm_physics"
group="clm_inparm"
valid_values="none,source_sink,three_dimensional" >
Type of lateral flow formulation supported in VSFM.
none = No lateral flow
source_sink = 1D VSFM solution + Lateral flow modeled as source/sink term
three_dimensional = 3D VSFM solution (only supported for serial run)
</entry>

<entry id=vsfm_include_seepage_bc" type="logical" category="default_settings"
group="clm_inparm" valid_values="">
Runtime flag to add seepage boundary condition on the top soil layer to allow for exfiltration.
</entry>

<!-- ======================================================================================== -->
<!-- Namelist options related to PETSc-based thermal model -->
<!-- ======================================================================================== -->

<entry id="use_petsc_thermal_model" type="logical" category="default_settings"
group="clm_inparm" valid_values="">
Runtime flag to turn on/off PETSc based thermal model.
</entry>


</namelist_definition>
7 changes: 6 additions & 1 deletion components/clm/src/biogeophys/BalanceCheckMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ subroutine BalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
qflx_ice_dynbal => waterflux_vars%qflx_ice_dynbal_grc , & ! Input: [real(r8) (:) ] ice runoff due to dynamic land cover change (mm H2O /s)
snow_sources => waterflux_vars%snow_sources_col , & ! Output: [real(r8) (:) ] snow sources (mm H2O /s)
snow_sinks => waterflux_vars%snow_sinks_col , & ! Output: [real(r8) (:) ] snow sinks (mm H2O /s)
qflx_lateral => waterflux_vars%qflx_lateral_col , & ! Input: [real(r8) (:) ] lateral flux of water to neighboring column (mm H2O /s)

eflx_lwrad_out => energyflux_vars%eflx_lwrad_out_patch , & ! Input: [real(r8) (:) ] emitted infrared (longwave) radiation (W/m**2)
eflx_lwrad_net => energyflux_vars%eflx_lwrad_net_patch , & ! Input: [real(r8) (:) ] net infrared (longwave) rad (W/m**2) [+ = to atm]
Expand Down Expand Up @@ -299,8 +300,10 @@ subroutine BalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
errh2o(c) = endwb(c) - begwb(c) &
- (forc_rain_col(c) + forc_snow_col(c) + qflx_floodc(c) + qflx_irrig(c) &
- qflx_evap_tot(c) - qflx_surf(c) - qflx_h2osfc_surf(c) &
- qflx_qrgwl(c) - qflx_drain(c) - qflx_drain_perched(c) - qflx_snwcp_ice(c)) * dtime
- qflx_qrgwl(c) - qflx_drain(c) - qflx_drain_perched(c) - qflx_snwcp_ice(c) &
- qflx_lateral(c) ) * dtime
dwb(c) = (endwb(c)-begwb(c))/dtime

else

errh2o(c) = 0.0_r8
Expand Down Expand Up @@ -362,6 +365,7 @@ subroutine BalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
write(iulog,*)'qflx_qrgwl = ',qflx_qrgwl(indexc)
write(iulog,*)'qflx_drain = ',qflx_drain(indexc)
write(iulog,*)'qflx_snwcp_ice = ',qflx_snwcp_ice(indexc)
write(iulog,*)'qflx_lateral = ',qflx_lateral(indexc)
write(iulog,*)'clm model is stopping'
call endrun(decomp_index=indexc, clmlevel=namec, msg=errmsg(__FILE__, __LINE__))

Expand All @@ -385,6 +389,7 @@ subroutine BalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
write(iulog,*)'qflx_snwcp_ice = ',qflx_snwcp_ice(indexc)
write(iulog,*)'qflx_glcice_melt = ',qflx_glcice_melt(indexc)
write(iulog,*)'qflx_glcice_frz = ',qflx_glcice_frz(indexc)
write(iulog,*)'qflx_lateral = ',qflx_lateral(indexc)
write(iulog,*)'clm model is stopping'
call endrun(decomp_index=indexc, clmlevel=namec, msg=errmsg(__FILE__, __LINE__))
end if
Expand Down
11 changes: 11 additions & 0 deletions components/clm/src/biogeophys/EnergyFluxType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ module EnergyFluxType
real(r8), pointer :: eflx_traffic_lun (:) ! lun traffic sensible heat flux (W/m**2)
real(r8), pointer :: eflx_wasteheat_lun (:) ! lun sensible heat flux from domestic heating/cooling sources of waste heat (W/m**2)
real(r8), pointer :: eflx_heat_from_ac_lun (:) ! lun sensible heat flux to be put back into canyon due to removal by AC (W/m**2)
real(r8), pointer :: eflx_hs_h2osfc_col (:) ! heat flux on standing water [W/m2]
real(r8), pointer :: eflx_hs_top_snow_col (:) ! heat flux on top snow layer [W/m2]
real(r8), pointer :: eflx_hs_soil_col (:) ! heat flux on soil [W/m2
real(r8), pointer :: eflx_sabg_lyr_col (:,:) ! absorbed solar radiation (col,lyr) [W/m2]

! Derivatives of energy fluxes
real(r8), pointer :: dgnetdT_patch (:) ! patch derivative of net ground heat flux wrt soil temp (W/m**2 K)
real(r8), pointer :: netrad_patch (:) ! col net radiation (W/m**2) [+ = to sfc]
real(r8), pointer :: cgrnd_patch (:) ! col deriv. of soil energy flux wrt to soil temp [W/m2/k]
real(r8), pointer :: cgrndl_patch (:) ! col deriv. of soil latent heat flux wrt soil temp [W/m**2/k]
real(r8), pointer :: cgrnds_patch (:) ! col deriv. of soil sensible heat flux wrt soil temp [W/m2/k]
real(r8), pointer :: eflx_dhsdT_col (:) ! col deriv. of energy flux into surface layer wrt temp [W/m2/K]

! Canopy radiation
real(r8), pointer :: dlrad_patch (:) ! col downward longwave radiation below the canopy [W/m2]
Expand Down Expand Up @@ -196,6 +201,12 @@ subroutine InitAllocate(this, bounds)
allocate( this%eflx_wasteheat_lun (begl:endl)) ; this%eflx_wasteheat_lun (:) = nan
allocate( this%eflx_anthro_patch (begp:endp)) ; this%eflx_anthro_patch (:) = nan

allocate( this%eflx_hs_top_snow_col (begc:endc)) ; this%eflx_hs_top_snow_col (:) = nan
allocate( this%eflx_hs_h2osfc_col (begc:endc)) ; this%eflx_hs_h2osfc_col (:) = nan
allocate( this%eflx_hs_soil_col (begc:endc)) ; this%eflx_hs_soil_col (:) = nan
allocate( this%eflx_sabg_lyr_col (begc:endc,-nlevsno+1:1)); this%eflx_sabg_lyr_col (:,:) = nan
allocate( this%eflx_dhsdT_col (begc:endc)) ; this%eflx_dhsdT_col (:) = nan

allocate( this%dgnetdT_patch (begp:endp)) ; this%dgnetdT_patch (:) = nan
allocate( this%cgrnd_patch (begp:endp)) ; this%cgrnd_patch (:) = nan
allocate( this%cgrndl_patch (begp:endp)) ; this%cgrndl_patch (:) = nan
Expand Down
138 changes: 132 additions & 6 deletions components/clm/src/biogeophys/SoilStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module SoilStateType
procedure, private :: InitHistory
procedure, private :: InitCold
procedure, public :: Restart
procedure, public :: InitColdGhost

end type soilstate_type
!------------------------------------------------------------------------
Expand Down Expand Up @@ -117,11 +118,13 @@ subroutine InitAllocate(this, bounds)
integer :: begp, endp
integer :: begc, endc
integer :: begg, endg
integer :: begc_all, endc_all
!------------------------------------------------------------------------

begp = bounds%begp; endp= bounds%endp
begc = bounds%begc; endc= bounds%endc
begg = bounds%begg; endg= bounds%endg
begp = bounds%begp ; endp = bounds%endp
begc = bounds%begc ; endc = bounds%endc
begg = bounds%begg ; endg = bounds%endg
begc_all = bounds%begc_all; endc_all = bounds%endc_all

allocate(this%mss_frc_cly_vld_col (begc:endc)) ; this%mss_frc_cly_vld_col (:) = nan
allocate(this%sandfrac_patch (begp:endp)) ; this%sandfrac_patch (:) = nan
Expand All @@ -131,14 +134,14 @@ subroutine InitAllocate(this, bounds)
allocate(this%cellclay_col (begc:endc,nlevsoi)) ; this%cellclay_col (:,:) = nan
allocate(this%bd_col (begc:endc,nlevgrnd)) ; this%bd_col (:,:) = nan

allocate(this%hksat_col (begc:endc,nlevgrnd)) ; this%hksat_col (:,:) = spval
allocate(this%hksat_col (begc_all:endc_all,nlevgrnd)) ; this%hksat_col (:,:) = spval
allocate(this%hksat_min_col (begc:endc,nlevgrnd)) ; this%hksat_min_col (:,:) = spval
allocate(this%hk_l_col (begc:endc,nlevgrnd)) ; this%hk_l_col (:,:) = nan
allocate(this%smp_l_col (begc:endc,nlevgrnd)) ; this%smp_l_col (:,:) = nan
allocate(this%smpmin_col (begc:endc)) ; this%smpmin_col (:) = nan

allocate(this%bsw_col (begc:endc,nlevgrnd)) ; this%bsw_col (:,:) = nan
allocate(this%watsat_col (begc:endc,nlevgrnd)) ; this%watsat_col (:,:) = nan
allocate(this%bsw_col (begc_all:endc_all,nlevgrnd)) ; this%bsw_col (:,:) = nan
allocate(this%watsat_col (begc_all:endc_all,nlevgrnd)) ; this%watsat_col (:,:) = nan
allocate(this%watdry_col (begc:endc,nlevgrnd)) ; this%watdry_col (:,:) = spval
allocate(this%watopt_col (begc:endc,nlevgrnd)) ; this%watopt_col (:,:) = spval
allocate(this%watfc_col (begc:endc,nlevgrnd)) ; this%watfc_col (:,:) = nan
Expand Down Expand Up @@ -855,4 +858,127 @@ subroutine Restart(this, bounds, ncid, flag)
end if
end subroutine Restart


!------------------------------------------------------------------------
#ifdef USE_PETSC_LIB
subroutine InitColdGhost(this, bounds_proc)
!
! !DESCRIPTION:
! Assign soil properties for ghost/halo columns
!
! !USES:
use domainLateralMod , only : ExchangeColumnLevelGhostData
use shr_infnan_mod , only : shr_infnan_isnan
use shr_infnan_mod , only : isnan => shr_infnan_isnan
use landunit_varcon , only : max_lunit
!
implicit none
!
! !ARGUMENTS:
class(soilstate_type) :: this
type(bounds_type), intent(in) :: bounds_proc
!
integer :: c,j ! indices
integer :: nvals_col ! number of values per subgrid category
integer :: beg_idx, end_idx ! begin/end index for accessing values in data_send/data_recv
real(r8) , parameter:: FILL_VALUE = -999999.d0 ! temporary
real(r8) , pointer :: data_send_col(:) ! data sent by local mpi rank
real(r8) , pointer :: data_recv_col(:) ! data received by local mpi rank

! Number of values per soil column
nvals_col = 4*nlevgrnd ! (watsat + hksat + bsw + sucsat) * nlevgrnd

! Allocate value
allocate(data_send_col((bounds_proc%endc - bounds_proc%begc + 1)*nvals_col))
allocate(data_recv_col((bounds_proc%endc_all - bounds_proc%begc_all + 1)*nvals_col))

! Assemble the data to send
do c = bounds_proc%begc, bounds_proc%endc

beg_idx = (c - bounds_proc%begc)*nvals_col

do j = 1, nlevgrnd

beg_idx = beg_idx + 1
if (.not. isnan(this%watsat_col(c,j)) .and. this%watsat_col(c,j) /= spval) then
data_send_col(beg_idx) = this%watsat_col(c,j)
else
data_send_col(beg_idx) = FILL_VALUE
endif

beg_idx = beg_idx + 1
if (.not. isnan(this%hksat_col(c,j)) .and. this%hksat_col(c,j) /= spval) then
data_send_col(beg_idx) = this%hksat_col(c,j)
else
data_send_col(beg_idx) = FILL_VALUE
endif

beg_idx = beg_idx + 1
if (.not. isnan(this%bsw_col(c,j)) .and. this%bsw_col(c,j) /= spval) then
data_send_col(beg_idx) = this%bsw_col(c,j)
else
data_send_col(beg_idx) = FILL_VALUE
endif

beg_idx = beg_idx + 1
if (.not. isnan(this%sucsat_col(c,j)) .and. this%sucsat_col(c,j) /= spval) then
data_send_col(beg_idx) = this%sucsat_col(c,j)
else
data_send_col(beg_idx) = FILL_VALUE
endif
enddo
enddo

! Send the data
call ExchangeColumnLevelGhostData(bounds_proc, nvals_col, data_send_col, data_recv_col)

! Assign data corresponding to ghost/halo soil columns
do c = bounds_proc%endc + 1, bounds_proc%endc_all
beg_idx = (c - bounds_proc%begc)*nvals_col
do j = 1, nlevgrnd
beg_idx = beg_idx + 1
this%watsat_col(c,j) = data_recv_col(beg_idx)

beg_idx = beg_idx + 1
this%hksat_col(c,j) = data_recv_col(beg_idx)

beg_idx = beg_idx + 1
this%bsw_col(c,j) = data_recv_col(beg_idx)

beg_idx = beg_idx + 1
this%sucsat_col(c,j) = data_recv_col(beg_idx)
enddo
enddo

! Free up memory
deallocate(data_send_col)
deallocate(data_recv_col)

end subroutine InitColdGhost

#else

!------------------------------------------------------------------------
subroutine InitColdGhost(this, bounds_proc)
!
! !DESCRIPTION:
! Assign soil properties for ghost/halo columns
!
! !USES:
implicit none
!
! !ARGUMENTS:
class(soilstate_type) :: this
type(bounds_type), intent(in) :: bounds_proc

character(len=*), parameter :: subname = 'InitColdGhost'

call endrun(msg='ERROR ' // trim(subname) //': Requires '//&
'PETSc, but the code was compiled without -DUSE_PETSC_LIB')

end subroutine InitColdGhost

#endif
!------------------------------------------------------------------------

end module SoilStateType
Loading