[net.ham-radio] VUCC grid responses and program

hanson@ihuxq.UUCP (R. J. Hanson) (02/17/84)

Thanks to everyone who called/mailed me responses. I now know my grid
location is EN51ws, which will be printed up on my new (only) QSL cards.

I received two programs to do the calculation. One is in BASIC from Dave
Knight KA1DT. If I ever get my home system up and running, it will be
resident for sure. The other came from Ron McConnell W2IOL, and is in
F77 Fortran. He sent me a followup message giving me permission to post
it to the net for him, since his new machine (whuxi) is having problems.
So here goes. Only one note about data entry: a leading zero MUST be
used where called for. For example, use "09.3" minutes, NOT " 9.3".

For anyone with UN*X 5.0, just "f77 vucc.f; a.out" and answer the
prompts:
--------------------------------------------------------------------------
C      13 January 1983 and 18 October 1983
C
C                      Ronald C. McConnell, W2IOL
C
C       VUCC, VHF/UHF Century Club grid locator
C
C      "VUCC" determines the grid location in the "Maidenhead"
C         format as adopted by the IARU
C         given latitude and longitude of a QTH
C            in integer degrees ( no decimal ) and decimal minutes
C
C       The 1st and 2nd characters ( A to R ) define an area, "field,"
C          20 degrees in longitude by 10 degrees in latitude.
C
C       The 3rd and 4th characters ( 0 to 9 ) define an area, "square,"
C          2 degrees in longitude by 1 degree in latitude.
C
C       The 5th and 6th characters ( a to x ) define an area, "sub-square,"
C          5 minutes in longitude by 2.5 minutes in latitude.
C            ( not needed for VUCC award )
C
C                   dd mm.m    ddd mm.m
C        Examples:  40 46.9 N, 074 41.4 W   =  FN20ps
C                   40 46.9 S, 074 41.4 E   =  ME79if
C
C       Note that latitude and longitude define a point.
C                 Grid location defines an area.
C
C        Characters 1, 3 and 5 start at 180 longitude and
C           increase alphabetically or numerically to the east.
C           Points on grid boundaries round to the east.
C
C        Characters 2, 4 and 6 start at 90 south latitude and
C           increase alphabetically or numerically to the north.
C           Points on grid boundaries round to the north.
C
C      See QST, January 1983, p49, "VHF/UHF Century Club Awards"
C           &   October 1983, p52, "Grid Locators for South America"
C        by John F. Lindholm, W1XX, ARRL Com. Mgr.
C
C       VUCC is written in a subset of fortran 77.
C
      integer lad, lod
      real lam, lom
      character n, s, e, w, grid(6) 
      character ncap, scap, ecap, wcap
      character lans, loew, ok, yes, no, ycap
C
      data yes, no, ycap/ 'y', 'n', 'Y' /
      data n, s, e, w / 'n', 's', 'e', 'w' /
      data ncap, scap, ecap, wcap/ 'N', 'S', 'E', 'W' /
C
      print 1000
 1000 format( ' VUCC Grid Location from Latitude and Longitude' /
     &          10( ' ' ), 'W2IOL  10/18/83 version' / )
C
   30 print 1300
 1300 format( ' Latitude? dd mm.m N/S' )
      read( 5, 1310 ) lad, lam, lans
 1310 format( i2, 1x, f4.1, 1x, a1 )
      if( ( lans .eq. s ) .or. ( lans .eq. scap ) )
     &   then
            lans = scap
         else
            lans = ncap
      end if
      print 1320, lad, lam, lans
 1320 format( i2, 1x, f4.1, 1x, a1, '    ok? y/n:' )
      read( 5, 1340 ) ok
 1340 format( a1 )
      if( ( ok .eq. no ) .or. ( ok .eq. ncap ) ) go to 30
C
   40 print 1400
 1400 format( ' Longitude? ddd mm.m W/E' )
      read( 5, 1420 ) lod, lom, loew
 1420 format( i3, 1x, f4.1, 1x, a1 )
      if( ( loew .eq. e ) .or. ( loew .eq. ecap ) )
     &   then
            loew = ecap
         else
            loew = wcap
      end if
      print 1450, lod, lom, loew
 1450 format( i3, 1x, f4.1, 1x, a1, '    ok? y/n:' )
      read( 5, 1340 ) ok
      if( ( ok .eq. no ) .or. ( ok .eq. ncap ) ) go to 40
C
      call mhgrid( lad, lam, lans, lod, lom, loew, grid )
      print 1900, grid
 1900 format( ' VUCC grid location = ', 6a1 )
C
      print 2000
 2000 format( / 30( '-' ) / ' more? y/n:' )
      read( 5, 1340 ) ok
      if( ( ok. eq. no ) .or. ( ok .eq. ncap ) )
     &   then
            stop
         else
            go to 30
      end if
