Author: Dave Case Date: 9/25/91 PROBLEM: It is possible to prepare constraint input to SANDER that has too many equivalence groups in it. Version 4.0 uses a guess at the number of groups, but this can be too small. SYMPTOM: SANDER exits with an error message if too many groups are used. No incorrect results would be obtained, but users might not find it easy to figure out which routines need to be changed to increase the number of allowed groups. FIX: In src/sander/restal.f, count the number of groups actually used prior to calling the memory allocation routines. This allows an arbitary number of groups to be present, and doesn't waste any space. ++++nmrcal.f: *** old nmrcal.f --- new nmrcal.f *************** *** 192,200 **** C MAXWT : The maximum allowable number of weight-change cards. C MAXGRP : The maximum number of ranges of atoms which can be stored C as group information (only needed when using group center-of-mass ! C coordinates in distance restraints). By default, this value ! C is set to MAXRST. If a non-zero value of MXGRP is passed ! C to RESTLX, this value will be used as MAXGRP. C INTREQ : The amount of integer work array (IWORK) storage required. C IRLREQ : The amount of real work arary (WORK) storage required. C --- 192,202 ---- C MAXWT : The maximum allowable number of weight-change cards. C MAXGRP : The maximum number of ranges of atoms which can be stored C as group information (only needed when using group center-of-mass ! C coordinates in distance restraints). This value is ! C computed in the initial call to RESTAL. ! C [If a non-zero value of MXGRP is passed ! C to RESTLX, this value will be used as MAXGRP; this ! C option is not used in the present code.] C INTREQ : The amount of integer work array (IWORK) storage required. C IRLREQ : The amount of real work arary (WORK) storage required. C *************** *** 395,404 **** C specify lots of unnecessary stuff in the calling list: C ENTRY RESTLX(IN,ITOTST,MXGRP,INTREQ,IRLREQ,DTT,IOUT,IERR) ! CALL RESTAL(ISCOP1,IN,ITOTST,ICHGWT,NMRNUM,ITMAV,IOUT,IERR) MAXRST = NMRNUM + 1 + 5*IERR MAXWT = ICHGWT + 1 + 5*IERR ! MAXGRP = MAX(MAXRST,100) IF (MXGRP.GT.0) MAXGRP = MXGRP ITIMAV = ITMAV IF (ITOTST.EQ.0) ITIMAV = 0 --- 397,407 ---- C specify lots of unnecessary stuff in the calling list: C ENTRY RESTLX(IN,ITOTST,MXGRP,INTREQ,IRLREQ,DTT,IOUT,IERR) ! CALL RESTAL(ISCOP1,IN,ITOTST,ICHGWT,NMRNUM,ITMAV,IOUT,IERR, ! * NUMGRP) MAXRST = NMRNUM + 1 + 5*IERR MAXWT = ICHGWT + 1 + 5*IERR ! MAXGRP = NUMGRP + 1 IF (MXGRP.GT.0) MAXGRP = MXGRP ITIMAV = ITMAV IF (ITOTST.EQ.0) ITIMAV = 0 ++++restal.f: *** old restal.f --- new restal.f *************** *** 16,22 **** C************************************************************************ C SUBROUTINE RESTAL(ISCOP1,IN,ITOTST,ICHGWT,NMRNUM,ITIMAV, ! * IOUT,IERR) C C Subroutine RESTraint Allocation C --- 16,22 ---- C************************************************************************ C SUBROUTINE RESTAL(ISCOP1,IN,ITOTST,ICHGWT,NMRNUM,ITIMAV, ! * IOUT,IERR,NUMGRP) C C Subroutine RESTraint Allocation C *************** *** 43,48 **** --- 43,49 ---- C OUTPUT: C ICHGWT : Number of change parameters read. C NMRNUM : The total number of NMR restraints defined. + C NUMGRP : The total number of NMR groups defined. C ITIMAV : = 1 If any time-averaged restraints were requested. C = 0 otherwise. C IERR : Returned as 0 if no problems reading input. Returned as *************** *** 125,130 **** --- 126,132 ---- C ICHGWT = 0 NMRNUM = 0 + NUMGRP = 0 IBAVER = 0 IAAVER = 0 IPAVER = 0 *************** *** 326,332 **** C C If IAT1=0, assume this a blank line & the last restraint has been read. C ! NMRNUM = NMRNUM + 1 IF (IAT1.EQ.0) GO TO 100 30 CONTINUE C --- 328,348 ---- C C If IAT1=0, assume this a blank line & the last restraint has been read. C ! if (iat1.lt.0) then ! numgrp = numgrp + 1 ! do 31 ig=2,MAXIGR ! if (igr1(ig).eq.0) go to 32 ! if (igr1(ig).ne.igr1(ig-1)+1) numgrp = numgrp + 1 ! 31 continue ! end if ! 32 if (iat2.lt.0) then ! numgrp = numgrp + 1 ! do 33 ig=2,MAXIGR ! if (igr2(ig).eq.0) go to 34 ! if (igr2(ig).ne.igr2(ig-1)+1) numgrp = numgrp + 1 ! 33 continue ! end if ! 34 NMRNUM = NMRNUM + 1 IF (IAT1.EQ.0) GO TO 100 30 CONTINUE C *************** *** 334,339 **** --- 350,356 ---- 100 CONTINUE C IF (IOTHRD.NE.0) CALL OPNMRG(REDIR(3),IIN,3,IOUT,IERR) + c write(6,*) 'returning from restal. nmrnum,numgrp=',nmrnum,numgrp RETURN C C Errors: