diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /map65/libm65/deg2grid.f90 | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (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/deg2grid.f90')
| -rw-r--r-- | map65/libm65/deg2grid.f90 | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/map65/libm65/deg2grid.f90 b/map65/libm65/deg2grid.f90 index 9ca3602f..442648fc 100644 --- a/map65/libm65/deg2grid.f90 +++ b/map65/libm65/deg2grid.f90 @@ -1,30 +1,55 @@ -subroutine deg2grid(dlong0,dlat,grid) - - real dlong !West longitude (deg) - real dlat !Latitude (deg) - character grid*6 - - dlong=dlong0 - if(dlong.lt.-180.0) dlong=dlong+360.0 - if(dlong.gt.180.0) dlong=dlong-360.0 - -! Convert to units of 5 min of longitude, working east from 180 deg. - nlong=60.0*(180.0-dlong)/5.0 - n1=nlong/240 !20-degree field - n2=(nlong-240*n1)/24 !2 degree square - n3=nlong-240*n1-24*n2 !5 minute subsquare - grid(1:1)=char(ichar('A')+n1) - grid(3:3)=char(ichar('0')+n2) - grid(5:5)=char(ichar('a')+n3) - -! Convert to units of 2.5 min of latitude, working north from -90 deg. - nlat=60.0*(dlat+90)/2.5 - n1=nlat/240 !10-degree field - n2=(nlat-240*n1)/24 !1 degree square - n3=nlat-240*n1-24*n2 !2.5 minuts subsquare - grid(2:2)=char(ichar('A')+n1) - grid(4:4)=char(ichar('0')+n2) - grid(6:6)=char(ichar('a')+n3) - - return +module deg2grid_mod + implicit none +contains + +subroutine deg2grid(dlong0, dlat, grid) + implicit none + + !-------------------------------------------------------------------- + ! Arguments + !-------------------------------------------------------------------- + real, intent(in) :: dlong0 ! West longitude (deg) + real, intent(in) :: dlat ! Latitude (deg) + character(len=6), intent(out) :: grid ! Maidenhead grid + + !-------------------------------------------------------------------- + ! Locals + !-------------------------------------------------------------------- + real :: dlong + integer :: nlong, nlat + integer :: n1, n2, n3 + + !-------------------------------------------------------------------- + ! Normalize longitude to [-180, 180] + !-------------------------------------------------------------------- + dlong = dlong0 + if (dlong < -180.0) dlong = dlong + 360.0 + if (dlong > 180.0) dlong = dlong - 360.0 + + !-------------------------------------------------------------------- + ! Longitude → grid characters 1,3,5 + !-------------------------------------------------------------------- + nlong = 60.0 * (180.0 - dlong) / 5.0 + n1 = nlong / 240 ! 20-degree field + n2 = (nlong - 240*n1) / 24 ! 2-degree square + n3 = nlong - 240*n1 - 24*n2 ! 5-minute subsquare + + grid(1:1) = char(ichar('A') + n1) + grid(3:3) = char(ichar('0') + n2) + grid(5:5) = char(ichar('a') + n3) + + !-------------------------------------------------------------------- + ! Latitude → grid characters 2,4,6 + !-------------------------------------------------------------------- + nlat = 60.0 * (dlat + 90.0) / 2.5 + n1 = nlat / 240 ! 10-degree field + n2 = (nlat - 240*n1) / 24 ! 1-degree square + n3 = nlat - 240*n1 - 24*n2 ! 2.5-minute subsquare + + grid(2:2) = char(ichar('A') + n1) + grid(4:4) = char(ichar('0') + n2) + grid(6:6) = char(ichar('a') + n3) + end subroutine deg2grid + +end module deg2grid_mod |
