anchor.diff:  c Convert line of sight displacement to phase difference from satellite
   c----
      13 read (10,*,end=14) stlo,stla,ulos
  -          ulos = 100.0*ulos
  -          phase = 2.0*(2.0*pi)*ulos/wvl
  -          phase = mod(phase,2.0*pi)
  -          if (phase.lt.-pi) phase = phase + 2.0*pi
  -          if (phase.gt.pi) phase = phase - 2.0*pi
  +          ulos = 100.0d0*ulos
  +          phase = 2.0d0*tpi*ulos/wvl
  +          phase = dmod(phase,tpi)
  +          if (phase.lt.-pi) phase = phase + tpi
  +          if (phase.gt.pi) phase = phase - tpi
             write (20,*) stlo,stla, phase
             goto 13
      14 continue
  
positive.code: c the wavelength of the InSAR satellite.
  c----
        IMPLICIT NONE
        REAL pi,d2r
        PARAMETER (pi=4.0*atan(1.0),d2r=pi/180.0)
  
        REAL stlo,stla,ulos,wvl,phase
        
        INTEGER narg,i
        CHARACTER*30 ifile,ofile
  
        call gcmdln(wvl,ifile,ofile)
  
        open (unit=10,file=ifile,status='old')
        open (unit=20,file=ofile,status='unknown')
  
negative.code:           if (tag(1:2).eq.'-w') then
                i = i + 1
                call getarg(i,tag)
                read (tag,'(BN,F12.0)') wvl
            elseif (tag(1:2).eq.'-f') then
                i = i + 1
                call getarg(i,ifile)
            elseif (tag(1:2).eq.'-o') then
                i = i + 1
                call getarg(i,ofile)
            elseif (tag(1:2).eq.'-h') then
                call usage(' ')
            endif
            goto 11
     12 continue
        RETURN
        END
  
  C----------------------------------------------------------------------C
  
        SUBROUTINE usage(str)
        IMPLICIT none
        INTEGER lstr
        CHARACTER str*(*)
        if (str.ne.' ') then
            lstr = len(str)
            write(*,*) str(1:lstr)
            write(*,*)
        endif
        write(*,*)
       1 'Usage: wraplos -w WVLNTH -f IFILE -o OFILE [-h]'
        write(*,*)
        write(*,*)
       1 '-w WVLNTH  Wavelength of radar signal (cm)'
        write(*,*)
       1 '-f IFILE   Input LOS displacement file (lo la uLOS)'
        write(*,*)
       1 '-o OFILE   Output phase file (lo la phase(rad))'
        write (*,*)
       1 '-h         Online help (this message)'
        write (*,*)
        STOP
        END
  
  