anchor.diff:  c
   c...  local variables
   c
  -      integer imat,npage,matmod,i,n,j,inf,ietypei,ngauss,nstate,imatvar
  -      integer ietype,nen,i1,i2,incstate0,nstatesz0
  +      integer ifam,incstate0,nstate0max,nelfamily,j,matmod,nstate
  +      integer nstate0,nprop,i,n,ietypev,imat,inf,iloc,npage,ielf,ielg
  +      integer itmp(nenmax)
   cdebug      integer idb,jdb
   c
   cdebug      write(6,*) "Hello from read_connect_f!"
  -cdebug      write(6,*) nconsz,numelt,numnp,numat,nstatesz,ndmatsz,kr,kw,kp
  -cdebug      write(6,*) (neni(idb),idb=1,netypesi)
  -cdebug      write(6,*) "infetype:"
  -cdebug      do idb=1,netypes
  -cdebug        write(6,*) (infetype(jdb,idb),jdb=1,4)
  -cdebug      end do
  -cdebug      write(6,*) "infmat:"
  -cdebug      do idb=1,numat
  -cdebug        write(6,*) (infmat(jdb,idb),jdb=1,3)
  -cdebug      end do
  -cdebug      write(6,*) "infmatmod:"
  -cdebug      do idb=1,nmatmodmax
  -cdebug        write(6,*) (infmatmod(jdb,idb),jdb=1,5)
  -cdebug      end do
  -      call ifill(ien,izero,nconsz)
  -      call ifill(indmat,izero,numat)
  -      call ifill(imgrp,izero,numat)
  -      call ifill(infiel,izero,iseven*numelt)
  +      call ifill(ien,izero,nen*numelv)
  +      call ifill(ivfamily,izero,5*nvfamilies)
  +      ifam=izero
         nstatesz=izero
  -      ngausstot=izero
  -      ndmatsz=izero
  +      nstatesz0=izero
  +      npropsz=izero
         incstate0=izero
  -      nstatesz0=izero
  +      nstate0max=izero
  +      nelfamily=izero
         if(nprestrflag.ne.izero) incstate0=ione
         ierr=izero
   c
  -c...  set initial pointers for different material types
  -c
  -      indmat(1)=ione
  -      do imat=2,numat
  -        indmat(imat)=indmat(imat-1)+infmat(2,imat-1)
  +c...  set up element family information array (ivfamily)
  +c
  +      do j=1,maxvfamilies
  +        if(ivflist(1,j).ne.izero) then
  +          ifam=ifam+ione
  +          if(ifam.eq.ione) then
  +            ivftmp(ifam)=ione
  +          else
  +            ivftmp(ifam)=ivftmp(ifam-ione)+nelfamily
  +          end if
  +          nelfamily=ivflist(1,j)
  +          matmod=ivflist(2,j)
  +          ivfamily(1,ifam)=nelfamily
  +          ivfamily(2,ifam)=matmod
  +          nstate=infmatmod(2,matmod)
  +          nstate0=infmatmod(6,matmod)
  +          nstate0max=max(nstate0max,nstate0)
  +          nprop=infmatmod(3,matmod)
  +          ivfamily(3,ifam)=nstatesz+ione
  +          ivfamily(4,ifam)=nstatesz0+ione
  +          ivfamily(5,ifam)=npropsz+ione
  +          nstatesz=nstatesz+nstate*ngauss*nelfamily
  +          nstatesz0=nstatesz0+incstate0*nstate0*ngauss*nelfamily
  +          npropsz=npropsz+nprop
  +        end if
         end do
  -cdebug      write(6,*) "indmat:",(indmat(idb),idb=1,numat)
  +c
  +c...  set size of state0 array if there are no prestresses
  +c
  +      if(nprestrflag.eq.izero) nstatesz0=ngauss*nstate0max
   c
   c...  read connectivity, material number, and infinite element info
   c
  -      infiel(1,1)=ione
         open(kr,file=ifile,status="old",err=20)
         call pskip(kr)
  -      do i=1,numelt
  -        if(i.ne.ione) infiel(1,i)=infiel(1,i-1)+neni(ietypei)
  -        read(kr,*,end=30,err=30) n,ietypei,imat,inf,
  -     &   (ien(j),j=infiel(1,i),infiel(1,i)+neni(ietypei)-1)
  -        infiel(2,i)=imat
  -c
  -c...  set global element type, after first checking for illegal
  -c     element type
  -c
  -        if(ietypei.le.izero.or.ietypei.gt.netypesi) then
  +      do i=1,numelv
  +        read(kr,*,end=30,err=30) n,ietypev,imat,inf,(itmp(j),j=1,nen)
  +        ifam=imat
  +        matmod=ivfamily(2,ifam)
  +c
  +c...  check for illegal element type
  +c
  +        if(ietypev.le.izero.or.ietypev.gt.netypesi) then
             ierr=106
             errstrng="read_connect"
             return
           end if
  -        call infcmp(ietypei,infiel(3,i),inf)
  -c
  -c...  index element into its material type group, after first checking
  -c     for illegal material type or material model
  -c
  -        matmod=infmat(1,imat)
  -        if(imat.le.izero.or.imat.gt.numat) then
  +clater        call infcmp(ietypev,infiel(3,i),inf)
  +c
  +c...  check for illegal material type or material model
  +c
  +        if(imat.le.izero.or.imat.gt.nvfamilies) then
             ierr=107
             errstrng="read_connect"
             return
  
