1 subroutine atom_partition(iprot)
4 include "DIMENSIONS.ZSCOPT"
5 include "COMMON.IOUNITS"
6 include "COMMON.FMATCH"
7 include "COMMON.INTERACT"
10 include "COMMON.PROTFILES"
11 character*4 recid,atnam,resnam
12 integer iprot,ires_prev,ires,nnres,nsc,iat,i,ii,j
16 write (iout,*) "In atom_partition"
17 call restore_molinfo(iprot)
18 write (iout,*) "nres",nres
19 open(ipdbin,file=fpdbfile(iprot),status="old",err=10)
21 10 write (iout,*) "Error opening all-atom-type file ",
22 & fpdbfile(iprot)(:ilen(fpdbfile(iprot)))
25 write (iout,*) "atom_partitio: after opening file"
29 read(ipdbin,'(i3,5x,i3,1x,$)',err=20,end=20) iii,natp(i,iprot)
31 read(ipdbin,'(a4,i4,1x,$)',err=20,end=20) atp(j,i,iprot),
34 read(ipdbin,'(3x,i3,1x,$)',err=20,end=20) natsc(i,iprot)
36 read(ipdbin,'(a4,i4,1x,$)',err=20,end=20) atsc(j,i,iprot),
50 read (ipdbin,'(a4,i7,1x,a4,1x,a3,i6)',end=20,err=20)
51 & recid,iat,atnam,resnam,ires
52 write (iout,*) recid,iat,atnam,resnam,ires
53 if (recid.ne."ATOM") cycle
54 if (iat.gt.nat(iprot)) nat(iprot)=iat
55 if (ires.ne.ires_prev) then
59 if (atnam.eq." CA ") then
60 if (restyp(itype(ires+nnt-1)).ne.resnam) then
62 & "Error: different residue name in force-match template",
63 & " protein",iprot," residue",ires,resnam,restyp(itype(ires+1))
67 iatsc(1,ires+nnt-1,iprot)=iat
68 atsc(1,ires+nnt-1,iprot)=atnam(2:)
70 c print *,"carflag ",carflag
71 if (.not.carflag) then
72 if (resnam.eq."PRO ") then
73 write (iout,*) resnam,ires
74 c if (atnam.eq." N ".or.atnam.eq." CD ".or.atnam.eq." HD2"
75 c if (atnam.eq." N ".or.atnam.eq." HD2".or.atnam.eq." HD3")
78 natp(ires-1+nnt-1,iprot)=natp(ires-1+nnt-1,iprot)+1
79 c print *,"back",natp(ires-1)
80 ii=natp(ires-1+nnt-1,iprot)
81 atp(ii,ires-1+nnt-1,iprot)=atnam(2:)
82 iatp(ii,ires-1+nnt-1,iprot)=iat
84 natsc(ires+nnt-1,iprot)=natsc(ires+nnt-1,iprot)+1
85 c print *,"sc",natsc(ires)
86 ii=natsc(ires+nnt-1,iprot)
87 iatsc(ii,ires+nnt-1,iprot)=iat
88 atsc(ii,ires+nnt-1,iprot)=atnam(2:)
91 natp(ires-1+nnt-1,iprot)=natp(ires-1+nnt-1,iprot)+1
92 ii=natp(ires-1+nnt-1,iprot)
93 atp(ii,ires-1+nnt-1,iprot)=atnam(2:)
94 iatp(ii,ires-1+nnt-1,iprot)=iat
96 elseif(atnam.eq." C ".or.atnam.eq." O " .or.atnam.eq." OXT")
98 natp(ires+nnt-1,iprot)=natp(ires+nnt-1,iprot)+1
99 ii=natp(ires+nnt-1,iprot)
100 if (atnam(1:1).eq." ") then
101 atp(ii,ires+nnt-1,iprot)=atnam(2:)
103 atp(ii,ires+nnt-1,iprot)=atnam
105 iatp(ii,ires+nnt-1,iprot)=iat
106 else if (atnam.ne. " CA ") then
107 natsc(ires+nnt-1,iprot)=natsc(ires+nnt-1,iprot)+1
108 ii=natsc(ires+nnt-1,iprot)
109 iatsc(ii,ires+nnt-1,iprot)=iat
110 if (atnam(1:1).eq." ") then
111 atsc(ii,ires+nnt-1,iprot)=atnam(2:)
113 atsc(ii,ires+nnt-1,iprot)=atnam
117 if (atnam.eq." CA ".and.resnam.ne."GLY ") nsc=nsc+1
121 write (iout,*) "End reading nnres",nnres," nres",nres,
122 & " nsc",nsc," nat",nat(iprot)
125 c---------------------------------------------------------------------
127 write(iout,'(i3,1x,a3,1x,5h back,i3,1x,$)')i,restyp(itype((i))),
130 write(iout,'(a4,i4,1x,$)') atp(j,i,iprot),iatp(j,i,iprot)
132 write(iout,'(i3,1x,3h sc,i3,1x,$)') i,natsc(i,iprot)
133 do j=1,natsc(i,iprot)
134 write(iout,'(a4,i4,1x,$)') atsc(j,i,iprot),iatsc(j,i,iprot)
140 if (itype(i).ne.10) nsite(iprot)=nsite(iprot)+1
142 write (iout,*) "iprot",iprot," nsite",nsite(iprot),nres+nsc
145 c---------------------------------------------------------------------
146 subroutine read_allat_coord_forces(iprot)
149 include "DIMENSIONS.ZSCOPT"
153 integer ierror,errcode
155 include "COMMON.CONTROL"
156 include "COMMON.IOUNITS"
157 include "COMMON.FMATCH"
158 include "COMMON.CHAIN"
159 include "COMMON.INTERACT"
160 include "COMMON.PROTFILES"
161 include "COMMON.SBRIDGE"
162 include "COMMON.NAMES"
163 include "COMMON.WEIGHTS"
164 include "COMMON.CLASSES"
165 include "COMMON.PROTNAME"
166 integer i,ii,j,k,l,kkk,kkkk,jj_old,jj,jjj,icount,iis,nnsc
170 double precision casc(3),dss
173 call restore_molinfo(iprot)
174 open (ientout,file=bprotfiles_MD(iprot),status="unknown",
175 & form="unformatted",access="direct",recl=lenrec_MD(iprot))
176 c Change AL 12/30/2017
178 if (me.eq.Master) then
179 ! Loop over snapshots
181 open(ipdbin,file=fcoordfile(iprot),status="old",err=10)
183 10 write (iout,*) "Error opening MD coordinate file ",
184 & fcoordfile(iprot)(:ilen(fcoordfile(iprot)))
187 call MPI_Abort(MPI_COMM_WORLD,ErrCode,IERROR)
192 open(ientin,file=fforcefile(iprot),status="old",err=20)
194 20 write (iout,*) "Error opening MD force file ",
195 & fforcefile(iprot)(:ilen(fforcefile(iprot)))
198 call MPI_Abort(MPI_COMM_WORLD,ErrCode,IERROR)
203 write (iout,*) "nat",nat(iprot)
214 read (ipdbin,'(10f8.3)',end=30,err=30)
215 & ((atcoord(j,i),j=1,3),i=1,nat(iprot))
216 read(ientin,'(10f8.3)',end=30,err=30)((atforce(j,i),j=1,3),i=1,
218 if (mod(kkk,ifreq_MD(iprot)).gt.0) cycle
221 write(iout,*) "All-atom Coordinates and forces",kkk,kkkk
224 write(iout,'(2i3,1x,a4,i5,3f8.3,5x,3f8.3)')
225 & i,j,atp(j,i,iprot),iatp(j,i,iprot),
226 & (atcoord(k,iatp(j,i,iprot)),k=1,3),
227 & (atforce(k,iatp(j,i,iprot)),k=1,3)
229 do j=1,natsc(i,iprot)
230 write(iout,'(2i3,1x,a4,i5,3f8.3,5x,3f8.3)')
231 & i,j,atsc(j,i,iprot),iatsc(j,i,iprot),
232 & (atcoord(k,iatsc(j,i,iprot)),k=1,3),
233 & (atforce(k,iatsc(j,i,iprot)),k=1,3)
238 c(k,1)=atcoord(k,iatp(1,1,iprot))
239 c(k,nres)=atcoord(k,iatp(3,nres-1,iprot))
243 c(j,i)=atcoord(j,iatsc(1,i,iprot))
249 c write (iout,*) "i",i," natsc",natsc(i)
251 do j=1,natsc(i,iprot)
252 c write (iout,*) "j",j," iatsc",iatsc(j,i)
253 if (atsc(j,i,iprot)(1:1).eq."H") cycle
256 casc(k)=casc(k)+atcoord(k,iatsc(j,i,iprot))
260 c(k,i+nres)=casc(k)/nnsc
262 c write (iout,*) (c(k,i+nres),k=1,3)
264 c Detect disulfide bonds
268 if (itype(i).eq.1 .and. itype(j).eq.1) then
269 do k=1,natsc(i,iprot)
270 do l=1,natsc(j,iprot)
271 if (atsc(k,i,iprot).eq." S ".and.
272 & atsc(l,j,iprot).eq." S ") then
275 dSS=dsqrt((atcoord(1,ii)-atcoord(1,jj))**2+
276 & (atcoord(2,ii)-atcoord(2,jj))**2+
277 & (atcoord(3,ii)-atcoord(3,jj))**2)
279 if (dSS.lt.2.5d0) then
290 write (iout,*) "CG Coordinates"
292 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
293 write (iout,'(a4,i5,3f10.3)')restyp(itype(i)),i,(c(j,i),j=1,3)
295 write (iout,'(a4,i5,3f10.3,5x,3f10.3)')
296 & restyp(itype(i)),i,(c(j,i),j=1,3),(c(j,i+nres),j=1,3)
299 write (iout,'(8f10.5)')
300 & ((c(l,k),l=1,3),k=1,nres),
301 & ((c(l,k+nres),l=1,3),k=nnt,nct)
302 call int_from_cart1(.true.)
305 call add_new_MDconf(jjj,jj,jj_old,icount,iprot)
309 call write_and_send_MDconf(icount,jj_old,jj,iprot)
310 nconf_forc(iprot)=kkkk
311 ntot_work_MD(iprot)=kkkk
312 call write_and_send_MDconf(0,jj_old,jj,iprot)
320 list_conf_MD(i,iprot)=i
322 call receive_and_write_MDconf(icount,jj_old,jj,iprot)
327 write (iout,*) "Protein",
328 & protname(iprot)(:ilen(protname(iprot))),", ",ntot_MD(iprot),
329 & " conformatons read ",ntot_MD(iprot),
330 & " conformations written to ",
331 & bprotfiles_MD(iprot)(:ilen(bprotfiles_MD(iprot)))
332 ntot_MD(0) = ntot_MD(0)+ntot_MD(iprot)
336 c-------------------------------------------------------------------
337 subroutine compute_CG_forces(kkkk,iprot)
340 include "DIMENSIONS.ZSCOPT"
341 include "COMMON.IOUNITS"
342 include "COMMON.FMATCH"
343 include "COMMON.CHAIN"
344 include "COMMON.INTERACT"
345 include "COMMON.NAMES"
346 integer i,ii,iis,j,k,kkkk,iprot,nsc,nscc,nnsc,n,nn
347 double precision yy(3),caca(3),casc(3),xx,cacanorm,cascnorm
348 double precision scalar
352 c write (iout,'(3i5,3f10.5)') kkkk,j,iatp(j,1,iprot),
353 c & (atforce(k,iatp(j,1,iprot)),k=1,3)
355 CGforce_MD(k,nnt,kkkk,iprot)=CGforce_MD(k,nnt,kkkk,iprot)
356 & +atforce(k,iatp(j,1,iprot))
361 caca(j)=atcoord(j,iatsc(1,i+1,iprot))
362 & -atcoord(j,iatsc(1,i,iprot))
364 cacanorm=dsqrt(scalar(caca,caca))
365 c write(iout,*)"i",i," cacanorm",cacanorm
367 caca(k)=caca(k)/cacanorm
372 yy(k)=atcoord(k,iatp(j,i,iprot))-atcoord(k,iatsc(1,i,iprot))
374 xx=scalar(caca,yy)/cacanorm
376 CGforce_MD(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
377 & +(1-xx)*atforce(k,iatp(j,i,iprot))
378 CGforce_MD(k,i+1,kkkk,iprot)=CGforce_MD(k,i+1,kkkk,iprot)
379 & +xx*atforce(k,iatp(j,i,iprot))
388 c print *,"i",i," natsc",natsc(i)
390 do j=1,natsc(i,iprot)
391 c print *,"j",j," iatsc",iatsc(j,i)
392 if (atsc(j,i,iprot)(1:1).eq."H") cycle
395 casc(k)=casc(k)+atcoord(k,iatsc(j,i,iprot))
399 casc(k)=casc(k)/nnsc-atcoord(k,iatsc(1,i,iprot))
401 cascnorm=dsqrt(scalar(casc,casc))
402 c write(iout,*)"i",i,restyp(itype(i))," natsc",natsc(i,iprot),
403 c & " nnsc",nnsc," cascnorm",cascnorm
409 c write (iout,*) "nnsc",nnsc," iis",iis
410 if (cascnorm.gt.1.0d-2) then
412 casc(k)=casc(k)/cascnorm
418 CGforce_MD(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
419 & +atforce(k,iatsc(1,i,iprot))
421 do j=2,natsc(i,iprot)
423 if (atsc(j,i,iprot)(1:2).eq."HA") then
426 CGforce_MD(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
427 & +atforce(k,iatsc(j,i,iprot))
429 c write (4,*) "HA",i,(CGforce_MD(k,i,kkkk),k=1,3)
434 yy(k)=atcoord(k,iatsc(j,i,iprot))-atcoord(k,iatsc(1,i,iprot))
436 xx=scalar(casc,yy)/cascnorm
438 CGforce_MD(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
439 & +(1.0d0-xx)*atforce(k,iatsc(j,i,iprot))
440 CGforce_MD(k,iis,kkkk,iprot)=CGforce_MD(k,iis,kkkk,iprot)
441 & +xx*atforce(k,iatsc(j,i,iprot))
443 c write (4,*)"REG CA",i,(CGforce_MD(k,i,kkkk),k=1,3)
444 c write (4,*)"REG SC",iis,(CGforce_MD(k,iis,kkkk),k=1,3)
450 do j=1,natp(nct,iprot)
452 CGforce_MD(k,nct,kkkk,iprot)=CGforce_MD(k,nct,kkkk,iprot)
453 & +atforce(k,iatp(j,nct,iprot))
458 c print *,"nres",nres," nsc",nsc
461 write (iout,*) "CG forces calculated from all-atom forces"
462 write (iout,"(4x,a,t55,a)") "Backbone","Sidechain"
465 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
466 write (iout,'(a4,i5,3e15.5)') restyp(itype(i)),i,
467 & (CGforce_MD(j,i,kkkk,iprot),j=1,3)
470 write (iout,'(a4,i5,3e15.5,5x,3e15.5)') restyp(itype(i)),i,
471 & (CGforce_MD(j,i,kkkk,iprot),j=1,3),
472 & (CGforce_MD(j,ii,kkkk,iprot),j=1,3)
478 c-------------------------------------------------------------------
479 subroutine compute_CG_forces_ave(kkkk,iprot)
482 include "DIMENSIONS.ZSCOPT"
483 include "COMMON.IOUNITS"
484 include "COMMON.FMATCH"
485 include "COMMON.CHAIN"
486 include "COMMON.INTERACT"
487 include "COMMON.NAMES"
488 integer i,ii,iis,j,k,kkkk,iprot,nsc,nscc,nnsc,n,nn
489 double precision yy(3),caca(3),casc(3),xx,cacanorm,cascnorm
490 double precision scalar
494 c write (iout,'(3i5,3f10.5)') kkkk,j,iatp(j,1,iprot),
495 c & (atforce(k,iatp(j,1,iprot)),k=1,3)
497 CGforce_MD_ave(k,nnt,kkkk,iprot)=CGforce_MD(k,nnt,kkkk,iprot)
498 & +atforce(k,iatp(j,1,iprot))
503 caca(j)=atcoord(j,iatsc(1,i+1,iprot))
504 & -atcoord(j,iatsc(1,i,iprot))
506 cacanorm=dsqrt(scalar(caca,caca))
507 c write(iout,*)"i",i," cacanorm",cacanorm
509 caca(k)=caca(k)/cacanorm
514 yy(k)=atcoord(k,iatp(j,i,iprot))-atcoord(k,iatsc(1,i,iprot))
516 xx=scalar(caca,yy)/cacanorm
518 CGforce_MD_ave(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
519 & +(1-xx)*atforce(k,iatp(j,i,iprot))
520 CGforce_MD_ave(k,i+1,kkkk,iprot)=CGforce_MD(k,i+1,kkkk,iprot)
521 & +xx*atforce(k,iatp(j,i,iprot))
530 c print *,"i",i," natsc",natsc(i)
532 do j=1,natsc(i,iprot)
533 c print *,"j",j," iatsc",iatsc(j,i)
534 if (atsc(j,i,iprot)(1:1).eq."H") cycle
537 casc(k)=casc(k)+atcoord(k,iatsc(j,i,iprot))
541 casc(k)=casc(k)/nnsc-atcoord(k,iatsc(1,i,iprot))
543 cascnorm=dsqrt(scalar(casc,casc))
544 c write(iout,*)"i",i,restyp(itype(i))," natsc",natsc(i,iprot),
545 c & " nnsc",nnsc," cascnorm",cascnorm
551 c write (iout,*) "nnsc",nnsc," iis",iis
552 if (cascnorm.gt.1.0d-2) then
554 casc(k)=casc(k)/cascnorm
560 CGforce_MD_ave(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
561 & +atforce(k,iatsc(1,i,iprot))
563 do j=2,natsc(i,iprot)
565 if (atsc(j,i,iprot)(1:2).eq."HA") then
568 CGforce_MD_ave(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
569 & +atforce(k,iatsc(j,i,iprot))
571 c write (4,*) "HA",i,(CGforce_MD(k,i,kkkk),k=1,3)
576 yy(k)=atcoord(k,iatsc(j,i,iprot))-atcoord(k,iatsc(1,i,iprot))
578 xx=scalar(casc,yy)/cascnorm
580 CGforce_MD_ave(k,i,kkkk,iprot)=CGforce_MD(k,i,kkkk,iprot)
581 & +(1.0d0-xx)*atforce(k,iatsc(j,i,iprot))
582 CGforce_MD_ave(k,iis,kkkk,iprot)=CGforce_MD(k,iis,kkkk,iprot)
583 & +xx*atforce(k,iatsc(j,i,iprot))
585 c write (4,*)"REG CA",i,(CGforce_MD(k,i,kkkk),k=1,3)
586 c write (4,*)"REG SC",iis,(CGforce_MD(k,iis,kkkk),k=1,3)
592 do j=1,natp(nct,iprot)
594 CGforce_MD_ave(k,nct,kkkk,iprot)=CGforce_MD(k,nct,kkkk,iprot)
595 & +atforce(k,iatp(j,nct,iprot))
600 c print *,"nres",nres," nsc",nsc
603 write (iout,*) "CG forces calculated from all-atom forces"
604 write (iout,"(4x,a,t55,a)") "Backbone","Sidechain"
607 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
608 write (iout,'(a4,i5,3e15.5)') restyp(itype(i)),i,
609 & (CGforce_MD_ave(j,i,kkkk,iprot),j=1,3)
612 write (iout,'(a4,i5,3e15.5,5x,3e15.5)') restyp(itype(i)),i,
613 & (CGforce_MD_ave(j,i,kkkk,iprot),j=1,3),
614 & (CGforce_MD_ave(j,ii,kkkk,iprot),j=1,3)
620 c----------------------------------------------------------------------
621 subroutine add_new_MDconf(jjj,jj,jj_old,icount,iprot)
624 include "DIMENSIONS.ZSCOPT"
625 include "COMMON.CHAIN"
626 include "COMMON.INTERACT"
627 include "COMMON.LOCAL"
628 include "COMMON.CLASSES"
629 include "COMMON.ENERGIES"
630 include "COMMON.IOUNITS"
631 include "COMMON.PROTFILES"
632 include "COMMON.PROTNAME"
633 include "COMMON.VMCPAR"
634 include "COMMON.WEIGHTS"
635 include "COMMON.NAMES"
636 include "COMMON.ALLPROT"
637 include "COMMON.WEIGHTDER"
639 include "COMMON.SBRIDGE"
641 include "COMMON.COMPAR"
642 integer i,j,jj,jjj,jj_old,icount,k,kk,l,iprot,ii,ib,ibatch,
643 & nn,nn1,inan,Next,itj
645 c write(iout,*) "add_new_MDconf jjj jj jj_old:",jjj,jj,jj_old
647 call int_from_cart1(.false.)
649 c write (iout,*) "After int_from_cart1"
652 if (vbld(j).lt.2.0d0 .or. vbld(j).gt.6.5d0) then
653 write (iout,*) "nnt",nnt," nct",nct
654 write (iout,*) "Bad CA-CA bond length",j," ",vbld(j)
655 write (iout,*) "Bad CA-SC bond length",ii," ",vbld(nres+j)
656 write (iout,*) "The Cartesian geometry is:"
657 write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
658 write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
659 write (iout,*) "The internal geometry is:"
660 write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
661 write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
662 write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
663 write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
664 write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
665 write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
667 & "This conformation WILL NOT be added to the database."
673 if (itype(j).ne.10 .and. (vbld(nres+j)-dsc(itj)).gt.2.0d0) then
674 write (iout,*) "nnt",nnt," nct",nct
675 write (iout,*) "Bad CA-SC bond length",ii," ",vbld(nres+j)
676 write (iout,*) "The Cartesian geometry is:"
677 write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
678 write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
679 write (iout,*) "The internal geometry is:"
680 write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
681 write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
682 write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
683 write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
684 write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
685 write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
687 & "This conformation WILL NOT be added to the database."
692 if (theta(j).le.0.0d0) then
694 & "Zero theta angle(s) in conformation",ii
695 write (iout,*) "The Cartesian geometry is:"
696 write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
697 write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
698 write (iout,*) "The internal geometry is:"
699 write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
700 write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
701 write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
702 write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
703 write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
704 write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
706 & "This conformation WILL NOT be added to the database."
709 if (theta(j).gt.179.97*deg2rad) theta(j)=179.97*deg2rad
713 list_conf_MD(jj,iprot)=jj
714 c write (iout,*) "calling store_MDconf",icount
716 call store_MDconf_from_file(jj,icount,iprot)
717 c write (iout,*) "finished store_MDconf"
719 if (icount.eq.maxstr_proc) then
721 write (iout,* ) "jj_old",jj_old," jj",jj
722 write (iout,*) "Calling write_and_send_cconf"
725 call write_and_send_MDconf(icount,jj_old,jj,iprot)
728 write (iout,*) "Exited write_and_send_cconf"
735 c------------------------------------------------------------------------------
736 subroutine store_MDconf_from_file(jj,icount,iprot)
739 include "DIMENSIONS.ZSCOPT"
740 include "COMMON.CHAIN"
741 include "COMMON.SBRIDGE"
742 include "COMMON.INTERACT"
743 include "COMMON.IOUNITS"
744 include "COMMON.CLASSES"
745 include "COMMON.ALLPROT"
747 include "COMMON.FMATCH"
748 integer i,j,jj,icount,ibatch,iprot
749 c Store the conformation that has been read in
752 cg_MD(j,i,icount,iprot)=c(j,i)
755 nss_MD(icount,iprot)=nss
757 ihpb_MD(i,icount,iprot)=ihpb(i)
758 jhpb_MD(i,icount,iprot)=jhpb(i)
760 call compute_CG_forces(icount,iprot)
763 c------------------------------------------------------------------------------
764 subroutine write_and_send_MDconf(icount,jj_old,jj,iprot)
767 include "DIMENSIONS.ZSCOPT"
773 include "COMMON.WEIGHTS"
774 include "COMMON.CHAIN"
775 include "COMMON.SBRIDGE"
776 include "COMMON.INTERACT"
777 include "COMMON.IOUNITS"
778 include "COMMON.CLASSES"
780 include "COMMON.ALLPROT"
781 include "COMMON.ENERGIES"
782 include "COMMON.WEIGHTDER"
783 include "COMMON.OPTIM"
784 include "COMMON.COMPAR"
785 include "COMMON.FMATCH"
786 integer icount,jj_old,jj,Next,iprot
787 c Write the structures to a scratch file
790 write (iout,*) "Processor",me," entered WRITE_AND_SEND_MDCONF"
791 write (iout,*) "iprot",iprot
794 call MPI_Bcast(icount,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
796 write (iout,*) "Processor",me," sent icount=",icount
797 write (iout,*) "Processor",me," jj_old",jj_old," jj",jj
800 if (icount.gt.0) then
801 call MPI_Bcast(jj_old,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
802 call MPI_Bcast(jj,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
803 write (iout,*) "Finished broadcast jj_old jj"
805 call MPI_Bcast(nss_MD(1,iprot),icount,MPI_INTEGER,Master,
807 write (iout,*) "Finished broadcast nss"
809 call MPI_Bcast(ihpb_MD(1,1,iprot),maxres*icount,MPI_INTEGER,
810 & Master,WHAM_COMM,IERROR)
811 call MPI_Bcast(jhpb_MD(1,1,iprot),maxres*icount,MPI_INTEGER,
812 & Master,WHAM_COMM,IERROR)
813 write (iout,*) "Finished broadcast ihpb jhpb"
815 call MPI_Bcast(cg_MD(1,1,1,iprot),3*icount*maxres2,
816 & MPI_REAL,Master,WHAM_COMM,IERROR)
817 write (iout,*) "Finished broadcast cg_MD"
819 call MPI_Bcast(cgforce_MD(1,1,1,iprot),3*icount*maxres2,
820 & MPI_REAL,Master,WHAM_COMM,IERROR)
821 write (iout,*) "Finished broadcast cgforce_MD"
824 write (iout,*) "Master finished broadcast"
827 call dawrite_MDcoords(iprot,jj_old,jj,ientout)
829 write (iout,*) "iprot",iprot," jj",jj," nconf_forc",
832 write (iout,*) "Protein",iprot
833 write(iout,*)"Processor",me," received",icount,
834 & " MD conformations and forces"
836 write (iout,'(8f10.4)') ((cg_MD(l,k,i,iprot),l=1,3,k=1,nres)
837 write(iout,'(8f10.4)')((cg_MD(l,k,i+nres,iprot),l=1,3,k=nnt,nct)
838 write (iout,'(16i5)') nss_MD(i,iprot),(ihpb_MD(k,i,iprot),
839 & jhpb_MD(k,i,iprot),k=1,nss_MD(i,iprot))
840 write(iout,'(8f10.4)')((cgforce_MD(l,k,i,iprot),l=1,3,k=,1,
846 c------------------------------------------------------------------------------
848 subroutine receive_and_write_MDconf(icount,jj_old,jj,iprot)
851 include "DIMENSIONS.ZSCOPT"
853 integer IERROR,STATUS(MPI_STATUS_SIZE)
855 include "COMMON.CHAIN"
856 include "COMMON.SBRIDGE"
857 include "COMMON.INTERACT"
858 include "COMMON.IOUNITS"
859 include "COMMON.CLASSES"
860 include "COMMON.FMATCH"
861 include "COMMON.ENERGIES"
864 include "COMMON.WEIGHTS"
865 include "COMMON.WEIGHTDER"
866 include "COMMON.COMPAR"
867 include "COMMON.OPTIM"
868 integer i,j,k,icount,jj_old,jj,iprot,Previous,Next
870 do while (icount.gt.0)
872 write (iout,*) "Processor",me," entered RECEIVE_AND_SEND_MDCONF"
873 write (iout,*) "iprot",iprot
876 call MPI_Bcast(icount,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
878 write (iout,*) "Processor",me," received icount=",icount
881 if (icount.gt.0) then
882 call MPI_Bcast(jj_old,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
883 call MPI_Bcast(jj,1,MPI_INTEGER,Master,WHAM_COMM,IERROR)
884 write (iout,*) "Finished broadcast jj_old jj"
885 write (iout,*) "Processor",me," jj_old",jj_old," jj",jj
887 call MPI_Bcast(nss_MD(1,iprot),icount,MPI_INTEGER,Master,
889 write (iout,*) "Finished broadcast nss"
891 call MPI_Bcast(ihpb_MD(1,1,iprot),maxres*icount,MPI_INTEGER,
892 & Master,WHAM_COMM,IERROR)
893 call MPI_Bcast(jhpb_MD(1,1,iprot),maxres*icount,MPI_INTEGER,
894 & Master,WHAM_COMM,IERROR)
895 write (iout,*) "Finished broadcast ihpb jhpb"
897 call MPI_Bcast(cg_MD(1,1,1,iprot),3*icount*maxres2,
898 & MPI_REAL,Master,WHAM_COMM,IERROR)
899 write (iout,*) "Finished broadcast cg_MD"
901 call MPI_Bcast(cgforce_MD(1,1,1,iprot),3*icount*maxres2,
902 & MPI_REAL,Master,WHAM_COMM,IERROR)
903 write (iout,*) "Finished broadcast cgforce_MD"
906 write (iout,*) "Processor",me," finished broadcast"
908 call dawrite_MDcoords(iprot,jj_old,jj,ientout)
910 write (iout,*) "Protein",iprot
911 write(iout,*)"Processor",me," received",icount,
912 & " MD conformations and forces"
914 write (iout,'(8f10.4)') ((cg_MD(l,k,i,iprot),l=1,3,k=1,nres)
915 write(iout,'(8f10.4)')((cg_MD(l,k,i+nres,iprot),l=1,3,k=nnt,nct)
916 write (iout,'(16i5)') nss_MD(i,iprot),(ihpb_MD(k,i,iprot),
917 & jhpb_MD(k,i,iprot),k=1,nss_MD(i,iprot))
918 write(iout,'(8f10.4)')((cgforce_MD(l,k,i,iprot),l=1,3,k=,1,
923 write (iout,*) "jj",jj," nconf_forc",nconf_forc(iprot)
927 c-------------------------------------------------------------------------------
928 subroutine work_partition_MD(lprint)
929 c Split the conformations between processors
932 include "DIMENSIONS.ZSCOPT"
934 include "COMMON.CLASSES"
935 include "COMMON.IOUNITS"
937 include "COMMON.VMCPAR"
938 include "COMMON.CONTROL"
939 integer n,chunk,iprot,i,j,ii,remainder
940 integer kolor,key,ierror,errcode
943 C Divide conformations between processors; for each proteins the first and
944 C the last conformation to handle by ith processor is stored in
945 C indstart(i,iprot) and indend(i,iprot), respectively.
947 C First try to assign equal number of conformations to each processor.
951 if (.not.fmatch(iprot)) cycle
953 n=ntot_work_MD(iprot)
954 write (iout,*) "Protein",iprot," n=",n
955 indstart_MD(0,iprot)=1
957 scount_MD(0,iprot) = chunk
958 c print *,"i",0," indstart",indstart(0,iprot)," scount",
961 indstart_MD(i,iprot)=chunk+indstart_MD(i-1,iprot)
962 scount_MD(i,iprot)=scount_MD(i-1,iprot)
963 c print *,"i",i," indstart",indstart(i,iprot)," scount",
967 C Determine how many conformations remained yet unassigned.
969 remainder=N-(indstart_MD(nprocs1-1,iprot)
970 & +scount_MD(nprocs1-1,iprot)-1)
971 c print *,"remainder",remainder
973 C Assign the remainder conformations to consecutive processors, starting
974 C from the lowest rank; this continues until the list is exhausted.
976 if (remainder .gt. 0) then
978 scount_MD(i-1,iprot) = scount_MD(i-1,iprot) + 1
979 indstart_MD(i,iprot) = indstart_MD(i,iprot) + i
981 do i=remainder+1,nprocs1-1
982 indstart_MD(i,iprot) = indstart_MD(i,iprot) + remainder
986 indstart_MD(nprocs1,iprot)=N+1
987 scount_MD(nprocs1,iprot)=0
990 indend_MD(i,iprot)=indstart_MD(i,iprot)+scount_MD(i,iprot)-1
991 idispl_MD(i,iprot)=indstart_MD(i,iprot)-1
996 N=N+indend_MD(i,iprot)-indstart_MD(i,iprot)+1
999 c print *,"N",n," NTOT",ntot_work(iprot)
1000 if (N.ne.ntot_MD(iprot)) then
1001 write (iout,*) "!!! Checksum error on processor",me
1003 call MPI_Abort( WHAM_COMM, Ierror, Errcode )
1008 write (iout,*) "Partition of work between processors"
1010 write (iout,*) "Protein",iprot
1012 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
1013 & "Processor",i," indstart_MD",indstart_MD(i,iprot),
1014 & " indend_MD",indend_MD(i,iprot),
1015 & " count_MD",scount_MD(i,iprot)
1021 c------------------------------------------------------------------------------