2 C Thread the sequence through a database of known structures
3 implicit real*8 (a-h,o-z)
8 include 'COMMON.CONTROL'
10 include 'COMMON.DBASE'
11 include 'COMMON.INTERACT'
13 include 'COMMON.THREAD'
14 include 'COMMON.FFIELD'
15 include 'COMMON.SBRIDGE'
16 include 'COMMON.HEADER'
17 include 'COMMON.IOUNITS'
18 include 'COMMON.TIME1'
19 include 'COMMON.CONTACTS'
21 include 'COMMON.NAMES'
24 integer ThreadId,ThreadType,Kwita
26 double precision varia(maxvar)
27 double precision przes(3),obr(3,3)
28 double precision time_for_thread
29 logical found_pattern,non_conv
31 double precision energia(0:n_ene)
55 ave_time_for_thread=0.0D0
56 max_time_for_thread=0.0D0
57 cd print *,'nthread=',nthread,' nseq=',nseq,' nres0=',nres0
62 do while (.not.found_pattern)
64 if (itrial.gt.1000) then
65 write (iout,'(/a/)') 'Too many attempts to find pattern.'
68 call recv_stop_sig(Kwita)
69 call send_stop_sig(-3)
73 C Find long enough chain in the database
75 nres_t=nres_base(1,ii)
76 C Select the starting position to thread.
77 print *,'nseq',nseq,' ii=',ii,' nres_t=',
78 & nres_t,' nres0=',nres0
79 if (nres_t.ge.nres0) then
80 ist=iran_num(0,nres_t-nres0)
82 if (Kwita.eq.0) call recv_stop_sig(Kwita)
84 write (iout,*) 'Stop signal received. Terminating.'
85 write (*,*) 'Stop signal received. Terminating.'
87 write (*,*) 'ithread=',ithread,' nthread=',nthread
93 if (iexam(1,i).eq.ii .and. iexam(2,i).eq.ist) goto 10
97 C If this point is reached, the pattern has not yet been examined.
99 c print *,'found_pattern:',found_pattern
105 if (Kwita.eq.0) call recv_stop_sig(Kwita)
107 write (iout,*) 'Stop signal received. Terminating.'
109 write (*,*) 'ithread=',ithread,' nthread=',nthread
117 write (iout,'(/80(1h*)/a,i4,a,i5,2a,i3,a,i3,a,i3/)')
118 & 'Processor:',me,' Attempt:',ithread,
119 & ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),
120 & ' start at res.',ist+1
121 write (*,'(a,i4,a,i5,2a,i3,a,i3,a,i3)') 'Processor:',me,
122 & ' Attempt:',ithread,
123 & ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),
124 & ' start at res.',ist+1
126 write (iout,'(/80(1h*)/a,i5,2a,i3,a,i3,a,i3/)')
127 & 'Attempt:',ithread,
128 & ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),
129 & ' start at res.',ist+1
130 write (*,'(a,i5,2a,i3,a,i3,a,i3)')
131 & 'Attempt:',ithread,
132 & ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),
133 & ' start at res.',ist+1
136 C Copy coordinates from the database.
140 c(j,i)=cart_base(j,i+ist,ii)
143 cd write (iout,'(a,i4,3f10.5)') restyp(itype(i)),i,(c(j,i),j=1,3)
145 cd call fitsq(rms,c(1,nnt),cref(1,nnt),nct-nnt+1,przes,obr,
147 cd write (iout,'(a,f10.5)')
148 cd & 'Initial RMS deviation from reference structure:',rms
149 if (itype(nres).eq.21) then
151 dcj=c(j,nres-2)-c(j,nres-3)
152 c(j,nres)=c(j,nres-1)+dcj
153 c(j,2*nres)=c(j,nres)
156 if (itype(1).eq.21) then
163 call int_from_cart(.false.,.false.)
164 cd print *,'Exit INT_FROM_CART.'
165 cd print *,'nhpb=',nhpb
170 c write (iout,'(2i5,2f10.5)') ihpb(i),jhpb(i),dhpb(i),forcon(i)
172 c stop 'End generate'
173 C Generate SC conformations.
177 cd print *,'Processor:',me,': exit GEN_SIDE.'
179 cd print *,'Exit GEN_SIDE.'
181 C Calculate initial energy.
183 call etotal(energia(0))
186 ener0(i,ithread)=energia(i)
188 ener0(n_ene_comp+1,ithread)=energia(0)
190 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
191 ener0(n_ene_comp+3,ithread)=contact_fract(ncont,ncont_ref,
193 ener0(n_ene_comp+2,ithread)=rms
194 ener0(n_ene_comp+4,ithread)=frac
195 ener0(n_ene_comp+5,ithread)=frac_nn
197 ener0(n_ene_comp+3,ithread)=0.0d0
200 print*,'Processor:',me,' ithread=',ithread,' Start REGULARIZE.'
202 print*,'ithread=',ithread,' Start REGULARIZE.'
205 call regularize(nct-nnt+1,etot,rms,
206 & cart_base(1,ist+nnt,ipattern),iretcode)
208 time_for_thread=curr_tim1-curr_tim
210 & ((ithread-1)*ave_time_for_thread+time_for_thread)/ithread
211 if (time_for_thread.gt.max_time_for_thread)
212 & max_time_for_thread=time_for_thread
214 print *,'Processor',me,': Exit REGULARIZE.'
215 if (WhatsUp.eq.2) then
217 & 'Sufficient number of confs. collected. Terminating.'
220 else if (WhatsUp.eq.-1) then
222 write (iout,*) 'Time up in REGULARIZE. Call SEND_STOP_SIG.'
223 if (Kwita.eq.0) call recv_stop_sig(Kwita)
224 call send_stop_sig(-2)
226 else if (WhatsUp.eq.-2) then
228 write (iout,*) 'Timeup signal received. Terminating.'
230 else if (WhatsUp.eq.-3) then
232 write (iout,*) 'Error stop signal received. Terminating.'
236 print *,'Exit REGULARIZE.'
237 if (iretcode.eq.11) then
239 &'******* Allocated time exceeded in SUMSL. The program will stop.'
244 head_pdb=titel(:24)//':'//str_nam(ipattern)
245 if (outpdb) call pdbout(etot,head_pdb,ipdb)
246 if (outmol2) call mol2out(etot,head_pdb)
248 call briefout(ithread,etot)
250 link_end=min0(link_end,nss)
251 write (iout,*) 'link_end=',link_end,' link_end0=',link_end0,
253 call etotal(energia(0))
254 c call enerprint(energia(0))
257 cd call fitsq(rms,c(1,nnt),cref(1,nnt),nct-nnt+1,przes,obr,non_conv)
258 cd write (iout,'(a,f10.5)')
259 cd & 'RMS deviation from reference structure:',dsqrt(rms)
261 ener(i,ithread)=energia(i)
263 ener(n_ene_comp+1,ithread)=energia(0)
264 ener(n_ene_comp+3,ithread)=rms
266 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
267 ener(n_ene_comp+2,ithread)=rms
268 ener(n_ene_comp+4,ithread)=frac
269 ener(n_ene_comp+5,ithread)=frac_nn
271 call write_stat_thread(ithread,ipattern,ist)
272 c write (istat,'(i4,2x,a8,i4,11(1pe14.5),2(0pf8.3),f8.5)')
273 c & ithread,str_nam(ipattern),ist+1,(ener(k,ithread),k=1,11),
274 c & (ener(k,ithread),k=12,14)
279 call receive_MCM_info
280 if (nacc_tot.ge.nthread) then
282 & 'Sufficient number of conformations collected nacc_tot=',
283 & nacc_tot,'. Stopping other processors and terminating.'
285 & 'Sufficient number of conformations collected nacc_tot=',
286 & nacc_tot,'. Stopping other processors and terminating.'
287 call recv_stop_sig(Kwita)
288 if (Kwita.eq.0) call send_stop_sig(-1)
293 call send_MCM_info(2)
296 if (timlim-curr_tim1-safety .lt. max_time_for_thread) then
298 & '********** There would be not enough time for another thread. ',
299 & 'The program will stop.'
301 & '********** There would be not enough time for another thread. ',
302 & 'The program will stop.'
303 write (iout,'(a,1pe14.4/)')
304 & 'Elapsed time for last threading step: ',time_for_thread
307 call recv_stop_sig(Kwita)
308 call send_stop_sig(-2)
313 write (iout,'(a,1pe14.4)')
314 & 'Elapsed time for this threading step: ',time_for_thread
317 if (Kwita.eq.0) call recv_stop_sig(Kwita)
319 write (iout,*) 'Stop signal received. Terminating.'
320 write (*,*) 'Stop signal received. Terminating.'
322 write (*,*) 'nthread=',nthread,' ithread=',ithread
328 call send_stop_sig(-1)
332 C Any messages left for me?
334 if (Kwita.eq.0) call recv_stop_sig(Kwita)
336 call write_thread_summary
338 if (king.eq.king) then
340 do while (Kwita.ne.0 .or. nacc_tot.ne.0)
343 call recv_stop_sig(Kwita)
344 call receive_MCM_info
347 call receive_thread_results(iproc)
349 call write_thread_summary
351 call send_thread_results
356 c--------------------------------------------------------------------------
357 subroutine write_thread_summary
358 C Thread the sequence through a database of known structures
359 implicit real*8 (a-h,o-z)
364 include 'COMMON.CONTROL'
365 include 'COMMON.CHAIN'
366 include 'COMMON.DBASE'
367 include 'COMMON.INTERACT'
369 include 'COMMON.THREAD'
370 include 'COMMON.FFIELD'
371 include 'COMMON.SBRIDGE'
372 include 'COMMON.HEADER'
373 include 'COMMON.NAMES'
374 include 'COMMON.IOUNITS'
375 include 'COMMON.TIME1'
377 include 'COMMON.INFO'
379 dimension ip(maxthread)
380 double precision energia(0:n_ene)
381 write (iout,'(30x,a/)')
382 & ' *********** Summary threading statistics ************'
383 write (iout,'(a)') 'Initial energies:'
384 write (iout,'(a4,2x,a12,14a14,3a8)')
385 & 'No','seq',(ename(print_order(i)),i=1,nprint_ene),'ETOT',
386 & 'RMSnat','NatCONT','NNCONT','RMS'
387 C Energy sort patterns
392 enet=ener(n_ene-1,ip(i))
395 if (ener(n_ene-1,ip(j)).lt.enet) then
397 enet=ener(n_ene-1,ip(j))
409 ist=nres_base(2,ii)+ipatt(2,i)
411 energia(i)=ener0(kk,i)
413 etot=ener0(n_ene_comp+1,i)
414 rmsnat=ener0(n_ene_comp+2,i)
415 rms=ener0(n_ene_comp+3,i)
416 frac=ener0(n_ene_comp+4,i)
417 frac_nn=ener0(n_ene_comp+5,i)
420 write (iout,'(i4,2x,a8,i4,14(1pe14.5),0pf8.3,f8.5,f8.5,f8.3)')
421 & i,str_nam(ii),ist+1,
422 & (energia(print_order(kk)),kk=1,nprint_ene),
423 & etot,rmsnat,frac,frac_nn,rms
425 write (iout,'(i4,2x,a8,i4,14(1pe14.5),0pf8.3)')
426 & i,str_nam(ii),ist+1,
427 & (energia(print_order(kk)),kk=1,nprint_ene),etot
430 write (iout,'(//a)') 'Final energies:'
431 write (iout,'(a4,2x,a12,17a14,3a8)')
432 & 'No','seq',(ename(print_order(kk)),kk=1,nprint_ene),'ETOT',
433 & 'RMSnat','NatCONT','NNCONT','RMS'
437 ist=nres_base(2,ii)+ipatt(2,i)
439 energia(kk)=ener(kk,ik)
441 etot=ener(n_ene_comp+1,i)
442 rmsnat=ener(n_ene_comp+2,i)
443 rms=ener(n_ene_comp+3,i)
444 frac=ener(n_ene_comp+4,i)
445 frac_nn=ener(n_ene_comp+5,i)
446 write (iout,'(i4,2x,a8,i4,14(1pe14.5),0pf8.3,f8.5,f8.5,f8.3)')
447 & i,str_nam(ii),ist+1,
448 & (energia(print_order(kk)),kk=1,nprint_ene),
449 & etot,rmsnat,frac,frac_nn,rms
451 write (iout,'(/a/)') 'IEXAM array:'
452 write (iout,'(i5)') nexcl
454 write (iout,'(2i5)') iexam(1,i),iexam(2,i)
456 write (iout,'(/a,1pe14.4/a,1pe14.4/)')
457 & 'Max. time for threading step ',max_time_for_thread,
458 & 'Average time for threading step: ',ave_time_for_thread
461 c----------------------------------------------------------------------------
463 C Sample (hopefully) optimal SC orientations given backcone conformation.
464 implicit real*8 (a-h,o-z)
466 include 'COMMON.CHAIN'
467 include 'COMMON.DBASE'
468 include 'COMMON.INTERACT'
470 include 'COMMON.THREAD'
471 include 'COMMON.FFIELD'
472 include 'COMMON.SBRIDGE'
473 include 'COMMON.HEADER'
475 include 'COMMON.IOUNITS'
476 double precision varia(maxvar)
478 double precision energia(0:n_ene)
482 link_end=min0(link_end,nss)
484 if (itype(i).ne.10) then
485 cd print *,'i=',i,' itype=',itype(i),' theta=',theta(i+1)
486 call gen_side(itype(i),theta(i+1),alph(i),omeg(i),fail)
490 call etotal(energia(0))
491 do isample=1,maxsample
492 C Choose a non-glycine side chain.
495 ind_sc=iran_num(nnt,nct)
496 glycine=(itype(ind_sc).eq.10)
500 call gen_side(itype(ind_sc),theta(ind_sc+1),alph(ind_sc),
503 call etotal(energia(0))
504 cd write (iout,'(a,i5,a,i4,2(a,f8.3),2(a,1pe14.5))')
505 cd & 'Step:',isample,' SC',ind_sc,' alpha',alph(ind_sc)*rad2deg,
506 cd & ' omega',omeg(ind_sc)*rad2deg,' old energy',e0,' new energy',e1
518 c---------------------------------------------------------------------------
519 subroutine write_stat_thread(ithread,ipattern,ist)
520 implicit real*8 (a-h,o-z)
522 include "COMMON.CONTROL"
523 include "COMMON.IOUNITS"
524 include "COMMON.THREAD"
525 include "COMMON.FFIELD"
526 include "COMMON.DBASE"
527 include "COMMON.NAMES"
528 double precision energia(0:n_ene)
530 #if defined(AIX) || defined(PGI)
531 open(istat,file=statname,position='append')
533 open(istat,file=statname,access='append')
536 energia(i)=ener(i,ithread)
538 etot=ener(n_ene_comp+1,ithread)
539 rmsnat=ener(n_ene_comp+2,ithread)
540 rms=ener(n_ene_comp+3,ithread)
541 frac=ener(n_ene_comp+4,ithread)
542 frac_nn=ener(n_ene_comp+5,ithread)
543 write (istat,'(i4,2x,a8,i4,14(1pe14.5),0pf8.3,f8.5,f8.5,f8.3)')
544 & ithread,str_nam(ipattern),ist+1,
545 & (energia(print_order(i)),i=1,nprint_ene),
546 & etot,rmsnat,frac,frac_nn,rms