C
      end
C
C
C
      subroutine mhgrid( lad, lam, lans, lod, lom, loew, grid )
C       07 January 1983,   18 October 1983
C        Ronald C. McConnell, W2IOL
C
      integer lad, lod, latdeg, lngdeg
      real lam, lom, latmin, lngmin
      character lans, north, south, loew, east, west
      character grid(6), ltrbig(26), ltrsml(26), nbrchr(10)
C
      data north, south, east, west / 'N', 'S', 'E', 'W' /
      data nbrchr / '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' /
      data ltrsml/ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
     &             'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
     &             's', 't', 'u', 'v', 'w', 'x', 'y', 'z' /
      data ltrbig/ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
     &             'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
     &             'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' /
C
C         Translate latitude relative to 90 south, South Pole
C
      if( lans .eq. north )
     &   then
C             "north"
            latdeg = 90 + lad
            latmin = lam
         else
C             "south"
            if( lam .eq. 0.0 )
     &         then
                  latdeg = 90 - lad
                  latmin = 0.0
               else
                  latdeg = 89 - lad
                  latmin = 60.0 - lam
               end if
      end if
C
C         Translate longitude relative to 180 meridian
C               increasing toward the east
C
      if( loew .eq. west )
     &   then
C             "west"
            if( lom .eq. 0.0 )
     &         then
                  lngdeg = 180 - lod
                  lngmin = 0.0
               else
                  lngdeg = 179 - lod
                  lngmin = 60.0 - lom
            end if
         else
C             "east"
            lngdeg = 180 + lod
            lngmin = lom
      end if
C
C         NOTE: integer arithmetic with lngdeg and latdeg
C               meaning all fractional parts truncated
C
C         First Character = capital letter, A to R,
C               based on 20 degree longitude block from 180 meridian
C
      k = ( lngdeg / 20 ) + 1
C          Meridian 180
      if( k .eq. 19 ) k = 18
C
      grid( 1 ) = ltrbig( k )
C
C         Second Character = capital letter, A to R,
C                based on 10 degree latitude block from South Pole
C
      k = ( latdeg / 10 ) + 1
C         North Pole
      if( k .eq. 19 ) k = 18
C
      grid( 2 ) = ltrbig( k )
C
C         Third Character = number, 0 to 9, based on
C               position within 20 degree longitude block
C
      lotwty = lngdeg / 20
      k = ( lngdeg - ( lotwty * 20 ) ) / 2
      if( k .eq. 0 ) k = 10
      grid( 3 ) = nbrchr( k )
C
C         Fourth Character = number, 0 to 9, based on
C                position within 10 degree latitude block
C
      latens = latdeg / 10
      k = latdeg - ( latens * 10 )
      if( k .eq. 0 ) k = 10
      grid( 4 ) = nbrchr( k )
C
C         Fifth Character = small letter, a to x,
C           in 5 minute longitude blocks
C           based on odd or even longitude degrees
C
C             Note: real variables latmin and lngmin "ifix"ed
C                   to integers
C
      if( loew .eq. east )
     &   then
            j = ifix( lngmin / 4.999 ) + 1
         else
            j = ifix( lngmin / 5.001 ) + 1
      end if
      neveod = ( lngdeg / 2 ) * 2
      if( lngdeg .eq. neveod )
     &   then
C                "even"
             k = j
         else
C                "odd"
             k = 12 + j
             if( k .eq. 25 ) k = 1
      end if
      grid( 5 ) = ltrsml( k )
C
C         Sixth Character = small letter, a to x,
C               in 2.5 minute latitude blocks
C
      if( lans .eq. north )
     &   then
            k = ifix( latmin / 2.499 ) + 1
         else
            k = ifix( latmin / 2.501 ) + 1
      end if
      if( k .eq. 25 ) k = 1
      grid( 6 ) = ltrsml( k )
C
C    South Pole grid( 2 ) = "A", North Pole grid( 2 ) = "R"
C
      if( lad .eq. 90 ) then
         grid( 1 ) = ltrbig( 1 )
         grid( 3 ) = nbrchr( 10 )
         grid( 4 ) = nbrchr( 10 )
         grid( 5 ) = ltrsml( 1 )
         grid( 6 ) = ltrsml( 1 )
      end if
C
C        Meridian 180
C
      if( lod .eq. 180 ) then
         grid( 1 ) = ltrbig( 1 )
         grid( 3 ) = nbrchr( 10 )
         grid( 5 ) = ltrsml( 1 )
      end if
C
      return
      end
-----------------------------------------------------------------------------
-- 

                  R. J. Hanson  N9DZZ  ihnp4!ihuxq!hanson
                  AT&T Bell Labs  Room IW 1A-407
                  1100 East Warrenville Road
                  Naperville, IL  60566      312-979-7663