 
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LSM_PARSETUP     **
C**************************
C
CD-Routine: Set up other LSM parameters - LSM_PARSETUP
C This routine (or one of its alternatives) needs to be called to set
C up the parameters required by the LSM routines in addition to those
C defined within the LSM parameter set itself. Remember to call this
C routine again if any of the previously passed parameter values have changed.
CD-end
CD-Fortran:
      SUBROUTINE LSM_PARSETUP (NPACK, NPLATES, SPIN, CTF, IDIM, CELL)
CD-end
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Set up associated parameters required internally by LSM routines
C
C Author:  Steffi Arzt, John Campbell, July 1997
C
C Arguments:
C
C
      INTEGER IDIM
      INTEGER NPACK
      INTEGER NPLATES(*)
      REAL SPIN(*)
      REAL CTF(IDIM,*)
      REAL CELL(6)

CD-Parameters:
C  NPACK       i (R)   Number of packs
C  NPLATES()   i (R)   Number of plates/pack for each pack
C  SPIN()      r (R)   'spindle' value for each pack (cf LDM parameters)
C  CTF()       r (R)   'ctof' value for each plate and pack -
C                      dimensioned CTOF(IDIM, *) - IDIM must be at
C                      least NPACK. First index packs, 2'nd index plates
C  IDIM        i (R)   First dimension of CTF array
C  CELL(6)     r (R)   Cell parameters A, B, C, ALPHA, BETA, GAMMA
CD-end
C
C Implementation note: Sets 'markup required' flag
C Implementation note: Sets 'more than one plate defined' flag
C Implementation note: Sets 'minimum crystal-film/plate distance' variable
C
C====== PARAMETERS:
C
      INCLUDE 'limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'lsm_flags.finc'
      INCLUDE 'other_scale.finc'
      INCLUDE 'scp.finc'
      INCLUDE 'scps_counters.finc'
C
C====== FUNCTION TYPES:
C

C
C====== LOCALS:
C
      INTEGER I, J 

C     INTEGER I, J                !Temp/loop variables
C
C-------------------------------------------------------------------------------
C
C
C====== Set 'markup-required' flag
C
      MARKUP_REQUIRED = .TRUE.
C
C====== GET LSM-PARAMETERS:
C
      PLFLAG = .FALSE.
      NPK = NPACK
      AMINCTOF = CTF(1,1)
      AMAXCTOF = CTF(1,1)
       DO 20 I = 1, NPK
         NPL(I) = NPLATES(I)
         IF (NPL(I).GT.1) PLFLAG = .TRUE.
         IF (AMINCTOF.GT.CTOF(I,1)) AMINCTOF = CTOF(I,1)
         IF (AMAXCTOF.LT.CTOF(I,1)) AMAXCTOF = CTOF(I,1)
         SPINDLE(I) = SPIN(I)
         DO 10 J = 1, NPLATES(I)
            CTOF(I,J) = CTF(I,J)
 10      CONTINUE
 20   CONTINUE
      A = CELL(1) 
      B = CELL(2)       
      C = CELL(3)       
      ALPHA = CELL(4)    
      BETA = CELL(5) 
      GAMMA = CELL(6)   
      RETURN
      END
