anchor.diff:            goto 101
     103 continue
   
  - 9999 format (2(f10.3),3(f14.4)) 
  + 9999 format (2(f10.3),3(f14.4))
   
         END
   
   C======================================================================C
   
         SUBROUTINE readfaults(nflt,evlo,evla,evdp,str,dip,rak,slip,dy,dx,
  -     1                      area,flttyp,maxflt)
  -
  -      IMPLICIT none
  -      INTEGER flt,nflt,maxflt,flttyp(maxflt)
  -      REAL*8 evlo(maxflt),evla(maxflt),evdp(maxflt),str(maxflt),
  -     1       dip(maxflt),rak(maxflt),slip(maxflt),dy(maxflt),dx(maxflt),
  -     2       area(maxflt)
  -      
  +     1                      area,flttyp,FMAX)
  +
  +      IMPLICIT none
  +      INTEGER flt,nflt,FMAX,flttyp(FMAX)
  +      REAL*8 evlo(FMAX),evla(FMAX),evdp(FMAX),str(FMAX),
  +     1       dip(FMAX),rak(FMAX),slip(FMAX),dy(FMAX),dx(FMAX),
  +     2       area(FMAX)
  +
         flt = 0
     201 flt = flt + 1
         read (21,*,END=202) evlo(flt),evla(flt),evdp(flt),str(flt),
  
positive.code: C----------------------------------------------------------------------C
  
        SUBROUTINE xy2NE(uN,uE,ux,uy,str)
        
        IMPLICIT none
        REAL*8 uN,uE,ux,uy,str,theta,uhor
        REAL*8 pi,d2r
        PARAMETER (pi=4.0d0*datan(1.0d0),d2r=pi/1.8d2)
        
        theta = datan2(uy,ux)
        uhor = dsqrt(ux*ux+uy*uy)
        theta = d2r*str - theta
        uN = uhor*dcos(theta)
        uE = uhor*dsin(theta)
        
        RETURN
        END
  
  C----------------------------------------------------------------------C
  
        SUBROUTINE checkctrlfiles(srcfile,stafile,haffile,verbose)
        IMPLICIT none
        CHARACTER*20 srcfile,stafile,haffile
        LOGICAL ex,verbose
  
        srcfile = 'faults.txt'
        stafile = 'stations.txt'
        haffile = 'structure.txt'
  C----
  C Fault file
  C----
     11 if (verbose) write (*,9996,advance='no'),srcfile
        inquire(file=srcfile,EXIST=ex)
        if (.not.ex) then
            write (*,8889) srcfile
            write (*,8886)
            read *,srcfile
            if (srcfile.eq.'quit') stop
            if (srcfile.eq.'help') call usage()
            goto 11
        else
            if (verbose) write(*,9999)
        endif
  C----
  C Stations
  C----
     12 if (verbose) write (*,9997,advance='no'),stafile
        inquire (file=stafile,EXIST=ex)
        if (.not.ex) then
            write (*,8889) stafile
            write (*,8887)
            read *,stafile
            if (stafile.eq.'quit') stop
            if (stafile.eq.'help') call usage()
            goto 12
        else
            if (verbose) write(*,9999)
        endif
  C----
  C Halfspace
  C----
     13 if (verbose) write (*,9998,advance='no'),haffile
        inquire (file=haffile,EXIST=ex)
        if (.not.ex) then
            write (*,8889) haffile
            write (*,8888)
            read *,haffile
            if (haffile.eq.'quit') stop
            if (haffile.eq.'help') call usage()
            goto 13
        else
            if (verbose) write(*,9999)
        endif
  
   9996 format('Looking for fault file:      ',A20)
   9997 format('Looking for station file:    ',A20)
   9998 format('Looking for half-space file: ',A20)
   9999 format('FOUND')
   8886 format('Enter name of fault file, "quit", or "help":')
   8887 format('Enter name of station file, "quit", or "help":')
   8888 format('Enter name of half-space file, "quit" or "help":')
   8889 format('No file named ',A20)
  
        RETURN
        END
  
  C----------------------------------------------------------------------C
  
        SUBROUTINE gcmdln(verbose)
  
        IMPLICIT none
        INTEGER i,narg
        CHARACTER*25 tag
        LOGICAL verbose
  
        verbose = .false.
  
        narg = iargc()
        i = 0
    101 i = i + 1
        if (i.gt.narg) goto 102
        call getarg(i,tag)
        if (tag(1:2).eq.'-V') then
            verbose = .true.
        elseif (tag(1:2).eq.'-h'.or.tag(1:2).eq.'-?') then
            call usage()
        endif
        goto 101
    102 continue
        RETURN
        END
  
  C----------------------------------------------------------------------C
  
        SUBROUTINE usage()
        IMPLICIT none
        write (*,*)
       1 'Usage: flt2displacement -V -h/-?'
        write (*,*)
  
negative.code: C   1 for finite source
  C----
        call readfaults(nflt,evlo,evla,evdp,str,dip,rak,slip,dy,dx,area,
       1                flttyp,FMAX)
  C----
  C Calculate net displacements at each station
  C----
  