Skip to content

Commit

Permalink
Dynamically compute MAXSUM used in the computation of GWD
Browse files Browse the repository at this point in the history
fields.

Fixes ufs-community#1000.
  • Loading branch information
GeorgeGayno-NOAA committed Nov 22, 2024
1 parent 53a97b8 commit fe71fa1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions sorc/orog_mask_tools.fd/orog.fd/mtnlm7_oclsm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ SUBROUTINE MAKEMT2(ZAVG,ZSLM,ORO,SLM,VAR,VAR4, &
real, intent(out) :: oro(im,jm)
real, intent(out) :: var(im,jm),var4(im,jm)

integer, parameter :: MAXSUM=65000000
! integer, parameter :: MAXSUM=65000000
integer :: MAXSUM
real, parameter :: D2R = 3.14159265358979/180.

real, dimension(:), allocatable :: hgt_1d, hgt_1d_all
Expand All @@ -564,8 +565,6 @@ SUBROUTINE MAKEMT2(ZAVG,ZSLM,ORO,SLM,VAR,VAR4, &
real XL1_ALL,XS1_ALL,XW1_ALL,XW2_ALL,XW4_ALL

print*,'- CREATE OROGRAPHY AND CONVEXITY.'
allocate(hgt_1d(MAXSUM))
allocate(hgt_1d_all(MAXSUM))
!---- GLOBAL XLAT AND XLON ( DEGREE )
!
JM1 = JM - 1
Expand All @@ -578,7 +577,24 @@ SUBROUTINE MAKEMT2(ZAVG,ZSLM,ORO,SLM,VAR,VAR4, &
GLON(I) = 0. + (I-1) * DELXN + DELXN * 0.5
ENDDO

! land_frac(:,:) = 0.0
MAXSUM=0
DO J=1,JM
DO I=1,IM
LONO(1) = lon_c(i,j)
LONO(2) = lon_c(i+1,j)
LONO(3) = lon_c(i+1,j+1)
LONO(4) = lon_c(i,j+1)
LATO(1) = lat_c(i,j)
LATO(2) = lat_c(i+1,j)
LATO(3) = lat_c(i+1,j+1)
LATO(4) = lat_c(i,j+1)
call get_index(IMN,JMN,4,LONO,LATO,DELXN,jst,jen,ilist,numx)
MAXSUM=MAX(MAXSUM,(JEN-JST+1)*IMN)
print*,'test point ',i,j,jst,jen,imn,((JEN-JST+1)*IMN),maxsum
ENDDO
ENDDO
allocate(hgt_1d(MAXSUM))
allocate(hgt_1d_all(MAXSUM))
!
!---- FIND THE AVERAGE OF THE MODES IN A GRID BOX
!
Expand Down

0 comments on commit fe71fa1

Please sign in to comment.