Skip to content

Commit

Permalink
Merge pull request #497 from dustinswales/hotfix/clmlake_in_scm
Browse files Browse the repository at this point in the history
Changes for CLM lake to work in CCPP SCM
  • Loading branch information
grantfirl authored Aug 1, 2024
2 parents 5702b65 + aa99c2d commit 5be44bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions scm/src/scm_type_defs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1082,10 +1082,7 @@ subroutine physics_set(physics, scm_input, scm_state)
call conditionally_set_var(scm_input%input_elvmax, physics%Sfcprop%hprime(i,14), "elvmax", .true., missing_var(14))
call conditionally_set_var(scm_input%input_oro, physics%Sfcprop%oro(i), "oro", .true., missing_var(15))
call conditionally_set_var(scm_input%input_oro_uf, physics%Sfcprop%oro_uf(i), "oro_uf", (physics%Model%do_ugwp .and. physics%Model%nmtvr == 14), missing_var(16))
call conditionally_set_var(scm_input%input_landfrac, physics%Sfcprop%landfrac(i), "landfrac", physics%Model%frac_grid, missing_var(17))
call conditionally_set_var(scm_input%input_lakefrac, physics%Sfcprop%lakefrac(i), "lakefrac", (physics%Model%lkm == 1), missing_var(18))
call conditionally_set_var(scm_input%input_lakedepth, physics%Sfcprop%lakedepth(i), "lakedepth", (physics%Model%lkm == 1), missing_var(19))


n = 19
if ( i==1 .and. ANY( missing_var(1:n) ) ) then
write(0,'(a)') "INPUT CHECK: Some missing input data was found related to (potentially non-required) orography and gravity wave drag parameters. This may lead to crashes or other strange behavior."
Expand All @@ -1097,6 +1094,20 @@ subroutine physics_set(physics, scm_input, scm_state)
missing_var = .false.
end if

! Variables found in orographic dataset but needed for non-orographic reasons (e.g. lake model, fractional grid)
call conditionally_set_var(scm_input%input_landfrac, physics%Sfcprop%landfrac(i), "landfrac", physics%Model%frac_grid, missing_var(1))
call conditionally_set_var(scm_input%input_lakefrac, physics%Sfcprop%lakefrac(i), "lakefrac", (physics%Model%lkm == 1), missing_var(2))
call conditionally_set_var(scm_input%input_lakedepth, physics%Sfcprop%lakedepth(i), "lakedepth", (physics%Model%lkm == 1), missing_var(3))
n = 3
if ( i==1 .and. ANY( missing_var(1:n) ) ) then
write(0,'(a)') "INPUT CHECK: Some missing input data was found related to (potentially non-required) lake-related or fractional grid-related variables. This may lead to crashes or other strange behavior."
write(0,'(a)') "Check scm_type_defs.F90/physics_set to see the names of variables that are missing, corresponding to the following indices:"
do j=1, n
if (missing_var(j)) write(0,'(a,i0)') "variable index ",j
end do
end if
missing_var = .false.

!
! Surface data (2D)
!
Expand Down Expand Up @@ -1203,7 +1214,7 @@ subroutine physics_set(physics, scm_input, scm_state)
! Derive physics quantities using surface model ICs.
!
if(scm_state%model_ics .or. scm_state%lsm_ics) then
if (physics%Sfcprop%stype(i) == 14 .or. physics%Sfcprop%stype(i)+0.5 <= 0) then
if (physics%Sfcprop%stype(i) == 14 .or. physics%Sfcprop%stype(i) <= 0) then
physics%Sfcprop%landfrac(i) = real_zero
physics%Sfcprop%stype(i) = 0
if (physics%Sfcprop%lakefrac(i) > real_zero) then
Expand Down

0 comments on commit 5be44bd

Please sign in to comment.