2 c feeds tasks for parallel processing
3 implicit real*8 (a-h,o-z)
9 include 'COMMON.IOUNITS'
10 include 'COMMON.CHAIN'
11 include 'COMMON.TIME1'
12 include 'COMMON.SETUP'
15 include 'COMMON.CONTROL'
16 include 'COMMON.SBRIDGE'
18 double precision time_start,time_start_c,time0f,time0i
19 logical ovrtim,sync_iter,timeout,flag,timeout1
20 dimension muster(mpi_status_size)
21 dimension t100(0:100),indx(mxio)
22 dimension xout(maxvar),eout(mxch*(mxch+1)/2+1),ind(9)
24 parameter (rad=1.745329252d-2)
26 cccccccccccccccccccccccccccccccccccccccccccccccc
40 if(iref.ne.0) call from_int(1,0,idum)
42 c To minimize input conformation (bank conformation)
43 c Output to $mol.reminimized
44 if (irestart.lt.0) then
45 call read_bank(0,nft,cutdifr)
46 if (irestart.lt.-10) then
48 call prune_bank(p_cut)
55 if (irestart.eq.0) then
59 if (ntbankm.eq.0) ntbank=0
68 c!bankt call read_bankt(jlee,nft,cutdifr)
69 call read_bank(jlee,nft,cutdifr)
70 call read_rbank(jlee,adif)
71 if(iref.ne.0) call from_int(1,0,idum)
75 ntrial=n1+n2+n3+n4+n5+n6+n7+n8
79 c ntrial : number of trial conformations per seed.
80 c ntry : total number of trial conformations including seed conformations.
90 call mpi_bcast(jend,1,mpi_integer,0,CG_COMM,ierr)
91 cccccccccccccccccccccccccccccccccccccccc
93 cccccccccccccccccccccccccccccccccccccccc
96 if(sync_iter) goto 333
97 idum=- ran2(idum2)*imax
98 if(jlee.lt.jstart) goto 300
100 C Restart the random number generator for conformation generation
102 if(irestart.gt.0) then
104 if(idum2.le.0) idum2=-idum2+1
105 idum=- ran2(idum2)*imax
111 open(icsa_seed,file=csa_seed,status="old")
112 write(icsa_seed,*) "jlee : ",jlee
116 write(icsa_history,*) "number of procs is ",nodes
117 write(icsa_history,*) jlee,idum,idum2
120 cccccccccccccccccccccccccccccccccccccccccccccccc
124 write(icsa_history,*) "nbank is ",nbank
127 if(irestart.eq.1) goto 111
128 if(irestart.eq.2) then
133 do i=nbank+1,nbank+nconf
138 c start energy minimization
139 nconfr=max0(nconf+nadd,nodes-1)
140 if (sync_iter) nconf_in=0
141 c king-emperor - feed input and sort output
142 write (iout,*) "NCONF_IN",nconf_in
144 if (nconf_in.gt.0) then
145 c al 7/2/00 - added possibility to read in some of the initial conformations
147 read (intin,'(i5)',end=11,err=12) iconf
149 write (iout,*) "write READ_ANGLES",iconf,m
150 call read_angles(intin,*11)
157 dihang_in(1,j,1,mm)=theta(j+1)
158 dihang_in(2,j,1,mm)=phi(j+2)
159 dihang_in(3,j,1,mm)=alph(j)
160 dihang_in(4,j,1,mm)=omeg(j)
164 11 write (iout,*) nconf_in," conformations requested, but only",
165 & m-1," found in the angle file."
169 write (iout,*) nconf_in,
170 & " initial conformations have been read in."
173 if (nconfr.gt.nconf_in) then
174 call make_ranvar(nconfr,m,idum)
175 write (iout,*) nconfr-nconf_in,
176 & " conformations have been generated randomly."
180 call from_int(nconfr,m,idum)
181 c call from_pdb(nconfr,idum)
183 write (iout,*) 'Exitted from make_ranvar nconfr=',nconfr
184 write (*,*) 'Exitted from make_ranvar nconfr=',nconfr
186 write (iout,*) 'Initial conformation',m
187 write(iout,'(8f10.4)') (rad2deg*dihang_in(1,j,1,m),j=2,nres-1)
188 write(iout,'(8f10.4)') (rad2deg*dihang_in(2,j,1,m),j=2,nres-1)
189 write(iout,'(8f10.4)') (rad2deg*dihang_in(3,j,1,m),j=2,nres-1)
190 write(iout,'(8f10.4)') (rad2deg*dihang_in(4,j,1,m),j=2,nres-1)
192 write(iout,*)'Calling FEEDIN NCONF',nconfr
194 call feedin(nconfr,nft)
195 write (iout,*) ' Time for first bank min.',MPI_WTIME()-time1i
197 write(icsa_history,*) jlee,nft,nbank
198 write(icsa_history,851) (etot(i),i=1,nconfr)
199 write(icsa_history,850) (rmsn(i),i=1,nconfr)
200 write(icsa_history,850) (pncn(i),i=1,nconfr)
201 write(icsa_history,*)
204 c To minimize input conformation (bank conformation)
205 c Output to $mol.reminimized
206 if (irestart.lt.0) then
207 call reminimize(jlee)
210 if (irestart.eq.1) goto 111
211 c soldier - perform energy minimization
217 ccccccccccccccccccccccccccccccccccc
218 c need to syncronize all procs
219 call mpi_barrier(CG_COMM,ierr)
221 print *, ' cannot synchronize MPI'
224 ccccccccccccccccccccccccccccccccccc
228 c print *,"ok after minim"
230 if(irestart.eq.2) then
232 c ntbank=ntbank+nconf
233 if(ntbank.gt.ntbankm) ntbank=ntbankm
235 c print *,"ok before indexx"
237 call indexx(nconfr,etot,indx)
243 call indexx(nconfr-nconf_in,rmsn(nconf_in+1),indx(nconf_in+1))
244 do k=nconf_in+1,nconfr
245 indx(k)=indx(k)+nconf_in
248 c call indexx(nconfr,rmsn,indx)
250 c print *,"ok after indexx"
253 if (m.gt.mxio .or. m.lt.1) then
254 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,' M',m
255 call mpi_abort(mpi_comm_world,ierror,ierrcode)
257 jbank(im+nbank-nconf)=0
258 bene(im+nbank-nconf)=etot(m)
259 rene(im+nbank-nconf)=etot(m)
260 c!bankt btene(im)=etot(m)
262 brmsn(im+nbank-nconf)=rmsn(m)
263 bpncn(im+nbank-nconf)=pncn(m)
264 rrmsn(im+nbank-nconf)=rmsn(m)
265 rpncn(im+nbank-nconf)=pncn(m)
266 if (im+nbank-nconf.gt.mxio .or. im+nbank-nconf.lt.1) then
267 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,
268 & ' NBANK',nbank,' NCONF',nconf,' IM+NBANK-NCONF',im+nbank-nconf
269 call mpi_abort(mpi_comm_world,ierror,ierrcode)
274 bvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
275 rvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
276 c!bankt btvar(i,j,k,im)=dihang(i,j,k,m)
282 if(brmsn(im+nbank-nconf).gt.rmscut.or.
283 & bpncn(im+nbank-nconf).lt.pnccut) ibank(im+nbank-nconf)=9
286 bvar_ns(im+nbank-nconf)=ns-2*nss
290 do while( iss(i).ne.ihpb(j)-nres .and.
291 & iss(i).ne.jhpb(j)-nres .and. j.le.nss)
296 bvar_s(k,im+nbank-nconf)=iss(i)
300 bvar_nss(im+nbank-nconf)=nss
302 bvar_ss(1,i,im+nbank-nconf)=ihpb(i)
303 bvar_ss(2,i,im+nbank-nconf)=jhpb(i)
320 if(nbank.eq.nconf.and.irestart.eq.0) then
324 write (iout,*) "AVEDIF",avedif
328 cd print *,"adif,xctdif,cutdifr"
329 cd print *,adif,xctdif,cutdifr
330 nst=ntotal/ntrial/nseed
331 xctdif=(cutdif/ctdif1)**(-1.0/nst)
332 if(irestart.ge.1) call estimate_cutdif(adif,xctdif,cutdifr)
333 c print *,"ok after estimate"
337 call write_rbank(jlee,adif,nft)
338 call write_bank(jlee,nft)
339 c!bankt call write_bankt(jlee,nft)
340 c call write_bank1(jlee)
342 write(icsa_history,*) "xctdif: ", xctdif,nst,adif/cut1,ctdif1
343 write(icsa_history,851) (bene(i),i=1,nbank)
344 write(icsa_history,850) (brmsn(i),i=1,nbank)
345 write(icsa_history,850) (bpncn(i),i=1,nbank)
363 if (.not.sync_iter) then
371 ccccccccccccccccccccccccccccccccccccccc
372 do while (.not. finished)
373 ccccccccccccccccccccccccccccccccccccccc
374 crc print *,"iter ", iter,' isent=',isent
377 c start energy minimization
380 c king-emperor - select seeds & make var & feed input
381 cd print *,'generating new conf',ntrial,MPI_WTIME()
382 call select_is(nseed,ifar,idum)
384 open(icsa_seed,file=csa_seed,status="old")
386 & jlee,icycle,nstep,(is(i),bene(is(i)),i=1,nseed)
389 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
390 * ebmin,ebmax,nft,iuse,nbank,ntbank
395 call make_var(ntry,idum,iter)
396 cd print *,'new trial generated',ntrial,MPI_WTIME()
398 write (iout,'(a20,i4,f12.2)')
399 & 'Time for make trial',iter+1,time2i-time1i
402 crc write(iout,*)'1:Calling FEEDIN NTRY',NTRY,' ntrial',ntrial
403 crc call feedin(ntry,nft)
406 if (isent.ge.nodes.or.iter.gt.0) then
407 ct print *,'waiting ',MPI_WTIME()
409 call recv(0,ifrom,xout,eout,ind,timeout)
410 ct print *,' ',irecv,' received from',ifrom,MPI_WTIME()
414 movernx(irecv)=iabs(ind(5))
415 call getx(ind,xout,eout,cout,rad,iw_pdb,irecv)
419 iss_out(i,irecv)=ihpb(i)
420 jss_out(i,irecv)=jhpb(i)
424 & call write_csa_pdb(xout,eout,nft,irecv,iw_pdb)
427 if(tm_score.and.eout(1).lt.ebmax) then
429 & (rmsn(irecv).le.rmscut.and.pncn(irecv).ge.pnccut))
430 & call refresh_bank_master_tmscore(ifrom,eout(1),irecv)
436 ct print *,'sending to',ifrom,MPI_WTIME()
437 call send(isent,ifrom,iter)
438 ct print *,isent,' sent ',MPI_WTIME()
440 c store results -----------------------------------------------
441 if ((isent.ge.nodes.or.iter.gt.0).and..not.tm_score) then
443 movernx(irecv)=iabs(ind(5))
444 call getx(ind,xout,eout,cout,rad,iw_pdb,irecv)
448 iss_out(i,irecv)=ihpb(i)
449 jss_out(i,irecv)=jhpb(i)
453 & call write_csa_pdb(xout,eout,nft,irecv,iw_pdb)
455 c--------------------------------------------------------------
456 if (isent.eq.ntry) then
458 write (iout,'(a18,f12.2,a14,f10.2)')
459 & 'Nonsetup time ',time1i-time_start_c,
460 & ' sec, Eval/s =',(nft-nft00_c)/(time1i-time_start_c)
461 write (iout,'(a14,i4,f12.2,a14,f10.2)')
462 & 'Time for iter ',iter+1,time1i-time0i,
463 & ' sec, Eval/s =',(nft-nft0i)/(time1i-time0i)
467 if(cutdif.lt.ctdif1) cutdif=ctdif1
469 print *,'UPDATING ',ntry-nodes+1,irecv
470 write(iout,*) 'UPDATING ',ntry-nodes+1
472 c----------------- call update(ntry-nodes+1) -------------------
473 nstep=nstep+ntry-nseed-(nodes-1)
475 ctm call refresh_bank(ntry)
479 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
484 call refresh_bank(ntry-nodes+1)
486 c!bankt call refresh_bankt(ntry-nodes+1)
488 c----------------- call update(ntry) ---------------------------
490 print *,'UPDATING ',ntry,irecv
491 write(iout,*) 'UPDATING ',ntry
492 nstep=nstep+ntry-nseed
494 ctm call refresh_bank(ntry)
498 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
503 call refresh_bank(ntry)
505 c!bankt call refresh_bankt(ntry)
507 c-----------------------------------------------------------------
509 call write_bank(jlee,nft)
510 c!bankt call write_bankt(jlee,nft)
514 write (iout,'(a20,i4,f12.2)')
515 & 'Time for refresh ',iter,time1i-time0i
517 if(ebmin.lt.estop) finished=.true.
518 if(icycle.gt.icmax) then
519 call write_bank1(jlee)
525 if(nbank.gt.nbankm) then
533 if(nstep.gt.nstmax) finished=.true.
535 if(finished.or.sync_iter) then
537 call recv(1,ifrom,xout,eout,ind,timeout)
540 print *,'ERROR worker is not responding'
541 write(iout,*) 'ERROR worker is not responding'
542 time1i=MPI_WTIME()-time_start_c
543 print *,'End of cycle, master time for ',iter,' iters ',
544 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
545 write (iout,*) 'End of cycle, master time for ',iter,
546 & ' iters ',time1i,' sec'
547 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
548 print *,'UPDATING ',ij-1
549 write(iout,*) 'UPDATING ',ij-1
551 call refresh_bank(ij-1)
552 c!bankt call refresh_bankt(ij-1)
555 c print *,'node ',ifrom,' finished ',ij,nft
556 write(iout,*) 'node ',ifrom,' finished ',ij,nft
559 movernx(ij)=iabs(ind(5))
560 call getx(ind,xout,eout,cout,rad,iw_pdb,ij)
564 iss_out(i,ij)=ihpb(i)
565 jss_out(i,ij)=jhpb(i)
569 & call write_csa_pdb(xout,eout,nft,ij,iw_pdb)
572 crc print *,'---------bcast finished--------',finished
573 time1i=MPI_WTIME()-time_start_c
574 print *,'End of cycle, master time for ',iter,' iters ',
575 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
576 write (iout,*) 'End of cycle, master time for ',iter,
577 & ' iters ',time1i,' sec'
578 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
580 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
581 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,
582 ctimeout & CG_COMM,ierr)
585 call mpi_issend(finished,1,mpi_logical,ij,idchar,
587 call mpi_issend(sync_iter,1,mpi_logical,ij,idchar,
588 & CG_COMM,ireq2,ierr)
591 do while(.not. (flag .or. timeout1))
592 call MPI_TEST(ireq2,flag,muster,ierr)
594 if(tend1-tstart.gt.60) then
595 print *,'ERROR worker ',ij,' is not responding'
596 write(iout,*) 'ERROR worker ',ij,' is not responding'
601 write(iout,*) 'worker ',ij,' NOT OK ',tend1-tstart
604 write(iout,*) 'worker ',ij,' OK ',tend1-tstart
607 print *,'UPDATING ',nodes-1,ij
608 write(iout,*) 'UPDATING ',nodes-1
609 call refresh_bank(nodes-1)
610 c!bankt call refresh_bankt(nodes-1)
612 call write_bank(jlee,nft)
613 c!bankt call write_bankt(jlee,nft)
618 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
623 write(iout,*)'### Total stats:'
625 if(nstatnx_tot(i,1).ne.0) then
627 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
628 & '### N',i,' total=',nstatnx_tot(i,1),
629 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
630 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
632 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
633 & '###N',i,' total=',nstatnx_tot(i,1),
634 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
635 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
639 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
640 & '### N',i,' total=',nstatnx_tot(i,1),
641 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
644 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
645 & '###N',i,' total=',nstatnx_tot(i,1),
646 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
653 if(sync_iter) goto 331
655 39 format(2i3,i7,5(i4,f8.3,1x),19(/,13x,5(i4,f8.3,1x)))
656 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
658 44 format('jlee =',i3,':',4f10.1,' E =',f15.5,i7,i10)
667 c soldier - perform energy minimization
669 print *,'End of minim, proc',me,'time ',MPI_WTIME()-time_start
670 write (iout,*) 'End of minim, proc',me,'time ',
671 & MPI_WTIME()-time_start
673 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
674 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,CG_COMM,ierr)
675 call mpi_recv(finished,1,mpi_logical,0,idchar,
676 * CG_COMM,muster,ierr)
677 call mpi_recv(sync_iter,1,mpi_logical,0,idchar,
678 * CG_COMM,muster,ierr)
679 if(sync_iter) goto 331
682 ccccccccccccccccccccccccccccccccccccccc
684 ccccccccccccccccccccccccccccccccccccccc
688 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
689 * ebmin,ebmax,nft,iuse,nbank,ntbank
691 write(icsa_history,44) jlee,0.0,0.0,0.0,
692 & 0.0,ebmin,nstep,nft
693 write(icsa_history,*)
696 time1i=MPI_WTIME()-time_start
697 print *,'End of RUN, master time ',
698 & time1i,'sec, Eval/s ',(nft-nft00)/time1i
699 write (iout,*) 'End of RUN, master time ',
701 write (iout,*) 'Total eval/s ',(nft-nft00)/time1i
704 write(iout,*) '!!!! ERROR worker was not responding'
705 write(iout,*) '!!!! cannot finish work normally'
706 write(iout,*) 'Processor0 is calling MPI_ABORT'
707 print *,'!!!! ERROR worker was not responding'
708 print *,'!!!! cannot finish work normally'
709 print *,'Processor0 is calling MPI_ABORT'
711 call mpi_abort(mpi_comm_world, 111, ierr)
715 cccccccccccccccccccccccccccccc
717 cccccccccccccccccccccccccccccc
721 c-------------------------------------------------
722 subroutine feedin(nconf,nft)
723 c sends out starting conformations and receives results of energy minimization
724 implicit real*8 (a-h,o-z)
727 include 'COMMON.IOUNITS'
728 include 'COMMON.CONTROL'
730 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
731 * cout(2),ind(9),info(12)
732 dimension muster(mpi_status_size)
733 include 'COMMON.SETUP'
734 parameter (rad=1.745329252d-2)
736 print *,'FEEDIN: NCONF=',nconf
738 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
739 if (nconf .lt. nodes-1) then
740 write (*,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
742 write (iout,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
744 call mpi_abort(mpi_comm_world,ierror,ierrcode)
747 c pull out external and internal variables for next start
749 ! write (iout,*) 'XIN from FEEDIN N=',n
750 ! write(iout,'(8f10.4)') (xin(j),j=1,nvar)
752 if (mm.lt.nodes) then
753 c feed task to soldier
754 ! print *, ' sending input for start # ',n
761 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
763 call mpi_send(xin,nvar,mpi_double_precision,mm,
764 * idreal,CG_COMM,ierr)
766 c find an available soldier
767 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
768 * CG_COMM,muster,ierr)
769 ! print *, ' receiving output from start # ',ind(1)
770 man=muster(mpi_source)
771 c receive final energies and variables
773 call mpi_recv(eout,1,mpi_double_precision,
774 * man,idreal,CG_COMM,muster,ierr)
777 call mpi_recv(co,1,mpi_double_precision,
778 * man,idreal,CG_COMM,muster,ierr)
779 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
781 call mpi_recv(xout,nvar,mpi_double_precision,
782 * man,idreal,CG_COMM,muster,ierr)
783 ! print *,nvar , ierr
784 c feed next task to soldier
785 ! print *, ' sending input for start # ',n
795 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
797 call mpi_send(xin,nvar,mpi_double_precision,man,
798 * idreal,CG_COMM,ierr)
799 c retrieve latest results
800 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
802 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
805 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
807 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
810 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
811 * CG_COMM,muster,ierr)
812 crc if (ierr.ne.0) go to 30
813 ! print *, ' receiving output from start # ',ind(1)
814 man=muster(mpi_source)
815 c receive final energies and variables
817 call mpi_recv(eout,1,
818 * mpi_double_precision,man,idreal,
819 * CG_COMM,muster,ierr)
822 call mpi_recv(co,1,mpi_double_precision,
823 * man,idreal,CG_COMM,muster,ierr)
824 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
826 crc if (ierr.ne.0) go to 30
827 call mpi_recv(xout,nvar,mpi_double_precision,
828 * man,idreal,CG_COMM,muster,ierr)
829 ! print *,nvar , ierr
830 crc if (ierr.ne.0) go to 30
838 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
841 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
843 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
845 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
847 10 print *, ' dispatching error'
848 call mpi_abort(mpi_comm_world,ierror,ierrcode)
850 20 print *, ' communication error'
851 call mpi_abort(mpi_comm_world,ierror,ierrcode)
853 30 print *, ' receiving error'
854 call mpi_abort(mpi_comm_world,ierror,ierrcode)
857 cccccccccccccccccccccccccccccccccccccccccccccccccc
858 subroutine getx(ind,xout,eout,cout,rad,iw_pdb,k)
859 c receives and stores data from soldiers
860 implicit real*8 (a-h,o-z)
862 include 'COMMON.IOUNITS'
864 include 'COMMON.BANK'
866 include 'COMMON.CHAIN'
867 include 'COMMON.CONTACTS'
868 dimension ind(9),xout(maxvar),eout(mxch*(mxch+1)/2+1)
870 double precision przes(3),obr(3,3)
874 if (k.gt.mxio .or. k.lt.1) then
876 & 'ERROR - dimensions of ANGMIN have been exceeded K=',k
877 call mpi_abort(mpi_comm_world,ierror,ierrcode)
885 c retrieve dihedral angles etc
886 call var_to_geom(nvar,xout)
888 dihang(1,j,1,k)=theta(j+1)
889 dihang(2,j,1,k)=phi(j+2)
890 dihang(3,j,1,k)=alph(j)
891 dihang(4,j,1,k)=omeg(j)
893 dihang(2,nres-1,1,k)=0.0d0
897 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a4,i3,i4)')
898 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' mv ',
903 c call dihang_to_c(dihang(1,1,1,k))
904 c call fitsq(rms,c(1,1),crefjlee(1,1),nres,przes,obr,non_conv)
905 c call fitsq(rms,c(1,2),crefjlee(1,2),nres-1,przes,obr,non_conv)
906 c call fitsq(rms,c(1,nstart_seq),crefjlee(1,nstart_sup),
907 c & nsup,przes,obr,non_conv)
910 call rmsd_csa(rmsn(k))
911 call contact(.false.,ncont,icont,co)
912 pncn(k)=contact_fract(ncont,ncont_ref,icont,icont_ref)
914 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a5
915 cd & ,0pf5.2,a5,f5.1,a,f6.3,a4,i3,i4)')
916 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' rms ',
917 cd & rmsn(k),' %NC ',pncn(k)*100,' cont.order',co,' mv ',
921 if (rmsn(k).gt.rmscut.or.pncn(k).lt.pnccut) iw_pdb=0
924 cccccccccccccccccccccccccccccccccccccccccccccccccc
925 subroutine putx(xin,n,rad)
926 c gets starting variables
927 implicit real*8 (a-h,o-z)
930 include 'COMMON.BANK'
932 include 'COMMON.CHAIN'
933 include 'COMMON.IOUNITS'
934 dimension xin(maxvar)
936 c pull out starting values for variables
937 ! write (iout,*)'PUTX: N=',n
939 ! write (iout,'(8f10.4)') (dihang_in(1,j,m,n),j=2,nres-1)
940 ! write (iout,'(8f10.4)') (dihang_in(2,j,m,n),j=2,nres-1)
941 ! write (iout,'(8f10.4)') (dihang_in(3,j,m,n),j=2,nres-1)
942 ! write (iout,'(8f10.4)') (dihang_in(4,j,m,n),j=2,nres-1)
944 theta(j+1)=dihang_in(1,j,m,n)
945 phi(j+2)=dihang_in(2,j,m,n)
946 alph(j)=dihang_in(3,j,m,n)
947 omeg(j)=dihang_in(4,j,m,n)
950 c set up array of variables
951 call geom_to_var(nvar,xin)
952 ! write (iout,*) 'xin in PUTX N=',n
954 ! write (iout,'(8f10.4)') (xin(i),i=1,nvar)
957 c--------------------------------------------------------
958 subroutine putx2(xin,iff,n)
959 c gets starting variables
960 implicit real*8 (a-h,o-z)
963 include 'COMMON.BANK'
965 include 'COMMON.CHAIN'
966 include 'COMMON.IOUNITS'
967 dimension xin(maxvar),iff(maxres)
969 c pull out starting values for variables
972 theta(j+1)=dihang_in2(1,j,m,n)
973 phi(j+2)=dihang_in2(2,j,m,n)
974 alph(j)=dihang_in2(3,j,m,n)
975 omeg(j)=dihang_in2(4,j,m,n)
978 c set up array of variables
979 call geom_to_var(nvar,xin)
987 c-------------------------------------------------------
988 subroutine prune_bank(p_cut)
989 implicit real*8 (a-h,o-z)
993 include 'COMMON.BANK'
994 include 'COMMON.IOUNITS'
995 include 'COMMON.CHAIN'
996 include 'COMMON.TIME1'
997 include 'COMMON.SETUP'
998 c---------------------------
999 c This subroutine prunes bank conformations using p_cut
1000 c---------------------------
1008 dihang(i,j,k,nprune)=bvar(i,j,k,m)
1012 bene(nprune)=bene(m)
1013 brmsn(nprune)=brmsn(m)
1014 bpncn(nprune)=bpncn(m)
1019 call get_diff12(dihang(1,1,1,ip),bvar(1,1,1,m),diff)
1020 if(diff.lt.p_cut) goto 100
1021 if(diff.lt.ddmin) ddmin=diff
1027 dihang(i,j,k,nprune)=bvar(i,j,k,m)
1031 bene(nprune)=bene(m)
1032 brmsn(nprune)=brmsn(m)
1033 bpncn(nprune)=bpncn(m)
1035 write (iout,*) 'Pruning :',m,nprune,p_cut,ddmin
1038 print *, 'Pruning :',m,nprune,p_cut
1039 call write_bank(0,0)
1043 c-------------------------------------------------------
1045 subroutine reminimize(jlee)
1046 implicit real*8 (a-h,o-z)
1047 include 'DIMENSIONS'
1049 include 'COMMON.CSA'
1050 include 'COMMON.BANK'
1051 include 'COMMON.IOUNITS'
1052 include 'COMMON.CHAIN'
1053 include 'COMMON.TIME1'
1054 include 'COMMON.SETUP'
1055 c---------------------------
1056 c This subroutine re-minimizes bank conformations:
1057 c---------------------------
1064 if (me.eq.king) then
1065 open(icsa_history,file=csa_history,status="old")
1066 write(icsa_history,*) "Re-minimization",nodes,"nodes"
1067 write(icsa_history,851) (bene(i),i=1,nbank)
1068 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1069 * ebmin,ebmax,nft,iuse,nbank,ntbank
1075 dihang_in(i,j,k,index)=bvar(i,j,k,index)
1081 call feedin(ntry,nft)
1089 if (me.eq.king) then
1091 call replace_bvar(i,i)
1093 open(icsa_history,file=csa_history,status="old")
1094 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1095 * ebmin,ebmax,nft,iuse,nbank,ntbank
1096 write(icsa_history,851) (bene(i),i=1,nbank)
1098 call write_bank_reminimized(jlee,nft)
1101 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
1104 c 850 format(10f8.3)
1108 c-------------------------------------------------------
1109 subroutine send(n,mm,it)
1110 c sends out starting conformation for minimization
1111 implicit real*8 (a-h,o-z)
1112 include 'DIMENSIONS'
1113 include 'COMMON.VAR'
1114 include 'COMMON.IOUNITS'
1115 include 'COMMON.CONTROL'
1116 include 'COMMON.BANK'
1117 include 'COMMON.CHAIN'
1119 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1120 * cout(2),ind(8),xin2(maxvar),iff(maxres),info(12)
1121 dimension muster(mpi_status_size)
1122 include 'COMMON.SETUP'
1123 parameter (rad=1.745329252d-2)
1125 if (isend2(n).eq.0) then
1126 c pull out external and internal variables for next start
1127 call putx(xin,n,rad)
1135 if (movenx(n).eq.14.or.movenx(n).eq.17) then
1138 else if (movenx(n).eq.16) then
1152 if (movenx(n).eq.15) then
1157 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1159 call mpi_send(xin,nvar,mpi_double_precision,mm,
1160 * idreal,CG_COMM,ierr)
1162 c distfit & minimization for n7 move
1172 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1174 call putx2(xin,iff,isend2(n))
1175 call mpi_send(xin,nvar,mpi_double_precision,mm,
1176 * idreal,CG_COMM,ierr)
1177 call mpi_send(iff,nres,mpi_integer,mm,
1178 * idint,CG_COMM,ierr)
1179 call putx(xin2,n,rad)
1180 call mpi_send(xin2,nvar,mpi_double_precision,mm,
1181 * idreal,CG_COMM,ierr)
1183 if (vdisulf.and.nss_in(n).ne.0) then
1184 call mpi_send(iss_in(1,n),nss_in(n),mpi_integer,mm,
1185 * idint,CG_COMM,ierr)
1186 call mpi_send(jss_in(1,n),nss_in(n),mpi_integer,mm,
1187 * idint,CG_COMM,ierr)
1191 c-------------------------------------------------
1193 subroutine recv(ihalt,man,xout,eout,ind,tout)
1194 c receives results of energy minimization
1195 implicit real*8 (a-h,o-z)
1196 include 'DIMENSIONS'
1197 include 'COMMON.VAR'
1198 include 'COMMON.IOUNITS'
1199 include 'COMMON.CONTROL'
1200 include 'COMMON.SBRIDGE'
1201 include 'COMMON.BANK'
1202 include 'COMMON.CHAIN'
1204 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1205 * cout(2),ind(9),info(12)
1206 dimension muster(mpi_status_size)
1207 include 'COMMON.SETUP'
1209 double precision twait,tstart,tend1
1210 parameter(twait=600.0d0)
1212 c find an available soldier
1216 do while(.not. (flag .or. tout))
1217 call MPI_IPROBE(mpi_any_source,idint,CG_COMM,flag,
1220 if(tend1-tstart.gt.twait .and. ihalt.eq.1) tout=.true.
1221 c_error if(tend1-tstart.gt.twait) tout=.true.
1224 write(iout,*) 'ERROR = timeout for recv ',tend1-tstart
1228 man=muster(mpi_source)
1230 ctimeout call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
1231 ctimeout * CG_COMM,muster,ierr)
1232 ! print *, ' receiving output from start # ',ind(1)
1233 ct print *,'receiving ',MPI_WTIME()
1234 ctimeout man=muster(mpi_source)
1235 call mpi_recv(ind,9,mpi_integer,man,idint,
1236 * CG_COMM,muster,ierr)
1238 c receive final energies and variables
1239 call mpi_recv(eout,1,mpi_double_precision,
1240 * man,idreal,CG_COMM,muster,ierr)
1243 call mpi_recv(co,1,mpi_double_precision,
1244 * man,idreal,CG_COMM,muster,ierr)
1245 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
1247 call mpi_recv(xout,nvar,mpi_double_precision,
1248 * man,idreal,CG_COMM,muster,ierr)
1249 ! print *,nvar , ierr
1250 if(vdisulf) nss=ind(6)
1251 if(vdisulf.and.nss.ne.0) then
1252 call mpi_recv(ihpb,nss,mpi_integer,
1253 * man,idint,CG_COMM,muster,ierr)
1254 call mpi_recv(jhpb,nss,mpi_integer,
1255 * man,idint,CG_COMM,muster,ierr)
1259 c print *,'sending halt to ',man
1260 write(iout,*) 'sending halt to ',man
1263 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,ierr)
1268 c----------------------------------------------------------
1269 subroutine history_append
1270 implicit real*8 (a-h,o-z)
1271 include 'DIMENSIONS'
1272 include 'COMMON.IOUNITS'
1274 #if defined(AIX) || defined(PGI)
1275 open(icsa_history,file=csa_history,position="append")
1277 open(icsa_history,file=csa_history,access="append")