From a85155db5e529f0391db293922565fb379e942bf Mon Sep 17 00:00:00 2001 From: lvanroekel Date: Mon, 28 Apr 2025 13:34:55 -0600 Subject: [PATCH 1/6] Addresses oro drag bugs --- components/eam/src/physics/cam/od_common.F90 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index 52658d2dbecb..3b155f0d2131 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -276,7 +276,7 @@ subroutine oro_drag_interface(state, cam_in, sgh, pbuf, dtime, nm, integer :: kpbl2d_in(pcols) integer :: kpbl2d_reverse_in(pcols) real(r8), pointer :: pblh(:) - real(r8) :: dx(pcols),dy(pcols) + real(r8),allocatable,dimension(:) :: dx,dy real(r8), pointer :: oro_drag_convexity(:) real(r8), pointer :: oro_drag_asymmetry(:,:) @@ -289,6 +289,7 @@ subroutine oro_drag_interface(state, cam_in, sgh, pbuf, dtime, nm, !----------------------------------------------------------------------- ncol=state%ncol + allocate(dx(ncol),dy(ncol)) !convert heights above surface to heights above sea level !obtain z,dz,dx,dy,and k for pblh kpbl2d_in=0_r8 @@ -392,8 +393,8 @@ function pblh_get_level_idx(height_array,pblheight) pblh_get_level_idx = -1 found=.false. !get the pblh level index and return - do k = 1, pver - if((pblheight >= height_array(k+1).and.pblheight = height_array(k).and.pblheight Date: Tue, 29 Apr 2025 22:54:58 -0600 Subject: [PATCH 2/6] Fixes from PR review --- components/eam/src/physics/cam/od_common.F90 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index 3b155f0d2131..11160f129e54 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -276,7 +276,7 @@ subroutine oro_drag_interface(state, cam_in, sgh, pbuf, dtime, nm, integer :: kpbl2d_in(pcols) integer :: kpbl2d_reverse_in(pcols) real(r8), pointer :: pblh(:) - real(r8),allocatable,dimension(:) :: dx,dy + real(r8) :: dx(pcols),dy(pcols) real(r8), pointer :: oro_drag_convexity(:) real(r8), pointer :: oro_drag_asymmetry(:,:) @@ -289,7 +289,6 @@ subroutine oro_drag_interface(state, cam_in, sgh, pbuf, dtime, nm, !----------------------------------------------------------------------- ncol=state%ncol - allocate(dx(ncol),dy(ncol)) !convert heights above surface to heights above sea level !obtain z,dz,dx,dy,and k for pblh kpbl2d_in=0_r8 @@ -395,7 +394,7 @@ function pblh_get_level_idx(height_array,pblheight) !get the pblh level index and return do k = 2, pver if((pblheight >= height_array(k).and.pblheight Date: Wed, 30 Apr 2025 10:52:45 -0600 Subject: [PATCH 3/6] Changes dxmeter,dymeter declaration --- components/eam/src/physics/cam/od_common.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index 11160f129e54..bfcdf4fd8876 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -781,8 +781,8 @@ subroutine od2d(dudt,dvdt,dthdt,ncleff,ncd,sncleff, & !model timestep and other parameters real(r8), intent(in) :: g,rd,rv,fv,cp,pi,deltim,rcl !input model grid length - real(r8), dimension(its:ite), intent(in) :: dxmeter - real(r8), dimension(its:ite), intent(in) :: dymeter + real(r8), dimension(:), intent(in) :: dxmeter + real(r8), dimension(:), intent(in) :: dymeter !input topo variables real(r8), dimension( ims:ime,ndir_asymmetry ), intent(in) :: oa4 real(r8), dimension( ims:ime,ndir_efflength ), intent(in) :: ol4 @@ -967,8 +967,8 @@ subroutine od2d(dudt,dvdt,dthdt,ncleff,ncd,sncleff, & ! !--- calculate length of grid for flow-blocking drag ! - delx=dxmeter - dely=dymeter + delx(its:ite)=dxmeter(its:ite) + dely(its:ite)=dymeter(its:ite) ! ! !-----initialize arrays From 37a516a3760ee46f1bb14b51eaf648437c71d31d Mon Sep 17 00:00:00 2001 From: lvanroekel Date: Thu, 15 May 2025 19:37:53 -0600 Subject: [PATCH 4/6] updates to loop bound on z_bot in od_common --- components/eam/src/physics/cam/od_common.F90 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index bfcdf4fd8876..93444565e356 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -335,7 +335,7 @@ subroutine oro_drag_interface(state, cam_in, sgh, pbuf, dtime, nm, !get the layer index of pblh in layer for input in drag scheme pblh_idx = pbuf_get_index('pblh') call pbuf_get_field(pbuf, pblh_idx, pblh) - do i=1,pcols + do i=1,ncol kpbl2d_in(i)=pblh_get_level_idx(zbot(i,:)-(state%phis(i)/gravit),pblh(i)) kpbl2d_reverse_in(i)=pverp-kpbl2d_in(i)!pverp-k end do @@ -394,12 +394,18 @@ function pblh_get_level_idx(height_array,pblheight) !get the pblh level index and return do k = 2, pver if((pblheight >= height_array(k).and.pblheight Date: Thu, 29 May 2025 15:48:59 -0600 Subject: [PATCH 5/6] updates check on pbl index not found --- components/eam/src/physics/cam/od_common.F90 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index 93444565e356..b97e7a7a1410 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -400,12 +400,8 @@ function pblh_get_level_idx(height_array,pblheight) endif enddo - if (.not. found) then - print *, 'error, pbl not found' - print *, height_array - print *, pblheight - stop - endif + if (.not.found) call endrun('ERROR - pblh_get_level_idx: pbl top index not found') + end function !========================================================================== From 384a7ceab70c99865ba032d1ea2abcc46d4d20aa Mon Sep 17 00:00:00 2001 From: lvanroekel Date: Mon, 14 Jul 2025 13:08:50 -0600 Subject: [PATCH 6/6] fixes indexing error in pbl height finder --- components/eam/src/physics/cam/od_common.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index b97e7a7a1410..be773ab70dc4 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -394,7 +394,7 @@ function pblh_get_level_idx(height_array,pblheight) !get the pblh level index and return do k = 2, pver if((pblheight >= height_array(k).and.pblheight