      SUBROUTINE JCARIN (COORD,XPARAM,STEP,PRECI,B,NCOL)
      implicit double precision (A-H,O-Z)
      include 'SIZES'
      include 'MOP6FILE'
C     JACOBIAN dCARTESIAN/dINTERNAL, WORKED OUT BY FINITE DIFFERENCE.
C  INPUT
C     XPARAM(*) : INTERNAL COORDINATES
C     STEP      : STEP SIZE FOR FINITE DIFFERENCE METHOD
C     PRECI     : .TRUE. if 2-POINTS FINITE DIFFERENCES TO BE USED,
C                 .FALSE. OTHERWISE.
C  OUTPUT
C     B(NVAR,NCOL) : JACOBIAN, STEP TIME TOO LARGE.
C
      common /GEOSYM/ NDEP, LOCPAR(MAXPAR), IDEPFN(MAXPAR),
     1                      LOCDEP(MAXPAR)
      common /MOLKST/ NUMAT,NAT(NUMATM),NFIRST(NUMATM),NMIDLE(NUMATM),
     1                NLAST(NUMATM), NORBS, NELECS,NALPHA,NBETA,
     2                NCLOSE,NOPEN,NDUMY,FRACT
     3       /GEOVAR/ NVAR,LOC(2,MAXPAR), IDUMY, YPARAM(MAXPAR)
     4       /EULER / TVEC(3,3),ID
     5       /UCELL / L1L,L2L,L3L,L1U,L2U,L3U
     6       /GEOM  / GEO(3,NUMATM)
      dimension COORD(3,*),XPARAM(*),B(NVAR,*), COOLD(3,NUMATM*27)
      logical PRECI
C
      NCOL=3*NUMAT
      if (ID.NE.0)
     1 NCOL=NCOL*(L1U-L1L+1)*(L2U-L2L+1)*(L3U-L3L+1)
C
C     INTERNAL OF CENTRAL POINT
      do 10 IVAR=1,NVAR
   10 GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)
C
      if (ID.EQ.0) then
C
C        MOLECULAR SYSTEM
C        ----------------
         do 30 IVAR=1,NVAR
C        STEP FORWARD
            GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)+STEP
            if (NDEP.NE.0) call SYMTRY
            call GMETRY (GEO,COORD)
            do 20 J=1,NCOL
   20       B(IVAR,J)=COORD(J,1)
   30    GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)
         if (PRECI) then
            do 50 IVAR=1,NVAR
C           STEP BACKWARD
               GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)-STEP
               if (NDEP.NE.0) call SYMTRY
               call GMETRY (GEO,COORD)
               do 40 J=1,NCOL
   40          B(IVAR,J)=B(IVAR,J)-COORD(J,1)
   50       GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)
         else
C           CENTRAL POINT
            if (NDEP.NE.0) call SYMTRY
            call GMETRY (GEO,COORD)
            do 60 IVAR=1,NVAR
               do 60 J=1,NCOL
   60       B(IVAR,J)=B(IVAR,J)-COORD(J,1)
         end if
      else
C
C        SOLID STATE
C        -----------
         do 80 IVAR=1,NVAR
C        STEP FORWARD
            GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)+STEP
            if (NDEP.NE.0) call SYMTRY
            call GMETRY (GEO,COORD)
            IJ=0
            do 70 II=1,NUMAT
               do 70 IL=L1L,L1U
                  do 70 JL=L2L,L2U
                     do 70 KL=L3L,L3U
                        do 70 LL=1,3
                           IJ=IJ+1
   70       B(IVAR,IJ)=COORD(LL,II)
     1            +TVEC(LL,1)*IL+TVEC(LL,2)*JL+TVEC(LL,3)*KL
   80    GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)
         if (PRECI) then
            do 100 IVAR=1,NVAR
C           STEP BACKWARD
               GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)-STEP
               if (NDEP.NE.0) call SYMTRY
               call GMETRY (GEO,COORD)
               IJ=0
               do 90 II=1,NUMAT
                  do 90 IL=L1L,L1U
                     do 90 JL=L2L,L2U
                        do 90 KL=L3L,L3U
                           do 90 LL=1,3
                              IJ=IJ+1
   90          B(IVAR,IJ)=B(IVAR,IJ)-COORD(LL,II)
     1                -TVEC(LL,1)*IL-TVEC(LL,2)*JL-TVEC(LL,3)*KL
  100       GEO(LOC(2,IVAR),LOC(1,IVAR))=XPARAM(IVAR)
         else
C           CENTRAL POINT
            if (NDEP.NE.0) call SYMTRY
            call GMETRY (GEO,COORD)
            IJ=0
            do 110 II=1,NUMAT
               do 110 IL=L1L,L1U
                  do 110 JL=L2L,L2U
                     do 110 KL=L3L,L3U
                        IJ=IJ+1
                        do 110 LL=1,3
  110       COOLD(LL,IJ)=COORD(LL,II)
     1                  +TVEC(LL,1)*IL+TVEC(LL,2)*JL+TVEC(LL,3)*KL
            do 120 IVAR=1,NVAR
               do 120 IJ=1,NCOL
  120       B(IVAR,IJ)=B(IVAR,IJ)-COOLD(IJ,1)
         end if
      end if
      return
      end
