summaryrefslogtreecommitdiff
path: root/map65/libm65/dpol.f90
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /map65/libm65/dpol.f90
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'map65/libm65/dpol.f90')
-rw-r--r--map65/libm65/dpol.f90115
1 files changed, 75 insertions, 40 deletions
diff --git a/map65/libm65/dpol.f90 b/map65/libm65/dpol.f90
index 3f8085c0..b67f9e3e 100644
--- a/map65/libm65/dpol.f90
+++ b/map65/libm65/dpol.f90
@@ -1,41 +1,76 @@
-real function dpol(mygrid,hisgrid)
-
-! Compute spatial polartzation offset in degrees for the present
-! time, between two specified grid locators.
-
- character*6 MyGrid,HisGrid
- real lat,lon,LST
- character cdate*8,ctime2*10,czone*5
- integer it(8)
- data rad/57.2957795/
-
- call date_and_time(cdate,ctime2,czone,it)
- nyear=it(1)
- month=it(2)
- nday=it(3)
- nh=it(5)-it(4)/60
- nm=it(6)
- ns=it(7)
- uth=nh + nm/60.0 + ns/3600.0
-
- call grid2deg(MyGrid,lon,lat)
- call MoonDop(nyear,month,nday,uth,-lon,lat,RAMoon,DecMoon, &
- LST,HA,AzMoon,ElMoon,vr,dist)
- xx=sin(lat/rad)*cos(ElMoon/rad) - cos(lat/rad)* &
- cos(AzMoon/rad)*sin(ElMoon/rad)
- yy=cos(lat/rad)*sin(AzMoon/rad)
- poloffset1=rad*atan2(yy,xx)
-
- call grid2deg(hisGrid,lon,lat)
- call MoonDop(nyear,month,nday,uth,-lon,lat,RAMoon,DecMoon, &
- LST,HA,AzMoon,ElMoon,vr,dist)
- xx=sin(lat/rad)*cos(ElMoon/rad) - cos(lat/rad)* &
- cos(AzMoon/rad)*sin(ElMoon/rad)
- yy=cos(lat/rad)*sin(AzMoon/rad)
- poloffset2=rad*atan2(yy,xx)
-
- dpol=mod(poloffset2-poloffset1+720.0,180.0)
- if(dpol.gt.90.0) dpol=dpol-180.0
-
- return
+module dpol_mod
+ implicit none
+contains
+
+real(8) function dpol(mygrid, hisgrid) result(r)
+ use moondop_mod
+ use grid2deg_mod, only: grid2deg
+ implicit none
+
+ !--------------------------------------------------------------------
+ ! Arguments
+ !--------------------------------------------------------------------
+ character(len=6), intent(in) :: mygrid, hisgrid
+
+ !--------------------------------------------------------------------
+ ! Locals
+ !--------------------------------------------------------------------
+ character(len=8) :: cdate
+ character(len=10) :: ctime2
+ character(len=5) :: czone
+ integer :: it(8)
+ integer :: nyear, month, nday
+ integer :: nh, nm, ns
+
+ real(4) :: lat, lon, LST, HA
+ real(4) :: RAMoon, DecMoon, AzMoon, ElMoon
+ real(4) :: vr, dist
+ real(4) :: xx, yy
+ real(4) :: poloffset1, poloffset2
+ real(8), parameter :: rad = 57.2957795d0
+ real(4) :: uth
+
+ !--------------------------------------------------------------------
+ ! Get current date/time
+ !--------------------------------------------------------------------
+ call date_and_time(cdate, ctime2, czone, it)
+ nyear = it(1)
+ month = it(2)
+ nday = it(3)
+ nh = it(5) - it(4)/60
+ nm = it(6)
+ ns = it(7)
+ uth = nh + nm/60.0d0 + ns/3600.0d0
+
+ !--------------------------------------------------------------------
+ ! First grid
+ !--------------------------------------------------------------------
+ call grid2deg(mygrid, lon, lat)
+ call MoonDop(nyear, month, nday, uth, -lon, lat, RAMoon, DecMoon, &
+ LST, HA, AzMoon, ElMoon, vr, dist)
+
+ xx = sin(lat/rad)*cos(ElMoon/rad) - cos(lat/rad)*cos(AzMoon/rad)*sin(ElMoon/rad)
+ yy = cos(lat/rad)*sin(AzMoon/rad)
+ poloffset1 = rad * atan2(yy, xx)
+
+ !--------------------------------------------------------------------
+ ! Second grid
+ !--------------------------------------------------------------------
+ call grid2deg(hisgrid, lon, lat)
+ call MoonDop(nyear, month, nday, uth, -lon, lat, RAMoon, DecMoon, &
+ LST, HA, AzMoon, ElMoon, vr, dist)
+
+ xx = sin(lat/rad)*cos(ElMoon/rad) - cos(lat/rad)*cos(AzMoon/rad)*sin(ElMoon/rad)
+ yy = cos(lat/rad)*sin(AzMoon/rad)
+ poloffset2 = rad * atan2(yy, xx)
+
+ !--------------------------------------------------------------------
+ ! Final polarization offset
+ !--------------------------------------------------------------------
+ r = mod(poloffset2 - poloffset1 + 720.0d0, 180.0d0)
+ if (r > 90.0d0) r = r - 180.0d0
+
end function dpol
+
+end module dpol_mod
+