anchor.diff:        prog = 0
         progtag = 0
         call progbar(prog,prog100,progtag)
  -      if (.not.trgmatchsta) read(24,*) trgstr,trgdip,trgrak,frict
  +      if (trgmatchsta.eq.0) read(24,*) trgstr,trgdip,trgrak,frict
     101 read (22,*,end=107) stlo,stla,stdp
  -          if (trgmatchsta) read(24,*) trgstr,trgdip,trgrak,frict
  +          if (trgmatchsta.eq.1) read(24,*) trgstr,trgdip,trgrak,frict
             stdp = 1.0d3*stdp
             do 103 i = 1,3
                 do 102 j = 1,3
  
positive.code: C     static_out: finite fault model in subfault format
  C     stations.txt: list of receiver lon, lat, and depth (km)
  C     structure.txt: vp (m/s) vs (m/s) density (kg/m^3)
  C     targetparams.txt: target fault strike, dip, rake, and
  C                             coefficient of friction
  C
  C Produces the output files:
  
negative.code: 
  C----------------------------------------------------------------------C
  
        SUBROUTINE checkctrlfiles(ffmfile,stafile,haffile,trgfile)
        IMPLICIT none
        CHARACTER*20 ffmfile,stafile,haffile,trgfile
        LOGICAL ex
        inquire(file=ffmfile,EXIST=ex)
        if (.not.ex) call usage('!! Error: no file named '//ffmfile)
        inquire(file=stafile,EXIST=ex)
        if (.not.ex) call usage('!! Error: no file named '//stafile)
        inquire(file=haffile,EXIST=ex)
        if (.not.ex) call usage('!! Error: no file named '//haffile)
        inquire (file=trgfile,EXIST=ex)
        if (.not.ex) call usage('!! Error: no file named '//trgfile)
        RETURN
        END
  
  C----------------------------------------------------------------------C
  
        SUBROUTINE usage(str)
        IMPLICIT none
        INTEGER STER,lstr
        PARAMETER (STER=0)
        CHARACTER str*(*)
  
        if (str.ne.' ') then
            lstr = len(str)
            write(STER,*)
            write(STER,*) str(1:lstr)
            write(STER,*)
        endif
  
        write (STER,*)
       1 'Usage: ff2coulomb -ffm FFMFILE ',
       2                   '-sta STAFILE -haf HAFFILE ',
       2                   '-haf HAFFILE -trg TRGFILE ',
       3                   '-stra STRAFILE -stre STREFILE ',
       4                   '-nor NORMLFILE -shr SHEARFILE ',
       5                   '-coul COULFILE ',
       6                   '-fn -pt -AUTO ',
       7                   '-h -?'
        write(STER,*)
        write(STER,*)
       1 'Compute strains and stresses resulting from finite fault model'
        write(STER,*)
        write (STER,*)
       1 '-ffm FFMFILE   (static_out)     name of finite fault model file'
        write (STER,*)
       1 '-sta STAFILE   (stations.txt)   name of receiver location file'
        write (STER,*)
       1 '-haf HAFFILE   (structure.txt)  name of half-space ',
       2                                  'parameter file'
        write (STER,*)
       1 '-trg TRGFILE   (trgparams.txt)  name of target fault file'
        write (STER,*)
       1 '-stra STRAFILE (strain.out)     name of output strain matrix ',
       2                                  'file'
        write (STER,*)
       1 '-stre STREFILE (stress.out)     name of output stress matrix ',
       2                                  'file'
        write (STER,*)
       1 '-nor NORMLFILE (norml.out)      name of output normal stress ',
       2                                  'file'
        write (STER,*)
       1 '-shr SHEARFILE (shear.out)      name of output shear stress ',
       2                                  'file'
        write (STER,*)
       1 '-coul COULFILE (coul.out)       name of output Coulomb stress ',
       2                                  'file'
        write (STER,*)
       1 '-fn            (default)        treat subfaults as ',
       2                                    'finite sources'
        write (STER,*)
       1 '-pt                             treat subfaults as ',
       2                                       'point sources'
        write (STER,*)
       1 '-AUTO'
        write (STER,*)
       1 '-h                              this online help'
        write (STER,*)
       1 '-?                              this online help'
        write (STER,*)
        write (STER,*)
       1 'FILE FORMATS'
        write (STER,*)
       1 '------------'
        write (STER,*)
       1 'FFMFILE: finite fault model in standard subfault format'
        write (STER,*)
       1 'STAFILE: list of station/receiver locations and depths'
        write (STER,*)
       1 '    stlo stla stdp(km)'
        write (STER,*)
       1 'HAFFILE: half-space parameters'
        write (STER,*)
       1 '    vp(km/s) vs(km/s) dens(kg/m^3)'
        write (STER,*)
       1 'TRGFILE: target fault parameters'
        write (STER,*)
       1 '    str(deg) dip(deg) rak(deg) coeff_frict'
        write (STER,*)
       1 '    NOTE: If NTRG = 1, all faults have same parameters'
        write (STER,*)
       1 '          If NTRG = NSTA, parameters correspond to location'
        write (STER,*)
       1 'STRAFILE: list of station locations (corresponds to STAFILE) ',
       2           'and strain components at receiver'
        write (STER,*)
       1 '    stlo stla eEE eNN eZZ eEN eEZ eNZ'
        write (STER,*)
       1 'STREFILE: list of station locations (corresponds to STAFILE) ',
       2           'and stress components at receiver'
        write (STER,*)
       1 '    stlo stla sEE(Pa) sNN(Pa) sZZ(Pa) sEN(Pa) sEZ(Pa) sNZ(Pa)'
        write (STER,*)
       1 'NORMLFILE: list of station locations (corresponds to STAFILE) ',
       2           'and normal stresses on receiver'
        write (STER,*)
       1 '    stlo stla norml_stress(Pa)'
        write (STER,*)
       1 '    NOTE: positive => dilation'
        write (STER,*)
       1 'SHEARFILE: list of station locations (corresponds to STAFILE) ',
       2           'and shear stresses on receiver'
        write (STER,*)
       1 '    stlo stla shear_stress(Pa)'
        write (STER,*)
       1 '    NOTE: projection of shear traction along rake direction'
        write (STER,*)
       1 'COULFILE: list of station locations (corresponds to STAFILE) ',
       2           'and Coulomb stresses on receiver'
        write (STER,*)
       1 '    stlo stla coul_stress(Pa)'
        write (STER,*)
  
        STOP
        END
  