      subroutine scfcontrol(nfdpbcalc,nreal,ninteger,natoms,nmaxorbs,
     &                      nmaxaux,nmaxpts,nmaxesp,mesp,nmaxiterations,
     &                      nfunctional,idiis,ngridtype,iptsflag,
     &                      ncenters,nptcharges,nbsystems,level,nalpha,
     &                      nbeta,nconts,ncontp,ncontd,ncds,ncdspd,nxcs,
     &                      nxcspd,ixcfit,natomtype,nptsatom,nshels,
     &                      nshelp,nsheld,ilfunc,icfunc,ngaussians,
     &                      mtloca,nfuncatom,icdlfunc,icdcfunc,ixclfunc,
     &                      ixccfunc,isys,iwkvec,epsilon,econvergence,
     &                      dmixing,elevelshift,cutoff,coord,charge,
     &                      coordpc,ptcharge,core,focka,fockb,focke,
     &                      dmta,dmtb,coeffa,coeffb,overlapinv,alpha,
     &                      coeffs,alphacd,coefscd,coefpcd,coefdcd,
     &                      alphaxc,coefsxc,coefpxc,coefdxc,cdfitc,
     &                      xcfita,xcfitb,xcfite,xcfitesave,tvector,
     &                      tveca,tvecb,tvece,wkvec)

c  this subroutine written by alain st-amant of the department of
c  pharmaceutical chemistry, university of california, san francisco.
c  all rights reserved.  this is part of the DeFT project.

      implicit real*8(a-h,o-z)

      include "mpif.h"

      dimension natomtype(*),nptsatom(*),nshels(*),nshelp(*),nsheld(*),
     &          ilfunc(*),icfunc(*),ngaussians(*),mtloca(*),
     &          nfuncatom(*),icdlfunc(*),icdcfunc(*),ixclfunc(*),
     &          ixccfunc(*),isys(natoms,*),iwkvec(*)

      dimension cutoff(*),coord(3,*),charge(*),coordpc(3,*),ptcharge(*),
     &          core(*),focka(*),fockb(*),focke(*),dmta(*),dmtb(*),
     &          coeffa(nmaxorbs,*),coeffb(nmaxorbs,*),
     &          overlapinv(nmaxorbs,*),alpha(*),coeffs(*),alphacd(*),
     &          coefscd(*),coefpcd(*),coefdcd(*),alphaxc(*),coefsxc(*),
     &          coefpxc(*),coefdxc(*),cdfitc(*),xcfita(*),xcfitb(*),
     &          xcfite(*),xcfitesave(*),tvector(*),tveca(*),tvecb(*),
     &          tvece(*),wkvec(*)

      call mpi_comm_rank(mpi_comm_world,myid,ierr)
      call mpi_comm_size(mpi_comm_world,numprocs,ierr)

      call mpi_bcast(nfdpbcalc,1,mpi_integer,0,mpi_comm_world,ierr)

      if(nfdpbcalc.eq.1) then

         call delphidr(nreal,ninteger,natoms,nmaxorbs,nmaxaux,nmaxpts,
     &                 nmaxesp,mesp,nmaxiterations,idiis,ngridtype,
     &                 nfunctional,iptsflag,ncenters,nptcharges,
     &                 nbsystems,level,nalpha,nbeta,nconts,ncontp,
     &                 ncontd,ncds,ncdspd,nxcs,nxcspd,ixcfit,natomtype,
     &                 nptsatom,nshels,nshelp,nsheld,ilfunc,icfunc,
     &                 ngaussians,mtloca,nfuncatom,icdlfunc,icdcfunc,
     &                 ixclfunc,ixccfunc,isys,iwkvec,cutoff,epsilon,
     &                 econvergence,dmixing,elevelshift,coord,charge,
     &                 coordpc,ptcharge,core,focka,fockb,focke,dmta,
     &                 dmtb,coeffa,coeffb,overlapinv,alpha,coeffs,
     &                 alphacd,coefscd,coefpcd,coefdcd,alphaxc,coefsxc,
     &                 coefpxc,coefdxc,cdfitc,xcfita,xcfitb,xcfite,
     &                 tvector,tveca,tvecb,tvece,xcfitesave,wkvec)

                         else

         call scfrun(nreal,ninteger,natoms,nmaxorbs,nmaxaux,nmaxpts,
     &               nfunctional,nmaxiterations,idiis,ngridtype,
     &               ncenters,nptcharges,nbsystems,level,nalpha,nbeta,
     &               nconts,ncontp,ncontd,ncds,ncdspd,nxcs,nxcspd,
     &               ixcfit,natomtype,nptsatom,nshels,nshelp,nsheld,
     &               ilfunc,icfunc,mtloca,ngaussians,nfuncatom,icdlfunc,
     &               icdcfunc,ixclfunc,ixccfunc,isys,iwkvec,
     &               econvergence,dmixing,elevelshift,diiserror,cutoff,
     &               coord,charge,coordpc,ptcharge,core,focka,fockb,
     &               focke,dmta,dmtb,coeffa,coeffb,alpha,coeffs,alphacd,
     &               coefscd,coefpcd,coefdcd,alphaxc,coefsxc,coefpxc,
     &               coefdxc,cdfitc,xcfita,xcfitb,xcfite,xcfitesave,
     &               tvector,tveca,tvecb,tvece,overlapinv,wkvec)

                         endif

      return
      end
