2 !-----------------------------------------------------------------------------
11 !-----------------------------------------------------------------------------
14 !-----------------------------------------------------------------------------
18 real(kind=8),dimension(:,:,:),allocatable :: t,r !(3,3,maxres)
19 !-----------------------------------------------------------------------------
22 !-----------------------------------------------------------------------------
24 ! Variables (set in init routine) never modified by local_move
26 integer :: init_called
27 logical :: locmove_output
28 real(kind=8) :: min_theta, max_theta
29 real(kind=8) :: dmin2,dmax2
30 real(kind=8) :: flag,small,small2
31 ! Workspace for local_move
33 integer :: a_n,b_n,res_n
34 real(kind=8),dimension(0:7) :: a_ang
35 real(kind=8),dimension(0:3) :: b_ang
36 real(kind=8),dimension(0:11) :: res_ang
37 logical,dimension(0:2,0:7) :: a_tab
38 logical,dimension(0:2,0:3) :: b_tab
39 logical,dimension(0:2,0:2,0:11) :: res_tab
40 !-----------------------------------------------------------------------------
41 ! integer,dimension(:),allocatable :: itype_pdb !(maxres) initialize in molread
42 !-----------------------------------------------------------------------------
45 !-----------------------------------------------------------------------------
47 !-----------------------------------------------------------------------------
49 !-----------------------------------------------------------------------------
50 real(kind=8) function ARCOS(X)
51 ! implicit real*8 (a-h,o-z)
52 ! include 'COMMON.GEO'
55 IF (DABS(X).LT.1.0D0) GOTO 1
56 ARCOS=PIPOL*(1.0d0-DSIGN(1.0D0,X))
61 !-----------------------------------------------------------------------------
63 !-----------------------------------------------------------------------------
66 ! Build the virtual polypeptide chain. Side-chain centroids are moveable.
69 ! implicit real*8 (a-h,o-z)
70 ! include 'DIMENSIONS'
71 ! include 'COMMON.CHAIN'
72 ! include 'COMMON.LOCAL'
73 ! include 'COMMON.GEO'
74 ! include 'COMMON.VAR'
75 ! include 'COMMON.IOUNITS'
76 ! include 'COMMON.NAMES'
77 ! include 'COMMON.INTERACT'
81 real(kind=8) :: be,be1,alfai
84 ! Set lprn=.true. for debugging
86 print *,"I ENTER CHAINBUILD"
88 ! Define the origin and orientation of the coordinate system and locate the
89 ! first three CA's and SC(2).
91 !elwrite(iout,*)"in chainbuild"
93 !elwrite(iout,*)"after orig_frame"
95 ! Build the alpha-carbon chain.
98 call locate_next_res(i)
100 !elwrite(iout,*)"after locate_next_res"
102 ! First and last SC must coincide with the corresponding CA.
106 dc_norm(j,nres+1)=0.0D0
107 dc(j,nres+nres)=0.0D0
108 dc_norm(j,nres+nres)=0.0D0
110 c(j,nres+nres)=c(j,nres)
113 ! Temporary diagnosis
118 write (iout,'(/a)') 'Recalculated internal coordinates'
121 c(j,nres2+2)=0.5D0*(c(j,i-1)+c(j,i+1)) !maxres2=2*maxres
124 if (i.gt.3) be=rad2deg*beta(i-3,i-2,i-1,i)
125 be1=rad2deg*beta(nres+i,i,nres2+2,i+1)
127 if (i.gt.2) alfai=rad2deg*alpha(i-2,i-1,i)
128 write (iout,1212) restyp(itype(i,1),1),i,dist(i-1,i),&
129 alfai,be,dist(nres+i,i),rad2deg*alpha(nres+i,i,nres2+2),be1
131 1212 format (a3,'(',i3,')',2(f10.5,2f10.2))
136 end subroutine chainbuild
137 !-----------------------------------------------------------------------------
138 subroutine orig_frame
140 ! Define the origin and orientation of the coordinate system and locate
141 ! the first three atoms.
143 ! implicit real*8 (a-h,o-z)
144 ! include 'DIMENSIONS'
145 ! include 'COMMON.CHAIN'
146 ! include 'COMMON.LOCAL'
147 ! include 'COMMON.GEO'
148 ! include 'COMMON.VAR'
151 real(kind=8) :: cost,sint
153 !el allocate(t(3,3,nres)) !(3,3,maxres)
154 !el allocate(r(3,3,nres)) !(3,3,maxres)
155 !el allocate(rt(3,3,nres)) !(3,3,maxres)
156 !el allocate(dc_norm(3,0:2*nres)) !(3,0:maxres2)
157 !el allocate(prod(3,3,nres)) !(3,3,maxres)
210 dc_norm(j,2)=prod(j,1,2)
211 dc(j,2)=vbld(3)*prod(j,1,2)
212 c(j,3)=c(j,2)+dc(j,2)
214 call locate_side_chain(2)
216 end subroutine orig_frame
217 !-----------------------------------------------------------------------------
218 subroutine locate_next_res(i)
220 ! Locate CA(i) and SC(i-1)
222 ! implicit real*8 (a-h,o-z)
223 ! include 'DIMENSIONS'
224 ! include 'COMMON.CHAIN'
225 ! include 'COMMON.LOCAL'
226 ! include 'COMMON.GEO'
227 ! include 'COMMON.VAR'
228 ! include 'COMMON.IOUNITS'
229 ! include 'COMMON.NAMES'
230 ! include 'COMMON.INTERACT'
232 ! Define the rotation matrices corresponding to CA(i)
236 real(kind=8) :: theti,phii
237 real(kind=8) :: cost,sint,cosphi,sinphi
242 call proc_proc(theti,icrc)
243 if(icrc.eq.1)theti=100.0
246 call proc_proc(phii,icrc)
247 if(icrc.eq.1)phii=180.0
250 if (theti.ne.theti) theti=100.0
252 if (phii.ne.phii) phii=180.0
262 ! Define the matrices of the rotation about the virtual-bond valence angles
263 ! theta, T(i,j,k), virtual-bond dihedral angles gamma (miscalled PHI in this
264 ! program), R(i,j,k), and, the cumulative matrices of rotation RT
286 rt(2,1,i-2)=sint*cosphi
287 rt(2,2,i-2)=-cost*cosphi
289 rt(3,1,i-2)=-sint*sinphi
290 rt(3,2,i-2)=cost*sinphi
292 call matmult(prod(1,1,i-2),rt(1,1,i-2),prod(1,1,i-1))
294 dc_norm(j,i-1)=prod(j,1,i-1)
295 dc(j,i-1)=vbld(i)*prod(j,1,i-1)
296 c(j,i)=c(j,i-1)+dc(j,i-1)
298 !d print '(2i3,2(3f10.5,5x))', i-1,i,(dc(j,i-1),j=1,3),(c(j,i),j=1,3)
300 ! Now calculate the coordinates of SC(i-1)
302 call locate_side_chain(i-1)
304 end subroutine locate_next_res
305 !-----------------------------------------------------------------------------
306 subroutine locate_side_chain(i)
308 ! Locate the side-chain centroid i, 1 < i < NRES. Put in C(*,NRES+i).
310 ! implicit real*8 (a-h,o-z)
311 ! include 'DIMENSIONS'
312 ! include 'COMMON.CHAIN'
313 ! include 'COMMON.LOCAL'
314 ! include 'COMMON.GEO'
315 ! include 'COMMON.VAR'
316 ! include 'COMMON.IOUNITS'
317 ! include 'COMMON.NAMES'
318 ! include 'COMMON.INTERACT'
320 real(kind=8),dimension(3) :: xx
321 real(kind=8) :: alphi,omegi,theta2
322 real(kind=8) :: dsci,dsci_inv,sinalphi,cosalphi,cosomegi,sinomegi
323 real(kind=8) :: xp,yp,zp,cost2,sint2,rj
324 ! dsci=dsc(itype(i,1))
325 ! dsci_inv=dsc_inv(itype(i,1))
327 dsci_inv=vbld_inv(i+nres)
334 call proc_proc(alphi,icrc)
335 if(icrc.eq.1)alphi=100.0
337 call proc_proc(omegi,icrc)
338 if(icrc.eq.1)omegi=-100.0
340 if (alphi.ne.alphi) alphi=100.0
341 if (omegi.ne.omegi) omegi=-100.0
352 yp= dsci*sinalphi*cosomegi
353 zp=-dsci*sinalphi*sinomegi
354 ! Now we have to rotate the coordinate system by 180-theta(i)/2 so as to get its
355 ! X-axis aligned with the vector DC(*,i)
356 theta2=pi-0.5D0*theta(i+1)
359 xx(1)= xp*cost2+yp*sint2
360 xx(2)=-xp*sint2+yp*cost2
362 !d print '(a3,i3,3f10.5,5x,3f10.5)',restyp(itype(i,1)),i,
363 !d & xp,yp,zp,(xx(k),k=1,3)
367 ! Bring the SC vectors to the common coordinate system.
369 xx(2)=xloc(2,i)*r(2,2,i-1)+xloc(3,i)*r(2,3,i-1)
370 xx(3)=xloc(2,i)*r(3,2,i-1)+xloc(3,i)*r(3,3,i-1)
377 rj=rj+prod(j,k,i-1)*xx(k)
380 dc_norm(j,nres+i)=rj*dsci_inv
381 c(j,nres+i)=c(j,i)+rj
384 end subroutine locate_side_chain
385 !-----------------------------------------------------------------------------
387 !-----------------------------------------------------------------------------
388 subroutine int_from_cart1(lprn)
389 ! implicit real*8 (a-h,o-z)
390 ! include 'DIMENSIONS'
395 ! include 'COMMON.IOUNITS'
396 ! include 'COMMON.VAR'
397 ! include 'COMMON.CHAIN'
398 ! include 'COMMON.GEO'
399 ! include 'COMMON.INTERACT'
400 ! include 'COMMON.LOCAL'
401 ! include 'COMMON.NAMES'
402 ! include 'COMMON.SETUP'
403 ! include 'COMMON.TIME1'
407 real(kind=8) :: dnorm1,dnorm2,be
410 if (lprn) write (iout,'(/a)') 'Recalculated internal coordinates'
417 !write(iout,*)"geometry warring, vbld=",(vbld(i),i=1,nres+1)
419 vbld_inv(nres+1)=0.0d0
420 vbld_inv(2*nres)=0.0d0
423 #if defined(PARINT) && defined(MPI)
424 do i=iint_start,iint_end
431 c(j,nres2+2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))/dnorm1 &
432 +(c(j,i+1)-c(j,i))/dnorm2)
436 if (i.le.nres) phi(i+1)=beta(i-2,i-1,i,i+1)
437 if ((itype(i,1).ne.10).and.(itype(i-1,1).ne.10)) then
438 tauangle(3,i+1)=beta(i+nres-1,i-1,i,i+nres)
440 if (itype(i-1,1).ne.10) then
441 tauangle(1,i+1)=beta(i-1+nres,i-1,i,i+1)
442 omicron(1,i)=alpha(i-2,i-1,i-1+nres)
443 omicron(2,i)=alpha(i-1+nres,i-1,i)
445 if (itype(i,1).ne.10) then
446 tauangle(2,i+1)=beta(i-2,i-1,i,i+nres)
449 omeg(i)=beta(nres+i,i,nres2+2,i+1)
450 alph(i)=alpha(nres+i,i,nres2+2)
451 theta(i+1)=alpha(i-1,i,i+1)
453 ! print *,i,vbld(i),"vbld(i)"
454 vbld_inv(i)=1.0d0/vbld(i)
455 vbld(nres+i)=dist(nres+i,i)
456 if (itype(i,1).ne.10) then
457 vbld_inv(nres+i)=1.0d0/vbld(nres+i)
459 vbld_inv(nres+i)=0.0d0
462 #if defined(PARINT) && defined(MPI)
463 if (nfgtasks1.gt.1) then
464 !d write(iout,*) "iint_start",iint_start," iint_count",
465 !d & (iint_count(i),i=0,nfgtasks-1)," iint_displ",
466 !d & (iint_displ(i),i=0,nfgtasks-1)
467 !d write (iout,*) "Gather vbld backbone"
470 call MPI_Allgatherv(vbld(iint_start),iint_count(fg_rank1),&
471 MPI_DOUBLE_PRECISION,vbld(1),iint_count(0),iint_displ(0),&
472 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
473 !d write (iout,*) "Gather vbld_inv"
475 call MPI_Allgatherv(vbld_inv(iint_start),iint_count(fg_rank1),&
476 MPI_DOUBLE_PRECISION,vbld_inv(1),iint_count(0),iint_displ(0),&
477 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
478 !d write (iout,*) "Gather vbld side chain"
480 call MPI_Allgatherv(vbld(iint_start+nres),iint_count(fg_rank1),&
481 MPI_DOUBLE_PRECISION,vbld(nres+1),iint_count(0),iint_displ(0),&
482 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
483 !d write (iout,*) "Gather vbld_inv side chain"
485 call MPI_Allgatherv(vbld_inv(iint_start+nres),&
486 iint_count(fg_rank1),MPI_DOUBLE_PRECISION,vbld_inv(nres+1),&
487 iint_count(0),iint_displ(0),MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
488 !d write (iout,*) "Gather theta"
490 call MPI_Allgatherv(theta(iint_start+1),iint_count(fg_rank1),&
491 MPI_DOUBLE_PRECISION,theta(2),iint_count(0),iint_displ(0),&
492 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
493 !d write (iout,*) "Gather phi"
495 call MPI_Allgatherv(phi(iint_start+1),iint_count(fg_rank1),&
496 MPI_DOUBLE_PRECISION,phi(2),iint_count(0),iint_displ(0),&
497 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
499 !d write (iout,*) "Gather alph"
501 call MPI_Allgatherv(alph(iint_start),iint_count(fg_rank1),&
502 MPI_DOUBLE_PRECISION,alph(1),iint_count(0),iint_displ(0),&
503 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
504 !d write (iout,*) "Gather omeg"
506 call MPI_Allgatherv(omeg(iint_start),iint_count(fg_rank1),&
507 MPI_DOUBLE_PRECISION,omeg(1),iint_count(0),iint_displ(0),&
508 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
510 time_gather=time_gather+MPI_Wtime()-time00
516 #if defined(WHAM_RUN) || defined(CLUSTER)
517 dc(j,i)=c(j,i+1)-c(j,i)
519 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
525 #if defined(WHAM_RUN) || defined(CLUSTER)
526 dc(j,i+nres)=c(j,i+nres)-c(j,i)
528 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
533 write (iout,1212) restyp(itype(i,1),1),i,vbld(i),&
534 rad2deg*theta(i),rad2deg*phi(i),vbld(nres+i),&
535 rad2deg*alph(i),rad2deg*omeg(i)
538 1212 format (a3,'(',i3,')',2(f15.10,2f10.2))
540 time_intfcart=time_intfcart+MPI_Wtime()-time01
543 end subroutine int_from_cart1
544 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
545 !-----------------------------------------------------------------------------
547 !-----------------------------------------------------------------------------
548 subroutine check_sc_distr
549 ! implicit real*8 (a-h,o-z)
550 ! include 'DIMENSIONS'
551 ! include 'COMMON.TIME1'
552 ! include 'COMMON.INTERACT'
553 ! include 'COMMON.NAMES'
554 ! include 'COMMON.GEO'
555 ! include 'COMMON.HEADER'
556 ! include 'COMMON.CONTROL'
558 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
559 real(kind=8) :: hrtime,mintime,sectime
560 integer,parameter :: MaxSample=10000000
561 real(kind=8),parameter :: delt=1.0D0/MaxSample
562 real(kind=8),dimension(0:72,0:90) :: prob
564 integer :: it,i,j,isample,indal,indom
565 real(kind=8) :: al,om,dV
566 dV=2.0D0*5.0D0*deg2rad*deg2rad
569 if (it.eq.10) goto 10
570 open (20,file=restyp(it,1)//'_distr.sdc',status='unknown')
571 call gen_side(it,90.0D0 * deg2rad,al,om,fail)
574 open (20,file=restyp(it,1)//'_distr1.sdc',status='unknown')
580 do isample=1,MaxSample
581 call gen_side(it,90.0D0 * deg2rad,al,om,fail)
583 indom=(rad2deg*om+180.0D0)/5
584 prob(indom,indal)=prob(indom,indal)+delt
588 write (20,'(2f10.3,1pd15.5)') 2*i+0.0D0,5*j-180.0D0,&
594 end subroutine check_sc_distr
596 !-----------------------------------------------------------------------------
598 !-----------------------------------------------------------------------------
599 subroutine geom_to_var(n,x)
601 ! Transfer the geometry parameters to the variable array.
602 ! The positions of variables are as follows:
603 ! 1. Virtual-bond torsional angles: 1 thru nres-3
604 ! 2. Virtual-bond valence angles: nres-2 thru 2*nres-5
605 ! 3. The polar angles alpha of local SC orientation: 2*nres-4 thru
607 ! 4. The torsional angles omega of SC orientation: 2*nres-4+nside+1
608 ! thru 2*nre-4+2*nside
610 ! implicit real*8 (a-h,o-z)
611 ! include 'DIMENSIONS'
612 ! include 'COMMON.VAR'
613 ! include 'COMMON.GEO'
614 ! include 'COMMON.CHAIN'
616 real(kind=8),dimension(n) :: x
617 !d print *,'nres',nres,' nphi',nphi,' ntheta',ntheta,' nvar',nvar
620 !d print *,i,i-3,phi(i)
622 if (n.eq.nphi) return
625 !d print *,i,i-2+nphi,theta(i)
627 if (n.eq.nphi+ntheta) return
629 if (ialph(i,1).gt.0) then
630 x(ialph(i,1))=alph(i)
631 x(ialph(i,1)+nside)=omeg(i)
632 !d print *,i,ialph(i,1),ialph(i,1)+nside,alph(i),omeg(i)
636 end subroutine geom_to_var
637 !-----------------------------------------------------------------------------
638 subroutine var_to_geom(n,x)
640 ! Update geometry parameters according to the variable array.
642 ! implicit real*8 (a-h,o-z)
643 ! include 'DIMENSIONS'
644 ! include 'COMMON.VAR'
645 ! include 'COMMON.CHAIN'
646 ! include 'COMMON.GEO'
647 ! include 'COMMON.IOUNITS'
649 real(kind=8),dimension(n) :: x
650 logical :: change !,reduce
657 if (n.gt.nphi+ntheta) then
660 alph(ii)=x(nphi+ntheta+i)
661 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
662 !elwrite(iout,*) "alph",ii,alph
663 !elwrite(iout,*) "omeg",ii,omeg
668 !elwrite(iout,*) "phi",i,phi
670 if (n.eq.nphi) return
673 !elwrite(iout,*) "theta",i,theta
674 if (theta(i).eq.pi) theta(i)=0.99d0*pi
678 end subroutine var_to_geom
679 !-----------------------------------------------------------------------------
680 logical function convert_side(alphi,omegi)
682 real(kind=8) :: alphi,omegi
683 !el real(kind=8) :: pinorm
684 ! include 'COMMON.GEO'
686 ! Apply periodicity restrictions.
687 if (alphi.gt.pi) then
689 omegi=pinorm(omegi+pi)
693 end function convert_side
694 !-----------------------------------------------------------------------------
695 logical function reduce(x)
697 ! Apply periodic restrictions to variables.
699 ! implicit real*8 (a-h,o-z)
700 ! include 'DIMENSIONS'
701 ! include 'COMMON.VAR'
702 ! include 'COMMON.CHAIN'
703 ! include 'COMMON.GEO'
704 logical :: zm,zmiana !,convert_side
705 real(kind=8),dimension(nvar) :: x
709 x(i-3)=pinorm(x(i-3))
711 if (nvar.gt.nphi+ntheta) then
715 x(ii)=thetnorm(x(ii))
716 x(iii)=pinorm(x(iii))
717 ! Apply periodic restrictions.
718 zm=convert_side(x(ii),x(iii))
722 if (nvar.eq.nphi) return
726 x(ii)=dmod(x(ii),dwapi)
727 ! Apply periodic restrictions.
728 if (x(ii).gt.pi) then
731 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
732 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
735 x(ii)=dmod(pi-x(ii),dwapi)
736 x(ii+nside)=pinorm(-x(ii+nside))
737 zm=convert_side(x(ii),x(ii+nside))
739 else if (x(ii).lt.-pi) then
744 x(ii)=dmod(pi-x(ii),dwapi)
745 x(ii+nside)=pinorm(-pi-x(ii+nside))
746 zm=convert_side(x(ii),x(ii+nside))
748 else if (x(ii).lt.0.0d0) then
751 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
752 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
755 x(ii+nside)=pinorm(-x(ii+nside))
756 zm=convert_side(x(ii),x(ii+nside))
763 !-----------------------------------------------------------------------------
764 real(kind=8) function thetnorm(x)
765 ! This function puts x within [0,2Pi].
768 ! include 'COMMON.GEO'
770 if (xx.lt.0.0d0) xx=xx+dwapi
771 if (xx.gt.0.9999d0*pi) xx=0.9999d0*pi
774 end function thetnorm
775 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
776 !-----------------------------------------------------------------------------
777 subroutine var_to_geom_restr(n,xx)
779 ! Update geometry parameters according to the variable array.
781 ! implicit real*8 (a-h,o-z)
782 ! include 'DIMENSIONS'
783 ! include 'COMMON.VAR'
784 ! include 'COMMON.CHAIN'
785 ! include 'COMMON.GEO'
786 ! include 'COMMON.IOUNITS'
788 real(kind=8),dimension(6*nres) :: x,xx !(maxvar) (maxvar=6*maxres)
789 logical :: change !,reduce
795 alph(ii)=x(nphi+ntheta+i)
796 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
803 if (theta(i).eq.pi) theta(i)=0.99d0*pi
807 end subroutine var_to_geom_restr
808 !-----------------------------------------------------------------------------
810 !-----------------------------------------------------------------------------
811 subroutine gen_rand_conf(nstart,*)
812 ! Generate random conformation or chain cut and regrowth.
814 ! implicit real*8 (a-h,o-z)
815 ! include 'DIMENSIONS'
816 ! include 'COMMON.CHAIN'
817 ! include 'COMMON.LOCAL'
818 ! include 'COMMON.VAR'
819 ! include 'COMMON.INTERACT'
820 ! include 'COMMON.IOUNITS'
821 ! include 'COMMON.MCM'
822 ! include 'COMMON.GEO'
823 ! include 'COMMON.CONTROL'
824 logical :: back,fail !overlap,
826 integer :: i,nstart,maxsi,nsi,maxnit,nit,niter
827 integer :: it1,it2,it,j
828 !d print *,' CG Processor',me,' maxgen=',maxgen
830 !d write (iout,*) 'Gen_Rand_conf: nstart=',nstart
831 if (nstart.lt.5) then
833 phi(4)=gen_phi(4,iabs(itype(2,1)),iabs(itype(3,1)))
834 ! write(iout,*)'phi(4)=',rad2deg*phi(4)
835 if (nstart.lt.3) theta(3)=gen_theta(iabs(itype(2,1)),pi,phi(4))
836 ! write(iout,*)'theta(3)=',rad2deg*theta(3)
840 do while (fail.and.nsi.le.maxsi)
841 call gen_side(it1,theta(3),alph(2),omeg(2),fail)
844 if (nsi.gt.maxsi) return 1
859 do while (i.le.nres .and. niter.lt.maxgen)
860 if (i.lt.nstart) then
862 write (iout,'(/80(1h*)/2a/80(1h*))') &
863 'Generation procedure went down to ',&
864 'chain beginning. Cannot continue...'
865 write (*,'(/80(1h*)/2a/80(1h*))') &
866 'Generation procedure went down to ',&
867 'chain beginning. Cannot continue...'
871 it1=iabs(itype(i-1,molnum(i-1)))
872 it2=iabs(itype(i-2,molnum(i-2)))
873 it=iabs(itype(i,molnum(i)))
874 ! print *,'Gen_Rand_Conf: i=',i,' it=',it,' it1=',it1,' it2=',it2,
875 ! & ' nit=',nit,' niter=',niter,' maxgen=',maxgen
876 phi(i+1)=gen_phi(i+1,it1,it)
878 phi(i)=gen_phi(i+1,it2,it1)
879 ! print *,'phi(',i,')=',phi(i)
880 theta(i-1)=gen_theta(it2,phi(i-1),phi(i))
884 do while (fail.and.nsi.le.maxsi)
885 call gen_side(it2,theta(i-1),alph(i-2),omeg(i-2),fail)
888 if (nsi.gt.maxsi) return 1
890 call locate_next_res(i-1)
892 theta(i)=gen_theta(it1,phi(i),phi(i+1))
896 do while (fail.and.nsi.le.maxsi)
897 call gen_side(it1,theta(i),alph(i-1),omeg(i-1),fail)
900 if (nsi.gt.maxsi) return 1
902 call locate_next_res(i)
903 if (overlap(i-1)) then
904 if (nit.lt.maxnit) then
914 'Cannot generate non-overlaping conformation. Increase MAXNIT.'
916 'Cannot generate non-overlaping conformation. Increase MAXNIT.'
927 if (niter.ge.maxgen) then
928 write (iout,'(a,2i5)') &
929 'Too many trials in conformation generation',niter,maxgen
930 write (*,'(a,2i5)') &
931 'Too many trials in conformation generation',niter,maxgen
936 c(j,nres+nres)=c(j,nres)
939 end subroutine gen_rand_conf
940 !-----------------------------------------------------------------------------
941 logical function overlap(i)
942 ! implicit real*8 (a-h,o-z)
943 ! include 'DIMENSIONS'
944 ! include 'COMMON.CHAIN'
945 ! include 'COMMON.INTERACT'
946 ! include 'COMMON.FFIELD'
947 integer :: i,j,iti,itj,iteli,itelj,k
948 real(kind=8) :: redfac,rcomp
954 if (iti.gt.ntyp) return
955 ! Check for SC-SC overlaps.
956 !d print *,'nnt=',nnt,' nct=',nct
959 if (j.lt.i-1 .or. ipot.ne.4) then
960 rcomp=sigmaii(iti,itj)
965 if (dist(nres+i,nres+j).lt.redfac*rcomp) then
967 ! print *,'overlap, SC-SC: i=',i,' j=',j,
968 ! & ' dist=',dist(nres+i,nres+j),' rcomp=',
973 ! Check for overlaps between the added peptide group and the preceding
977 ! c(j,nres2+1)=0.5D0*(c(j,i)+c(j,i+1))
978 c(j,nres2+3)=0.5D0*(c(j,i)+c(j,i+1))
982 !d print *,'overlap, p-Sc: i=',i,' j=',j,
983 !d & ' dist=',dist(nres+j,maxres2+1)
984 if (dist(nres+j,nres2+3).lt.4.0D0*redfac) then
989 ! Check for overlaps between the added side chain and the preceding peptide
993 c(k,nres2+3)=0.5D0*(c(k,j)+c(k,j+1))
995 !d print *,'overlap, SC-p: i=',i,' j=',j,
996 !d & ' dist=',dist(nres+i,maxres2+1)
997 if (dist(nres+i,nres2+3).lt.4.0D0*redfac) then
1002 ! Check for p-p overlaps
1004 c(j,nres2+4)=0.5D0*(c(j,i)+c(j,i+1))
1009 c(k,nres2+4)=0.5D0*(c(k,j)+c(k,j+1))
1011 !d print *,'overlap, p-p: i=',i,' j=',j,
1012 !d & ' dist=',dist(maxres2+1,maxres2+2)
1013 if(iteli.ne.0.and.itelj.ne.0)then
1014 if (dist(nres2+3,nres2+4).lt.rpp(iteli,itelj)*redfac) then
1021 end function overlap
1022 !-----------------------------------------------------------------------------
1023 real(kind=8) function gen_phi(i,it1,it2)
1024 use random, only:ran_number
1025 ! implicit real*8 (a-h,o-z)
1026 ! include 'DIMENSIONS'
1027 ! include 'COMMON.GEO'
1028 ! include 'COMMON.BOUNDS'
1029 integer :: i,it1,it2
1030 ! gen_phi=ran_number(-pi,pi)
1031 ! 8/13/98 Generate phi using pre-defined boundaries
1032 gen_phi=ran_number(phibound(1,i),phibound(2,i))
1034 end function gen_phi
1035 !-----------------------------------------------------------------------------
1036 real(kind=8) function gen_theta(it,gama,gama1)
1037 use random,only:binorm
1038 ! implicit real*8 (a-h,o-z)
1039 ! include 'DIMENSIONS'
1040 ! include 'COMMON.LOCAL'
1041 ! include 'COMMON.GEO'
1042 real(kind=8),dimension(2) :: y,z
1043 real(kind=8) :: theta_max,theta_min,sig,ak
1046 real(kind=8) :: gama,gama1,thet_pred_mean,theta_temp
1047 ! print *,'gen_theta: it=',it
1050 if (dabs(gama).gt.dwapi) then
1057 if (dabs(gama1).gt.dwapi) then
1064 thet_pred_mean=a0thet(it)
1066 thet_pred_mean=thet_pred_mean+athet(k,it,1,1)*y(k) &
1067 +bthet(k,it,1,1)*z(k)
1071 sig=sig*thet_pred_mean+polthet(j,it)
1073 sig=0.5D0/(sig*sig+sigc0(it))
1074 ak=dexp(gthet(1,it)- &
1075 0.5D0*((gthet(2,it)-thet_pred_mean)/gthet(3,it))**2)
1076 ! print '(i5,5(1pe14.4))',it,(gthet(j,it),j=1,3)
1077 ! print '(5(1pe14.4))',thet_pred_mean,theta0(it),sig,sig0(it),ak
1078 theta_temp=binorm(thet_pred_mean,theta0(it),sig,sig0(it),ak)
1079 if (theta_temp.lt.theta_min) theta_temp=theta_min
1080 if (theta_temp.gt.theta_max) theta_temp=theta_max
1081 gen_theta=theta_temp
1082 ! print '(a)','Exiting GENTHETA.'
1084 end function gen_theta
1085 !-----------------------------------------------------------------------------
1086 subroutine gen_side(it,the,al,om,fail)
1087 use random, only:ran_number,mult_norm1
1088 ! implicit real*8 (a-h,o-z)
1089 ! include 'DIMENSIONS'
1090 ! include 'COMMON.GEO'
1091 ! include 'COMMON.LOCAL'
1092 ! include 'COMMON.SETUP'
1093 ! include 'COMMON.IOUNITS'
1094 real(kind=8) :: MaxBoxLen=10.0D0
1095 real(kind=8),dimension(3,3) :: Ap_inv,a,vec
1096 real(kind=8),dimension(:,:),allocatable :: z !(3,maxlob)
1097 real(kind=8),dimension(:),allocatable :: W1,detAp !(maxlob)
1098 real(kind=8),dimension(:),allocatable :: sumW !(0:maxlob)
1099 real(kind=8),dimension(2) :: y,cm,eig
1100 real(kind=8),dimension(2,2) :: box
1101 real(kind=8),dimension(100) :: work
1102 real(kind=8) :: eig_limit=1.0D-8
1103 real(kind=8) :: Big=10.0D0
1104 logical :: lprint,fail,lcheck
1106 integer :: it,i,j,k,l,nlobit,ial,iom,iii,ilob
1107 real(kind=8) :: the,al,om,detApi,wart,y2,wykl,radmax
1108 real(kind=8) :: tant,zz1,W1i,radius,zk,fac,dV,sum,sum1
1109 real(kind=8) :: which_lobe
1113 if (the.eq.0.0D0 .or. the.eq.pi) then
1115 write (*,'(a,i4,a,i3,a,1pe14.5)') &
1116 'CG Processor:',me,' Error in GenSide: it=',it,' theta=',the
1118 !d write (iout,'(a,i3,a,1pe14.5)')
1119 !d & 'Error in GenSide: it=',it,' theta=',the
1124 tant=dtan(the-pipol)
1126 allocate(z(3,nlobit))
1127 allocate(W1(nlobit))
1128 allocate(detAp(nlobit))
1129 allocate(sumW(0:nlobit))
1132 print '(a,i4,a)','CG Processor:',me,' Enter Gen_Side.'
1133 write (iout,'(a,i4,a)') 'Processor:',me,' Enter Gen_Side.'
1135 print *,'it=',it,' nlobit=',nlobit,' the=',the,' tant=',tant
1136 write (iout,*) 'it=',it,' nlobit=',nlobit,' the=',the,&
1140 zz1=tant-censc(1,i,it)
1143 a(k,l)=gaussc(k,l,i,it)
1146 detApi=a(2,2)*a(3,3)-a(2,3)**2
1147 Ap_inv(2,2)=a(3,3)/detApi
1148 Ap_inv(2,3)=-a(2,3)/detApi
1149 Ap_inv(3,2)=Ap_inv(2,3)
1150 Ap_inv(3,3)=a(2,2)/detApi
1152 write (*,'(/a,i2/)') 'Cluster #',i
1153 write (*,'(3(1pe14.5),5x,1pe14.5)') &
1154 ((a(l,k),l=1,3),censc(k,i,it),k=1,3)
1155 write (iout,'(/a,i2/)') 'Cluster #',i
1156 write (iout,'(3(1pe14.5),5x,1pe14.5)') &
1157 ((a(l,k),l=1,3),censc(k,i,it),k=1,3)
1162 W1i=W1i+a(k,1)*a(l,1)*Ap_inv(k,l)
1166 W1(i)=dexp(bsc(i,it)-0.5D0*W1i*zz1*zz1)
1167 ! if (lprint) write(*,'(a,3(1pe15.5)/)')
1168 ! & 'detAp, W1, anormi',detApi,W1i,anormi
1172 zk=zk+zz1*Ap_inv(k,l)*a(l,1)
1176 detAp(i)=dsqrt(detApi)
1180 print *,'W1:',(w1(i),i=1,nlobit)
1181 print *,'detAp:',(detAp(i),i=1,nlobit)
1184 print '(i2,3f10.5)',i,(rad2deg*z(j,i),j=2,3)
1186 write (iout,*) 'W1:',(w1(i),i=1,nlobit)
1187 write (iout,*) 'detAp:',(detAp(i),i=1,nlobit)
1190 write (iout,'(i2,3f10.5)') i,(rad2deg*z(j,i),j=2,3)
1194 ! Writing the distribution just to check the procedure
1196 dV=deg2rad**2*10.0D0
1200 fac=fac+W1(i)/detAp(i)
1202 fac=1.0D0/(2.0D0*fac*pi)
1203 !d print *,it,'fac=',fac
1212 a(j-1,k-1)=gaussc(j,k,i,it)
1224 wykl=wykl+a(j,k)*(y(j)-z(j+1,i))*(y(k)-z(k+1,i))
1227 wart=wart+W1(i)*dexp(-0.5D0*wykl)
1234 ! print *,'y',y(1),y(2),' fac=',fac
1236 write (20,'(2f10.3,1pd15.5)') y(1)*rad2deg,y(2)*rad2deg,wart
1241 ! print *,'it=',it,' sum=',sum*dV,' sum1=',sum1*dV
1245 ! Calculate the CM of the system
1248 W1(i)=W1(i)/detAp(i)
1252 sumW(i)=sumW(i-1)+W1(i)
1257 cm(1)=cm(1)+z(2,j)*W1(j)
1258 cm(2)=cm(2)+W1(j)*(z(3,1)+pinorm(z(3,j)-z(3,1)))
1260 cm(1)=cm(1)/sumW(nlobit)
1261 cm(2)=cm(2)/sumW(nlobit)
1262 if (cm(1).gt.Big .or. cm(1).lt.-Big .or. &
1263 cm(2).gt.Big .or. cm(2).lt.-Big) then
1264 !d write (iout,'(a)')
1265 !d & 'Unexpected error in GenSide - CM coordinates too large.'
1266 !d write (iout,'(i5,2(1pe14.5))') it,cm(1),cm(2)
1268 !d & 'Unexpected error in GenSide - CM coordinates too large.'
1269 !d write (*,'(i5,2(1pe14.5))') it,cm(1),cm(2)
1273 !d print *,'CM:',cm(1),cm(2)
1275 ! Find the largest search distance from CM
1281 a(j-1,k-1)=gaussc(j,k,i,it)
1285 call f02faf('N','U',2,a,3,eig,work,100,ifail)
1287 call djacob(2,3,10000,1.0d-10,a,vec,eig)
1291 print *,'*************** CG Processor',me
1292 print *,'CM:',cm(1),cm(2)
1293 write (iout,*) '*************** CG Processor',me
1294 write (iout,*) 'CM:',cm(1),cm(2)
1295 print '(A,8f10.5)','Eigenvalues: ',(1.0/dsqrt(eig(k)),k=1,2)
1296 write (iout,'(A,8f10.5)') &
1297 'Eigenvalues: ',(1.0/dsqrt(eig(k)),k=1,2)
1300 if (eig(1).lt.eig_limit) then
1302 'From Mult_Norm: Eigenvalues of A are too small.'
1304 'From Mult_Norm: Eigenvalues of A are too small.'
1311 radius=radius+pinorm(z(j+1,i)-cm(j))**2
1313 radius=dsqrt(radius)+3.0D0/dsqrt(eig(1))
1314 if (radius.gt.radmax) radmax=radius
1316 if (radmax.gt.pi) radmax=pi
1318 ! Determine the boundaries of the search rectangle.
1321 print '(a,4(1pe14.4))','W1: ',(W1(i),i=1,nlob(it) )
1322 print '(a,4(1pe14.4))','radmax: ',radmax
1324 box(1,1)=dmax1(cm(1)-radmax,0.0D0)
1325 box(2,1)=dmin1(cm(1)+radmax,pi)
1326 box(1,2)=cm(2)-radmax
1327 box(2,2)=cm(2)+radmax
1330 print *,'CG Processor',me,' Array BOX:'
1332 print *,'Array BOX:'
1334 print '(4(1pe14.4))',((box(k,j),k=1,2),j=1,2)
1335 print '(a,4(1pe14.4))','sumW: ',(sumW(i),i=0,nlob(it) )
1337 write (iout,*)'CG Processor',me,' Array BOX:'
1339 write (iout,*)'Array BOX:'
1341 write(iout,'(4(1pe14.4))') ((box(k,j),k=1,2),j=1,2)
1342 write(iout,'(a,4(1pe14.4))')'sumW: ',(sumW(i),i=0,nlob(it) )
1344 if (box(1,2).lt.-MaxBoxLen .or. box(2,2).gt.MaxBoxLen) then
1346 write (iout,'(a,i4,a,3e15.5)') 'CG Processor:',me,': bad sampling box.',box(1,2),box(2,2),radmax
1347 write (*,'(a,i4,a)') 'CG Processor:',me,': bad sampling box.'
1349 ! write (iout,'(a)') 'Bad sampling box.'
1354 which_lobe=ran_number(0.0D0,sumW(nlobit))
1355 ! print '(a,1pe14.4)','which_lobe=',which_lobe
1357 if (sumW(i-1).le.which_lobe .and. sumW(i).ge.which_lobe) goto 1
1360 ! print *,'ilob=',ilob,' nlob=',nlob(it)
1364 a(i-1,j-1)=gaussc(i,j,ilob,it)
1367 !d print '(a,i4,a)','CG Processor',me,' Calling MultNorm1.'
1368 call mult_norm1(3,2,a,cm,box,y,fail)
1372 !d print *,'al=',al,' om=',om
1375 end subroutine gen_side
1376 !-----------------------------------------------------------------------------
1377 subroutine overlap_sc(scfail)
1379 ! Internal and cartesian coordinates must be consistent as input,
1380 ! and will be up-to-date on return.
1381 ! At the end of this procedure, scfail is true if there are
1382 ! overlapping residues left, or false otherwise (success)
1384 ! implicit real*8 (a-h,o-z)
1385 ! include 'DIMENSIONS'
1386 ! include 'COMMON.CHAIN'
1387 ! include 'COMMON.INTERACT'
1388 ! include 'COMMON.FFIELD'
1389 ! include 'COMMON.VAR'
1390 ! include 'COMMON.SBRIDGE'
1391 ! include 'COMMON.IOUNITS'
1392 logical :: had_overlaps,fail,scfail
1393 integer,dimension(nres) :: ioverlap !(maxres)
1394 integer :: ioverlap_last,k,maxsi,i,iti,nsi
1397 had_overlaps=.false.
1398 call overlap_sc_list(ioverlap,ioverlap_last)
1399 if (ioverlap_last.gt.0) then
1400 write (iout,*) '#OVERLAPing residues ',ioverlap_last
1401 write (iout,'(20i4)') (ioverlap(k),k=1,ioverlap_last)
1407 if (ioverlap_last.eq.0) exit
1409 do ires=1,ioverlap_last
1411 iti=iabs(itype(i,1))
1415 do while (fail.and.nsi.le.maxsi)
1416 call gen_side(iti,theta(i+1),alph(i),omeg(i),fail)
1424 call overlap_sc_list(ioverlap,ioverlap_last)
1425 ! write (iout,*) 'Overlaping residues ',ioverlap_last,
1426 ! & (ioverlap(j),j=1,ioverlap_last)
1429 if (k.le.1000.and.ioverlap_last.eq.0) then
1431 if (had_overlaps) then
1432 write (iout,*) '#OVERLAPing all corrected after ',k,&
1433 ' random generation'
1437 write (iout,*) '#OVERLAPing NOT all corrected ',ioverlap_last
1438 write (iout,'(20i4)') (ioverlap(j),j=1,ioverlap_last)
1444 write (iout,'(a30,i5,a12,i4)') &
1445 '#OVERLAP FAIL in gen_side after',maxsi,&
1449 end subroutine overlap_sc
1450 !-----------------------------------------------------------------------------
1451 subroutine overlap_sc_list(ioverlap,ioverlap_last)
1453 ! implicit real*8 (a-h,o-z)
1454 ! include 'DIMENSIONS'
1455 ! include 'COMMON.GEO'
1456 ! include 'COMMON.LOCAL'
1457 ! include 'COMMON.IOUNITS'
1458 ! include 'COMMON.CHAIN'
1459 ! include 'COMMON.INTERACT'
1460 ! include 'COMMON.FFIELD'
1461 ! include 'COMMON.VAR'
1462 ! include 'COMMON.CALC'
1464 integer,dimension(nres) :: ioverlap !(maxres)
1465 integer :: ioverlap_last
1468 real(kind=8) :: redfac,sig !rrij,sigsq,
1469 integer :: itypi,itypj,itypi1
1470 real(kind=8) :: xi,yi,zi,sig0ij,rcomp,rrij,rij_shift
1474 ! Check for SC-SC overlaps and mark residues
1475 ! print *,'>>overlap_sc nnt=',nnt,' nct=',nct
1477 do i=iatsc_s,iatsc_e
1478 if (itype(i,molnum(i)).eq.ntyp1_molec(molnum(i))) cycle
1479 itypi=iabs(itype(i,molnum(i)))
1480 itypi1=iabs(itype(i+1,1))
1484 dxi=dc_norm(1,nres+i)
1485 dyi=dc_norm(2,nres+i)
1486 dzi=dc_norm(3,nres+i)
1487 dsci_inv=dsc_inv(itypi)
1489 do iint=1,nint_gr(i)
1490 do j=istart(i,iint),iend(i,iint)
1491 if (itype(j,molnum(j)).eq.ntyp1_molec(molnum(j))) cycle
1493 itypj=iabs(itype(j,molnum(j)))
1494 dscj_inv=dsc_inv(itypj)
1495 sig0ij=sigma(itypi,itypj)
1496 chi1=chi(itypi,itypj)
1497 chi2=chi(itypj,itypi)
1504 alf12=0.5D0*(alf1+alf2)
1506 rcomp=sigmaii(itypi,itypj)
1508 rcomp=sigma(itypi,itypj)
1510 ! print '(2(a3,2i3),a3,2f10.5)',
1511 ! & ' i=',i,iti,' j=',j,itj,' d=',dist(nres+i,nres+j)
1516 dxj=dc_norm(1,nres+j)
1517 dyj=dc_norm(2,nres+j)
1518 dzj=dc_norm(3,nres+j)
1519 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1523 sig=sig0ij*dsqrt(sigsq)
1524 rij_shift=1.0D0/rij-sig+sig0ij
1526 !t if ( 1.0/rij .lt. redfac*rcomp .or.
1527 !t & rij_shift.le.0.0D0 ) then
1528 if ( rij_shift.le.0.0D0 ) then
1529 !d write (iout,'(a,i3,a,i3,a,f10.5,a,3f10.5)')
1530 !d & 'overlap SC-SC: i=',i,' j=',j,
1531 !d & ' dist=',dist(nres+i,nres+j),' rcomp=',
1532 !d & rcomp,1.0/rij,rij_shift
1533 ioverlap_last=ioverlap_last+1
1534 ioverlap(ioverlap_last)=i
1535 do k=1,ioverlap_last-1
1536 if (ioverlap(k).eq.i) ioverlap_last=ioverlap_last-1
1538 ioverlap_last=ioverlap_last+1
1539 ioverlap(ioverlap_last)=j
1540 do k=1,ioverlap_last-1
1541 if (ioverlap(k).eq.j) ioverlap_last=ioverlap_last-1
1548 end subroutine overlap_sc_list
1550 !-----------------------------------------------------------------------------
1551 ! energy_p_new_barrier.F
1552 !-----------------------------------------------------------------------------
1553 subroutine sc_angular
1554 ! Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
1555 ! om12. Called by ebp, egb, and egbv.
1558 ! include 'COMMON.CALC'
1559 ! include 'COMMON.IOUNITS'
1563 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
1564 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
1565 om12=dxi*dxj+dyi*dyj+dzi*dzj
1567 ! Calculate eps1(om12) and its derivative in om12
1568 faceps1=1.0D0-om12*chiom12
1569 faceps1_inv=1.0D0/faceps1
1570 eps1=dsqrt(faceps1_inv)
1571 ! Following variable is eps1*deps1/dom12
1572 eps1_om12=faceps1_inv*chiom12
1577 ! write (iout,*) "om12",om12," eps1",eps1
1578 ! Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
1583 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
1584 sigsq=1.0D0-facsig*faceps1_inv
1585 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
1586 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
1587 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
1593 ! write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
1594 ! write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
1596 ! Calculate eps2 and its derivatives in om1, om2, and om12.
1599 chipom12=chip12*om12
1600 facp=1.0D0-om12*chipom12
1602 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
1603 ! write (iout,*) "chipom1",chipom1," chipom2",chipom2,
1604 ! & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
1605 ! Following variable is the square root of eps2
1606 eps2rt=1.0D0-facp1*facp_inv
1607 ! Following three variables are the derivatives of the square root of eps
1608 ! in om1, om2, and om12.
1609 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
1610 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
1611 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
1612 ! Evaluate the "asymmetric" factor in the VDW constant, eps3
1613 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
1614 ! write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
1615 ! write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
1616 ! & " eps2rt_om12",eps2rt_om12
1617 ! Calculate whole angle-dependent part of epsilon and contributions
1618 ! to its derivatives
1620 end subroutine sc_angular
1621 !-----------------------------------------------------------------------------
1623 subroutine sc_angular_nucl
1624 ! Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
1625 ! om12. Called by ebp, egb, and egbv.
1628 ! include 'COMMON.CALC'
1629 ! include 'COMMON.IOUNITS'
1635 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
1636 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
1637 om12=dxi*dxj+dyi*dyj+dzi*dzj
1639 ! Calculate eps1(om12) and its derivative in om12
1640 faceps1=1.0D0-om12*chiom12
1641 faceps1_inv=1.0D0/faceps1
1642 eps1=dsqrt(faceps1_inv)
1643 ! Following variable is eps1*deps1/dom12
1644 eps1_om12=faceps1_inv*chiom12
1649 ! write (iout,*) "om12",om12," eps1",eps1
1650 ! Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
1655 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
1656 sigsq=1.0D0-facsig*faceps1_inv
1657 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
1658 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
1659 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
1662 chipom12=chip12*om12
1663 facp=1.0D0-om12*chipom12
1665 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
1666 ! write (iout,*) "chipom1",chipom1," chipom2",chipom2,
1667 ! & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
1668 ! Following variable is the square root of eps2
1669 eps2rt=1.0D0-facp1*facp_inv
1670 ! Following three variables are the derivatives of the square root of eps
1671 ! in om1, om2, and om12.
1672 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
1673 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
1674 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
1675 ! Evaluate the "asymmetric" factor in the VDW constant, eps3
1676 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
1677 ! write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
1678 ! write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
1679 ! & " eps2rt_om12",eps2rt_om12
1680 ! Calculate whole angle-dependent part of epsilon and contributions
1681 ! to its derivatives
1683 end subroutine sc_angular_nucl
1685 !-----------------------------------------------------------------------------
1686 subroutine int_bounds(total_ints,lower_bound,upper_bound)
1687 ! implicit real*8 (a-h,o-z)
1688 ! include 'DIMENSIONS'
1690 ! include 'COMMON.SETUP'
1691 integer :: total_ints,lower_bound,upper_bound,nint
1692 integer,dimension(0:nfgtasks) :: int4proc,sint4proc !(0:max_fg_procs)
1693 integer :: i,nexcess
1694 nint=total_ints/nfgtasks
1698 nexcess=total_ints-nint*nfgtasks
1700 int4proc(nfgtasks-i)=int4proc(nfgtasks-i)+1
1704 lower_bound=lower_bound+int4proc(i)
1706 upper_bound=lower_bound+int4proc(fg_rank)
1707 lower_bound=lower_bound+1
1709 end subroutine int_bounds
1710 !-----------------------------------------------------------------------------
1711 subroutine int_bounds1(total_ints,lower_bound,upper_bound)
1712 ! implicit real*8 (a-h,o-z)
1713 ! include 'DIMENSIONS'
1715 ! include 'COMMON.SETUP'
1716 integer :: total_ints,lower_bound,upper_bound,nint
1717 integer :: nexcess,i
1718 integer,dimension(0:nfgtasks) :: int4proc,sint4proc !(0:max_fg_procs)
1719 nint=total_ints/nfgtasks1
1723 nexcess=total_ints-nint*nfgtasks1
1725 int4proc(nfgtasks1-i)=int4proc(nfgtasks1-i)+1
1729 lower_bound=lower_bound+int4proc(i)
1731 upper_bound=lower_bound+int4proc(fg_rank1)
1732 lower_bound=lower_bound+1
1734 end subroutine int_bounds1
1735 !-----------------------------------------------------------------------------
1737 !-----------------------------------------------------------------------------
1738 subroutine chainbuild_cart
1739 ! implicit real*8 (a-h,o-z)
1740 ! include 'DIMENSIONS'
1745 ! include 'COMMON.SETUP'
1746 ! include 'COMMON.CHAIN'
1747 ! include 'COMMON.LOCAL'
1748 ! include 'COMMON.TIME1'
1749 ! include 'COMMON.IOUNITS'
1750 integer :: j,i,ierror,ierr
1751 real(kind=8) :: time00,time01
1753 if (nfgtasks.gt.1) then
1754 ! write (iout,*) "BCAST in chainbuild_cart"
1756 ! Broadcast the order to build the chain and compute internal coordinates
1757 ! to the slaves. The slaves receive the order in ERGASTULUM.
1759 ! write (iout,*) "CHAINBUILD_CART: DC before BCAST"
1761 ! write (iout,'(i3,3f10.5,5x,3f10.5)') i,(dc(j,i),j=1,3),
1762 ! & (dc(j,i+nres),j=1,3)
1765 call MPI_Bcast(7,1,MPI_INTEGER,king,FG_COMM,IERROR)
1766 time_bcast7=time_bcast7+MPI_Wtime()-time00
1768 call MPI_Bcast(dc(1,0),6*(nres+1),MPI_DOUBLE_PRECISION,&
1770 ! write (iout,*) "CHAINBUILD_CART: DC after BCAST"
1772 ! write (iout,'(i3,3f10.5,5x,3f10.5)') i,(dc(j,i),j=1,3),
1773 ! & (dc(j,i+nres),j=1,3)
1775 ! write (iout,*) "End BCAST in chainbuild_cart"
1777 time_bcast=time_bcast+MPI_Wtime()-time00
1778 time_bcastc=time_bcastc+MPI_Wtime()-time01
1786 c(j,i)=c(j,i-1)+dc(j,i-1)
1791 c(j,i+nres)=c(j,i)+dc(j,i+nres)
1794 ! write (iout,*) "CHAINBUILD_CART"
1796 call int_from_cart1(.false.)
1798 end subroutine chainbuild_cart
1799 !-----------------------------------------------------------------------------
1801 !-----------------------------------------------------------------------------
1802 real(kind=8) function alpha(i1,i2,i3)
1804 ! Calculates the planar angle between atoms (i1), (i2), and (i3).
1806 ! implicit real*8 (a-h,o-z)
1807 ! include 'DIMENSIONS'
1808 ! include 'COMMON.GEO'
1809 ! include 'COMMON.CHAIN'
1812 real(kind=8) :: x12,x23,y12,y23,z12,z23,vnorm,wnorm,scalar
1819 vnorm=dsqrt(x12*x12+y12*y12+z12*z12)
1820 wnorm=dsqrt(x23*x23+y23*y23+z23*z23)
1821 scalar=(x12*x23+y12*y23+z12*z23)/(vnorm*wnorm)
1825 !-----------------------------------------------------------------------------
1826 real(kind=8) function beta(i1,i2,i3,i4)
1828 ! Calculates the dihedral angle between atoms (i1), (i2), (i3) and (i4)
1830 ! implicit real*8 (a-h,o-z)
1831 ! include 'DIMENSIONS'
1832 ! include 'COMMON.GEO'
1833 ! include 'COMMON.CHAIN'
1835 integer :: i1,i2,i3,i4
1836 real(kind=8) :: x12,x23,x34,y12,y23,y34,z12,z23,z34
1837 real(kind=8) :: wx,wy,wz,wnorm,vx,vy,vz,vnorm,scalar,angle
1838 real(kind=8) :: tx,ty,tz
1848 !d print '(2i3,3f10.5)',i1,i2,x12,y12,z12
1849 !d print '(2i3,3f10.5)',i2,i3,x23,y23,z23
1850 !d print '(2i3,3f10.5)',i3,i4,x34,y34,z34
1854 wnorm=dsqrt(wx*wx+wy*wy+wz*wz)
1858 vnorm=dsqrt(vx*vx+vy*vy+vz*vz)
1859 if (vnorm.gt.1.0D-13 .and. wnorm.gt.1.0D-13) then
1860 scalar=(vx*wx+vy*wy+vz*wz)/(vnorm*wnorm)
1861 if (dabs(scalar).gt.1.0D0) &
1862 scalar=0.99999999999999D0*scalar/dabs(scalar)
1864 !d print '(2i4,10f7.3)',i2,i3,vx,vy,vz,wx,wy,wz,vnorm,wnorm,
1869 ! if (angle.le.0.0D0) angle=pi+angle
1873 scalar=tx*x23+ty*y23+tz*z23
1874 if (scalar.lt.0.0D0) angle=-angle
1878 !-----------------------------------------------------------------------------
1879 real(kind=8) function dist(i1,i2)
1881 ! Calculates the distance between atoms (i1) and (i2).
1883 ! implicit real*8 (a-h,o-z)
1884 ! include 'DIMENSIONS'
1885 ! include 'COMMON.GEO'
1886 ! include 'COMMON.CHAIN'
1889 real(kind=8) :: x12,y12,z12
1893 dist=dsqrt(x12*x12+y12*y12+z12*z12)
1896 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
1897 !-----------------------------------------------------------------------------
1899 !-----------------------------------------------------------------------------
1900 subroutine local_move_init(debug)
1904 ! implicit real*8 (a-h,o-z)
1905 ! include 'DIMENSIONS' ! Needed by COMMON.LOCAL
1906 ! include 'COMMON.GEO' ! For pi, deg2rad
1907 ! include 'COMMON.LOCAL' ! For vbl
1908 ! include 'COMMON.LOCMOVE'
1914 ! Determine wheter to do some debugging output
1915 locmove_output=debug
1917 ! Set the init_called flag to 1
1920 ! The following are never changed
1921 min_theta=60.D0*deg2rad ! (0,PI)
1922 max_theta=175.D0*deg2rad ! (0,PI)
1923 dmin2=vbl*vbl*2.*(1.-cos(min_theta))
1924 dmax2=vbl*vbl*2.*(1.-cos(max_theta))
1927 small2=0.5*small*small
1929 ! Not really necessary...
1935 end subroutine local_move_init
1936 !-----------------------------------------------------------------------------
1937 subroutine local_move(n_start, n_end, PHImin, PHImax)
1938 ! Perform a local move between residues m and n (inclusive)
1939 ! PHImin and PHImax [0,PI] determine the size of the move
1940 ! Works on whatever structure is in the variables theta and phi,
1941 ! sidechain variables are left untouched
1942 ! The final structure is NOT minimized, but both the cartesian
1943 ! variables c and the angles are up-to-date at the end (no further
1944 ! chainbuild is required)
1946 use random,only:ran_number
1948 ! implicit real*8 (a-h,o-z)
1949 ! include 'DIMENSIONS'
1950 ! include 'COMMON.GEO'
1951 ! include 'COMMON.CHAIN'
1952 ! include 'COMMON.VAR'
1953 ! include 'COMMON.MINIM'
1954 ! include 'COMMON.SBRIDGE'
1955 ! include 'COMMON.LOCMOVE'
1957 ! External functions
1958 !EL integer move_res
1959 !EL external move_res
1960 !EL double precision ran_number
1961 !EL external ran_number
1964 integer :: n_start, n_end ! First and last residues to move
1965 real(kind=8) :: PHImin, PHImax ! min/max angles [0,PI]
1969 real(kind=8) :: min,max
1973 ! Check if local_move_init was called. This assumes that it
1974 ! would not be 1 if not explicitely initialized
1975 if (init_called.ne.1) then
1976 write(6,*)' *** local_move_init not called!!!'
1980 ! Quick check for crazy range
1981 if (n_start.gt.n_end .or. n_start.lt.1 .or. n_end.gt.nres) then
1982 write(6,'(a,i3,a,i3)') &
1983 ' *** Cannot make local move between n_start = ',&
1984 n_start,' and n_end = ',n_end
1988 ! Take care of end residues first...
1989 if (n_start.eq.1) then
1990 ! Move residue 1 (completely random)
1991 theta(3)=ran_number(min_theta,max_theta)
1992 phi(4)=ran_number(-PI,PI)
1997 if (n_end.eq.nres) then
1998 ! Move residue nres (completely random)
1999 theta(nres)=ran_number(min_theta,max_theta)
2000 phi(nres)=ran_number(-PI,PI)
2006 ! ...then go through all other residues one by one
2007 ! Start from the two extremes and converge
2012 !$$$c Move the first two residues by less than the others
2013 !$$$ if (i-n_start.lt.3) then
2014 !$$$ if (i-n_start.eq.0) then
2017 !$$$ else if (i-n_start.eq.1) then
2020 !$$$ else if (i-n_start.eq.2) then
2026 ! The actual move, on residue i
2027 iretcode=move_res(min,max,i) ! Discard iretcode
2033 !$$$c Move the last two residues by less than the others
2034 !$$$ if (n_end-j.lt.3) then
2035 !$$$ if (n_end-j.eq.0) then
2038 !$$$ else if (n_end-j.eq.1) then
2041 !$$$ else if (n_end-j.eq.2) then
2047 ! The actual move, on residue j
2048 iretcode=move_res(min,max,j) ! Discard iretcode
2053 call int_from_cart(.false.,.false.)
2056 end subroutine local_move
2057 !-----------------------------------------------------------------------------
2058 subroutine output_tabs
2059 ! Prints out the contents of a_..., b_..., res_...
2063 ! include 'COMMON.GEO'
2064 ! include 'COMMON.LOCMOVE'
2070 write(6,'(8f7.1)')(a_ang(i)*rad2deg,i=0,a_n-1)
2071 write(6,'(8(2x,3l1,2x))')((a_tab(i,j),i=0,2),j=0,a_n-1)
2074 write(6,'(4f7.1)')(b_ang(i)*rad2deg,i=0,b_n-1)
2075 write(6,'(4(2x,3l1,2x))')((b_tab(i,j),i=0,2),j=0,b_n-1)
2078 write(6,'(12f7.1)')(res_ang(i)*rad2deg,i=0,res_n-1)
2079 write(6,'(12(2x,3l1,2x))')((res_tab(0,i,j),i=0,2),j=0,res_n-1)
2080 write(6,'(12(2x,3l1,2x))')((res_tab(1,i,j),i=0,2),j=0,res_n-1)
2081 write(6,'(12(2x,3l1,2x))')((res_tab(2,i,j),i=0,2),j=0,res_n-1)
2084 end subroutine output_tabs
2085 !-----------------------------------------------------------------------------
2086 subroutine angles2tab(PHImin,PHImax,n,ang,tab)
2087 ! Only uses angles if [0,PI] (but PHImin cannot be 0.,
2088 ! and PHImax cannot be PI)
2092 ! include 'COMMON.GEO'
2095 real(kind=8) :: PHImin,PHImax
2099 real(kind=8),dimension(0:3) :: ang
2100 logical,dimension(0:2,0:3) :: tab
2103 if (PHImin .eq. PHImax) then
2104 ! Special case with two 010's
2114 else if (PHImin .eq. PI) then
2115 ! Special case with one 010
2121 else if (PHImax .eq. 0.) then
2122 ! Special case with one 010
2131 if (PHImin .gt. 0.) then
2132 ! Start of range (011)
2137 ! End of range (110)
2141 tab(2,n+1) = .false.
2144 if (PHImax .lt. PI) then
2145 ! Start of range (011)
2150 ! End of range (110)
2154 tab(2,n+1) = .false.
2160 end subroutine angles2tab
2161 !-----------------------------------------------------------------------------
2162 subroutine minmax_angles(x,y,z,r,n,ang,tab)
2163 ! When solutions do not exist, assume all angles
2164 ! are acceptable - i.e., initial geometry must be correct
2168 ! include 'COMMON.GEO'
2169 ! include 'COMMON.LOCMOVE'
2172 real(kind=8) :: x,y,z,r
2176 real(kind=8),dimension(0:3) :: ang
2177 logical,dimension(0:2,0:3) :: tab
2180 real(kind=8) :: num, denom, phi
2181 real(kind=8) :: Kmin, Kmax
2185 num = x*x + y*y + z*z
2188 if (denom .gt. 0.) then
2190 denom = 2.*r*sqrt(denom)
2192 Kmin = (num - dmin2)/denom
2193 Kmax = (num - dmax2)/denom
2195 ! Allowed values of K (else all angles are acceptable)
2198 if (Kmin .gt. 1. .or. abs(Kmin-1.) .lt. small2) then
2200 else if (Kmin .lt. -1. .or. abs(Kmin+1.) .lt. small2) then
2206 if (Kmax .lt. -1. .or. abs(Kmax+1.) .lt. small2) then
2208 else if (Kmax .gt. 1. .or. abs(Kmax-1.) .lt. small2) then
2214 if (Kmax .lt. Kmin) Kmax = Kmin
2216 call angles2tab(Kmin, Kmax, n, ang, tab)
2218 ! Add phi and check that angles are within range (-PI,PI]
2221 if (ang(i) .le. -PI) then
2222 ang(i) = ang(i)+2.*PI
2223 else if (ang(i) .gt. PI) then
2224 ang(i) = ang(i)-2.*PI
2230 end subroutine minmax_angles
2231 !-----------------------------------------------------------------------------
2232 subroutine construct_tab
2233 ! Take a_... and b_... values and produces the results res_...
2234 ! x_ang are assumed to be all different (diff > small)
2235 ! x_tab(1,i) must be 1 for all i (i.e., all x_ang are acceptable)
2239 ! include 'COMMON.LOCMOVE'
2242 integer :: n_max,i,j,index
2248 if (n_max .eq. 0) then
2255 res_tab(j,0,i) = .true.
2256 res_tab(j,2,i) = .true.
2257 res_tab(j,1,i) = .false.
2264 do while (.not.done)
2265 res_ang(index) = flag
2269 if ((a_ang(i)-phi).gt.small .and. &
2270 a_ang(i) .lt. res_ang(index)) then
2271 ! Found a lower angle
2272 res_ang(index) = a_ang(i)
2273 ! Copy the values from a_tab into res_tab(0,,)
2274 res_tab(0,0,index) = a_tab(0,i)
2275 res_tab(0,1,index) = a_tab(1,i)
2276 res_tab(0,2,index) = a_tab(2,i)
2277 ! Set default values for res_tab(1,,)
2278 res_tab(1,0,index) = .true.
2279 res_tab(1,1,index) = .false.
2280 res_tab(1,2,index) = .true.
2281 else if (abs(a_ang(i)-res_ang(index)).lt.small) then
2282 ! Found an equal angle (can only be equal to a b_ang)
2283 res_tab(0,0,index) = a_tab(0,i)
2284 res_tab(0,1,index) = a_tab(1,i)
2285 res_tab(0,2,index) = a_tab(2,i)
2290 if ((b_ang(i)-phi).gt.small .and. &
2291 b_ang(i) .lt. res_ang(index)) then
2292 ! Found a lower angle
2293 res_ang(index) = b_ang(i)
2294 ! Copy the values from b_tab into res_tab(1,,)
2295 res_tab(1,0,index) = b_tab(0,i)
2296 res_tab(1,1,index) = b_tab(1,i)
2297 res_tab(1,2,index) = b_tab(2,i)
2298 ! Set default values for res_tab(0,,)
2299 res_tab(0,0,index) = .true.
2300 res_tab(0,1,index) = .false.
2301 res_tab(0,2,index) = .true.
2302 else if (abs(b_ang(i)-res_ang(index)).lt.small) then
2303 ! Found an equal angle (can only be equal to an a_ang)
2304 res_tab(1,0,index) = b_tab(0,i)
2305 res_tab(1,1,index) = b_tab(1,i)
2306 res_tab(1,2,index) = b_tab(2,i)
2310 if (res_ang(index) .eq. flag) then
2313 else if (index .eq. n_max-1) then
2317 phi = res_ang(index) ! Store previous angle
2325 if (a_n .gt. 0) then
2326 do while (.not.res_tab(0,1,index))
2329 done = res_tab(0,2,index)
2330 do i=index+1,res_n-1
2331 if (res_tab(0,1,i)) then
2332 done = res_tab(0,2,i)
2334 res_tab(0,0,i) = done
2335 res_tab(0,1,i) = done
2336 res_tab(0,2,i) = done
2339 done = res_tab(0,0,index)
2341 if (res_tab(0,1,i)) then
2342 done = res_tab(0,0,i)
2344 res_tab(0,0,i) = done
2345 res_tab(0,1,i) = done
2346 res_tab(0,2,i) = done
2351 res_tab(0,0,i) = .true.
2352 res_tab(0,1,i) = .true.
2353 res_tab(0,2,i) = .true.
2358 if (b_n .gt. 0) then
2359 do while (.not.res_tab(1,1,index))
2362 done = res_tab(1,2,index)
2363 do i=index+1,res_n-1
2364 if (res_tab(1,1,i)) then
2365 done = res_tab(1,2,i)
2367 res_tab(1,0,i) = done
2368 res_tab(1,1,i) = done
2369 res_tab(1,2,i) = done
2372 done = res_tab(1,0,index)
2374 if (res_tab(1,1,i)) then
2375 done = res_tab(1,0,i)
2377 res_tab(1,0,i) = done
2378 res_tab(1,1,i) = done
2379 res_tab(1,2,i) = done
2384 res_tab(1,0,i) = .true.
2385 res_tab(1,1,i) = .true.
2386 res_tab(1,2,i) = .true.
2390 ! Finally fill the last row with AND operation
2393 res_tab(2,j,i) = (res_tab(0,j,i) .and. res_tab(1,j,i))
2398 end subroutine construct_tab
2399 !-----------------------------------------------------------------------------
2400 subroutine construct_ranges(phi_n,phi_start,phi_end)
2401 ! Given the data in res_..., construct a table of
2402 ! min/max allowed angles
2406 ! include 'COMMON.GEO'
2407 ! include 'COMMON.LOCMOVE'
2411 real(kind=8),dimension(0:11) :: phi_start,phi_end
2418 if (res_n .eq. 0) then
2419 ! Any move is allowed
2427 do while (.not.done)
2428 ! Find start of range (01x)
2430 do while (.not.done)
2431 if (res_tab(2,0,index).or.(.not.res_tab(2,1,index))) then
2435 phi_start(phi_n) = res_ang(index)
2437 if (index .eq. res_n) done = .true.
2439 ! If a start was found (index < res_n), find the end of range (x10)
2440 ! It may not be found without wrapping around
2441 if (index .lt. res_n) then
2443 do while (.not.done)
2444 if ((.not.res_tab(2,1,index)).or.res_tab(2,2,index)) then
2449 if (index .eq. res_n) done = .true.
2451 if (index .lt. res_n) then
2452 ! Found the end of the range
2453 phi_end(phi_n) = res_ang(index)
2456 if (index .eq. res_n) then
2462 ! Need to wrap around
2464 phi_end(phi_n) = flag
2468 ! Take care of the last one if need to wrap around
2469 if (phi_end(phi_n) .eq. flag) then
2471 do while ((.not.res_tab(2,1,index)).or.res_tab(2,2,index))
2474 phi_end(phi_n) = res_ang(index) + 2.*PI
2480 end subroutine construct_ranges
2481 !-----------------------------------------------------------------------------
2482 subroutine fix_no_moves(phi)
2486 ! include 'COMMON.GEO'
2487 ! include 'COMMON.LOCMOVE'
2494 real(kind=8) :: diff,temp
2497 ! Look for first 01x in gammas (there MUST be at least one)
2500 do while (res_tab(1,0,index) .or. (.not.res_tab(1,1,index)))
2503 if (res_ang(index) .le. 0.D0) then ! Make sure it's from PHImax
2504 ! Try to increase PHImax
2505 if (index .gt. 0) then
2506 phi = res_ang(index-1)
2507 diff = abs(res_ang(index) - res_ang(index-1))
2509 ! Look for last (corresponding) x10
2511 do while ((.not.res_tab(1,1,index)) .or. res_tab(1,2,index))
2514 if (index .lt. res_n-1) then
2515 temp = abs(res_ang(index) - res_ang(index+1))
2516 if (temp .lt. diff) then
2517 phi = res_ang(index+1)
2523 ! If increasing PHImax didn't work, decreasing PHImin
2524 ! will (with one exception)
2525 ! Look for first x10 (there MUST be at least one)
2527 do while ((.not.res_tab(1,1,index)) .or. res_tab(1,2,index))
2530 if (res_ang(index) .lt. 0.D0) then ! Make sure it's from PHImin
2531 ! Try to decrease PHImin
2532 if (index .lt. res_n-1) then
2533 temp = abs(res_ang(index) - res_ang(index+1))
2534 if (res_ang(index+1) .le. 0.D0 .and. temp .lt. diff) then
2535 phi = res_ang(index+1)
2539 ! Look for last (corresponding) 01x
2541 do while (res_tab(1,0,index) .or. (.not.res_tab(1,1,index)))
2544 if (index .gt. 0) then
2545 temp = abs(res_ang(index) - res_ang(index-1))
2546 if (res_ang(index-1) .ge. 0.D0 .and. temp .lt. diff) then
2547 phi = res_ang(index-1)
2553 ! If it still didn't work, it must be PHImax == 0. or PHImin == PI
2554 if (diff .eq. flag) then
2556 if (res_tab(index,1,0) .or. (.not.res_tab(index,1,1)) .or. &
2557 res_tab(index,1,2)) index = res_n - 1
2558 ! This MUST work at this point
2559 if (index .eq. 0) then
2562 phi = res_ang(index - 1)
2567 end subroutine fix_no_moves
2568 !-----------------------------------------------------------------------------
2569 integer function move_res(PHImin,PHImax,i_move)
2570 ! Moves residue i_move (in array c), leaving everything else fixed
2571 ! Starting geometry is not checked, it should be correct!
2572 ! R(,i_move) is the only residue that will move, but must have
2573 ! 1 < i_move < nres (i.e., cannot move ends)
2574 ! Whether any output is done is controlled by locmove_output
2576 use random,only:ran_number
2578 ! implicit real*8 (a-h,o-z)
2579 ! include 'DIMENSIONS'
2580 ! include 'COMMON.CHAIN'
2581 ! include 'COMMON.GEO'
2582 ! include 'COMMON.LOCMOVE'
2584 ! External functions
2585 !EL double precision ran_number
2586 !EL external ran_number
2589 real(kind=8) :: PHImin,PHImax
2593 ! 0: move successfull
2594 ! 1: Dmin or Dmax had to be modified
2595 ! 2: move failed - check your input geometry
2599 real(kind=8),dimension(0:2) :: X,Y,Z,Orig
2600 real(kind=8),dimension(0:2) :: P
2601 logical :: no_moves,done
2602 integer :: index,i,j
2603 real(kind=8) :: phi,temp,radius
2604 real(kind=8),dimension(0:11) :: phi_start,phi_end
2607 ! Set up the coordinate system
2609 Orig(i)=0.5*(c(i+1,i_move-1)+c(i+1,i_move+1)) ! Position of origin
2613 Z(i)=c(i+1,i_move+1)-c(i+1,i_move-1)
2615 temp=sqrt(Z(0)*Z(0)+Z(1)*Z(1)+Z(2)*Z(2))
2621 X(i)=c(i+1,i_move)-Orig(i)
2623 ! radius is the radius of the circle on which c(,i_move) can move
2624 radius=sqrt(X(0)*X(0)+X(1)*X(1)+X(2)*X(2))
2629 Y(0)=Z(1)*X(2)-X(1)*Z(2)
2630 Y(1)=X(0)*Z(2)-Z(0)*X(2)
2631 Y(2)=Z(0)*X(1)-X(0)*Z(1)
2633 ! Calculate min, max angles coming from dmin, dmax to c(,i_move-2)
2634 if (i_move.gt.2) then
2636 P(i)=c(i+1,i_move-2)-Orig(i)
2638 call minmax_angles(P(0)*X(0)+P(1)*X(1)+P(2)*X(2),&
2639 P(0)*Y(0)+P(1)*Y(1)+P(2)*Y(2),&
2640 P(0)*Z(0)+P(1)*Z(1)+P(2)*Z(2),&
2641 radius,a_n,a_ang,a_tab)
2646 ! Calculate min, max angles coming from dmin, dmax to c(,i_move+2)
2647 if (i_move.lt.nres-2) then
2649 P(i)=c(i+1,i_move+2)-Orig(i)
2651 call minmax_angles(P(0)*X(0)+P(1)*X(1)+P(2)*X(2),&
2652 P(0)*Y(0)+P(1)*Y(1)+P(2)*Y(2),&
2653 P(0)*Z(0)+P(1)*Z(1)+P(2)*Z(2),&
2654 radius,b_n,b_ang,b_tab)
2659 ! Construct the resulting table for alpha and beta
2660 call construct_tab()
2662 if (locmove_output) then
2663 print *,'ALPHAS & BETAS TABLE'
2667 ! Check that there is at least one possible move
2669 if (res_n .eq. 0) then
2673 do while ((index .lt. res_n) .and. no_moves)
2674 if (res_tab(2,1,index)) no_moves = .false.
2679 if (locmove_output) print *,' *** Cannot move anywhere'
2684 ! Transfer res_... into a_...
2687 if ( (res_tab(2,0,i).neqv.res_tab(2,1,i)) .or. &
2688 (res_tab(2,0,i).neqv.res_tab(2,2,i)) ) then
2689 a_ang(a_n) = res_ang(i)
2691 a_tab(j,a_n) = res_tab(2,j,i)
2697 ! Check that the PHI's are within [0,PI]
2698 if (PHImin .lt. 0. .or. abs(PHImin) .lt. small) PHImin = -flag
2699 if (PHImin .gt. PI .or. abs(PHImin-PI) .lt. small) PHImin = PI
2700 if (PHImax .gt. PI .or. abs(PHImax-PI) .lt. small) PHImax = flag
2701 if (PHImax .lt. 0. .or. abs(PHImax) .lt. small) PHImax = 0.
2702 if (PHImax .lt. PHImin) PHImax = PHImin
2703 ! Calculate min and max angles coming from PHImin and PHImax,
2704 ! and put them in b_...
2705 call angles2tab(PHImin, PHImax, b_n, b_ang, b_tab)
2706 ! Construct the final table
2707 call construct_tab()
2709 if (locmove_output) then
2710 print *,'FINAL TABLE'
2714 ! Check that there is at least one possible move
2716 if (res_n .eq. 0) then
2720 do while ((index .lt. res_n) .and. no_moves)
2721 if (res_tab(2,1,index)) no_moves = .false.
2727 ! Take care of the case where no solution exists...
2728 call fix_no_moves(phi)
2729 if (locmove_output) then
2730 print *,' *** Had to modify PHImin or PHImax'
2731 print *,'phi: ',phi*rad2deg
2735 ! ...or calculate the solution
2736 ! Construct phi_start/phi_end arrays
2737 call construct_ranges(phi_n, phi_start, phi_end)
2738 ! Choose random angle phi in allowed range(s)
2741 temp = temp + phi_end(i) - phi_start(i)
2743 phi = ran_number(phi_start(0),phi_start(0)+temp)
2746 do while (.not.done)
2747 if (phi .lt. phi_end(index)) then
2752 if (index .eq. phi_n) then
2754 else if (.not.done) then
2755 phi = phi + phi_start(index) - phi_end(index-1)
2758 if (index.eq.phi_n) phi=phi_end(phi_n-1) ! Fix numerical errors
2759 if (phi .gt. PI) phi = phi-2.*PI
2761 if (locmove_output) then
2762 print *,'ALLOWED RANGE(S)'
2764 print *,phi_start(i)*rad2deg,phi_end(i)*rad2deg
2766 print *,'phi: ',phi*rad2deg
2771 ! Re-use radius as temp variable
2772 temp=radius*cos(phi)
2773 radius=radius*sin(phi)
2775 c(i+1,i_move)=Orig(i)+temp*X(i)+radius*Y(i)
2779 end function move_res
2780 !-----------------------------------------------------------------------------
2785 ! implicit real*8 (a-h,o-z)
2786 ! include 'DIMENSIONS'
2787 ! include 'COMMON.GEO'
2788 ! include 'COMMON.LOCAL'
2789 ! include 'COMMON.LOCMOVE'
2791 ! External functions
2792 !EL integer move_res
2793 !EL external move_res
2798 real(kind=8),dimension(0:11) :: phi_start,phi_end
2800 real(kind=8),dimension(0:2,0:5) :: R
2802 locmove_output=.true.
2804 ! call angles2tab(30.*deg2rad,70.*deg2rad,a_n,a_ang,a_tab)
2805 ! call angles2tab(80.*deg2rad,130.*deg2rad,b_n,b_ang,b_tab)
2806 ! call minmax_angles(0.D0,3.8D0,0.D0,3.8D0,b_n,b_ang,b_tab)
2807 ! call construct_tab
2810 ! call construct_ranges(phi_n,phi_start,phi_end)
2812 ! print *,phi_start(i)*rad2deg,phi_end(i)*rad2deg
2815 ! call fix_no_moves(phi)
2816 ! print *,'NO MOVES FOUND, BEST PHI IS',phi*rad2deg
2822 R(1,1)=-cos(28.D0*deg2rad)
2823 R(2,1)=-0.5D0-sin(28.D0*deg2rad)
2827 R(0,3)=cos(30.D0*deg2rad)
2834 R(1,5)=cos(26.D0*deg2rad)
2835 R(2,5)=0.5D0+sin(26.D0*deg2rad)
2841 ! i=move_res(R(0,1),0.D0*deg2rad,180.D0*deg2rad)
2843 i=move_res(0.D0*deg2rad,180.D0*deg2rad,imov)
2844 print *,'RETURNED ',i
2845 print *,(R(i,3)/vbl,i=0,2)
2848 end subroutine loc_test
2850 !-----------------------------------------------------------------------------
2852 !-----------------------------------------------------------------------------
2853 subroutine MATMULT(A1,A2,A3)
2854 ! implicit real*8 (a-h,o-z)
2855 ! include 'DIMENSIONS'
2858 real(kind=8) :: A3IJ
2860 real(kind=8),DIMENSION(3,3) :: A1,A2,A3
2861 real(kind=8),DIMENSION(3,3) :: AI3
2866 3 A3IJ=A3IJ+A1(I,K)*A2(K,J)
2874 end subroutine MATMULT
2875 !-----------------------------------------------------------------------------
2877 !-----------------------------------------------------------------------------
2878 subroutine int_from_cart(lside,lprn)
2879 ! implicit real*8 (a-h,o-z)
2880 ! include 'DIMENSIONS'
2881 use control_data,only:out1file
2885 ! include 'COMMON.LOCAL'
2886 ! include 'COMMON.VAR'
2887 ! include 'COMMON.CHAIN'
2888 ! include 'COMMON.INTERACT'
2889 ! include 'COMMON.IOUNITS'
2890 ! include 'COMMON.GEO'
2891 ! include 'COMMON.NAMES'
2892 ! include 'COMMON.CONTROL'
2893 ! include 'COMMON.SETUP'
2894 character(len=3) :: seq,res
2896 character(len=80) :: card
2897 real(kind=8),dimension(3,20) :: sccor
2898 integer :: i,j,iti !el rescode,
2899 logical :: lside,lprn
2900 real(kind=8) :: di,cosfac,sinfac
2904 if(me.eq.king.or..not.out1file)then
2906 write (iout,'(/a)') &
2907 'Internal coordinates calculated from crystal structure.'
2909 write (iout,'(8a)') ' Res ',' dvb',' Theta',&
2910 ' Gamma',' Dsc_id',' Dsc',' Alpha',&
2913 write (iout,'(4a)') ' Res ',' dvb',' Theta',&
2919 ! if (molnum(i).ne.1) cycle
2920 !in wham do i=1,nres
2922 if (((dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0).and.&
2923 (iti.ne.ntyp1 .and. itype(i+1,1).ne.ntyp1)).and.molnum(i).eq.1) then
2924 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
2928 vbld(i+1)=dist(i,i+1)
2929 vbld_inv(i+1)=1.0d0/vbld(i+1)
2931 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
2932 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
2936 ! if (itype(1,1).eq.ntyp1) then
2938 ! c(j,1)=c(j,2)+(c(j,3)-c(j,4))
2941 ! if (itype(nres,1).eq.ntyp1) then
2943 ! c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
2947 ! if (unres_pdb) then
2948 ! if (itype(1,1).eq.21) then
2949 ! theta(3)=90.0d0*deg2rad
2950 ! phi(4)=180.0d0*deg2rad
2952 ! vbld_inv(2)=1.0d0/vbld(2)
2954 ! if (itype(nres,1).eq.21) then
2955 ! theta(nres)=90.0d0*deg2rad
2956 ! phi(nres)=180.0d0*deg2rad
2958 ! vbld_inv(nres)=1.0d0/vbld(2)
2964 c(j,nres2+2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i) &
2965 +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
2966 ! in wham c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1)
2971 ! 10/03/12 Adam: Correction for zero SC-SC bond length
2973 if (itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1 .and. di.eq.0.0d0) &
2974 di=dsc(itype(i,molnum(i)))
2976 if (itype(i,1).ne.10) then
2977 vbld_inv(i+nres)=1.0d0/di
2979 vbld_inv(i+nres)=0.0d0
2983 alph(i)=alpha(nres+i,i,nres2+2)
2984 omeg(i)=beta(nres+i,i,nres2+2,i+1)
2987 if(me.eq.king.or..not.out1file)then
2989 write (iout,'(a3,i4,7f10.3)') restyp(iti,1),i,vbld(i),&
2990 rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),&
2991 rad2deg*alph(i),rad2deg*omeg(i)
2994 if(me.eq.king.or..not.out1file)then
2996 write (iout,'(a3,i4,7f10.3)') restyp(iti,1),i,vbld(i),&
2997 rad2deg*theta(i),rad2deg*phi(i),dsc(iti+1),vbld(nres+i),&
2998 rad2deg*alph(i),rad2deg*omeg(i)
3005 if(me.eq.king.or..not.out1file) &
3006 write (iout,'(a3,i4,7f10.3)') restyp(iti,1),i,dist(i,i-1),&
3007 rad2deg*theta(i),rad2deg*phi(i)
3011 end subroutine int_from_cart
3012 !-----------------------------------------------------------------------------
3013 subroutine sc_loc_geom(lprn)
3014 ! implicit real*8 (a-h,o-z)
3015 ! include 'DIMENSIONS'
3016 use control_data,only:out1file
3020 ! include 'COMMON.LOCAL'
3021 ! include 'COMMON.VAR'
3022 ! include 'COMMON.CHAIN'
3023 ! include 'COMMON.INTERACT'
3024 ! include 'COMMON.IOUNITS'
3025 ! include 'COMMON.GEO'
3026 ! include 'COMMON.NAMES'
3027 ! include 'COMMON.CONTROL'
3028 ! include 'COMMON.SETUP'
3029 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
3032 integer :: i,j,it,iti
3033 real(kind=8) :: cosfac2,sinfac2,xx,yy,zz,cosfac,sinfac
3036 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
3040 if (itype(i,1).ne.10) then
3042 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
3046 dc_norm(j,i+nres)=0.0d0
3051 costtab(i+1) =dcos(theta(i+1))
3052 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
3053 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
3054 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
3055 cosfac2=0.5d0/(1.0d0+costtab(i+1))
3056 cosfac=dsqrt(cosfac2)
3057 sinfac2=0.5d0/(1.0d0-costtab(i+1))
3058 sinfac=dsqrt(sinfac2)
3061 if ((it.ne.10).and.(it.ne.ntyp1)) then
3062 !el if (it.ne.10) then
3064 ! Compute the axes of tghe local cartesian coordinates system; store in
3065 ! x_prime, y_prime and z_prime
3073 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
3074 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
3076 call vecpr(x_prime,y_prime,z_prime)
3078 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
3079 ! to local coordinate system. Store in xx, yy, zz.
3085 xx = xx + x_prime(j)*dc_norm(j,i+nres)
3086 yy = yy + y_prime(j)*dc_norm(j,i+nres)
3087 zz = zz + z_prime(j)*dc_norm(j,i+nres)
3102 if(me.eq.king.or..not.out1file) &
3103 write (iout,'(a3,i4,3f10.5)') restyp(iti,1),i,xxref(i),&
3109 end subroutine sc_loc_geom
3110 !-----------------------------------------------------------------------------
3111 subroutine sccenter(ires,nscat,sccor)
3112 ! implicit real*8 (a-h,o-z)
3113 ! include 'DIMENSIONS'
3114 ! include 'COMMON.CHAIN'
3115 integer :: i,j,ires,nscat
3116 real(kind=8),dimension(3,20) :: sccor
3117 real(kind=8) :: sccmj
3118 ! print *,"I am in sccenter",ires,nscat
3122 sccmj=sccmj+sccor(j,i)
3123 !C print *,"insccent", ires,sccor(j,i)
3125 dc(j,ires)=sccmj/nscat
3128 end subroutine sccenter
3129 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
3130 !-----------------------------------------------------------------------------
3131 subroutine bond_regular
3133 ! implicit real*8 (a-h,o-z)
3134 ! include 'DIMENSIONS'
3135 ! include 'COMMON.VAR'
3136 ! include 'COMMON.LOCAL'
3137 ! include 'COMMON.CALC'
3138 ! include 'COMMON.INTERACT'
3139 ! include 'COMMON.CHAIN'
3143 vbld_inv(i+1)=1.0d0/vbld(i+1)
3144 vbld(i+1+nres)=dsc(itype(i+1,molnum(i)))
3145 vbld_inv(i+1+nres)=dsc_inv(itype(i+1,molnum(i)))
3146 ! print *,vbld(i+1),vbld(i+1+nres)
3149 end subroutine bond_regular
3151 !-----------------------------------------------------------------------------
3153 !-----------------------------------------------------------------------------
3154 subroutine refsys(i2,i3,i4,e1,e2,e3,fail)
3155 ! This subroutine calculates unit vectors of a local reference system
3156 ! defined by atoms (i2), (i3), and (i4). The x axis is the axis from
3157 ! atom (i3) to atom (i2), and the xy plane is the plane defined by atoms
3158 ! (i2), (i3), and (i4). z axis is directed according to the sign of the
3159 ! vector product (i3)-(i2) and (i3)-(i4). Sets fail to .true. if atoms
3160 ! (i2) and (i3) or (i3) and (i4) coincide or atoms (i2), (i3), and (i4)
3161 ! form a linear fragment. Returns vectors e1, e2, and e3.
3162 ! implicit real*8 (a-h,o-z)
3163 ! include 'DIMENSIONS'
3165 real(kind=8),dimension(3) :: e1,e2,e3
3166 real(kind=8),dimension(3) :: u,z
3167 ! include 'COMMON.IOUNITS'
3168 ! include 'COMMON.CHAIN'
3169 real(kind=8) :: coinc=1.0D-13,align=1.0D-13
3171 integer :: i,i1,i2,i3,i4
3172 real(kind=8) :: v1,v2,v3,s1,s2,zi,ui,anorm
3185 if (s1.gt.coinc) goto 2
3186 write (iout,1000) i2,i3,i1
3191 2 if (s2.gt.coinc) goto 4
3192 write(iout,1000) i3,i4,i1
3199 v1=z(2)*u(3)-z(3)*u(2)
3200 v2=z(3)*u(1)-z(1)*u(3)
3201 v3=z(1)*u(2)-z(2)*u(1)
3202 anorm=dsqrt(v1*v1+v2*v2+v3*v3)
3203 if (anorm.gt.align) goto 6
3204 write (iout,1010) i2,i3,i4,i1
3216 e2(1)=e1(3)*e3(2)-e1(2)*e3(3)
3217 e2(2)=e1(1)*e3(3)-e1(3)*e3(1)
3218 e2(3)=e1(2)*e3(1)-e1(1)*e3(2)
3219 1000 format (/1x,' * * * Error - atoms',i4,' and',i4,' coincide.',&
3220 'coordinates of atom',i4,' are set to zero.')
3221 1010 format (/1x,' * * * Error - atoms',2(i4,2h, ),i4,' form a linear',&
3222 ' fragment. coordinates of atom',i4,' are set to zero.')
3224 end subroutine refsys
3225 !-----------------------------------------------------------------------------
3227 !-----------------------------------------------------------------------------
3228 subroutine int_to_cart
3229 !--------------------------------------------------------------
3230 ! This subroutine converts the energy derivatives from internal
3231 ! coordinates to cartesian coordinates
3232 !-------------------------------------------------------------
3233 ! implicit real*8 (a-h,o-z)
3234 ! include 'DIMENSIONS'
3235 ! include 'COMMON.VAR'
3236 ! include 'COMMON.CHAIN'
3237 ! include 'COMMON.DERIV'
3238 ! include 'COMMON.GEO'
3239 ! include 'COMMON.LOCAL'
3240 ! include 'COMMON.INTERACT'
3241 ! include 'COMMON.MD'
3242 ! include 'COMMON.IOUNITS'
3243 ! include 'COMMON.SCCOR'
3244 ! calculating dE/ddc1
3247 ! print *,"gloc",gloc(:,:)
3248 ! print *, "gcart",gcart(:,:)
3249 if (nres.lt.3) go to 18
3251 gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4) &
3252 +gloc(nres-2,icg)*dtheta(j,1,3)
3253 if ((itype(2,1).ne.10).and.&
3254 (itype(2,molnum(2)).ne.ntyp1_molec(molnum(2)))) then
3255 gcart(j,1)=gcart(j,1)+gloc(ialph(2,1),icg)*dalpha(j,1,2)+ &
3256 gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
3259 ! Calculating the remainder of dE/ddc2
3261 gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+ &
3262 gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
3263 if(itype(2,1).ne.10) then
3264 gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+ &
3265 gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
3267 if(itype(3,1).ne.10) then
3268 gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+ &
3269 gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
3272 gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
3275 ! If there are only five residues
3278 gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)* &
3279 dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)* &
3281 ! if(itype(3,1).ne.10) then
3282 if ((itype(3,1).ne.10).and.&
3283 (itype(3,molnum(3)).ne.ntyp1_molec(molnum(3)))) then
3284 gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)* &
3285 dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
3287 ! if(itype(4,1).ne.10) then
3288 if ((itype(4,1).ne.10).and.&
3289 (itype(4,molnum(4)).ne.ntyp1_molec(molnum(4)))) then
3290 gcart(j,3)=gcart(j,3)+gloc(ialph(4,1),icg)* &
3291 dalpha(j,1,4)+gloc(ialph(4,1)+nside,icg)*domega(j,1,4)
3295 ! If there are more than five residues
3299 gcart(j,i)=gcart(j,i)+gloc(i-2,icg)*dphi(j,3,i+1) &
3300 +gloc(i-1,icg)*dphi(j,2,i+2)+ &
3301 gloc(i,icg)*dphi(j,1,i+3)+gloc(nres+i-4,icg)*dtheta(j,2,i+1)+ &
3302 gloc(nres+i-3,icg)*dtheta(j,1,i+2)
3303 if(itype(i,1).ne.10) then
3304 gcart(j,i)=gcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,2,i)+ &
3305 gloc(ialph(i,1)+nside,icg)*domega(j,2,i)
3307 if(itype(i+1,1).ne.10) then
3308 gcart(j,i)=gcart(j,i)+gloc(ialph(i+1,1),icg)*dalpha(j,1,i+1) &
3309 +gloc(ialph(i+1,1)+nside,icg)*domega(j,1,i+1)
3314 ! Setting dE/ddnres-2
3317 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)* &
3318 dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres) &
3319 +gloc(2*nres-6,icg)* &
3320 dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
3321 if(itype(nres-2,1).ne.10) then
3322 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)* &
3323 dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)* &
3326 if(itype(nres-1,1).ne.10) then
3327 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)* &
3328 dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)* &
3333 ! Settind dE/ddnres-1
3337 write(iout,*)"in int to carta",nres-1,gcart(j,nres-1),gloc(nres-3,icg),dphi(j,3,nres), &
3338 gloc(2*nres-5,icg),dtheta(j,2,nres)
3344 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+ &
3345 gloc(2*nres-5,icg)*dtheta(j,2,nres)
3348 write(iout,*)"in int to cartb",nres-1,gcart(j,nres-1),gloc(nres-3,icg),dphi(j,3,nres), &
3349 gloc(2*nres-5,icg),dtheta(j,2,nres)
3353 if(itype(nres-1,1).ne.10) then
3354 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)* &
3355 dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)* &
3359 write(iout,*)"in int to cart2",i,gcart(j,nres-1),gloc(ialph(nres-1,1),icg)* &
3360 dalpha(j,2,nres-1),gloc(ialph(nres-1,1)+nside,icg), &
3368 ! The side-chain vector derivatives
3370 if(itype(i,1).ne.10 .and. &
3371 itype(i,molnum(i)).ne.ntyp1_molec(molnum(i))) then
3373 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i) &
3374 +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
3377 write(iout,*)"in int to cart",i, gxcart(j,i),gloc(ialph(i,1),icg),dalpha(j,3,i), &
3378 gloc(ialph(i,1)+nside,icg),domega(j,3,i)
3384 !----------------------------------------------------------------------
3385 ! INTERTYP=1 SC...Ca...Ca...Ca
3386 ! INTERTYP=2 Ca...Ca...Ca...SC
3387 ! INTERTYP=3 SC...Ca...Ca...SC
3388 ! calculating dE/ddc1
3392 ! write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
3394 if (nres.lt.2) return
3395 if ((nres.lt.3).and.(itype(1,1).eq.10)) return
3396 if ((itype(1,1).ne.10).and. &
3397 (itype(1,molnum(1)).ne.ntyp1_molec(molnum(1)))) then
3399 !c Derviative was calculated for oposite vector of side chain therefore
3400 ! there is "-" sign before gloc_sc
3401 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)* &
3403 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)* &
3405 if ((itype(2,1).ne.10).and. &
3406 (itype(2,molnum(2)).ne.ntyp1_molec(molnum(2)))) then
3407 gxcart(j,1)= gxcart(j,1) &
3408 -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
3409 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)* &
3414 if ((nres.ge.3).and.(itype(3,molnum(3)).ne.10).and.&
3415 (itype(3,molnum(3)).ne.ntyp1_molec(molnum(3)))) &
3418 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
3421 ! As potetnial DO NOT depend on omicron anlge their derivative is
3423 ! & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
3425 ! Calculating the remainder of dE/ddc2
3427 if((itype(2,1).ne.10).and. &
3428 (itype(2,molnum(2)).ne.ntyp1_molec(molnum(2)))) then
3429 if ((itype(1,1).ne.10).and.&
3430 ((itype(1,molnum(1)).ne.ntyp1_molec(molnum(1)))))&
3431 gxcart(j,2)=gxcart(j,2)+ &
3432 gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
3433 if ((itype(3,1).ne.10).and.(nres.ge.3).and.(itype(3,molnum(3)).ne.ntyp1_molec(3))) &
3435 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
3436 !c the - above is due to different vector direction
3437 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
3440 ! if ((itype(1,1).ne.10).and.&
3441 ! ((itype(1,molnum(1)).ne.ntyp1_molec(molnum(1))))) &
3442 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
3443 !c the - above is due to different vector direction
3444 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
3445 ! write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
3446 ! write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
3449 if ((itype(1,1).ne.10).and.&
3450 (itype(1,molnum(1)).ne.ntyp1_molec(molnum(1)))) then
3451 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
3452 ! write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
3454 if ((itype(3,1).ne.10).and.(nres.ge.3)) then
3455 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
3456 ! write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
3458 if ((itype(4,1).ne.10).and.(nres.ge.4)) then
3459 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
3460 ! write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
3463 ! write(iout,*) gcart(j,2),itype(2,1),itype(1,1),itype(3,1), "gcart2"
3465 ! If there are more than five residues
3469 ! write(iout,*) "before", gcart(j,i)
3470 if ((itype(i,1).ne.10).and.&
3471 (itype(i,molnum(i)).ne.ntyp1_molec(molnum(i)))) then
3472 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg) &
3473 *dtauangle(j,2,3,i+1) &
3474 -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
3475 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg) &
3476 *dtauangle(j,1,2,i+2)
3477 ! write(iout,*) "new",j,i,
3478 ! & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
3479 ! if (itype(i-1,1).ne.10) then
3480 if ((itype(i-1,1).ne.10).and.&
3481 (itype(i-1,molnum(i-1)).ne.ntyp1_molec(molnum(i-1)))) then
3483 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg) &
3484 *dtauangle(j,3,3,i+1)
3486 ! if (itype(i+1,1).ne.10) then
3487 if ((itype(i+1,1).ne.10).and.&
3488 (itype(i+1,molnum(i+1)).ne.ntyp1_molec(molnum(i+1)))) then
3489 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg) &
3490 *dtauangle(j,3,1,i+2)
3491 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg) &
3492 *dtauangle(j,3,2,i+2)
3495 ! if (itype(i-1,1).ne.10) then
3496 if ((itype(i-1,1).ne.10).and.&
3497 (itype(i-1,molnum(i-1)).ne.ntyp1_molec(molnum(i-1)))) then
3498 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)* &
3499 dtauangle(j,1,3,i+1)
3501 ! if (itype(i+1,1).ne.10) then
3502 if ((itype(i+1,1).ne.10).and.&
3503 (itype(i+1,molnum(i+1)).ne.ntyp1_molec(molnum(i+1)))) then
3504 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)* &
3505 dtauangle(j,2,2,i+2)
3506 ! write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
3507 ! & dtauangle(j,2,2,i+2)
3509 ! if (itype(i+2,1).ne.10) then
3510 if ((itype(i+2,1).ne.10).and.&
3511 (itype(i+2,molnum(i+2)).ne.ntyp1_molec(molnum(i+2)))) then
3512 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)* &
3513 dtauangle(j,2,1,i+3)
3518 ! Setting dE/ddnres-1
3521 if ((itype(nres-1,1).ne.10).and.&
3522 (itype(nres-1,molnum(nres-1)).ne.ntyp1_molec(molnum(nres-1)))) then
3523 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg) &
3524 *dtauangle(j,2,3,nres)
3525 ! write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
3526 ! & dtauangle(j,2,3,nres), gxcart(j,nres-1)
3527 ! if (itype(nres-2,1).ne.10) then
3528 if ((itype(nres-2,1).ne.10).and.&
3529 (itype(nres-2,molnum(nres-2)).ne.ntyp1_molec(molnum(nres-2)))) then
3530 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg) &
3531 *dtauangle(j,3,3,nres)
3533 if ((itype(nres,1).ne.10).and.&
3534 (itype(nres,molnum(nres)).ne.ntyp1_molec(molnum(nres)))) then
3535 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg) &
3536 *dtauangle(j,3,1,nres+1)
3537 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg) &
3538 *dtauangle(j,3,2,nres+1)
3541 if ((itype(nres-2,1).ne.10).and.&
3542 (itype(nres-2,molnum(nres-2)).ne.ntyp1_molec(molnum(nres-2)))) then
3543 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)* &
3544 dtauangle(j,1,3,nres)
3546 if ((itype(nres,1).ne.10).and.(itype(nres,molnum(nres)).ne.ntyp1_molec(molnum(nres)))) then
3547 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)* &
3548 dtauangle(j,2,2,nres+1)
3549 ! write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
3550 ! & dtauangle(j,2,2,nres+1), itype(nres-1,1),itype(nres,1)
3555 if ((nres.ge.3).and.(itype(nres,1).ne.10).and. &
3556 (itype(nres,molnum(nres)).ne.ntyp1_molec(molnum(nres))))then
3558 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg) &
3559 *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg) &
3560 *dtauangle(j,2,3,nres+1)
3563 ! The side-chain vector derivatives
3564 ! print *,"gcart",gcart(:,:)
3566 end subroutine int_to_cart
3567 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
3568 !-----------------------------------------------------------------------------
3570 !-----------------------------------------------------------------------------
3571 subroutine gen_dist_constr
3572 ! Generate CA distance constraints.
3573 ! implicit real*8 (a-h,o-z)
3574 ! include 'DIMENSIONS'
3575 ! include 'COMMON.IOUNITS'
3576 ! include 'COMMON.GEO'
3577 ! include 'COMMON.VAR'
3578 ! include 'COMMON.INTERACT'
3579 ! include 'COMMON.LOCAL'
3580 ! include 'COMMON.NAMES'
3581 ! include 'COMMON.CHAIN'
3582 ! include 'COMMON.FFIELD'
3583 ! include 'COMMON.SBRIDGE'
3584 ! include 'COMMON.HEADER'
3585 ! include 'COMMON.CONTROL'
3586 ! include 'COMMON.DBASE'
3587 ! include 'COMMON.THREAD'
3588 ! include 'COMMON.TIME1'
3589 ! integer :: itype_pdb !(maxres)
3590 ! common /pizda/ itype_pdb(nres)
3591 character(len=2) :: iden
3594 !d print *,'gen_dist_constr: nnt=',nnt,' nct=',nct
3595 !d write (2,*) 'gen_dist_constr: nnt=',nnt,' nct=',nct,
3596 !d & ' nstart_sup',nstart_sup,' nstart_seq',nstart_seq,
3598 do i=nstart_sup,nstart_sup+nsup-1
3599 !d write (2,*) 'i',i,' seq ',restyp(itype(i+nstart_seq-nstart_sup)),
3600 !d & ' seq_pdb', restyp(itype_pdb(i))
3601 do j=i+2,nstart_sup+nsup-1
3603 ihpb(nhpb)=i+nstart_seq-nstart_sup
3604 jhpb(nhpb)=j+nstart_seq-nstart_sup
3606 dhpb(nhpb)=dist(i,j)
3609 !d write (iout,'(a)') 'Distance constraints:'
3614 !d if (ii.gt.nres) then
3619 !d write (iout,'(a,1x,a,i4,3x,a,1x,a,i4,2f10.3)')
3620 !d & restyp(itype(ii)),iden,ii,restyp(itype(jj)),iden,jj,
3621 !d & dhpb(i),forcon(i)
3623 ! deallocate(itype_pdb)
3626 end subroutine gen_dist_constr
3628 !-----------------------------------------------------------------------------
3630 !-----------------------------------------------------------------------------
3631 subroutine cartprint
3633 use geometry_data, only: c
3634 use energy_data, only: itype
3635 ! implicit real*8 (a-h,o-z)
3636 ! include 'DIMENSIONS'
3637 ! include 'COMMON.CHAIN'
3638 ! include 'COMMON.INTERACT'
3639 ! include 'COMMON.NAMES'
3640 ! include 'COMMON.IOUNITS'
3645 write (iout,110) restyp(itype(i,1),1),i,c(1,i),c(2,i),&
3646 c(3,i),c(1,nres+i),c(2,nres+i),c(3,nres+i)
3648 100 format (//' alpha-carbon coordinates ',&
3649 ' centroid coordinates'/ &
3650 ' ', 6X,'X',11X,'Y',11X,'Z',&
3651 10X,'X',11X,'Y',11X,'Z')
3652 110 format (a,'(',i3,')',6f12.5)
3654 end subroutine cartprint
3655 !-----------------------------------------------------------------------------
3656 !-----------------------------------------------------------------------------
3657 subroutine alloc_geo_arrays
3658 !EL Allocation of tables used by module energy
3660 integer :: i,j,nres2
3664 allocate(phibound(2,nres+2)) !(2,maxres)
3665 !----------------------
3667 ! common /chain/ in molread
3668 ! real(kind=8),dimension(:,:),allocatable :: c !(3,maxres2+2)
3669 ! real(kind=8),dimension(:,:),allocatable :: dc
3670 allocate(dc_old(3,0:nres2))
3671 ! if(.not.allocated(dc_norm2)) allocate(dc_norm2(3,0:nres2+2)) !(3,0:maxres2)
3672 if(.not.allocated(dc_norm2)) then
3673 allocate(dc_norm2(3,0:nres2+2)) !(3,0:maxres2)
3677 !el if(.not.allocated(dc_norm))
3678 !elwrite(iout,*) "jestem w alloc geo 1"
3679 if(.not.allocated(dc_norm)) then
3680 allocate(dc_norm(3,0:nres2+2)) !(3,0:maxres2)
3683 !elwrite(iout,*) "jestem w alloc geo 1"
3684 allocate(xloc(3,nres),xrot(3,nres))
3685 !elwrite(iout,*) "jestem w alloc geo 1"
3687 !elwrite(iout,*) "jestem w alloc geo 1"
3688 allocate(dc_work(6*nres)) !(MAXRES6) maxres6=6*maxres
3690 allocate(t(3,3,nres),r(3,3,nres))
3691 allocate(prod(3,3,nres),rt(3,3,nres)) !(3,3,maxres)
3692 ! common /refstruct/
3693 if(.not.allocated(cref)) allocate(cref(3,nres2+2,maxperm)) !(3,maxres2+2,maxperm)
3694 !elwrite(iout,*) "jestem w alloc geo 2"
3695 allocate(crefjlee(3,nres2+2)) !(3,maxres2+2)
3696 if(.not.allocated(chain_rep)) allocate(chain_rep(3,nres2+2,maxsym)) !(3,maxres2+2,maxsym)
3697 if(.not.allocated(tabperm)) allocate(tabperm(maxperm,maxsym)) !(maxperm,maxsym)
3698 ! common /from_zscore/ in module.compare
3699 !----------------------
3701 ! Inverses of the actual virtual bond lengths
3702 ! common /invlen/ in io_conf: molread or readpdb
3703 ! real(kind=8),dimension(:),allocatable :: vbld_inv !(maxres2)
3704 !----------------------
3706 ! Store the geometric variables in the following COMMON block.
3707 ! common /var/ in readpdb or ...
3708 if(.not.allocated(theta)) allocate(theta(nres+2))
3709 if(.not.allocated(phi)) allocate(phi(nres+2))
3710 if(.not.allocated(alph)) allocate(alph(nres+2))
3711 if(.not.allocated(omeg)) allocate(omeg(nres+2))
3712 if(.not.allocated(thetaref)) allocate(thetaref(nres+2))
3713 if(.not.allocated(phiref)) allocate(phiref(nres+2))
3714 if(.not.allocated(costtab)) allocate(costtab(nres))
3715 if(.not.allocated(sinttab)) allocate(sinttab(nres))
3716 if(.not.allocated(cost2tab)) allocate(cost2tab(nres))
3717 if(.not.allocated(sint2tab)) allocate(sint2tab(nres))
3718 ! real(kind=8),dimension(:),allocatable :: vbld !(2*maxres) in io_conf: molread or readpdb
3719 allocate(omicron(2,nres+2)) !(2,maxres)
3720 allocate(tauangle(3,nres+2)) !(3,maxres)
3721 !elwrite(iout,*) "jestem w alloc geo 3"
3722 if(.not.allocated(xxtab)) allocate(xxtab(nres))
3723 if(.not.allocated(yytab)) allocate(yytab(nres))
3724 if(.not.allocated(zztab)) allocate(zztab(nres)) !(maxres)
3725 if(.not.allocated(xxref)) allocate(xxref(nres))
3726 if(.not.allocated(yyref)) allocate(yyref(nres))
3727 if(.not.allocated(zzref)) allocate(zzref(nres)) !(maxres)
3728 allocate(ialph(nres,2)) !(maxres,2)
3731 allocate(ivar(4*nres2)) !(4*maxres2)
3733 #if defined(WHAM_RUN) || defined(CLUSTER)
3734 allocate(vbld(2*nres))
3736 allocate(vbld_inv(2*nres))
3741 end subroutine alloc_geo_arrays
3742 !-----------------------------------------------------------------------------
3743 !-----------------------------------------------------------------------------
3744 subroutine returnbox
3745 integer :: allareout,i,j,k,nojumpval,chain_beg,mnum
3746 integer :: chain_end,ireturnval
3747 real*8 :: difference
3748 !C change suggested by Ana - end
3752 !C write(*,*) 'initial', i,j,c(j,i)
3754 !C change suggested by Ana - begin
3756 !C change suggested by Ana -end
3759 if ((itype(i,mnum).eq.ntyp1_molec(mnum))&
3760 .and.(itype(i+1,mnum).eq.ntyp1_molec(mnum))) then
3762 if (allareout.eq.1) then
3763 ireturnval=int(c(j,i)/boxxsize)
3764 if (c(j,i).le.0) ireturnval=ireturnval-1
3765 do k=chain_beg,chain_end
3766 c(j,k)=c(j,k)-ireturnval*boxxsize
3767 c(j,k+nres)=c(j,k+nres)-ireturnval*boxxsize
3770 if (chain_beg.eq.1) &
3771 dc_old(1,0)=dc_old(1,0)-ireturnval*boxxsize
3772 !C Suggested by Ana -end
3777 if (int(c(j,i)/boxxsize).eq.0) allareout=0
3780 if (allareout.eq.1) then
3781 ireturnval=int(c(j,i)/boxxsize)
3782 if (c(j,i).le.0) ireturnval=ireturnval-1
3784 c(j,k)=c(j,k)-ireturnval*boxxsize
3785 c(j,k+nres)=c(j,k+nres)-ireturnval*boxxsize
3790 !C write(*,*) 'befor no jump', i,j,c(j,i)
3795 if (itype(i,mnum).eq.ntyp1_molec(mnum)&
3796 .and. itype(i-1,mnum).eq.ntyp1_molec(mnum)) then
3797 difference=abs(c(j,i-1)-c(j,i))
3798 !C print *,'diff', difference
3799 if (difference.gt.boxxsize/2.0) then
3800 if (c(j,i-1).gt.c(j,i)) then
3809 c(j,i)=c(j,i)+nojumpval*boxxsize
3810 c(j,i+nres)=c(j,i+nres)+nojumpval*boxxsize
3815 if (itype(i,mnum).eq.ntyp1_molec(mnum) .and. itype(i-1,mnum).eq.ntyp1_molec(mnum)) then
3816 difference=abs(c(j,i-1)-c(j,i))
3817 if (difference.gt.boxxsize/2.0) then
3818 if (c(j,i-1).gt.c(j,i)) then
3827 c(j,i)=c(j,i)+nojumpval*boxxsize
3828 c(j,i+nres)=c(j,i+nres)+nojumpval*boxxsize
3832 !C write(*,*) 'after no jump', i,j,c(j,i)
3836 !C suggesed by Ana begins
3842 if ((itype(i,mnum).eq.ntyp1_molec(mnum))&
3843 .and.(itype(i+1,mnum).eq.ntyp1_molec(mnum))) then
3845 if (allareout.eq.1) then
3846 ireturnval=int(c(j,i)/boxysize)
3847 if (c(j,i).le.0) ireturnval=ireturnval-1
3848 do k=chain_beg,chain_end
3849 c(j,k)=c(j,k)-ireturnval*boxysize
3850 c(j,k+nres)=c(j,k+nres)-ireturnval*boxysize
3853 if (chain_beg.eq.1) &
3854 dc_old(1,0)=dc_old(1,0)-ireturnval*boxxsize
3855 !C Suggested by Ana -end
3860 if (int(c(j,i)/boxysize).eq.0) allareout=0
3863 if (allareout.eq.1) then
3864 ireturnval=int(c(j,i)/boxysize)
3865 if (c(j,i).le.0) ireturnval=ireturnval-1
3867 c(j,k)=c(j,k)-ireturnval*boxysize
3868 c(j,k+nres)=c(j,k+nres)-ireturnval*boxysize
3874 if (itype(i,mnum).eq.ntyp1_molec(mnum)&
3875 .and. itype(i-1,mnum).eq.ntyp1_molec(mnum)) then
3876 difference=abs(c(j,i-1)-c(j,i))
3877 if (difference.gt.boxysize/2.0) then
3878 if (c(j,i-1).gt.c(j,i)) then
3887 c(j,i)=c(j,i)+nojumpval*boxysize
3888 c(j,i+nres)=c(j,i+nres)+nojumpval*boxysize
3893 if (itype(i,mnum).eq.ntyp1_molec(mnum)&
3894 .and. itype(i-1,mnum).eq.ntyp1) then
3895 difference=abs(c(j,i-1)-c(j,i))
3896 if (difference.gt.boxysize/2.0) then
3897 if (c(j,i-1).gt.c(j,i)) then
3906 c(j,i)=c(j,i)+nojumpval*boxysize
3907 c(j,i+nres)=c(j,i+nres)+nojumpval*boxysize
3910 !C Suggested by Ana -begins
3912 !C Suggested by Ana -ends
3917 if ((itype(i,mnum).eq.ntyp1_molec(mnum))&
3918 .and.(itype(i+1,mnum).eq.ntyp1_molec(mnum))) then
3920 if (allareout.eq.1) then
3921 ireturnval=int(c(j,i)/boxysize)
3922 if (c(j,i).le.0) ireturnval=ireturnval-1
3923 do k=chain_beg,chain_end
3924 c(j,k)=c(j,k)-ireturnval*boxzsize
3925 c(j,k+nres)=c(j,k+nres)-ireturnval*boxzsize
3928 if (chain_beg.eq.1) dc_old(1,0)=dc_old(1,0)-ireturnval*boxxsize
3929 !C Suggested by Ana -end
3934 if (int(c(j,i)/boxzsize).eq.0) allareout=0
3937 if (allareout.eq.1) then
3938 ireturnval=int(c(j,i)/boxzsize)
3939 if (c(j,i).le.0) ireturnval=ireturnval-1
3941 c(j,k)=c(j,k)-ireturnval*boxzsize
3942 c(j,k+nres)=c(j,k+nres)-ireturnval*boxzsize
3948 if (itype(i,mnum).eq.ntyp1_molec(mnum) .and. itype(i-1,mnum).eq.ntyp1_molec(mnum)) then
3949 difference=abs(c(j,i-1)-c(j,i))
3950 if (difference.gt.(boxzsize/2.0)) then
3951 if (c(j,i-1).gt.c(j,i)) then
3960 c(j,i)=c(j,i)+nojumpval*boxzsize
3961 c(j,i+nres)=c(j,i+nres)+nojumpval*boxzsize
3966 if (itype(i,mnum).eq.ntyp1_molec(mnum) &
3967 .and. itype(i-1,mnum).eq.ntyp1_molec(mnum)) then
3968 difference=abs(c(j,i-1)-c(j,i))
3969 if (difference.gt.boxzsize/2.0) then
3970 if (c(j,i-1).gt.c(j,i)) then
3979 c(j,i)=c(j,i)+nojumpval*boxzsize
3980 c(j,i+nres)=c(j,i+nres)+nojumpval*boxzsize
3983 if (molnum(i).eq.5) then
3984 c(1,i)=dmod(c(1,i),boxxsize)
3985 c(2,i)=dmod(c(2,i),boxysize)
3986 c(3,i)=dmod(c(3,i),boxzsize)
3987 c(1,i+nres)=dmod(c(1,i+nres),boxxsize)
3988 c(2,i+nres)=dmod(c(2,i+nres),boxysize)
3989 c(3,i+nres)=dmod(c(3,i+nres),boxzsize)
3993 end subroutine returnbox
3994 !-------------------------------------------------------------------------------------------------------