3 c feeds tasks for parallel processing
4 implicit real*8 (a-h,o-z)
10 include 'COMMON.IOUNITS'
11 include 'COMMON.CHAIN'
12 include 'COMMON.TIME1'
13 include 'COMMON.SETUP'
16 include 'COMMON.CONTROL'
17 include 'COMMON.SBRIDGE'
19 double precision time_start,time_start_c,time0f,time0i
20 logical ovrtim,sync_iter,timeout,flag,timeout1
21 dimension muster(mpi_status_size)
22 dimension t100(0:100),indx(mxio)
23 dimension xout(maxvar),eout(mxch*(mxch+1)/2+1),ind(9)
25 parameter (rad=1.745329252d-2)
27 cccccccccccccccccccccccccccccccccccccccccccccccc
41 if(iref.ne.0) call from_int(1,0,idum)
43 c To minimize input conformation (bank conformation)
44 c Output to $mol.reminimized
45 if (irestart.lt.0) then
46 call read_bank(0,nft,cutdifr)
47 if (irestart.lt.-10) then
49 call prune_bank(p_cut)
56 if (irestart.eq.0) then
60 if (ntbankm.eq.0) ntbank=0
69 c!bankt call read_bankt(jlee,nft,cutdifr)
70 call read_bank(jlee,nft,cutdifr)
71 call read_rbank(jlee,adif)
72 if(iref.ne.0) call from_int(1,0,idum)
76 ntrial=n1+n2+n3+n4+n5+n6+n7+n8
80 c ntrial : number of trial conformations per seed.
81 c ntry : total number of trial conformations including seed conformations.
91 call mpi_bcast(jend,1,mpi_integer,0,CG_COMM,ierr)
92 cccccccccccccccccccccccccccccccccccccccc
94 cccccccccccccccccccccccccccccccccccccccc
97 if(sync_iter) goto 333
98 idum=- ran2(idum2)*imax
99 if(jlee.lt.jstart) goto 300
101 C Restart the random number generator for conformation generation
103 if(irestart.gt.0) then
105 if(idum2.le.0) idum2=-idum2+1
106 idum=- ran2(idum2)*imax
112 open(icsa_seed,file=csa_seed,status="old")
113 write(icsa_seed,*) "jlee : ",jlee
117 write(icsa_history,*) "number of procs is ",nodes
118 write(icsa_history,*) jlee,idum,idum2
121 cccccccccccccccccccccccccccccccccccccccccccccccc
125 write(icsa_history,*) "nbank is ",nbank
128 if(irestart.eq.1) goto 111
129 if(irestart.eq.2) then
134 do i=nbank+1,nbank+nconf
139 c start energy minimization
140 nconfr=max0(nconf+nadd,nodes-1)
141 if (sync_iter) nconf_in=0
142 c king-emperor - feed input and sort output
143 write (iout,*) "NCONF_IN",nconf_in
145 if (nconf_in.gt.0) then
146 c al 7/2/00 - added possibility to read in some of the initial conformations
148 read (intin,'(i5)',end=11,err=12) iconf
150 write (iout,*) "write READ_ANGLES",iconf,m
151 call read_angles(intin,*11)
158 dihang_in(1,j,1,mm)=theta(j+1)
159 dihang_in(2,j,1,mm)=phi(j+2)
160 dihang_in(3,j,1,mm)=alph(j)
161 dihang_in(4,j,1,mm)=omeg(j)
165 11 write (iout,*) nconf_in," conformations requested, but only",
166 & m-1," found in the angle file."
170 write (iout,*) nconf_in,
171 & " initial conformations have been read in."
174 if (nconfr.gt.nconf_in) then
175 call make_ranvar(nconfr,m,idum)
176 write (iout,*) nconfr-nconf_in,
177 & " conformations have been generated randomly."
181 call from_int(nconfr,m,idum)
182 c call from_pdb(nconfr,idum)
184 write (iout,*) 'Exitted from make_ranvar nconfr=',nconfr
185 write (*,*) 'Exitted from make_ranvar nconfr=',nconfr
187 write (iout,*) 'Initial conformation',m
188 write(iout,'(8f10.4)') (rad2deg*dihang_in(1,j,1,m),j=2,nres-1)
189 write(iout,'(8f10.4)') (rad2deg*dihang_in(2,j,1,m),j=2,nres-1)
190 write(iout,'(8f10.4)') (rad2deg*dihang_in(3,j,1,m),j=2,nres-1)
191 write(iout,'(8f10.4)') (rad2deg*dihang_in(4,j,1,m),j=2,nres-1)
193 write(iout,*)'Calling FEEDIN NCONF',nconfr
195 call feedin(nconfr,nft)
196 write (iout,*) ' Time for first bank min.',MPI_WTIME()-time1i
198 write(icsa_history,*) jlee,nft,nbank
199 write(icsa_history,851) (etot(i),i=1,nconfr)
200 write(icsa_history,850) (rmsn(i),i=1,nconfr)
201 write(icsa_history,850) (pncn(i),i=1,nconfr)
202 write(icsa_history,*)
205 c To minimize input conformation (bank conformation)
206 c Output to $mol.reminimized
207 if (irestart.lt.0) then
208 call reminimize(jlee)
211 if (irestart.eq.1) goto 111
212 c soldier - perform energy minimization
218 ccccccccccccccccccccccccccccccccccc
219 c need to syncronize all procs
220 call mpi_barrier(CG_COMM,ierr)
222 print *, ' cannot synchronize MPI'
225 ccccccccccccccccccccccccccccccccccc
229 c print *,"ok after minim"
231 if(irestart.eq.2) then
233 c ntbank=ntbank+nconf
234 if(ntbank.gt.ntbankm) ntbank=ntbankm
236 c print *,"ok before indexx"
238 call indexx(nconfr,etot,indx)
244 call indexx(nconfr-nconf_in,rmsn(nconf_in+1),indx(nconf_in+1))
245 do k=nconf_in+1,nconfr
246 indx(k)=indx(k)+nconf_in
249 c call indexx(nconfr,rmsn,indx)
251 c print *,"ok after indexx"
254 if (m.gt.mxio .or. m.lt.1) then
255 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,' M',m
256 call mpi_abort(mpi_comm_world,ierror,ierrcode)
258 jbank(im+nbank-nconf)=0
259 bene(im+nbank-nconf)=etot(m)
260 rene(im+nbank-nconf)=etot(m)
261 c!bankt btene(im)=etot(m)
263 brmsn(im+nbank-nconf)=rmsn(m)
264 bpncn(im+nbank-nconf)=pncn(m)
265 rrmsn(im+nbank-nconf)=rmsn(m)
266 rpncn(im+nbank-nconf)=pncn(m)
267 if (im+nbank-nconf.gt.mxio .or. im+nbank-nconf.lt.1) then
268 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,
269 & ' NBANK',nbank,' NCONF',nconf,' IM+NBANK-NCONF',im+nbank-nconf
270 call mpi_abort(mpi_comm_world,ierror,ierrcode)
275 bvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
276 rvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
277 c!bankt btvar(i,j,k,im)=dihang(i,j,k,m)
283 if(brmsn(im+nbank-nconf).gt.rmscut.or.
284 & bpncn(im+nbank-nconf).lt.pnccut) ibank(im+nbank-nconf)=9
287 bvar_ns(im+nbank-nconf)=ns-2*nss
291 do while( iss(i).ne.ihpb(j)-nres .and.
292 & iss(i).ne.jhpb(j)-nres .and. j.le.nss)
297 bvar_s(k,im+nbank-nconf)=iss(i)
301 bvar_nss(im+nbank-nconf)=nss
303 bvar_ss(1,i,im+nbank-nconf)=ihpb(i)
304 bvar_ss(2,i,im+nbank-nconf)=jhpb(i)
321 if(nbank.eq.nconf.and.irestart.eq.0) then
325 write (iout,*) "AVEDIF",avedif
329 cd print *,"adif,xctdif,cutdifr"
330 cd print *,adif,xctdif,cutdifr
331 nst=ntotal/ntrial/nseed
332 xctdif=(cutdif/ctdif1)**(-1.0/nst)
333 if(irestart.ge.1) call estimate_cutdif(adif,xctdif,cutdifr)
334 c print *,"ok after estimate"
338 call write_rbank(jlee,adif,nft)
339 call write_bank(jlee,nft)
340 c!bankt call write_bankt(jlee,nft)
341 c call write_bank1(jlee)
343 write(icsa_history,*) "xctdif: ", xctdif,nst,adif/cut1,ctdif1
344 write(icsa_history,851) (bene(i),i=1,nbank)
345 write(icsa_history,850) (brmsn(i),i=1,nbank)
346 write(icsa_history,850) (bpncn(i),i=1,nbank)
364 if (.not.sync_iter) then
372 ccccccccccccccccccccccccccccccccccccccc
373 do while (.not. finished)
374 ccccccccccccccccccccccccccccccccccccccc
375 crc print *,"iter ", iter,' isent=',isent
378 c start energy minimization
381 c king-emperor - select seeds & make var & feed input
382 cd print *,'generating new conf',ntrial,MPI_WTIME()
383 call select_is(nseed,ifar,idum)
385 open(icsa_seed,file=csa_seed,status="old")
387 & jlee,icycle,nstep,(is(i),bene(is(i)),i=1,nseed)
390 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
391 * ebmin,ebmax,nft,iuse,nbank,ntbank
396 call make_var(ntry,idum,iter)
397 cd print *,'new trial generated',ntrial,MPI_WTIME()
399 write (iout,'(a20,i4,f12.2)')
400 & 'Time for make trial',iter+1,time2i-time1i
403 crc write(iout,*)'1:Calling FEEDIN NTRY',NTRY,' ntrial',ntrial
404 crc call feedin(ntry,nft)
407 if (isent.ge.nodes.or.iter.gt.0) then
408 ct print *,'waiting ',MPI_WTIME()
410 call recv(0,ifrom,xout,eout,ind,timeout)
411 ct print *,' ',irecv,' received from',ifrom,MPI_WTIME()
415 movernx(irecv)=iabs(ind(5))
416 call getx(ind,xout,eout,cout,rad,iw_pdb,irecv)
420 iss_out(i,irecv)=ihpb(i)
421 jss_out(i,irecv)=jhpb(i)
425 & call write_csa_pdb(xout,eout,nft,irecv,iw_pdb)
428 if(tm_score.and.eout(1).lt.ebmax) then
430 & (rmsn(irecv).le.rmscut.and.pncn(irecv).ge.pnccut))
431 & call refresh_bank_master_tmscore(ifrom,eout(1),irecv)
437 ct print *,'sending to',ifrom,MPI_WTIME()
438 call send(isent,ifrom,iter)
439 ct print *,isent,' sent ',MPI_WTIME()
441 c store results -----------------------------------------------
442 if ((isent.ge.nodes.or.iter.gt.0).and..not.tm_score) then
444 movernx(irecv)=iabs(ind(5))
445 call getx(ind,xout,eout,cout,rad,iw_pdb,irecv)
449 iss_out(i,irecv)=ihpb(i)
450 jss_out(i,irecv)=jhpb(i)
454 & call write_csa_pdb(xout,eout,nft,irecv,iw_pdb)
456 c--------------------------------------------------------------
457 if (isent.eq.ntry) then
459 write (iout,'(a18,f12.2,a14,f10.2)')
460 & 'Nonsetup time ',time1i-time_start_c,
461 & ' sec, Eval/s =',(nft-nft00_c)/(time1i-time_start_c)
462 write (iout,'(a14,i4,f12.2,a14,f10.2)')
463 & 'Time for iter ',iter+1,time1i-time0i,
464 & ' sec, Eval/s =',(nft-nft0i)/(time1i-time0i)
468 if(cutdif.lt.ctdif1) cutdif=ctdif1
470 print *,'UPDATING ',ntry-nodes+1,irecv
471 write(iout,*) 'UPDATING ',ntry-nodes+1
473 c----------------- call update(ntry-nodes+1) -------------------
474 nstep=nstep+ntry-nseed-(nodes-1)
476 ctm call refresh_bank(ntry)
480 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
485 call refresh_bank(ntry-nodes+1)
487 c!bankt call refresh_bankt(ntry-nodes+1)
489 c----------------- call update(ntry) ---------------------------
491 print *,'UPDATING ',ntry,irecv
492 write(iout,*) 'UPDATING ',ntry
493 nstep=nstep+ntry-nseed
495 ctm call refresh_bank(ntry)
499 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
504 call refresh_bank(ntry)
506 c!bankt call refresh_bankt(ntry)
508 c-----------------------------------------------------------------
510 call write_bank(jlee,nft)
511 c!bankt call write_bankt(jlee,nft)
515 write (iout,'(a20,i4,f12.2)')
516 & 'Time for refresh ',iter,time1i-time0i
518 if(ebmin.lt.estop) finished=.true.
519 if(icycle.gt.icmax) then
520 call write_bank1(jlee)
526 if(nbank.gt.nbankm) then
534 if(nstep.gt.nstmax) finished=.true.
536 if(finished.or.sync_iter) then
538 call recv(1,ifrom,xout,eout,ind,timeout)
541 print *,'ERROR worker is not responding'
542 write(iout,*) 'ERROR worker is not responding'
543 time1i=MPI_WTIME()-time_start_c
544 print *,'End of cycle, master time for ',iter,' iters ',
545 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
546 write (iout,*) 'End of cycle, master time for ',iter,
547 & ' iters ',time1i,' sec'
548 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
549 print *,'UPDATING ',ij-1
550 write(iout,*) 'UPDATING ',ij-1
552 call refresh_bank(ij-1)
553 c!bankt call refresh_bankt(ij-1)
556 c print *,'node ',ifrom,' finished ',ij,nft
557 write(iout,*) 'node ',ifrom,' finished ',ij,nft
560 movernx(ij)=iabs(ind(5))
561 call getx(ind,xout,eout,cout,rad,iw_pdb,ij)
565 iss_out(i,ij)=ihpb(i)
566 jss_out(i,ij)=jhpb(i)
570 & call write_csa_pdb(xout,eout,nft,ij,iw_pdb)
573 crc print *,'---------bcast finished--------',finished
574 time1i=MPI_WTIME()-time_start_c
575 print *,'End of cycle, master time for ',iter,' iters ',
576 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
577 write (iout,*) 'End of cycle, master time for ',iter,
578 & ' iters ',time1i,' sec'
579 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
581 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
582 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,
583 ctimeout & CG_COMM,ierr)
586 call mpi_issend(finished,1,mpi_logical,ij,idchar,
588 call mpi_issend(sync_iter,1,mpi_logical,ij,idchar,
589 & CG_COMM,ireq2,ierr)
592 do while(.not. (flag .or. timeout1))
593 call MPI_TEST(ireq2,flag,muster,ierr)
595 if(tend1-tstart.gt.60) then
596 print *,'ERROR worker ',ij,' is not responding'
597 write(iout,*) 'ERROR worker ',ij,' is not responding'
602 write(iout,*) 'worker ',ij,' NOT OK ',tend1-tstart
605 write(iout,*) 'worker ',ij,' OK ',tend1-tstart
608 print *,'UPDATING ',nodes-1,ij
609 write(iout,*) 'UPDATING ',nodes-1
610 call refresh_bank(nodes-1)
611 c!bankt call refresh_bankt(nodes-1)
613 call write_bank(jlee,nft)
614 c!bankt call write_bankt(jlee,nft)
619 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
624 write(iout,*)'### Total stats:'
626 if(nstatnx_tot(i,1).ne.0) then
628 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
629 & '### N',i,' total=',nstatnx_tot(i,1),
630 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
631 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
633 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
634 & '###N',i,' total=',nstatnx_tot(i,1),
635 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
636 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
640 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
641 & '### N',i,' total=',nstatnx_tot(i,1),
642 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
645 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
646 & '###N',i,' total=',nstatnx_tot(i,1),
647 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
654 if(sync_iter) goto 331
656 39 format(2i3,i7,5(i4,f8.3,1x),19(/,13x,5(i4,f8.3,1x)))
657 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
659 44 format('jlee =',i3,':',4f10.1,' E =',f15.5,i7,i10)
668 c soldier - perform energy minimization
670 print *,'End of minim, proc',me,'time ',MPI_WTIME()-time_start
671 write (iout,*) 'End of minim, proc',me,'time ',
672 & MPI_WTIME()-time_start
674 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
675 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,CG_COMM,ierr)
676 call mpi_recv(finished,1,mpi_logical,0,idchar,
677 * CG_COMM,muster,ierr)
678 call mpi_recv(sync_iter,1,mpi_logical,0,idchar,
679 * CG_COMM,muster,ierr)
680 if(sync_iter) goto 331
683 ccccccccccccccccccccccccccccccccccccccc
685 ccccccccccccccccccccccccccccccccccccccc
689 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
690 * ebmin,ebmax,nft,iuse,nbank,ntbank
692 write(icsa_history,44) jlee,0.0,0.0,0.0,
693 & 0.0,ebmin,nstep,nft
694 write(icsa_history,*)
697 time1i=MPI_WTIME()-time_start
698 print *,'End of RUN, master time ',
699 & time1i,'sec, Eval/s ',(nft-nft00)/time1i
700 write (iout,*) 'End of RUN, master time ',
702 write (iout,*) 'Total eval/s ',(nft-nft00)/time1i
705 write(iout,*) '!!!! ERROR worker was not responding'
706 write(iout,*) '!!!! cannot finish work normally'
707 write(iout,*) 'Processor0 is calling MPI_ABORT'
708 print *,'!!!! ERROR worker was not responding'
709 print *,'!!!! cannot finish work normally'
710 print *,'Processor0 is calling MPI_ABORT'
712 call mpi_abort(mpi_comm_world, 111, ierr)
716 cccccccccccccccccccccccccccccc
718 cccccccccccccccccccccccccccccc
724 c feeds tasks for parallel processing
725 implicit real*8 (a-h,o-z)
727 include 'COMMON.IOUNITS'
728 write (iout,*) "Unsupported option for the serial version"
733 c-------------------------------------------------
734 subroutine feedin(nconf,nft)
735 c sends out starting conformations and receives results of energy minimization
736 implicit real*8 (a-h,o-z)
739 include 'COMMON.IOUNITS'
740 include 'COMMON.CONTROL'
742 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
743 * cout(2),ind(9),info(12)
744 dimension muster(mpi_status_size)
745 include 'COMMON.SETUP'
746 parameter (rad=1.745329252d-2)
748 print *,'FEEDIN: NCONF=',nconf
750 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
751 if (nconf .lt. nodes-1) then
752 write (*,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
754 write (iout,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
756 call mpi_abort(mpi_comm_world,ierror,ierrcode)
759 c pull out external and internal variables for next start
761 ! write (iout,*) 'XIN from FEEDIN N=',n
762 ! write(iout,'(8f10.4)') (xin(j),j=1,nvar)
764 if (mm.lt.nodes) then
765 c feed task to soldier
766 ! print *, ' sending input for start # ',n
773 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
775 call mpi_send(xin,nvar,mpi_double_precision,mm,
776 * idreal,CG_COMM,ierr)
778 c find an available soldier
779 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
780 * CG_COMM,muster,ierr)
781 ! print *, ' receiving output from start # ',ind(1)
782 man=muster(mpi_source)
783 c receive final energies and variables
785 call mpi_recv(eout,1,mpi_double_precision,
786 * man,idreal,CG_COMM,muster,ierr)
789 call mpi_recv(co,1,mpi_double_precision,
790 * man,idreal,CG_COMM,muster,ierr)
791 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
793 call mpi_recv(xout,nvar,mpi_double_precision,
794 * man,idreal,CG_COMM,muster,ierr)
795 ! print *,nvar , ierr
796 c feed next task to soldier
797 ! print *, ' sending input for start # ',n
807 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
809 call mpi_send(xin,nvar,mpi_double_precision,man,
810 * idreal,CG_COMM,ierr)
811 c retrieve latest results
812 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
814 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
817 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
819 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
822 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
823 * CG_COMM,muster,ierr)
824 crc if (ierr.ne.0) go to 30
825 ! print *, ' receiving output from start # ',ind(1)
826 man=muster(mpi_source)
827 c receive final energies and variables
829 call mpi_recv(eout,1,
830 * mpi_double_precision,man,idreal,
831 * CG_COMM,muster,ierr)
834 call mpi_recv(co,1,mpi_double_precision,
835 * man,idreal,CG_COMM,muster,ierr)
836 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
838 crc if (ierr.ne.0) go to 30
839 call mpi_recv(xout,nvar,mpi_double_precision,
840 * man,idreal,CG_COMM,muster,ierr)
841 ! print *,nvar , ierr
842 crc if (ierr.ne.0) go to 30
850 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
853 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
855 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
857 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
859 10 print *, ' dispatching error'
860 call mpi_abort(mpi_comm_world,ierror,ierrcode)
862 20 print *, ' communication error'
863 call mpi_abort(mpi_comm_world,ierror,ierrcode)
865 30 print *, ' receiving error'
866 call mpi_abort(mpi_comm_world,ierror,ierrcode)
869 cccccccccccccccccccccccccccccccccccccccccccccccccc
870 subroutine getx(ind,xout,eout,cout,rad,iw_pdb,k)
871 c receives and stores data from soldiers
872 implicit real*8 (a-h,o-z)
874 include 'COMMON.IOUNITS'
876 include 'COMMON.BANK'
878 include 'COMMON.CHAIN'
879 include 'COMMON.CONTACTS'
880 dimension ind(9),xout(maxvar),eout(mxch*(mxch+1)/2+1)
883 double precision przes(3),obr(3,3)
887 if (k.gt.mxio .or. k.lt.1) then
889 & 'ERROR - dimensions of ANGMIN have been exceeded K=',k
890 call mpi_abort(mpi_comm_world,ierror,ierrcode)
898 c retrieve dihedral angles etc
899 call var_to_geom(nvar,xout)
901 dihang(1,j,1,k)=theta(j+1)
902 dihang(2,j,1,k)=phi(j+2)
903 dihang(3,j,1,k)=alph(j)
904 dihang(4,j,1,k)=omeg(j)
906 dihang(2,nres-1,1,k)=0.0d0
910 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a4,i3,i4)')
911 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' mv ',
916 c call dihang_to_c(dihang(1,1,1,k))
917 c call fitsq(rms,c(1,1),crefjlee(1,1),nres,przes,obr,non_conv)
918 c call fitsq(rms,c(1,2),crefjlee(1,2),nres-1,przes,obr,non_conv)
919 c call fitsq(rms,c(1,nstart_seq),crefjlee(1,nstart_sup),
920 c & nsup,przes,obr,non_conv)
923 call rmsd_csa(rmsn(k))
924 call contact(.false.,ncont,icont,co)
925 pncn(k)=contact_fract(ncont,ncont_ref,icont,icont_ref)
927 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a5
928 cd & ,0pf5.2,a5,f5.1,a,f6.3,a4,i3,i4)')
929 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' rms ',
930 cd & rmsn(k),' %NC ',pncn(k)*100,' cont.order',co,' mv ',
934 if (rmsn(k).gt.rmscut.or.pncn(k).lt.pnccut) iw_pdb=0
937 cccccccccccccccccccccccccccccccccccccccccccccccccc
938 subroutine putx(xin,n,rad)
939 c gets starting variables
940 implicit real*8 (a-h,o-z)
943 include 'COMMON.BANK'
945 include 'COMMON.CHAIN'
946 include 'COMMON.IOUNITS'
947 dimension xin(maxvar)
949 c pull out starting values for variables
950 ! write (iout,*)'PUTX: N=',n
952 ! write (iout,'(8f10.4)') (dihang_in(1,j,m,n),j=2,nres-1)
953 ! write (iout,'(8f10.4)') (dihang_in(2,j,m,n),j=2,nres-1)
954 ! write (iout,'(8f10.4)') (dihang_in(3,j,m,n),j=2,nres-1)
955 ! write (iout,'(8f10.4)') (dihang_in(4,j,m,n),j=2,nres-1)
957 theta(j+1)=dihang_in(1,j,m,n)
958 phi(j+2)=dihang_in(2,j,m,n)
959 alph(j)=dihang_in(3,j,m,n)
960 omeg(j)=dihang_in(4,j,m,n)
963 c set up array of variables
964 call geom_to_var(nvar,xin)
965 ! write (iout,*) 'xin in PUTX N=',n
967 ! write (iout,'(8f10.4)') (xin(i),i=1,nvar)
970 c--------------------------------------------------------
971 subroutine putx2(xin,iff,n)
972 c gets starting variables
973 implicit real*8 (a-h,o-z)
976 include 'COMMON.BANK'
978 include 'COMMON.CHAIN'
979 include 'COMMON.IOUNITS'
980 dimension xin(maxvar),iff(maxres)
982 c pull out starting values for variables
985 theta(j+1)=dihang_in2(1,j,m,n)
986 phi(j+2)=dihang_in2(2,j,m,n)
987 alph(j)=dihang_in2(3,j,m,n)
988 omeg(j)=dihang_in2(4,j,m,n)
991 c set up array of variables
992 call geom_to_var(nvar,xin)
1000 c-------------------------------------------------------
1001 subroutine prune_bank(p_cut)
1002 implicit real*8 (a-h,o-z)
1003 include 'DIMENSIONS'
1005 include 'COMMON.CSA'
1006 include 'COMMON.BANK'
1007 include 'COMMON.IOUNITS'
1008 include 'COMMON.CHAIN'
1009 include 'COMMON.TIME1'
1010 include 'COMMON.SETUP'
1011 c---------------------------
1012 c This subroutine prunes bank conformations using p_cut
1013 c---------------------------
1021 dihang(i,j,k,nprune)=bvar(i,j,k,m)
1025 bene(nprune)=bene(m)
1026 brmsn(nprune)=brmsn(m)
1027 bpncn(nprune)=bpncn(m)
1032 call get_diff12(dihang(1,1,1,ip),bvar(1,1,1,m),diff)
1033 if(diff.lt.p_cut) goto 100
1034 if(diff.lt.ddmin) ddmin=diff
1040 dihang(i,j,k,nprune)=bvar(i,j,k,m)
1044 bene(nprune)=bene(m)
1045 brmsn(nprune)=brmsn(m)
1046 bpncn(nprune)=bpncn(m)
1048 write (iout,*) 'Pruning :',m,nprune,p_cut,ddmin
1051 print *, 'Pruning :',m,nprune,p_cut
1052 call write_bank(0,0)
1056 c-------------------------------------------------------
1058 subroutine reminimize(jlee)
1059 implicit real*8 (a-h,o-z)
1060 include 'DIMENSIONS'
1062 include 'COMMON.CSA'
1063 include 'COMMON.BANK'
1064 include 'COMMON.IOUNITS'
1065 include 'COMMON.CHAIN'
1066 include 'COMMON.TIME1'
1067 include 'COMMON.SETUP'
1068 c---------------------------
1069 c This subroutine re-minimizes bank conformations:
1070 c---------------------------
1077 if (me.eq.king) then
1078 open(icsa_history,file=csa_history,status="old")
1079 write(icsa_history,*) "Re-minimization",nodes,"nodes"
1080 write(icsa_history,851) (bene(i),i=1,nbank)
1081 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1082 * ebmin,ebmax,nft,iuse,nbank,ntbank
1088 dihang_in(i,j,k,index)=bvar(i,j,k,index)
1094 call feedin(ntry,nft)
1102 if (me.eq.king) then
1104 call replace_bvar(i,i)
1106 open(icsa_history,file=csa_history,status="old")
1107 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1108 * ebmin,ebmax,nft,iuse,nbank,ntbank
1109 write(icsa_history,851) (bene(i),i=1,nbank)
1111 call write_bank_reminimized(jlee,nft)
1114 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
1117 c 850 format(10f8.3)
1121 c-------------------------------------------------------
1122 subroutine send(n,mm,it)
1123 c sends out starting conformation for minimization
1124 implicit real*8 (a-h,o-z)
1125 include 'DIMENSIONS'
1126 include 'COMMON.VAR'
1127 include 'COMMON.IOUNITS'
1128 include 'COMMON.CONTROL'
1129 include 'COMMON.BANK'
1130 include 'COMMON.CHAIN'
1132 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1133 * cout(2),ind(8),xin2(maxvar),iff(maxres),info(12)
1134 dimension muster(mpi_status_size)
1135 include 'COMMON.SETUP'
1136 parameter (rad=1.745329252d-2)
1138 if (isend2(n).eq.0) then
1139 c pull out external and internal variables for next start
1140 call putx(xin,n,rad)
1148 if (movenx(n).eq.14.or.movenx(n).eq.17) then
1151 else if (movenx(n).eq.16) then
1165 if (movenx(n).eq.15) then
1170 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1172 call mpi_send(xin,nvar,mpi_double_precision,mm,
1173 * idreal,CG_COMM,ierr)
1175 c distfit & minimization for n7 move
1185 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1187 call putx2(xin,iff,isend2(n))
1188 call mpi_send(xin,nvar,mpi_double_precision,mm,
1189 * idreal,CG_COMM,ierr)
1190 call mpi_send(iff,nres,mpi_integer,mm,
1191 * idint,CG_COMM,ierr)
1192 call putx(xin2,n,rad)
1193 call mpi_send(xin2,nvar,mpi_double_precision,mm,
1194 * idreal,CG_COMM,ierr)
1196 if (vdisulf.and.nss_in(n).ne.0) then
1197 call mpi_send(iss_in(1,n),nss_in(n),mpi_integer,mm,
1198 * idint,CG_COMM,ierr)
1199 call mpi_send(jss_in(1,n),nss_in(n),mpi_integer,mm,
1200 * idint,CG_COMM,ierr)
1204 c-------------------------------------------------
1206 subroutine recv(ihalt,man,xout,eout,ind,tout)
1207 c receives results of energy minimization
1208 implicit real*8 (a-h,o-z)
1209 include 'DIMENSIONS'
1210 include 'COMMON.VAR'
1211 include 'COMMON.IOUNITS'
1212 include 'COMMON.CONTROL'
1213 include 'COMMON.SBRIDGE'
1214 include 'COMMON.BANK'
1215 include 'COMMON.CHAIN'
1217 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1218 * cout(2),ind(9),info(12)
1219 dimension muster(mpi_status_size)
1220 include 'COMMON.SETUP'
1222 double precision twait,tstart,tend1
1223 parameter(twait=600.0d0)
1225 c find an available soldier
1229 do while(.not. (flag .or. tout))
1230 call MPI_IPROBE(mpi_any_source,idint,CG_COMM,flag,
1233 if(tend1-tstart.gt.twait .and. ihalt.eq.1) tout=.true.
1234 c_error if(tend1-tstart.gt.twait) tout=.true.
1237 write(iout,*) 'ERROR = timeout for recv ',tend1-tstart
1241 man=muster(mpi_source)
1243 ctimeout call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
1244 ctimeout * CG_COMM,muster,ierr)
1245 ! print *, ' receiving output from start # ',ind(1)
1246 ct print *,'receiving ',MPI_WTIME()
1247 ctimeout man=muster(mpi_source)
1248 call mpi_recv(ind,9,mpi_integer,man,idint,
1249 * CG_COMM,muster,ierr)
1251 c receive final energies and variables
1252 call mpi_recv(eout,1,mpi_double_precision,
1253 * man,idreal,CG_COMM,muster,ierr)
1256 call mpi_recv(co,1,mpi_double_precision,
1257 * man,idreal,CG_COMM,muster,ierr)
1258 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
1260 call mpi_recv(xout,nvar,mpi_double_precision,
1261 * man,idreal,CG_COMM,muster,ierr)
1262 ! print *,nvar , ierr
1263 if(vdisulf) nss=ind(6)
1264 if(vdisulf.and.nss.ne.0) then
1265 call mpi_recv(ihpb,nss,mpi_integer,
1266 * man,idint,CG_COMM,muster,ierr)
1267 call mpi_recv(jhpb,nss,mpi_integer,
1268 * man,idint,CG_COMM,muster,ierr)
1272 c print *,'sending halt to ',man
1273 write(iout,*) 'sending halt to ',man
1276 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,ierr)
1281 c----------------------------------------------------------
1282 subroutine history_append
1283 implicit real*8 (a-h,o-z)
1284 include 'DIMENSIONS'
1285 include 'COMMON.IOUNITS'
1287 #if defined(AIX) || defined(PGI)
1288 open(icsa_history,file=csa_history,position="append")
1290 open(icsa_history,file=csa_history,access="append")