Skip to content

Commit

Permalink
Enable max_points working properly in hafs_datool (from @yonghuiweng).
Browse files Browse the repository at this point in the history
  • Loading branch information
BinLiu-NOAA committed Apr 27, 2022
1 parent 156e8ca commit bebd1a2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions sorc/hafs_tools.fd/sorc/hafs_datool/sub_tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ subroutine cal_grid_weight(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
allocate(gw(i,j)%src_x(max_points), gw(i,j)%src_y(max_points), gw(i,j)%src_weight(max_points))
if ( ixs >= 1 .and. ixs <= src_ix .and. jxs >= 1 .and. jxs <= src_jx ) then
n=0 !gw(i,j)%src_points=0
!do j1 = -1, 1; do i1 = -1, 1;
do j1 = 0, 0; do i1 = 0, 0
!if ( i1*j1 == 0 ) then !5-point
do j1 = -1, 1; do i1 = -1, 1;
!do j1 = 0, 0; do i1 = 0, 0
if ( i1*j1 == 0 ) then !5-point
ixi=ixs+i1; jxi=jxs+j1
!---change left to center
if ( ixi < 1 ) ixi=3
Expand All @@ -642,8 +642,10 @@ subroutine cal_grid_weight(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
gw(i,j)%src_x(n)=ixi
gw(i,j)%src_y(n)=jxi
gw(i,j)%src_weight(n)=earth_dist(src_lon(ixi,jxi),src_lat(ixi,jxi),dst_lon(i,j),dst_lat(i,j))
!nolinear dis weight
!gw(i,j)%src_weight(n)=gw(i,j)%src_weight(n)*gw(i,j)%src_weight(n)
endif !if ( ixi >= 1 .and. ixi <= src_ix .and. jxi >= 1 .and. jxi <= src_jx ) then
!endif
endif
enddo; enddo

!---convert earth_dist to weightening
Expand All @@ -656,7 +658,12 @@ subroutine cal_grid_weight(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
if ( dis == 0. ) then
gw(i,j)%src_weight(1:n)=1.0/real(n)
else if (dis > 0. .and. dis < 9000000000. ) then
gw(i,j)%src_weight(1:n)=gw(i,j)%src_weight(1:n)/dis
!gw(i,j)%src_weight(1:n)=gw(i,j)%src_weight(1:n)/dis
if ( n <= 1 ) then
gw(i,j)%src_weight(1:n)=1.0
else
gw(i,j)%src_weight(1:n)=(dis-gw(i,j)%src_weight(1:n))/((n-1)*dis)
endif
else
write(*,'(a)')'earth_dist calculation is wrong'
endif
Expand Down

0 comments on commit bebd1a2

Please sign in to comment.