Skip to content

Commit

Permalink
Merge pull request #379 from yuanhuas/master
Browse files Browse the repository at this point in the history
1) Optimazation for single point run (fix for some sites not be able to run); 2) adjust for snow vegetation porcess.
  • Loading branch information
CoLM-SYSU authored Feb 12, 2025
2 parents c7d717b + 3294571 commit a73800d
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 51 deletions.
7 changes: 7 additions & 0 deletions main/CoLM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,16 @@ PROGRAM CoLM
CALL pixelset_load_from_file (dir_landdata, 'landpatch', landpatch, numpatch, lc_year)

#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
#ifdef SinglePoint
IF (patchtypes(SITE_landtype) == 0) THEN
CALL pixelset_load_from_file (dir_landdata, 'landpft', landpft , numpft , lc_year)
CALL map_patch_to_pft
ENDIF
#else
CALL pixelset_load_from_file (dir_landdata, 'landpft' , landpft , numpft , lc_year)
CALL map_patch_to_pft
#endif
#endif

#ifdef URBAN_MODEL
CALL pixelset_load_from_file (dir_landdata, 'landurban', landurban, numurban, lc_year)
Expand Down
4 changes: 2 additions & 2 deletions main/MOD_3DCanopyRadiation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ SUBROUTINE ThreeDCanopy_wrap (ipatch, czen, albg, albv, tran, ssun, ssha)

! vegetation snow optical properties, 1:vis, 2:nir
real(r8) :: rho_sno(2), tau_sno(2)
data rho_sno(1), rho_sno(2) /0.6, 0.3/
data tau_sno(1), tau_sno(2) /0.2, 0.1/
data rho_sno(1), rho_sno(2) /0.5, 0.2/
data tau_sno(1), tau_sno(2) /0.3, 0.2/

! get patch PFT index
ps = patch_pft_s(ipatch)
Expand Down
7 changes: 6 additions & 1 deletion main/MOD_LAIReadin.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ SUBROUTINE LAI_readin (year, time, dir_landdata)

#ifdef SinglePoint
#ifndef URBAN_MODEL
iyear = findloc_ud(SITE_LAI_year == min(DEF_LAI_END_YEAR, max(DEF_LAI_START_YEAR,year)))
IF (USE_SITE_LAI) THEN
iyear = findloc_ud(SITE_LAI_year == year)
ELSE
iyear = findloc_ud(SITE_LAI_year == min(DEF_LAI_END_YEAR, max(DEF_LAI_START_YEAR,year)))
ENDIF

IF (.not. DEF_LAI_MONTHLY) THEN
itime = (time-1)/8 + 1
ENDIF
Expand Down
12 changes: 2 additions & 10 deletions main/MOD_SnowFraction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,15 @@ SUBROUTINE snowfraction_pftwrap (ipatch,zlnd,scv,snowdp,wt,sigf,fsno)
ENDIF

! snow on vegetation, USE snowdp to calculate buried fraction
! distingush tree, shrub and grass
IF ( DEF_VEG_SNOW .and. tlai_p(i)+tsai_p(i) > 1.e-6 ) THEN
! for non-grass, use hbot, htop to determine how much lsai being buried.
IF (p.gt.0 .and. p.le.11) THEN
! for trees, use hbot, htop to determine how much lsai being buried.
IF (p.gt.0 .and. p.le.8) THEN
wt = max(0., (snowdp-hbot_p(i))) / (htop_p(i)-hbot_p(i))
wt = min(wt, 1.)
sigf_p(i) = 1. - wt
ELSE
! for grass, 0-0.2m?
wt = min(1., snowdp/0.2)
sigf_p(i) = 1. - wt
ENDIF
ENDIF

!IF(sigf_p(i) < 0.001) sigf_p(i) = 0.
!IF(sigf_p(i) > 0.999) sigf_p(i) = 1.

wt_tmp = wt_tmp + wt*pftfrac(i)
ENDDO

Expand Down
12 changes: 6 additions & 6 deletions main/MOD_Vars_1DFluxes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ MODULE MOD_Vars_1DFluxes

real(r8), allocatable :: qcharge(:) !groundwater recharge [mm/s]

integer, allocatable :: oroflag(:)
real(r8), allocatable :: oroflag(:) !/ocean(0)/seaice(2) flag

integer, parameter :: nsensor = 1
real(r8), allocatable :: sensors(:,:)
real(r8), allocatable :: sensors(:,:)

! PUBLIC MEMBER FUNCTIONS:
PUBLIC :: allocate_1D_Fluxes
Expand Down Expand Up @@ -152,8 +152,8 @@ SUBROUTINE allocate_1D_Fluxes

