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 maxpft>1 #161

Merged
merged 6 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 8 additions & 5 deletions bldsva/build_tsmp.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ getDefaults(){
def_mode="0" #0: let flags decide, 1:batch, 2:interactive
def_cplscheme="true"
def_readCLM="false"
def_maxpft="1"
def_freeDrain="false"

#compiler optimization
Expand Down Expand Up @@ -94,6 +95,7 @@ setDefaults(){

freeDrain=$def_freeDrain
readCLM=$def_readCLM
maxpft=${def_maxpft}
cplscheme=$def_cplscheme
mode=$def_mode

Expand Down Expand Up @@ -563,9 +565,10 @@ printState(){
print "${cred}(25)${cnormal} profiling (default=$def_profiling): ${cgreen}$profiling ${cnormal}"
print "${cred}(26)${cnormal} Couple-Scheme (default=$def_cplscheme): ${cgreen}$cplscheme ${cnormal}"
print "${cred}(27)${cnormal} readCLM: Consistently read CLM-mask (default=$def_readCLM): ${cgreen}$readCLM ${cnormal}"
print "${cred}(28)${cnormal} Compiles ParFlow with free drainage feature (default=$def_freeDrain): ${cgreen}$freeDrain ${cnormal}"
print "${cred}(29)${cnormal} compiler (default=$defaultcompiler): ${cgreen}$compiler ${cnormal}"
print "${cred}(30)${cnormal} processor (default=$defaultprocessor): ${cgreen}$processor ${cnormal}"
print "${cred}(28)${cnormal} maxpft: Set maxpft per grid cell for CLM (default=$def_maxpft): ${cgreen}$maxpft ${cnormal}"
print "${cred}(29)${cnormal} Compiles ParFlow with free drainage feature (default=$def_freeDrain): ${cgreen}$freeDrain ${cnormal}"
print "${cred}(30)${cnormal} compiler (default=$defaultcompiler): ${cgreen}$compiler ${cnormal}"
print "${cred}(31)${cnormal} processor (default=$defaultprocessor): ${cgreen}$processor ${cnormal}"
}

check(){
Expand Down Expand Up @@ -863,6 +866,7 @@ getGitInfo(){
USAGE+="[c:combination? Combination of component models.]:[combination:='$def_combination']"
USAGE+="[C:cplscheme? Couple-Scheme for CLM/COS coupling.]:[cplscheme:='$def_cplscheme']"
USAGE+="[r:readclm? Flag to consistently read in CLM mask.]:[readclm:='$def_readCLM']"
USAGE+="[f:maxpft? Flag to control maxpft per grid cell in CLM.]:[maxpft:='$def_maxpft']"
USAGE+="[d:freedrain? Compiles ParFlow with free drainage feature.]:[freedrain:='$def_freeDrain']"

USAGE+="[W:optoas?Build option for Oasis.]:[optoas:='${def_options["oas"]}']{"
Expand Down Expand Up @@ -916,6 +920,7 @@ getGitInfo(){
c) combination="$OPTARG" ; args=1 ;;
C) cplscheme="$OPTARG" ; args=1 ;;
r) readCLM="$OPTARG" ; args=1 ;;
f) maxpft="$OPTARG" ; args=1 ;;
d) freeDrain="$OPTARG" ; args=1 ;;
#DA
T) options+=(["icon"]="$OPTARG") ; args=1 ;;
Expand Down Expand Up @@ -944,8 +949,6 @@ getGitInfo(){
done




comment " source list with supported machines and configurations"
. $rootdir/bldsva/supported_versions.ksh
check
Expand Down
63 changes: 51 additions & 12 deletions bldsva/intf_oas3/clm3_5/tsmp/Biogeophysics1Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,20 @@ subroutine Biogeophysics1(lbg, ubg, lbc, ubc, lbp, ubp, &
real(r8) :: psit !negative potential of soil
real(r8) :: hr !relative humidity
real(r8) :: wx !partial volume of ice and water of surface layer
!NOTE: Arrays can start from arbitrary index...
! So in CLM the distributed arraies (over diff. CPUs) does take the index
! from the original array.
! original_array(0:10) --> array1(0:5) and array(6:10)
! The Uper and lower index bound is stored in `lbg`, `ubg`, etc.
real(r8) :: tmp_displacement_max(lbg:ubg) !helper var
real(r8) :: tmp_displacement !helper var
!------------------------------------------------------------------------------

! Assign local pointers to derived type members (gridcell-level)

forc_hgt_t => clm_a2l%forc_hgt_t
forc_pbot => clm_a2l%forc_pbot

forc_q => clm_a2l%forc_q
forc_t => clm_a2l%forc_t
forc_th => clm_a2l%forc_th
Expand Down Expand Up @@ -398,31 +406,62 @@ subroutine Biogeophysics1(lbg, ubg, lbc, ubc, lbp, ubp, &

end do

!CPS change forc_hgt = forc_hgt + z0m + displa at PFT level, works for 1 pft max
! if (max_pft_per_col .eq. 1) then
if (maxpatch_pft .eq. 1) then
! Change forc_hgt = forc_hgt + z0m + displa at PFT level
! forc_hgt is send from COSMO to CLM via fix value. In fully coupled mode, this
! fix value can conflict with the actual canopy height, showing up as CLM error
! with the message:
! > [...] forc height is below canopy height [...]
! To workaround this, forc_hgt is adjusted (increased) according to pft types
! present within each gridcell.
! As multiple pfts could be present in one gridcell, first the displacement is
! calculated for each pft present, and second the maximum displacement is taken
! to correct the forc_hgt. This way we do not run into above error.
! However, keep in mind that this correction is still a workaround.
tmp_displacement = 0._r8 ! scalar
tmp_displacement_max = 0._r8 ! same shape as forc_hgt
!
! First calculate max displacement for all columns and pfts on grid lvl
! max_pft_per_col = im code festgelegte max moeglicher pft (17)
do pi = 1,max_pft_per_col
! num_nolakec: number of column non-lake points in column filter
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = clandunit(c)
g = cgridcell(c)
if (pi <= npfts(c)) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain this line to me, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually I cannot. This is the official 'description' of this variable taken from Biogeophysics1Mod.F90#L80.

p = pfti(c) + pi - 1

if (frac_sno(c) > 0._r8 ) then
forc_hgt_u(p) = forc_hgt_u(g) + z0mg(c) + displa(p)
forc_hgt_t(g) = forc_hgt_t(g) + z0mg(c) + displa(p)
forc_hgt_q(g) = forc_hgt_q(g) + z0mg(c) + displa(p)
! Calculate displacement for related pft on related column
! If this displacement is higher than displacement_max overwrite
! displacement_max
tmp_displacement = z0mg(c) + displa(p)
if (tmp_displacement > tmp_displacement_max(g)) then
tmp_displacement_max(g) = tmp_displacement
end if
else
forc_hgt_u(g) = forc_hgt_u(g) + z0m(p) + displa(p)
forc_hgt_t(g) = forc_hgt_t(g) + z0m(p) + displa(p)
forc_hgt_q(g) = forc_hgt_q(g) + z0m(p) + displa(p)
! Calculate displacement for related pft on related column
! If this displacement is higher than displacement_max overwrite
! displacement_max
tmp_displacement = z0m(p) + displa(p)
if (tmp_displacement > tmp_displacement_max(g)) then
tmp_displacement_max(g) = tmp_displacement
end if
end if
end if
end do
end do
end if
!CPS
! Second increase forc_hgt on grid lvl with max displacement
! num_nolakec: number of column non-lake points in column filter
do fc = 1,num_nolakec
c = filter_nolakec(fc)
g = cgridcell(c)

! Update forc_hgt on grid lvl
forc_hgt_u(g) = forc_hgt_u(g) + tmp_displacement_max(g)
forc_hgt_t(g) = forc_hgt_t(g) + tmp_displacement_max(g)
forc_hgt_q(g) = forc_hgt_q(g) + tmp_displacement_max(g)
end do

end subroutine Biogeophysics1

Expand Down
1 change: 0 additions & 1 deletion bldsva/intf_oas3/common_build_interface.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ route "${cyellow}>>> c_configure_clm${cnormal}"
cp $rootdir/bldsva/intf_oas3/${mList[1]}/oas3/oas_clm_init.F90 $clmdir/src/oas3

spmd="on" # settings are [on | off ] (default is off)
maxpft="1" # settings are 4->17 (default is 4)
rtm="off" # settings are [on | off ] (default is off)
cps_catch="off" # settings are [on | off ] (default is off)
usr_src="$clmdir/bld/usr.src "
Expand Down