anchor.diff:            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)
  +c
  +c...  store element nodes in the proper family and update the pointer
  +c     array for that family
  +c
  +        iloc=ivftmp(imat)
  +        call iquate(ien(1,iloc),itmp,nen)
  +        ivftmp(imat)=ivftmp(imat)+ione
         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)
  +        write(kp,1000,err=50) numelv
  +        ielg=izero
  +        do ifam=1,nvfamilies
  +          nelfamily=ivfamily(1,ifam)
  +          matmod=ivfamily(2,ifam)
  +          do ielf=1,nelfamily
  +            ielg=ielg+ione
  +            write(kp,1000) ielg,matmod,ietypev,ngauss,
  +     &       (ien(j,ielg),j=1,nen)
  +          end do
           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) numelv,nen,ngauss
  +        write(kp,err=50) ivfamily
           write(kp,err=50) ien
           close(kp)
         end if
  
positive.code: c
  c...  local variables
  c
        integer imat,npage,matmod,i,n,j,inf,ietypei,ngauss,nstate,imatvar
        integer ietype,nen,i1,i2,incstate0,nstatesz0
  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)
        nstatesz=izero
        ngausstot=izero
        ndmatsz=izero
        incstate0=izero
        nstatesz0=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)
        end do
  cdebug      write(6,*) "indmat:",(indmat(idb),idb=1,numat)
  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
            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
            ierr=107
            errstrng="read_connect"
            return
  
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
  