      SUBROUTINE MDREAD
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
C
      implicit double precision(a-h,o-z)
      COMMON/OPTA/NTX,NTXO,NRC,NRCX,NPM,NRP,NSM,NRAM,NTB,BETA,BOX(3)
      COMMON/OPTF/NTP,NTC,NTCC,NTF,NTID,NTN,NTNB,NSNB,IMAX,EMAX(20)
      COMMON/NBTERM/CUT,SCNB,SCEE,DIELC,IDIEL
      COMMON/INFOV/NATOM,NRES,NBONH,NBONA,NTHETH,NTHETA,NPHIH,
     +             NPHIA,NNB,NTYPES,NRCP,NCONP,MEMA,MEMB,MAXNB,
     +             MBONA,MTHETA,MPHIA,NATC,NGRPA
      common/grpmem/ngrpx
      dimension ITITL(20)
      DIMENSION IFLD(20),IHOL(10),IVAR(10),FVAR(10)
C
      WRITE(6,9000)
C
      WRITE(6,9010)
C
C     ----- READ DATA CHARACTERIZING THE MD-RUN -----
C
      READ(5,'(20a4)') ITITL
C
      IFLD(1) = 2
      IFLD(2) = 2
      IFLD(3) = 2
      IFLD(4) = 2
      IFLD(5) = 2
      IFLD(6) = 2
      IFLD(7) = 0
      CALL RFREE(IFLD,IHOL,IVAR,FVAR,5,6)
      NTX = IVAR(1)
      NTXO = IVAR(2)
      NRC = IVAR(3)
      NRCX = IVAR(4)
      NGRPX = IVAR(5)
      KFORM = IVAR(6)
C
      IFLD(1) = 2
      IFLD(1) = 2
      IFLD(2) = 3
      IFLD(3) = 3
      IFLD(4) = 3
      IFLD(5) = 3
      IFLD(6) = 0
      IFLD(7) = 0
      CALL RFREE(IFLD,IHOL,IVAR,FVAR,5,6)
      NTB = IVAR(1)
      BOX(1) = FVAR(1)
      BOX(2) = FVAR(2)
      BOX(3) = FVAR(3)
      BETA   = FVAR(4)
C
      IFLD(1) = 2
      IFLD(2) = 2
      IFLD(3) = 2
      IFLD(4) = 2
      IFLD(5) = 2
      IFLD(6) = 2
      IFLD(7) = 0
      CALL RFREE(IFLD,IHOL,IVAR,FVAR,5,6)
      NTF = IVAR(1)
      NTID = IVAR(2)
      NTN = IVAR(3)
      NTNB = IVAR(4)
      NSNB = IVAR(5)
      IDIEL = IVAR(6)
C
      IFLD(1) = 3
      IFLD(2) = 3
      IFLD(3) = 3
      IFLD(4) = 3
      IFLD(5) = 0
      IFLD(6) = 0
      IFLD(7) = 0
      CALL RFREE(IFLD,IHOL,IVAR,FVAR,5,6)
      CUT = FVAR(1)
      SCNB = FVAR(2)
      SCEE = FVAR(3)
      DIELC = FVAR(4)
C
      IFLD(1) = 2
      IFLD(2) = 3
      IFLD(3) = 3
      IFLD(4) = 3
      IFLD(5) = 3
      IFLD(6) = 3
      IFLD(7) = 3
      IFLD(8) = 3
      IFLD(9) = 3
      IFLD(10)= 3
      IFLD(11)= 0
      CALL RFREE(IFLD,IHOL,IVAR,FVAR,5,6)
      IMAX = IVAR(1)
      DO 300 I = 1,9
      EMAX(I) = FVAR(I)
  300 CONTINUE
C
C     ----- NOW READ THE MOLECULAR TOPOLOGY FILE. AT THIS POINT
C           THE PARTITION OF MEMORY IS DONE AND ALL THE ARRAYS
C           WOULD BE REFERRED BY THE RESPECTIVE POINTERS -----
C
      NRCP = NRC
      IF(NGRPX.LE.0) NGRPX = 400
      CALL RDPARM(NGRPX,KFORM)
C
C     ----- SET THE DEFAULT VALUES FOR SOME VARIABLES -----
C
      NTP = 0
      NPM = 1
      NRP = NATOM
      NSM = 0
      NRAM = 0
      IF(SCNB.LE.0.0E0) SCNB = 2.0E0
      IF(SCEE.LE.0.0E0) SCEE = 2.0E0
      IF(DIELC.LE.0.0E0) DIELC = 1.0E0
C
C     ----- PRINT DATA CHARACTERIZING THE RUN -----
C
      NRPT = NPM*NRP
      NR = NRPT+NSM*NRAM
      WRITE(6,9020)
      WRITE(6,9030) ITITL
      WRITE(6,9040) NTX,NTXO,NRC,NRCX,NGRPX,KFORM
      WRITE(6,9050) NTB,BOX(1),BOX(2),BOX(3),BETA
      WRITE(6,9060) NTF,NTID,NTN,NTNB,NSNB,IDIEL
      WRITE(6,9070) CUT,SCNB,SCEE,DIELC
      WRITE(6,9080)
      WRITE(6,9090) IMAX,(EMAX(I),I=1,4)
      WRITE(6,9100)
      WRITE(6,9110) (EMAX(I),I=5,9)
      CUT = CUT*CUT
C
C     ----- SET THE EMAX TO HIGH IF IMAX .EQ. 0 -----
C
      IF(IMAX.GT.0) GO TO 120
      DO 140 I = 1,10
      EMAX(I) = 1.0E+10
  140 CONTINUE
  120 CONTINUE
C
      RETURN
C
 9000 FORMAT(/10X,
     +'---------------------------------------------------------------',
     +   /10x,
     +'Amber 5.0 ANAL:  Static Analysis for Energy/Structure UCSF 1997',
     +   /10x,
     +'---------------------------------------------------------------',
     + /)
 9010 FORMAT(/ /,'   1.  RESOURCE   USE:',/)
 9020 FORMAT(/ /,'   2.  DATA   CONTROL:',/)
 9030 FORMAT(2X,20A4)
 9040 FORMAT(/5X,'NTX   =',I5,7X,'NTXO  =',I5,7X,'NRC   =',I5,
     +       /5X,'NRCX  =',I5,7X,'NGRPX =',I5,7X,'KFORM =',I5)
 9050 FORMAT(/5X,'NTB   =',I5,7X,'BOXX  =',F9.3,3x,'BOXY  =',F9.3,
     +       /5x,'BOXZ  =',F9.3,3X,'BETA  =',F9.3)
 9060 FORMAT(/5X,'NTF   =',I5,7X,'NTID  =',I5,7X,'NTN   =',I5,
     +       /5X,'NTNB  =',I5,7X,'NSNB  =',I5,7X,'IDIEL =',I5)
 9070 FORMAT(/5X,'RCUT  =',F9.2,3X,'SCNB  =',F9.2,
     +       /5X,'SCEE  =',F9.2,3X,'DIELC =',F9.2)
 9080 format(/5x,'IMAX            EBMAX       EANMAX      EDIHMAX',
     +           '     ENB14MAX')
 9090 format(5x,i5,3x,4f13.2)
 9100 format(/5x,'EEL14MAX       ENBMAX       EELMAX       EHBMAX',
     +           '     ECONSMAX')
 9110 format(5f13.2)
      END