positive.code:           errstrng="read_connect"
            return
          end if
  cdebug        write(6,*) "i,imat,indmat(imat):",i,imat,indmat(imat)
          infiel(4,indmat(imat))=i
          indmat(imat)=indmat(imat)+ione
  c
  c...  set state variable and material matrix indices, and increment the
  c     total size of the state variable and material matrices.
  c
          ngauss=infetype(1,infiel(3,i))
          infiel(5,i)=nstatesz+ione
          infiel(7,i)=nstatesz0+ione
          ngausstot=ngausstot+ngauss
          nstate=infmatmod(2,matmod)
          imatvar=infmatmod(4,matmod)
          nstatesz=nstatesz+nstate*ngauss
          nstatesz0=nstatesz0+incstate0*ngauss
          if(imatvar.eq.izero) then
            if(imgrp(imat).eq.izero) then
              infiel(6,i)=ndmatsz+ione
              ndmatsz=ndmatsz+ngaussmax
              imgrp(imat)=infiel(6,i)
            else
              infiel(6,i)=imgrp(imat)
  cdebug            infiel(6,i)=infiel(6,infiel(4,i-1))
            end if
          else
            infiel(6,i)=ndmatsz+ione
            ndmatsz=ndmatsz+ngauss
          end if
  cdebug        write(6,*) "i,infiel:",i,(infiel(jdb,i),jdb=1,7)
        end do
        if(nprestrflag.eq.izero) nstatesz0=ngaussmax
        close(kr)
  cdebug      write(6,*) "infiel:"
  cdebug      do idb=1,numelt
  cdebug        write(6,*) idb,(infiel(jdb,idb),jdb=1,6)
  cdebug      end do
  c
  c...  output plot info, if desired
  c
        if(idsk.eq.ione) then
          open(kp,file=pfile,err=40,status="old",access="append")
          write(kp,1000,err=50) numelt
          do i=1,numelt
            imat=infiel(2,i)
            ietype=infiel(3,i)
            ngauss=infetype(1,ietype)
            nen=infetype(2,ietype)
            i1=infiel(1,i)
            i2=infiel(1,i)+nen-1
            write(kp,1000) i,imat,ietype,ngauss,(ien(j),j=i1,i2)
          end do
          close(kp)
        else if(idsk.eq.itwo) then
          open(kp,file=pfile,err=40,status="old",access="append",
       &   form="unformatted")
          write(kp,err=50) numelt,nconsz
          write(kp,err=50) infetype
          write(kp,err=50) infiel
          write(kp,err=50) ien
          close(kp)
        end if
  
negative.code: c
  c...  subroutine arguments
  c
        integer nen,ngauss,maxvfamilies,nvfamilies,nprestrflag,numelv
        integer numnp,nstatesz,nstatesz0,npropsz,kr,kw,kp,idout,idsk,ierr
        integer infmatmod(6,nmatmodmax),ivflist(2,maxvfamilies)
        integer ivfamily(5,nvfamilies),ivftmp(nvfamilies),ien(nen,numelv)
        character ifile*(*),ofile*(*),pfile*(*),errstrng*(*)
  c
  c...  local variables
  