allocate ( qcharge(numpatch) ) ; qcharge(:) = spval ! groundwater recharge [mm/s]

allocate ( oroflag(numpatch) ) ; oroflag(:) = spval_i4 !
allocate ( oroflag(numpatch) ) ; oroflag(:) = 1.0 ! /ocean(0)/seaice(2) flag

allocate ( sensors(nsensor,numpatch) ); sensors(:,:) = spval !

ENDIF
Expand Down Expand Up @@ -237,7 +237,7 @@ SUBROUTINE deallocate_1D_Fluxes ()
deallocate ( qcharge ) ! groundwater recharge [mm/s]

deallocate ( oroflag ) !

deallocate ( sensors ) !

ENDIF
Expand Down
20 changes: 14 additions & 6 deletions main/MOD_Vars_TimeInvariants.F90
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ MODULE MOD_Vars_TimeInvariants

integer, allocatable :: soiltext(:) ! USDA soil texture class

real(r8), allocatable :: fsatmax (:) ! maximum saturated area fraction [-]
real(r8), allocatable :: fsatdcf (:) ! decay factor in calucation of saturated area fraction [1/m]
real(r8), allocatable :: fsatmax (:) ! maximum saturated area fraction [-]
real(r8), allocatable :: fsatdcf (:) ! decay factor in calucation of saturated area fraction [1/m]

real(r8), allocatable :: vic_b_infilt (:)
real(r8), allocatable :: vic_Dsmax (:)
Expand Down Expand Up @@ -249,7 +249,7 @@ MODULE MOD_Vars_TimeInvariants
real(r8) :: zsno !roughness length for snow [m]
real(r8) :: csoilc !drag coefficient for soil under canopy [-]
real(r8) :: dewmx !maximum dew
! 'wtfact' is updated to gridded 'fsatmax' data.
! 'wtfact' is updated to gridded 'fsatmax' data.
! real(r8) :: wtfact !fraction of model area with high water table
real(r8) :: capr !tuning factor to turn first layer T into surface T
real(r8) :: cnfac !Crank Nicholson factor between 0 and 1
Expand Down Expand Up @@ -412,6 +412,7 @@ SUBROUTINE READ_TimeInvariants (lc_year, casename, dir_restart)
#endif
USE MOD_LandPatch
USE MOD_Vars_Global
USE MOD_Const_LC, only: patchtypes

IMPLICIT NONE

Expand Down Expand Up @@ -522,12 +523,19 @@ SUBROUTINE READ_TimeInvariants (lc_year, casename, dir_restart)
#else
CALL ncio_read_vector (file_restart, 'sf_curve_patches' , num_azimuth , num_zenith_parameter, landpatch, sf_curve_patches)
#endif
ENDIF
ENDIF

#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
#ifdef SinglePoint
IF (patchtypes(SITE_landtype) == 0) THEN
file_restart = trim(dir_restart) // '/const/' // trim(casename) //'_restart_pft_const' // '_lc' // trim(cyear) // '.nc'
CALL READ_PFTimeInvariants (file_restart)
ENDIF
#else
file_restart = trim(dir_restart) // '/const/' // trim(casename) //'_restart_pft_const' // '_lc' // trim(cyear) // '.nc'
CALL READ_PFTimeInvariants (file_restart)
#endif
#endif

#if (defined BGC)
file_restart = trim(dir_restart) // '/const/' // trim(casename) //'_restart_bgc_const' // '_lc' // trim(cyear) // '.nc'
Expand Down Expand Up @@ -650,7 +658,7 @@ SUBROUTINE WRITE_TimeInvariants (lc_year, casename, dir_restart)

CALL ncio_write_vector (file_restart, 'fsatmax', 'patch', landpatch, fsatmax)
CALL ncio_write_vector (file_restart, 'fsatdcf', 'patch', landpatch, fsatdcf)

CALL ncio_write_vector (file_restart, 'vic_b_infilt', 'patch', landpatch, vic_b_infilt)
CALL ncio_write_vector (file_restart, 'vic_Dsmax' , 'patch', landpatch, vic_Dsmax )
CALL ncio_write_vector (file_restart, 'vic_Ds' , 'patch', landpatch, vic_Ds )
Expand Down Expand Up @@ -917,7 +925,7 @@ SUBROUTINE check_TimeInvariants ()
IF(DEF_USE_BEDROCK)THEN
CALL check_vector_data ('dbedrock [m] ', dbedrock ) !
ENDIF

CALL check_vector_data ('topoelv [m] ', topoelv ) !
CALL check_vector_data ('topostd [m] ', topostd ) !
CALL check_vector_data ('BVIC [-] ', BVIC ) !
Expand Down
58 changes: 37 additions & 21 deletions main/MOD_Vars_TimeVariables.F90
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,12 @@ SUBROUTINE WRITE_TimeVariables (idate, lc_year, site, dir_restart)

