Bug in reading binary restart file with BOX parameters

From: Vlad <vvv900_at_anusf.anu.edu.au>
Date: Wed 16 Oct 2002 12:58:54 +1000

Hi All,

There are bugs in sander-7 (which migrated there from sander-6)
when program tries to read BINARY restart file with BOX
parameters. One needs to fix two subroutines.

1) getcor.f

One needs to change
++++++++++++++++++++++++++++++++++++
c
c READ(lun,end=1020,err=1020) a,b,c,alpha,beta,gamma
         do 102 i=1,6
            ifld(i)=3
            fvar(i)=0.0d0
 102 continue
         ifld(7)=0
         ihol(1)=0
         call rfree(ifld,ihol,ivar,fvar,lun,6)
         if((fvar(4).ne.0).or.(fvar(5).ne.0).or.(fvar(6).ne.0))
then
            alpha=fvar(4)
            beta=fvar(5)
            gamma=fvar(6)
         else
c -- defaults:
            alpha=90.0d0
            beta=90.0d0
            gamma=90.0d0
         endif
         a=fvar(1)
         b=fvar(2)
         c=fvar(3)
         box(1) = a
         box(2) = b
         box(3) = c
++++++++++++++++++++++++++++++++++++

into:

++++++++++++++++++++++++++++++++++++
c
      READ(lun,end=1020,err=1020) a,b,c,alpha,beta,gamma
c do 102 i=1,6
c ifld(i)=3
c fvar(i)=0.0d0
c 102 continue
c ifld(7)=0
c ihol(1)=0
c call rfree(ifld,ihol,ivar,fvar,lun,6)
c if((fvar(4).ne.0).or.(fvar(5).ne.0).or.(fvar(6).ne.0)) then
c alpha=fvar(4)
c beta=fvar(5)
c gamma=fvar(6)
c else
c -- defaults:
c alpha=90.0d0
c beta=90.0d0
c gamma=90.0d0
c endif
c a=fvar(1)
c b=fvar(2)
c c=fvar(3)
         box(1) = a
         box(2) = b
         box(3) = c
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

2) Subroutine peek_ewald_inpcrd in file ew_setup.f

One possible solution is

a) to add
++++++++++++++++++++++++++
#include "md.h"
      integer ITITL(20)
++++++++++++++++++++++++++
at the top of the subroutine; and

b)to modify
+++++++++++++++++++++++++++++++++++++++
      call amopen(9,inpcrd,'O','F','R')
      read(9,'(a)') line
c
      read(9,'(a)') line
      if( line(6:6).eq.' ' ) then ! this is an old, i5 file
        READ(line,'(i5,e15.7)') NATOM,TT
      else ! assume a new, i6 file
        READ(line,'(i6,e15.7)') NATOM,TT
      end if
c
      if ( natom .le. 2 )then
        write(6,*)'peek_ewald_inpcrd: ',
     $ ' Cannot Deduce box info from inpcrd. Too few atoms'
        return
      endif
      ic = 0
      do i = 1,9999999
       read(9,9028,end=81)x1,x2,x3,x4,x5,x6
       ic = ic+1
      enddo
+++++++++++++++++++++++++++++++++++++

into

+++++++++++++++++++++++++++++++++++++
      IF (NTX.EQ.1 .OR. NTX.EQ.5 .OR. NTX.EQ.7 .OR. NTX.EQ.9)
then
        call amopen(9,inpcrd,'O','F','R')
        read(9,'(a)') line
c
        read(9,'(a)') line
        if( line(6:6).eq.' ' ) then ! this is an old, i5 file
          READ(line,'(i5,e15.7)') NATOM,TT
        else ! assume a new, i6 file
          READ(line,'(i6,e15.7)') NATOM,TT
        end if
c
        if ( natom .le. 2 )then
          write(6,*)'peek_ewald_inpcrd: ',
     $ ' Cannot Deduce box info from inpcrd. Too few
atoms'
          return
        endif
        ic = 0
        do i = 1,9999999
          read(9,9028,end=81)x1,x2,x3,x4,x5,x6
          ic = ic+1
        enddo

      else ! Unformatted input
        call amopen(9,inpcrd,'O','U','R')
        read(9) ititl
        read(9) natom
        if ( natom .le. 2 )then
          write(6,*)'peek_ewald_inpcrd: ',
     $ ' Cannot Deduce box info from inpcrd. Too few atoms'
          return
        endif
        ic = natom/2 + mod(natom,2) + 1
        do i = 1,9999999
          read(9,end=81)x1,x2,x3,x4,x5,x6
        enddo
      endif
++++++++++++++++++++++++++++++++++

Dr. V Vasilyev
ANU, Canberra
Received on Tue Oct 15 2002 - 19:58:54 PDT
Custom Search