C Example program using symmtery library routines
C MSYMLB and SETLIM.
C
C The program gets the limits of the CCP4 asymmetric
C unit for each spacegroup no. using the library
C routine SETLIM.
C The routine MSYMLB is used to get the spacegroup
C name from the number. This should be replaced
C with a call to MSYMLB3 after version 3.5 of CCP4.
C
C   To run: compile as "symm_get_box" and run the
C   executable (no arguments or input files
C   required).
C
C Output consists of the spacegroup name
C corresponding to the number (and real space
C asymmetric unit limits, if defined) for each of the
C 230 spacegroups.
C
C Note that the asymmetric unit definition
C is not unique; these are the CCP4 definitions.
C
      PROGRAM SYMM_GET_BOX
C
      IMPLICIT NONE
C
      INTEGER I,J,LSPGRP,NSYMP,NSYM
      REAL    XYZLIM(2,3),RSYM(4,4,200)
      CHARACTER*20 NAMSPG,NAMPG
C
C CCP4 initialisations
C
      CALL CCPFYP
C
C This loop steps through all 230 spacegroups
C
      DO 10 LSPGRP = 1,230
C
C Clear the spacegroup names
C
        NAMSPG = ' '
        NAMPG  = ' '
C
C Set the limits to zero
C
        DO 20 I = 1,2
        DO 30 J = 1,3
          XYZLIM(I,J) = 0.0
 30     CONTINUE
 20     CONTINUE
C
C Call MSYMLB to get the s/grp name
C
        CALL MSYMLB(11,LSPGRP,NAMSPG,NAMPG,NSYMP,
     +              NSYM,RSYM)
C
C Call SETLIM to get the limits for this s/grp
C
        CALL SETLIM(LSPGRP,XYZLIM)
C
C Write out the spacegroup information
C
          WRITE(6,FMT=9040)
          WRITE(6,FMT=9010) LSPGRP, NAMSPG, NSYM, NAMPG, NSYMP
 9010     FORMAT (I3,': Spacegroup name ',A20,/,
     +               ' has ',I3,' symmetry operators',//,
     +               'The corresponding pointgroup is ',A20,/,
     +               ' with ',I3,' primitive operators',//)
C
C If xyzlim(1,1) = -1.0 then s/grp is unrecognised
C
        IF (XYZLIM(1,1).EQ.-1.0) THEN
C
          WRITE(6,FMT=9020)
 9020     FORMAT ('This spacegroup is not recognised by SETLIM')
C
C Otherwise, print the limits
C
        ELSE
C
          WRITE(6,FMT=9030) XYZLIM(2,1),XYZLIM(2,2), XYZLIM(2,3)
 9030     FORMAT ('Upper limits of the asymmetric unit are:',/
     +            ' x : ',F8.3,'   y : ',F8.3,'   z : ',F8.3,/)
C
        ENDIF
C
C Draw a line under this entry
C
        WRITE(6,FMT=9040)
 9040   FORMAT('-----------------------------------------------',/)
C
C Do the next spacegroup
C
 10   CONTINUE
C
C End the program cleanly
C
      CALL CCPERR (0, 'Normal termination')
C
      END