From d9c04c5472048d3b2eeef41df0905d5fd5edb08d Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 27 Apr 2016 17:03:24 +0000 Subject: [PATCH] Fix a bug in azdist() that can cause bad behavior when computed distance is 0. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6650 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/azdist.f90 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/azdist.f90 b/lib/azdist.f90 index 528801f47..dd2c51a86 100644 --- a/lib/azdist.f90 +++ b/lib/azdist.f90 @@ -1,5 +1,6 @@ -subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) +subroutine azdist(grid1,grid2,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) + character*(*) grid1,grid2 character*6 MyGrid,HisGrid,mygrid0,hisgrid0 real*8 utch,utch0 logical HotABetter,IamEast @@ -11,6 +12,11 @@ subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) data mygrid0/" "/,hisgrid0/" "/,utch0/-999.d0/ save + MyGrid=grid1 + HisGrid=grid2 + if(ichar(grid1(5:5)).eq.0) MyGrid(5:6)=' ' + if(ichar(grid2(5:5)).eq.0) HisGrid(5:6)=' ' + if(MyGrid.eq.HisGrid) then naz=0 nel=0 @@ -46,7 +52,19 @@ subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) call grid2deg(MyGrid,dlong1,dlat1) call grid2deg(HisGrid,dlong2,dlat2) - call geodist(dlat1,dlong1,dlat2,dlong2,Az,Baz,Dkm) + eps=1.e-6 + if(abs(dlat1-dlat2).lt.eps .and. abs(dling1-dling2).lt.eps) then + Az=0. + Dmiles=0. + Dkm=0.0 + El=0. + HotA=0. + HotB=0. + HotABetter=.true. + go to 900 + else + call geodist(dlat1,dlong1,dlat2,dlong2,Az,Baz,Dkm) + endif ndkm=Dkm/100 j=ndkm-4