      character sta*8,rest57*57
      data n,latdif,londif/3*0/
c Plouff 12-94. CHNGLOCS--ADD constants to geographic coordinates
      call promt (latdif,londif)
      if (latdif .gt. 90000) stop
    1 read (15,500,err=7,end=9) sta,latd,latm,lond,lonm,rest57
  500 format (bz,a8,i3,3i4,a57)
      n=n+1
      latm=latm+latdif
      if (latm .gt. 5999) then
        latd=latd+1
        latm=latm-6000
      end if
      if (latm .lt. 0) then
        latd=latd-1
        latm=latm+6000
      end if
      jond=iabs(lond)
      lonm=lonm+londif
      if (lonm .gt. 5999) then
        jond=jond+1
        lonm=lonm-6000
      end if
      if (lonm .lt. 0) then
        jond=jond-1
        lonm=lonm+6000
      end if
c Allows for input of negative U.S. longitude
      if (lond .lt. 0) jond=-jond
      write (7,700) sta,latd,latm,jond,lonm,rest57
  700 format (a8,i3,3i4,a57)
      go to 1
    7 n=n+1
      print 607, n
      write (16,607) n
  607 format (' **STOP. Format error on input line',i5,'.',/,
     1 ' **You may want to DELETE the output file.')
      go to 99
    9 print 609, n
      write (16,609) n
  609 format (' There are',i5,' stations in your plouff input file.')
      print 699
  699 format (' A record of this session is in file CHNGLOCS.PNT')
   99 close (15)
      close (16)
      close (7)
      stop
      end
      subroutine promt (latdif,londif)
      character ans*1,tim*5,clock*8,dat*9
      character*65 infile,outfile
      logical exists
c VAX date and time functions may need -lV77 option in UNIX
      call date(dat)
      call time(clock)
      tim=clock(1:5)
      print 100, dat,tim
  100 format (' CHNGLOCS.  Plouff, 12-1994.  To add constants to ',
     1 'latitudes and longitudes',/,'  (plouff format).  ',a9,1x,a5)
c Print record of this session
      inquire (file='CHNGLOCS.PNT',exist=exists)
      if (exists) then
        print 101
  101   format (' Print file CHNGLOCS.PNT already exists.',/,' Do you',
     1   ' want to STOP to save it?')
        read 501, ans
  501   format (a1)
        if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') then
          latdif=9999999
          return
        end if
      end if
      print 102
  102 format (' TYPE the name of your plouff file to be revised:')
      read 565, infile
  565 format (a65)
      inquire (file=infile,exist=exists)
      if (.not. exists) then
        print 103
  103   format (' That file was not found.  Try once more.')
        print 102
        read 565, infile
        inquire (file=infile,exist=exists)
        if (.not. exists) then
          print 104
  104     format (' **STOP.  The specified input file was not found.')
          latdif=9999999
          return
        end if
      end if
      print 105
  105 format (' TYPE a name for your revised plouff-file:')
      read 565, outfile
      inquire (file=outfile,exist=exists)
      if (exists) then
        print 106
  106   format (' Your output file already exists.',/,' Do you ',
     1   'want to STOP to save it?')
        read 501, ans
        if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') then
          latdif=9999999
          return
        end if
      end if
      open (16,file='CHNGLOCS.PNT',form='formatted',status='unknown')
      write (16,100) dat,tim
      write (16,601) infile,outfile
  601 format (' Input file: ',a65,/,' Revised output file: ',a65)
      print 107
  107 format (' You will type constants to be added to the input ',
     1 'coordinates, that is, to',/,'  move the locations to the ',
     2 'north and to the west for positive numbers and to',/,'  the ',
     3 'south and east for negative numbers.  Units are decimal ',
     4 'minutes.')
    2 print 108
  108 format (' TYPE the northward latitude shift (minutes):')
      read (5,*,err=2) chnglat
      latdif=100.0*chnglat+0.005
      if (chnglat .lt. 0.0) latdif=0.01*chnglat-0.005
    3 print 109
  109 format (' TYPE the westward longitude shift (minutes):')
      read (5,*,err=3) chnglon
      londif=100.0*chnglon+0.005
      if (chnglon .lt. 0.0) londif=0.01*chnglon-0.005
      write (16,602) chnglat,chnglon
  602 format (' Your constant shifts are',f6.2,' minutes north and',
     1 f6.2,' minutes west.')
      open (15,file=infile,form='formatted',status='old',blank='zero')
      open (7,file=outfile,form='formatted',status='unknown')
      return
      end