USE MOD_SPMD_Task
USE MOD_Namelist, only : DEF_REST_CompressLevel, DEF_USE_PLANTHYDRAULICS, DEF_USE_OZONESTRESS, &
DEF_USE_IRRIGATION, DEF_USE_Dynamic_Lake
DEF_USE_IRRIGATION, DEF_USE_Dynamic_Lake, SITE_landtype
USE MOD_LandPatch
USE MOD_NetCDFVector
USE MOD_Vars_Global
USE MOD_Vars_TimeInvariants, only : dz_lake
USE MOD_Const_LC, only: patchtypes
IMPLICIT NONE

integer, intent(in) :: idate(3)
Expand Down Expand Up @@ -1034,33 +1035,40 @@ SUBROUTINE WRITE_TimeVariables (idate, lc_year, site, dir_restart)
CALL ncio_write_vector (file_restart, 'fq ', 'patch', landpatch, fq , compress) ! integral of profile FUNCTION for moisture

IF (DEF_USE_IRRIGATION) THEN
CALL Ncio_write_vector (file_restart, 'irrig_rate ' , 'patch',landpatch,irrig_rate , compress)
CALL Ncio_write_vector (file_restart, 'deficit_irrig ' , 'patch',landpatch,deficit_irrig , compress)
CALL Ncio_write_vector (file_restart, 'sum_irrig ' , 'patch',landpatch,sum_irrig , compress)
CALL Ncio_write_vector (file_restart, 'sum_irrig_count ' , 'patch',landpatch,sum_irrig_count , compress)
CALL Ncio_write_vector (file_restart, 'n_irrig_steps_left ' , 'patch',landpatch,n_irrig_steps_left , compress)
CALL Ncio_write_vector (file_restart, 'tairday ' , 'patch',landpatch,tairday , compress)
CALL Ncio_write_vector (file_restart, 'usday ' , 'patch',landpatch,usday , compress)
CALL Ncio_write_vector (file_restart, 'vsday ' , 'patch',landpatch,vsday , compress)
CALL Ncio_write_vector (file_restart, 'pairday ' , 'patch',landpatch,pairday , compress)
CALL Ncio_write_vector (file_restart, 'rnetday ' , 'patch',landpatch,rnetday , compress)
CALL Ncio_write_vector (file_restart, 'fgrndday ' , 'patch',landpatch,fgrndday , compress)
CALL Ncio_write_vector (file_restart, 'potential_evapotranspiration', 'patch',landpatch, &
CALL ncio_write_vector (file_restart, 'irrig_rate ' , 'patch',landpatch,irrig_rate , compress)
CALL ncio_write_vector (file_restart, 'deficit_irrig ' , 'patch',landpatch,deficit_irrig , compress)
CALL ncio_write_vector (file_restart, 'sum_irrig ' , 'patch',landpatch,sum_irrig , compress)
CALL ncio_write_vector (file_restart, 'sum_irrig_count ' , 'patch',landpatch,sum_irrig_count , compress)
CALL ncio_write_vector (file_restart, 'n_irrig_steps_left ' , 'patch',landpatch,n_irrig_steps_left , compress)
CALL ncio_write_vector (file_restart, 'tairday ' , 'patch',landpatch,tairday , compress)
CALL ncio_write_vector (file_restart, 'usday ' , 'patch',landpatch,usday , compress)
CALL ncio_write_vector (file_restart, 'vsday ' , 'patch',landpatch,vsday , compress)
CALL ncio_write_vector (file_restart, 'pairday ' , 'patch',landpatch,pairday , compress)
CALL ncio_write_vector (file_restart, 'rnetday ' , 'patch',landpatch,rnetday , compress)
CALL ncio_write_vector (file_restart, 'fgrndday ' , 'patch',landpatch,fgrndday , compress)
CALL ncio_write_vector (file_restart, 'potential_evapotranspiration', 'patch',landpatch, &
potential_evapotranspiration, compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_corn ' , 'patch',landpatch,irrig_method_corn , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_swheat ' , 'patch',landpatch,irrig_method_swheat , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_wwheat ' , 'patch',landpatch,irrig_method_wwheat , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_soybean ' , 'patch',landpatch,irrig_method_soybean , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_cotton ' , 'patch',landpatch,irrig_method_cotton , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_rice1 ' , 'patch',landpatch,irrig_method_rice1 , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_rice2 ' , 'patch',landpatch,irrig_method_rice2 , compress)
CALL Ncio_write_vector (file_restart, 'irrig_method_sugarcane' , 'patch',landpatch,irrig_method_sugarcane, compress)
CALL ncio_write_vector (file_restart, 'irrig_method_corn ' , 'patch',landpatch,irrig_method_corn , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_swheat ' , 'patch',landpatch,irrig_method_swheat , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_wwheat ' , 'patch',landpatch,irrig_method_wwheat , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_soybean ' , 'patch',landpatch,irrig_method_soybean , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_cotton ' , 'patch',landpatch,irrig_method_cotton , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_rice1 ' , 'patch',landpatch,irrig_method_rice1 , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_rice2 ' , 'patch',landpatch,irrig_method_rice2 , compress)
CALL ncio_write_vector (file_restart, 'irrig_method_sugarcane' , 'patch',landpatch,irrig_method_sugarcane, compress)
ENDIF

#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
#ifdef SinglePoint
IF (patchtypes(SITE_landtype) == 0) THEN
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_pft_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
CALL WRITE_PFTimeVariables (file_restart)
ENDIF
#else
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_pft_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
CALL WRITE_PFTimeVariables (file_restart)
#endif
#endif

#if (defined BGC)
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_bgc_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
Expand Down Expand Up @@ -1094,6 +1102,7 @@ SUBROUTINE READ_TimeVariables (idate, lc_year, site, dir_restart)
USE MOD_LandPatch
USE MOD_Vars_Global
USE MOD_Vars_TimeInvariants, only : dz_lake
USE MOD_Const_LC, only: patchtypes

IMPLICIT NONE

Expand Down Expand Up @@ -1229,9 +1238,16 @@ SUBROUTINE READ_TimeVariables (idate, lc_year, site, dir_restart)
ENDIF

#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
#ifdef SinglePoint
IF (patchtypes(SITE_landtype) == 0) THEN
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_pft_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
CALL READ_PFTimeVariables (file_restart)
ENDIF
#else
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_pft_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
CALL READ_PFTimeVariables (file_restart)
#endif
#endif

#if (defined BGC)
file_restart = trim(dir_restart)// '/'//trim(cdate)//'/' // trim(site) //'_restart_bgc_'//trim(cdate)//'_lc'//trim(cyear)//'.nc'
Expand Down
7 changes: 7 additions & 0 deletions mkinidata/CoLMINI.F90
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,16 @@ PROGRAM CoLMINI
CALL pixelset_load_from_file (dir_landdata, 'landpatch', landpatch, numpatch, lc_year)

#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
#ifdef SinglePoint
IF (patchtypes(SITE_landtype) == 0) THEN
CALL pixelset_load_from_file (dir_landdata, 'landpft', landpft, numpft, lc_year)
CALL map_patch_to_pft
ENDIF
#else
CALL pixelset_load_from_file (dir_landdata, 'landpft', landpft, numpft, lc_year)
CALL map_patch_to_pft
#endif
#endif

#ifdef URBAN_MODEL
CALL pixelset_load_from_file (dir_landdata, 'landurban', landurban, numurban, lc_year)
Expand Down
8 changes: 4 additions & 4 deletions mksrfdata/MOD_LandPFT.F90
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ SUBROUTINE landpft_build (lc_year)
patch_pft_s (ipft) = ipft
patch_pft_e (ipft) = ipft
ENDDO
landpft%pctshared = landpatch%pctshared

landpft%pctshared = landpatch%pctshared
#endif
ENDIF
ELSE
Expand All @@ -151,7 +151,7 @@ SUBROUTINE landpft_build (lc_year)
#ifdef USEMPI
CALL mpi_barrier (p_comm_glb, p_err)
#endif

landpft%has_shared = .true.

IF (p_is_io) THEN
Expand Down Expand Up @@ -274,7 +274,7 @@ SUBROUTINE landpft_build (lc_year)
landpft%ipxstt(npft) = landpatch%ipxstt(ipatch)
landpft%ipxend(npft) = landpatch%ipxend(ipatch)
landpft%settyp(npft) = cropclass(ipatch)

landpft%pctshared(npft) = landpatch%pctshared(ipatch)

pft2patch(npft) = npatch
Expand Down
2 changes: 1 addition & 1 deletion mksrfdata/MOD_SingleSrfdata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ SUBROUTINE read_surface_data_single (fsrfdata, mksrfdata)

CALL normalize_longitude (SITE_lon_location)

IF (USE_SITE_landtype) THEN
IF (USE_SITE_landtype .or. .not.mksrfdata) THEN
IF (trim(fsrfdata) /= 'null') THEN
#ifdef LULC_USGS
CALL ncio_read_serial (fsrfdata, 'USGS_classification', SITE_landtype)
Expand Down

0 comments on commit a73800d

Please sign in to comment.