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.
86 call mpi_bcast(jend,1,mpi_integer,0,CG_COMM,ierr)
87 cccccccccccccccccccccccccccccccccccccccc
89 cccccccccccccccccccccccccccccccccccccccc
92 if(sync_iter) goto 333
93 idum=- ran2(idum2)*imax
94 if(jlee.lt.jstart) goto 300
96 C Restart the random number generator for conformation generation
98 if(irestart.gt.0) then
100 if(idum2.le.0) idum2=-idum2+1
101 idum=- ran2(idum2)*imax
107 open(icsa_seed,file=csa_seed,status="old")
108 write(icsa_seed,*) "jlee : ",jlee
112 write(icsa_history,*) "number of procs is ",nodes
113 write(icsa_history,*) jlee,idum,idum2
116 cccccccccccccccccccccccccccccccccccccccccccccccc
120 write(icsa_history,*) "nbank is ",nbank
123 if(irestart.eq.1) goto 111
124 if(irestart.eq.2) then
129 do i=nbank+1,nbank+nconf
134 c start energy minimization
135 nconfr=max0(nconf+nadd,nodes-1)
136 if (sync_iter) nconf_in=0
137 c king-emperor - feed input and sort output
138 write (iout,*) "NCONF_IN",nconf_in
140 if (nconf_in.gt.0) then
141 c al 7/2/00 - added possibility to read in some of the initial conformations
143 read (intin,'(i5)',end=11,err=12) iconf
145 write (iout,*) "write READ_ANGLES",iconf,m
146 call read_angles(intin,*11)
153 dihang_in(1,j,1,mm)=theta(j+1)
154 dihang_in(2,j,1,mm)=phi(j+2)
155 dihang_in(3,j,1,mm)=alph(j)
156 dihang_in(4,j,1,mm)=omeg(j)
160 11 write (iout,*) nconf_in," conformations requested, but only",
161 & m-1," found in the angle file."
165 write (iout,*) nconf_in,
166 & " initial conformations have been read in."
169 if (nconfr.gt.nconf_in) then
170 call make_ranvar(nconfr,m,idum)
171 write (iout,*) nconfr-nconf_in,
172 & " conformations have been generated randomly."
176 call from_int(nconfr,m,idum)
177 c call from_pdb(nconfr,idum)
179 write (iout,*) 'Exitted from make_ranvar nconfr=',nconfr
180 write (*,*) 'Exitted from make_ranvar nconfr=',nconfr
182 write (iout,*) 'Initial conformation',m
183 write(iout,'(8f10.4)') (rad2deg*dihang_in(1,j,1,m),j=2,nres-1)
184 write(iout,'(8f10.4)') (rad2deg*dihang_in(2,j,1,m),j=2,nres-1)
185 write(iout,'(8f10.4)') (rad2deg*dihang_in(3,j,1,m),j=2,nres-1)
186 write(iout,'(8f10.4)') (rad2deg*dihang_in(4,j,1,m),j=2,nres-1)
188 write(iout,*)'Calling FEEDIN NCONF',nconfr
190 call feedin(nconfr,nft)
191 write (iout,*) ' Time for first bank min.',MPI_WTIME()-time1i
193 write(icsa_history,*) jlee,nft,nbank
194 write(icsa_history,851) (etot(i),i=1,nconfr)
195 write(icsa_history,850) (rmsn(i),i=1,nconfr)
196 write(icsa_history,850) (pncn(i),i=1,nconfr)
197 write(icsa_history,*)
200 c To minimize input conformation (bank conformation)
201 c Output to $mol.reminimized
202 if (irestart.lt.0) then
203 call reminimize(jlee)
206 if (irestart.eq.1) goto 111
207 c soldier - perform energy minimization
211 ccccccccccccccccccccccccccccccccccc
212 c need to syncronize all procs
213 call mpi_barrier(CG_COMM,ierr)
215 print *, ' cannot synchronize MPI'
218 ccccccccccccccccccccccccccccccccccc
222 c print *,"ok after minim"
224 if(irestart.eq.2) then
226 c ntbank=ntbank+nconf
227 if(ntbank.gt.ntbankm) ntbank=ntbankm
229 c print *,"ok before indexx"
231 call indexx(nconfr,etot,indx)
237 call indexx(nconfr-nconf_in,rmsn(nconf_in+1),indx(nconf_in+1))
238 do k=nconf_in+1,nconfr
239 indx(k)=indx(k)+nconf_in
242 c call indexx(nconfr,rmsn,indx)
244 c print *,"ok after indexx"
247 if (m.gt.mxio .or. m.lt.1) then
248 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,' M',m
249 call mpi_abort(mpi_comm_world,ierror,ierrcode)
251 jbank(im+nbank-nconf)=0
252 bene(im+nbank-nconf)=etot(m)
253 rene(im+nbank-nconf)=etot(m)
254 c!bankt btene(im)=etot(m)
256 brmsn(im+nbank-nconf)=rmsn(m)
257 bpncn(im+nbank-nconf)=pncn(m)
258 rrmsn(im+nbank-nconf)=rmsn(m)
259 rpncn(im+nbank-nconf)=pncn(m)
260 if (im+nbank-nconf.gt.mxio .or. im+nbank-nconf.lt.1) then
261 write (iout,*) 'Dimension ERROR in TOGEHER: IM',im,
262 & ' NBANK',nbank,' NCONF',nconf,' IM+NBANK-NCONF',im+nbank-nconf
263 call mpi_abort(mpi_comm_world,ierror,ierrcode)
268 bvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
269 rvar(i,j,k,im+nbank-nconf)=dihang(i,j,k,m)
270 c!bankt btvar(i,j,k,im)=dihang(i,j,k,m)
276 if(brmsn(im+nbank-nconf).gt.rmscut.or.
277 & bpncn(im+nbank-nconf).lt.pnccut) ibank(im+nbank-nconf)=9
280 bvar_ns(im+nbank-nconf)=ns-2*nss
284 do while( iss(i).ne.ihpb(j)-nres .and.
285 & iss(i).ne.jhpb(j)-nres .and. j.le.nss)
290 bvar_s(k,im+nbank-nconf)=iss(i)
294 bvar_nss(im+nbank-nconf)=nss
296 bvar_ss(1,i,im+nbank-nconf)=ihpb(i)
297 bvar_ss(2,i,im+nbank-nconf)=jhpb(i)
310 if(nbank.eq.nconf.and.irestart.eq.0) then
317 cd print *,"adif,xctdif,cutdifr"
318 cd print *,adif,xctdif,cutdifr
319 nst=ntotal/ntrial/nseed
320 xctdif=(cutdif/ctdif1)**(-1.0/nst)
321 if(irestart.ge.1) call estimate_cutdif(adif,xctdif,cutdifr)
322 c print *,"ok after estimate"
326 call write_rbank(jlee,adif,nft)
327 call write_bank(jlee,nft)
328 c!bankt call write_bankt(jlee,nft)
329 c call write_bank1(jlee)
331 write(icsa_history,*) "xctdif: ", xctdif,nst,adif/cut1,ctdif1
332 write(icsa_history,851) (bene(i),i=1,nbank)
333 write(icsa_history,850) (brmsn(i),i=1,nbank)
334 write(icsa_history,850) (bpncn(i),i=1,nbank)
352 if (.not.sync_iter) then
360 ccccccccccccccccccccccccccccccccccccccc
361 do while (.not. finished)
362 ccccccccccccccccccccccccccccccccccccccc
363 crc print *,"iter ", iter,' isent=',isent
366 c start energy minimization
369 c king-emperor - select seeds & make var & feed input
370 cd print *,'generating new conf',ntrial,MPI_WTIME()
371 call select_is(nseed,ifar,idum)
373 open(icsa_seed,file=csa_seed,status="old")
375 & jlee,icycle,nstep,(is(i),bene(is(i)),i=1,nseed)
378 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
379 * ebmin,ebmax,nft,iuse,nbank,ntbank
384 call make_var(ntry,idum,iter)
385 cd print *,'new trial generated',ntrial,MPI_WTIME()
387 write (iout,'(a20,i4,f12.2)')
388 & 'Time for make trial',iter+1,time2i-time1i
391 crc write(iout,*)'1:Calling FEEDIN NTRY',NTRY,' ntrial',ntrial
392 crc call feedin(ntry,nft)
395 if (isent.ge.nodes.or.iter.gt.0) then
396 ct print *,'waiting ',MPI_WTIME()
398 call recv(0,ifrom,xout,eout,ind,timeout)
399 ct print *,' ',irecv,' received from',ifrom,MPI_WTIME()
404 ct print *,'sending to',ifrom,MPI_WTIME()
405 call send(isent,ifrom,iter)
406 ct print *,isent,' sent ',MPI_WTIME()
408 c store results -----------------------------------------------
409 if (isent.ge.nodes.or.iter.gt.0) then
411 movernx(irecv)=iabs(ind(5))
412 call getx(ind,xout,eout,cout,rad,iw_pdb,irecv)
416 iss_out(i,irecv)=ihpb(i)
417 jss_out(i,irecv)=jhpb(i)
421 & call write_csa_pdb(xout,eout,nft,irecv,iw_pdb)
423 c--------------------------------------------------------------
424 if (isent.eq.ntry) then
426 write (iout,'(a18,f12.2,a14,f10.2)')
427 & 'Nonsetup time ',time1i-time_start_c,
428 & ' sec, Eval/s =',(nft-nft00_c)/(time1i-time_start_c)
429 write (iout,'(a14,i4,f12.2,a14,f10.2)')
430 & 'Time for iter ',iter+1,time1i-time0i,
431 & ' sec, Eval/s =',(nft-nft0i)/(time1i-time0i)
435 if(cutdif.lt.ctdif1) cutdif=ctdif1
437 print *,'UPDATING ',ntry-nodes+1,irecv
438 write(iout,*) 'UPDATING ',ntry-nodes+1
440 c----------------- call update(ntry-nodes+1) -------------------
441 nstep=nstep+ntry-nseed-(nodes-1)
442 call refresh_bank(ntry-nodes+1)
443 c!bankt call refresh_bankt(ntry-nodes+1)
445 c----------------- call update(ntry) ---------------------------
447 print *,'UPDATING ',ntry,irecv
448 write(iout,*) 'UPDATING ',ntry
449 nstep=nstep+ntry-nseed
450 call refresh_bank(ntry)
451 c!bankt call refresh_bankt(ntry)
453 c-----------------------------------------------------------------
455 call write_bank(jlee,nft)
456 c!bankt call write_bankt(jlee,nft)
460 write (iout,'(a20,i4,f12.2)')
461 & 'Time for refresh ',iter,time1i-time0i
463 if(ebmin.lt.estop) finished=.true.
464 if(icycle.gt.icmax) then
465 call write_bank1(jlee)
471 if(nbank.gt.1000) then
478 if(nstep.gt.nstmax) finished=.true.
480 if(finished.or.sync_iter) then
482 call recv(1,ifrom,xout,eout,ind,timeout)
485 print *,'ERROR worker is not responding'
486 write(iout,*) 'ERROR worker is not responding'
487 time1i=MPI_WTIME()-time_start_c
488 print *,'End of cycle, master time for ',iter,' iters ',
489 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
490 write (iout,*) 'End of cycle, master time for ',iter,
491 & ' iters ',time1i,' sec'
492 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
493 print *,'UPDATING ',ij-1
494 write(iout,*) 'UPDATING ',ij-1
496 call refresh_bank(ij-1)
497 c!bankt call refresh_bankt(ij-1)
500 c print *,'node ',ifrom,' finished ',ij,nft
501 write(iout,*) 'node ',ifrom,' finished ',ij,nft
504 movernx(ij)=iabs(ind(5))
505 call getx(ind,xout,eout,cout,rad,iw_pdb,ij)
509 iss_out(i,ij)=ihpb(i)
510 jss_out(i,ij)=jhpb(i)
514 & call write_csa_pdb(xout,eout,nft,ij,iw_pdb)
517 crc print *,'---------bcast finished--------',finished
518 time1i=MPI_WTIME()-time_start_c
519 print *,'End of cycle, master time for ',iter,' iters ',
520 & time1i,'sec, Eval/s ',(nft-nft00_c)/time1i
521 write (iout,*) 'End of cycle, master time for ',iter,
522 & ' iters ',time1i,' sec'
523 write (iout,*) 'Total eval/s ',(nft-nft00_c)/time1i
525 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
526 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,
527 ctimeout & CG_COMM,ierr)
530 call mpi_issend(finished,1,mpi_logical,ij,idchar,
532 call mpi_issend(sync_iter,1,mpi_logical,ij,idchar,
533 & CG_COMM,ireq2,ierr)
536 do while(.not. (flag .or. timeout1))
537 call MPI_TEST(ireq2,flag,muster,ierr)
539 if(tend1-tstart.gt.60) then
540 print *,'ERROR worker ',ij,' is not responding'
541 write(iout,*) 'ERROR worker ',ij,' is not responding'
546 write(iout,*) 'worker ',ij,' NOT OK ',tend1-tstart
549 write(iout,*) 'worker ',ij,' OK ',tend1-tstart
552 print *,'UPDATING ',nodes-1,ij
553 write(iout,*) 'UPDATING ',nodes-1
554 call refresh_bank(nodes-1)
555 c!bankt call refresh_bankt(nodes-1)
557 call write_bank(jlee,nft)
558 c!bankt call write_bankt(jlee,nft)
563 nstatnx_tot(i,j)=nstatnx_tot(i,j)+nstatnx(i,j)
568 write(iout,*)'### Total stats:'
570 if(nstatnx_tot(i,1).ne.0) then
572 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
573 & '### N',i,' total=',nstatnx_tot(i,1),
574 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
575 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
577 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
578 & '###N',i,' total=',nstatnx_tot(i,1),
579 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),'%acc',
580 & (nstatnx_tot(i,2)+nstatnx_tot(i,3))*100.0/nstatnx_tot(i,1)
584 write(iout,'(a5,i1,a7,i6,a7,i4,a5,i4,a5,f5.1)')
585 & '### N',i,' total=',nstatnx_tot(i,1),
586 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
589 write(iout,'(a4,i2,a7,i6,a7,i4,a5,i4,a5,f5.1)')
590 & '###N',i,' total=',nstatnx_tot(i,1),
591 & ' close=',nstatnx_tot(i,2),' far=',nstatnx_tot(i,3),
598 if(sync_iter) goto 331
600 39 format(2i3,i7,5(i4,f8.3,1x),19(/,13x,5(i4,f8.3,1x)))
601 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
603 44 format('jlee =',i3,':',4f10.1,' E =',f8.3,i7,i10)
609 c soldier - perform energy minimization
611 print *,'End of minim, proc',me,'time ',MPI_WTIME()-time_start
612 write (iout,*) 'End of minim, proc',me,'time ',
613 & MPI_WTIME()-time_start
615 ctimeout call mpi_bcast(finished,1,mpi_logical,0,CG_COMM,ierr)
616 ctimeout call mpi_bcast(sync_iter,1,mpi_logical,0,CG_COMM,ierr)
617 call mpi_recv(finished,1,mpi_logical,0,idchar,
618 * CG_COMM,muster,ierr)
619 call mpi_recv(sync_iter,1,mpi_logical,0,idchar,
620 * CG_COMM,muster,ierr)
621 if(sync_iter) goto 331
624 ccccccccccccccccccccccccccccccccccccccc
626 ccccccccccccccccccccccccccccccccccccccc
630 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
631 * ebmin,ebmax,nft,iuse,nbank,ntbank
633 write(icsa_history,44) jlee,0.0,0.0,0.0,
634 & 0.0,ebmin,nstep,nft
635 write(icsa_history,*)
638 time1i=MPI_WTIME()-time_start
639 print *,'End of RUN, master time ',
640 & time1i,'sec, Eval/s ',(nft-nft00)/time1i
641 write (iout,*) 'End of RUN, master time ',
643 write (iout,*) 'Total eval/s ',(nft-nft00)/time1i
646 write(iout,*) '!!!! ERROR worker was not responding'
647 write(iout,*) '!!!! cannot finish work normally'
648 write(iout,*) 'Processor0 is calling MPI_ABORT'
649 print *,'!!!! ERROR worker was not responding'
650 print *,'!!!! cannot finish work normally'
651 print *,'Processor0 is calling MPI_ABORT'
653 call mpi_abort(mpi_comm_world, 111, ierr)
657 cccccccccccccccccccccccccccccc
659 cccccccccccccccccccccccccccccc
663 c-------------------------------------------------
664 subroutine feedin(nconf,nft)
665 c sends out starting conformations and receives results of energy minimization
666 implicit real*8 (a-h,o-z)
669 include 'COMMON.IOUNITS'
670 include 'COMMON.CONTROL'
672 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
673 * cout(2),ind(9),info(12)
674 dimension muster(mpi_status_size)
675 include 'COMMON.SETUP'
676 parameter (rad=1.745329252d-2)
678 print *,'FEEDIN: NCONF=',nconf
680 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
681 if (nconf .lt. nodes-1) then
682 write (*,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
684 write (iout,*) 'FATAL ERROR in FEEDIN, nconf < nodes -1',
686 call mpi_abort(mpi_comm_world,ierror,ierrcode)
689 c pull out external and internal variables for next start
691 ! write (iout,*) 'XIN from FEEDIN N=',n
692 ! write(iout,'(8f10.4)') (xin(j),j=1,nvar)
694 if (mm.lt.nodes) then
695 c feed task to soldier
696 ! print *, ' sending input for start # ',n
703 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
705 call mpi_send(xin,nvar,mpi_double_precision,mm,
706 * idreal,CG_COMM,ierr)
708 c find an available soldier
709 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
710 * CG_COMM,muster,ierr)
711 ! print *, ' receiving output from start # ',ind(1)
712 man=muster(mpi_source)
713 c receive final energies and variables
715 call mpi_recv(eout,1,mpi_double_precision,
716 * man,idreal,CG_COMM,muster,ierr)
719 call mpi_recv(co,1,mpi_double_precision,
720 * man,idreal,CG_COMM,muster,ierr)
721 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
723 call mpi_recv(xout,nvar,mpi_double_precision,
724 * man,idreal,CG_COMM,muster,ierr)
725 ! print *,nvar , ierr
726 c feed next task to soldier
727 ! print *, ' sending input for start # ',n
737 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
739 call mpi_send(xin,nvar,mpi_double_precision,man,
740 * idreal,CG_COMM,ierr)
741 c retrieve latest results
742 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
744 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
747 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
749 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
752 call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
753 * CG_COMM,muster,ierr)
754 crc if (ierr.ne.0) go to 30
755 ! print *, ' receiving output from start # ',ind(1)
756 man=muster(mpi_source)
757 c receive final energies and variables
759 call mpi_recv(eout,1,
760 * mpi_double_precision,man,idreal,
761 * CG_COMM,muster,ierr)
764 call mpi_recv(co,1,mpi_double_precision,
765 * man,idreal,CG_COMM,muster,ierr)
766 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
768 crc if (ierr.ne.0) go to 30
769 call mpi_recv(xout,nvar,mpi_double_precision,
770 * man,idreal,CG_COMM,muster,ierr)
771 ! print *,nvar , ierr
772 crc if (ierr.ne.0) go to 30
780 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,
783 call getx(ind,xout,eout,cout,rad,iw_pdb,ind(1))
785 & call write_csa_pdb(xout,eout,nft,ind(1),iw_pdb)
787 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
789 10 print *, ' dispatching error'
790 call mpi_abort(mpi_comm_world,ierror,ierrcode)
792 20 print *, ' communication error'
793 call mpi_abort(mpi_comm_world,ierror,ierrcode)
795 30 print *, ' receiving error'
796 call mpi_abort(mpi_comm_world,ierror,ierrcode)
799 cccccccccccccccccccccccccccccccccccccccccccccccccc
800 subroutine getx(ind,xout,eout,cout,rad,iw_pdb,k)
801 c receives and stores data from soldiers
802 implicit real*8 (a-h,o-z)
804 include 'COMMON.IOUNITS'
806 include 'COMMON.BANK'
808 include 'COMMON.CHAIN'
809 include 'COMMON.CONTACTS'
810 dimension ind(9),xout(maxvar),eout(mxch*(mxch+1)/2+1)
812 double precision przes(3),obr(3,3)
816 if (k.gt.mxio .or. k.lt.1) then
818 & 'ERROR - dimensions of ANGMIN have been exceeded K=',k
819 call mpi_abort(mpi_comm_world,ierror,ierrcode)
827 c retrieve dihedral angles etc
828 call var_to_geom(nvar,xout)
830 dihang(1,j,1,k)=theta(j+1)
831 dihang(2,j,1,k)=phi(j+2)
832 dihang(3,j,1,k)=alph(j)
833 dihang(4,j,1,k)=omeg(j)
835 dihang(2,nres-1,1,k)=0.0d0
839 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a4,i3,i4)')
840 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' mv ',
845 c call dihang_to_c(dihang(1,1,1,k))
846 c call fitsq(rms,c(1,1),crefjlee(1,1),nres,przes,obr,non_conv)
847 c call fitsq(rms,c(1,2),crefjlee(1,2),nres-1,przes,obr,non_conv)
848 c call fitsq(rms,c(1,nstart_seq),crefjlee(1,nstart_sup),
849 c & nsup,przes,obr,non_conv)
852 call rmsd_csa(rmsn(k))
853 call contact(.false.,ncont,icont,co)
854 pncn(k)=contact_fract(ncont,ncont_ref,icont,icont_ref)
856 cd write(iout,'(i3,a3,i4,i5,a6,1pe12.4,a5
857 cd & ,0pf5.2,a5,f5.1,a,f6.3,a4,i3,i4)')
858 cd & ind(2),' e ',ind(3),ind(1),' etot ',etot(k),' rms ',
859 cd & rmsn(k),' %NC ',pncn(k)*100,' cont.order',co,' mv ',
863 if (rmsn(k).gt.rmscut.or.pncn(k).lt.pnccut) iw_pdb=0
866 cccccccccccccccccccccccccccccccccccccccccccccccccc
867 subroutine putx(xin,n,rad)
868 c gets starting variables
869 implicit real*8 (a-h,o-z)
872 include 'COMMON.BANK'
874 include 'COMMON.CHAIN'
875 include 'COMMON.IOUNITS'
876 dimension xin(maxvar)
878 c pull out starting values for variables
879 ! write (iout,*)'PUTX: N=',n
881 ! write (iout,'(8f10.4)') (dihang_in(1,j,m,n),j=2,nres-1)
882 ! write (iout,'(8f10.4)') (dihang_in(2,j,m,n),j=2,nres-1)
883 ! write (iout,'(8f10.4)') (dihang_in(3,j,m,n),j=2,nres-1)
884 ! write (iout,'(8f10.4)') (dihang_in(4,j,m,n),j=2,nres-1)
886 theta(j+1)=dihang_in(1,j,m,n)
887 phi(j+2)=dihang_in(2,j,m,n)
888 alph(j)=dihang_in(3,j,m,n)
889 omeg(j)=dihang_in(4,j,m,n)
892 c set up array of variables
893 call geom_to_var(nvar,xin)
894 ! write (iout,*) 'xin in PUTX N=',n
896 ! write (iout,'(8f10.4)') (xin(i),i=1,nvar)
899 c--------------------------------------------------------
900 subroutine putx2(xin,iff,n)
901 c gets starting variables
902 implicit real*8 (a-h,o-z)
905 include 'COMMON.BANK'
907 include 'COMMON.CHAIN'
908 include 'COMMON.IOUNITS'
909 dimension xin(maxvar),iff(maxres)
911 c pull out starting values for variables
914 theta(j+1)=dihang_in2(1,j,m,n)
915 phi(j+2)=dihang_in2(2,j,m,n)
916 alph(j)=dihang_in2(3,j,m,n)
917 omeg(j)=dihang_in2(4,j,m,n)
920 c set up array of variables
921 call geom_to_var(nvar,xin)
929 c-------------------------------------------------------
930 subroutine prune_bank(p_cut)
931 implicit real*8 (a-h,o-z)
935 include 'COMMON.BANK'
936 include 'COMMON.IOUNITS'
937 include 'COMMON.CHAIN'
938 include 'COMMON.TIME1'
939 include 'COMMON.SETUP'
940 c---------------------------
941 c This subroutine prunes bank conformations using p_cut
942 c---------------------------
950 dihang(i,j,k,nprune)=bvar(i,j,k,m)
955 brmsn(nprune)=brmsn(m)
956 bpncn(nprune)=bpncn(m)
961 call get_diff12(dihang(1,1,1,ip),bvar(1,1,1,m),diff)
962 if(diff.lt.p_cut) goto 100
963 if(diff.lt.ddmin) ddmin=diff
969 dihang(i,j,k,nprune)=bvar(i,j,k,m)
974 brmsn(nprune)=brmsn(m)
975 bpncn(nprune)=bpncn(m)
977 write (iout,*) 'Pruning :',m,nprune,p_cut,ddmin
980 print *, 'Pruning :',m,nprune,p_cut
985 c-------------------------------------------------------
987 subroutine reminimize(jlee)
988 implicit real*8 (a-h,o-z)
992 include 'COMMON.BANK'
993 include 'COMMON.IOUNITS'
994 include 'COMMON.CHAIN'
995 include 'COMMON.TIME1'
996 include 'COMMON.SETUP'
997 c---------------------------
998 c This subroutine re-minimizes bank conformations:
999 c---------------------------
1006 if (me.eq.king) then
1007 open(icsa_history,file=csa_history,status="old")
1008 write(icsa_history,*) "Re-minimization",nodes,"nodes"
1009 write(icsa_history,851) (bene(i),i=1,nbank)
1010 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1011 * ebmin,ebmax,nft,iuse,nbank,ntbank
1017 dihang_in(i,j,k,index)=bvar(i,j,k,index)
1023 call feedin(ntry,nft)
1031 if (me.eq.king) then
1033 call replace_bvar(i,i)
1035 open(icsa_history,file=csa_history,status="old")
1036 write(icsa_history,40) jlee,icycle,nstep,cutdif,ibmin,ibmax,
1037 * ebmin,ebmax,nft,iuse,nbank,ntbank
1038 write(icsa_history,851) (bene(i),i=1,nbank)
1040 call write_bank_reminimized(jlee,nft)
1043 40 format(2i2,i8,f8.1,2i4,2(1pe14.5),i10,3i4)
1046 c 850 format(10f8.3)
1050 c-------------------------------------------------------
1051 subroutine send(n,mm,it)
1052 c sends out starting conformation for minimization
1053 implicit real*8 (a-h,o-z)
1054 include 'DIMENSIONS'
1055 include 'COMMON.VAR'
1056 include 'COMMON.IOUNITS'
1057 include 'COMMON.CONTROL'
1058 include 'COMMON.BANK'
1059 include 'COMMON.CHAIN'
1061 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1062 * cout(2),ind(8),xin2(maxvar),iff(maxres),info(12)
1063 dimension muster(mpi_status_size)
1064 include 'COMMON.SETUP'
1065 parameter (rad=1.745329252d-2)
1067 if (isend2(n).eq.0) then
1068 c pull out external and internal variables for next start
1069 call putx(xin,n,rad)
1077 if (movenx(n).eq.14.or.movenx(n).eq.17) then
1080 else if (movenx(n).eq.16) then
1094 if (movenx(n).eq.15) then
1099 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1101 call mpi_send(xin,nvar,mpi_double_precision,mm,
1102 * idreal,CG_COMM,ierr)
1104 c distfit & minimization for n7 move
1114 call mpi_send(info,12,mpi_integer,mm,idint,CG_COMM,
1116 call putx2(xin,iff,isend2(n))
1117 call mpi_send(xin,nvar,mpi_double_precision,mm,
1118 * idreal,CG_COMM,ierr)
1119 call mpi_send(iff,nres,mpi_integer,mm,
1120 * idint,CG_COMM,ierr)
1121 call putx(xin2,n,rad)
1122 call mpi_send(xin2,nvar,mpi_double_precision,mm,
1123 * idreal,CG_COMM,ierr)
1125 if (vdisulf.and.nss_in(n).ne.0) then
1126 call mpi_send(iss_in(1,n),nss_in(n),mpi_integer,mm,
1127 * idint,CG_COMM,ierr)
1128 call mpi_send(jss_in(1,n),nss_in(n),mpi_integer,mm,
1129 * idint,CG_COMM,ierr)
1133 c-------------------------------------------------
1135 subroutine recv(ihalt,man,xout,eout,ind,tout)
1136 c receives results of energy minimization
1137 implicit real*8 (a-h,o-z)
1138 include 'DIMENSIONS'
1139 include 'COMMON.VAR'
1140 include 'COMMON.IOUNITS'
1141 include 'COMMON.CONTROL'
1142 include 'COMMON.SBRIDGE'
1143 include 'COMMON.BANK'
1144 include 'COMMON.CHAIN'
1146 dimension xin(maxvar),xout(maxvar),eout(mxch*(mxch+1)/2+1),
1147 * cout(2),ind(9),info(12)
1148 dimension muster(mpi_status_size)
1149 include 'COMMON.SETUP'
1151 double precision twait,tstart,tend1
1152 parameter(twait=600.0d0)
1154 c find an available soldier
1158 do while(.not. (flag .or. tout))
1159 call MPI_IPROBE(mpi_any_source,idint,CG_COMM,flag,
1162 if(tend1-tstart.gt.twait .and. ihalt.eq.1) tout=.true.
1163 c_error if(tend1-tstart.gt.twait) tout=.true.
1166 write(iout,*) 'ERROR = timeout for recv ',tend1-tstart
1170 man=muster(mpi_source)
1172 ctimeout call mpi_recv(ind,9,mpi_integer,mpi_any_source,idint,
1173 ctimeout * CG_COMM,muster,ierr)
1174 ! print *, ' receiving output from start # ',ind(1)
1175 ct print *,'receiving ',MPI_WTIME()
1176 ctimeout man=muster(mpi_source)
1177 call mpi_recv(ind,9,mpi_integer,man,idint,
1178 * CG_COMM,muster,ierr)
1180 c receive final energies and variables
1181 call mpi_recv(eout,1,mpi_double_precision,
1182 * man,idreal,CG_COMM,muster,ierr)
1185 call mpi_recv(co,1,mpi_double_precision,
1186 * man,idreal,CG_COMM,muster,ierr)
1187 write (iout,'(a15,f3.2,$)') ' BIAS by contact order*100 ',co
1189 call mpi_recv(xout,nvar,mpi_double_precision,
1190 * man,idreal,CG_COMM,muster,ierr)
1191 ! print *,nvar , ierr
1192 if(vdisulf) nss=ind(6)
1193 if(vdisulf.and.nss.ne.0) then
1194 call mpi_recv(ihpb,nss,mpi_integer,
1195 * man,idint,CG_COMM,muster,ierr)
1196 call mpi_recv(jhpb,nss,mpi_integer,
1197 * man,idint,CG_COMM,muster,ierr)
1201 c print *,'sending halt to ',man
1202 write(iout,*) 'sending halt to ',man
1204 call mpi_send(info,12,mpi_integer,man,idint,CG_COMM,ierr)
1209 c----------------------------------------------------------
1210 subroutine history_append
1211 implicit real*8 (a-h,o-z)
1212 include 'DIMENSIONS'
1213 include 'COMMON.IOUNITS'
1215 #if defined(AIX) || defined(PGI)
1216 open(icsa_history,file=csa_history,position="append")
1218 open(icsa_history,file=csa_history,access="append")