********>Bugfix 56:
Author: Dave Case (bug reported by Bob Duke)
Date: 12/7/2005

Programs: sander

Description: The bugfix.54 patch, which changed the way in which the ntt=2
             option applied its randomized velocities, is not correct for
             parallel runs.  Basically, the new update was placed before
             a broadcast of velocities, instead of after it.

Fix: Apply the following patch to amber8/src/sander/runmd.f

------------------------------------------------------------------------------
*** runmd.f.old	2005-12-07 16:59:29.645022320 -0800
--- runmd.f	2005-12-07 17:09:14.562101408 -0800
***************
*** 940,969 ****
        if (master) then
           write (6,'(a,i8)') 'Setting new random velocities at step ', &
                 nstep + 1
- #ifdef PSANDER
-       endif
-       call setvel(nr,v,winv,temp0*factt,init,iscale,scalm)
-       if (ibelly > 0) call bellyf(nr,ix(ibellygp),v)
- #else
           call setvel(nr,v,winv,temp0*factt,init,iscale,scalm)
  #ifdef LES
       
!       ! newvel call is fixed for the dual target temperatures
  
!       if (temp0les >= 0.d0.and.temp0 /= temp0les) then
!          vscalt = sqrt (temp0les/temp0) 
!          do j=istart,iend
!            if(cnum(j) > 0) then
!              i3 = 3*(j-1)
!              v(i3+1) = v(i3+1) * vscalt
!              v(i3+2) = v(i3+2) * vscalt
!              v(i3+3) = v(i3+3) * vscalt
!            endif
!          end do
!       end if
  #endif
           if (ibelly > 0) call bellyf(nr,ix(ibellygp),v)
        end if
  
        ! At this point in the code, the velocities lag the positions
        ! by half a timestep.  If we intend for the velocities to be drawn 
--- 940,968 ----
        if (master) then
           write (6,'(a,i8)') 'Setting new random velocities at step ', &
                 nstep + 1
           call setvel(nr,v,winv,temp0*factt,init,iscale,scalm)
  #ifdef LES
       
!          ! newvel call is fixed for the dual target temperatures
  
!          if (temp0les >= 0.d0.and.temp0 /= temp0les) then
!             vscalt = sqrt (temp0les/temp0) 
!             do j=1,natom
!               if(cnum(j) > 0) then
!                 i3 = 3*(j-1)
!                 v(i3+1) = v(i3+1) * vscalt
!                 v(i3+2) = v(i3+2) * vscalt
!                 v(i3+3) = v(i3+3) * vscalt
!               endif
!             end do
!          end if
  #endif
           if (ibelly > 0) call bellyf(nr,ix(ibellygp),v)
        end if
+ # ifdef MPI
+       call trace_mpi('mpi_bcast',3*natom,'MPI_DOUBLE_PRECISION',0)
+       call mpi_bcast(v, 3*natom, MPI_DOUBLE_PRECISION, 0, commsander, ierr)
+ # endif
  
        ! At this point in the code, the velocities lag the positions
        ! by half a timestep.  If we intend for the velocities to be drawn 
***************
*** 983,995 ****
           end do
        end if
  
- # ifdef MPI
-       call trace_mpi('mpi_bcast',3*natom,'MPI_DOUBLE_PRECISION',0)
-       call mpi_bcast(v, 3*natom, MPI_DOUBLE_PRECISION, &
-             0, commsander, ierr)
- # endif
- #endif
-       
     end if  ! (resetvelo)
     
     call timer_start(TIME_VERLET)
--- 982,987 ----
           end do
        end if
  
     end if  ! (resetvelo)
     
     call timer_start(TIME_VERLET)
-------------------------------------------------------------------------------
Temporary workarounds: none