      SUBROUTINE GETCMN(NR,X,NTX,BOX,BETA)
C
C************************************************************************
C                              AMBER                                   **
C                                                                      **
C                  Copyright (c) 1986, 1991, 1995                      **
C             Regents of the University of California                  **
C                       All Rights Reserved.                           ** 
C                                                                      **
C  This software provided pursuant to a license agreement containing   **
C  restrictions on its disclosure, duplication, and use. This software **
C  contains confidential and proprietary information, and may not be   **
C  extracted or distributed, in whole or in part, for any purpose      **
C  whatsoever, without the express written permission of the authors.  **
C  This notice, and the associated author list, must be attached to    **
C  all copies, or extracts, of this software. Any additional           **
C  restrictions set forth in the license agreement also apply to this  **
C  software.                                                           **
C************************************************************************
C
      implicit double precision(a-h,o-z)
#include "files.h"
      LOGICAL FORM
C
C     ----- ROUTINE TO READ THE COORDINATES FOR MINIMISATION -----
C
      COMMON/RUNHED/ITITL(20),ITITL1(20)
C
      DIMENSION X(*),BOX(3)
      character*80 line
C
      lun = 21
      NR3 = 3*NR
C
C     ----- OPEN THE COORDINATE FILE -----
C
      FORM = (NTX.EQ.1 .OR. NTX.EQ.5 .OR. NTX.EQ.7 .OR. NTX.EQ.9)
C
      if (form) then
c          subr amopen(lun,fname,fstat,fform,facc)
           call amopen(lun,inpcrd,'O','F','R')
      else
           call amopen(lun,inpcrd,'O','U','R')
      endif
C
      WRITE(6,9108)
      GOTO (75,80,83,84,75,84,75,84,75),NTX
   75 READ(lun,9008) ITITL1
      read(lun,'(a80)') line
      if( line(6:6).eq.' ' ) then ! this is an old, i5 file
        READ(line,'(i5)') NATOM
      else                   ! assume a new, i6 file
        READ(line,'(i6)') NATOM
      end if
      IF(NATOM.NE.NR) GOTO 200
      READ(lun,9028) (X(I),I = 1,NR3)
      IF(NTX.EQ.1) GOTO 81
      IF(NTX.LT.7) GOTO 100
      READ(lun,9028) (BOX(I),I = 1,3)
      GOTO 100
C
   80 READ(lun) ITITL1
      READ(lun) NATOM
      IF(NATOM.NE.NR) GO TO 200
      READ(lun) (X(I),I = 1,NR3)
   81 CONTINUE
   83 CONTINUE
      GOTO 100
   84 READ(lun) ITITL1
      READ(lun) NATOM
      IF(NATOM.NE.NR) GO TO 200
      READ(lun) (X(I),I = 1,NR3)
      IF(NTX.LT.6) GOTO 100
      READ(lun) (BOX(I),I = 1,3)
  100 CONTINUE
      WRITE(6,9008) ITITL1
      write(6,'(/10x,a,i6,/)') 'NUMBER OF ATOMS =',nr
      RETURN
  200 CONTINUE
      WRITE(6,9208)
      call mexit(6, 1)
 9008 FORMAT(20A4)
 9108 FORMAT(/ /,'   3.  A T O M I C   C O O R D I N A T E S',/ /)
 9018 FORMAT(10I5)
 9028 FORMAT(6F12.7)
 9208 FORMAT(/2X,'FATAL:  Topology and coord files do not match')
      END
