      subroutine readif(ix,x,mode)
c  To read input with <cr>-for-defaults.
c  Note this is written to minimize the amount of recoding
c  and definition of new variables needed to convert programs
c  from VAX to PC.
c
c  Call following an "Enter...[def]:" request.
c
c  mode: 1 if integer (ix); 2 if real (x) variable is expected.
c    If mode is 1, x is a dummy and is returned unchanged; if
c    mode is 2, ix is a dummy and is unchanged.
c
c    On return, mode=0 if response is <cr>, indicating default
c      selected and ix and x are returned unchanged,;
c      mode=1 or 2 if integer or real is returned, and either
c      ix or x, respectively, is read and returned;
c      mode=4 if an error occurred.
c
      character*80 ans,blank
      data blank/' '/
      if(mode.ne.1.and.mode.ne.2)then
        mode=4
        go to 99
      endif
      read(5,1) ans
1     format(a)
      if (ans.eq.blank)then
        mode=0
        go to 99
      else
        if(mode.eq.2)go to 10
        read(ans,2) ix
2       format(bn,i80)
        go to 99
10      continue
        do 4 k=80,1,-1
4       if(ans(k:k).ne.' ')go to 5
5       do 6 i=1,k
        if(ans(i:i).eq.'.')go to 7
6     continue
      ans(k+1:k+1)='.'
7     read(ans,8)x
8     format(g30.9)
      endif
99    return
      end
