      SUBROUTINE ALOCAT (ID1,ID2,ID3,II4,ID5,LAWORK,LNWORK)

*** ALLOCATE STORAGE

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)
      PARAMETER (MXSSN = 9999)
      COMMON /GPS/ MAXVEC
      COMMON /STRUCT/ NSTA,NAUX,NUNK,IDIM,NSTAS,NOBS,NCON,NZ,NCD
      COMMON /ALICE/ IPRSZ
      COMMON / SSNTBL / NSSN,ISSISN(MXSSN)

*** THE PARAMETER NVECS IS THE MAXIMUM NUMBER OF GPS VECTORS.
*** IT CONTROLS THE DIMENSION OF THE VECTORS ICM, CM, AND CM2 AND THE
*** VALUE OF THE VARIABLE MAXICM WHICH ARE ((NVECS+1)*3+1+6).
*** (THE 6 IS FOR THE CRUSTAL DYNAMICS PARAMETERS, THERE IS ONLY ONE
*** SET PER GPS OBS., REGARDLESS OF THE NUMBER OF VECTORS IN THE OBS.)
*** ALSO, THE DIMENSION OF THE VECTORS KINDS, ISNS, JSNS, LOBS,
*** AND GMDES ARE (3*NVECS).
*** FINALLY, THE VECTOR ICM2 ARE ((NVECS+1)*3+1).

*** COMPUTE STRUCTURE PARAMETERS

      NSTAS = 3 * NSTA
      NUNK = NCD + NAUX + NZ + 3 * NSTA
      NOBS = 0
      NCON = 0

      LENG = (MAXVEC + 1) * 15    + 1
      MAXROW = 3 * MAXVEC
      MAXCOL = MAXROW + LENG + 5
      LENGPS = MAXROW * MAXCOL


      ID1 = 6 * NSSN + NCD + NAUX + NZ
      ID2 = ID1 + NUNK
      ID3 = ID2 + 3 * NSTA      
      ID4 = ID3 + LENGPS
      ID5 = ID4 + (3 * NUNK + 3) / 2

      II4 = ID4 + ID4

      LAWORK = LAWORK - ID5
      LNWORK = LNWORK - II4

*** SEE IF STORAGE EXCEEDED

      IF ( LAWORK .LE. 2*NUNK ) THEN
        WRITE (6,1) LAWORK,NUNK
    1   FORMAT ('0',I6,' ERROR - DOUBLE PRECISION WORDS IS TOO SMALL',
     &          I5,' FOR PARAMETERS')
        CALL ABORT2
      ELSEIF (IPRSZ.EQ.1) THEN
        WRITE (6,2) LAWORK,NUNK
    2   FORMAT ('0',I8,' DOUBLE PRECISION WORDS AVAILABLE,',
     &          ' # PARAMETERS =',I6)
      ENDIF

      RETURN
      END
