2 ccccccccccccccccccccccccccccccccccccccccccccccccc
3 ccccccccccccccccccccccccccccccccccccccccccccccccc
4 subroutine make_var(n,idum,iter_csa)
5 implicit real*8 (a-h,o-z)
7 include 'COMMON.IOUNITS'
10 include 'COMMON.CHAIN'
11 include 'COMMON.INTERACT'
12 include 'COMMON.HAIRPIN'
14 include 'COMMON.DISTFIT'
16 include 'COMMON.CONTROL'
17 logical nicht_getan,nicht_getan1,fail,lfound
18 integer nharp,iharp(4,maxres/3),nconf_harp
21 integer nhx_seed(max_seed),ihx_seed(4,maxres/3,max_seed)
22 integer nhx_use(max_seed),ihx_use(0:4,maxres/3,max_seed)
23 integer nlx_seed(max_seed),ilx_seed(2,maxres/3,max_seed),
24 & nlx_use(max_seed),ilx_use(maxres/3,max_seed)
27 write (iout,*) 'make_var : nseed=',nseed,'ntry=',n
30 c-----------------------------------------
31 if (n7.gt.0.or.n8.gt.0.or.n9.gt.0.or.n14.gt.0.or.n15.gt.0
32 & .or.n16.gt.0.or.n17.gt.0.or.n18.gt.0)
33 & call select_frag(n7frag,n8frag,n14frag,
34 & n15frag,nbefrag,iter_csa)
36 c---------------------------------------------------
37 c N18 - random perturbation of one phi(=gamma) angle in a loop
45 if (lvar_frag(i2,1).eq.i1) then
46 nlx_seed(iters)=nlx_seed(iters)+5
47 ilx_seed(1,nlx_seed(iters),iters)=lvar_frag(i2,2)
48 ilx_seed(2,nlx_seed(iters),iters)=lvar_frag(i2,3)
49 ilx_use(nlx_seed(iters),iters)=5
52 nlx_use(iters)=nlx_seed(iters)
53 nlx_tot=nlx_tot+nlx_seed(iters)
56 if (nlx_tot .ge. n18*nseed) then
59 ntot_gen=(nlx_tot/nseed)*nseed
63 do while (ngen.lt.ntot_gen)
66 if (nlx_use(iters).gt.0) then
68 do while (nicht_getan)
69 iih=iran_num(1,nlx_seed(iters))
70 if (ilx_use(iih,iters).gt.0) then
72 ilx_use(iih,iters)=ilx_use(iih,iters)-1
73 nlx_use(iters)=nlx_use(iters)-1
84 nss_in(index)=bvar_nss(iseed)
86 iss_in(ij,index)=bvar_ss(1,ij,iseed)
87 jss_in(ij,index)=bvar_ss(2,ij,iseed)
95 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
100 jr=iran_num(ilx_seed(1,iih,iters),ilx_seed(2,iih,iters))
102 dihang_in(2,jr-2,1,index)=pinorm(dihang_in(2,jr-2,1,index)+d)
105 if (ngen.eq.ntot_gen) goto 145
114 c-----------------------------------------
115 c N17 : zip a beta in a seed by forcing one additional p-p contact
124 if (avar_frag(i2,1).eq.i1) then
125 nhx_seed(iters)=nhx_seed(iters)+1
126 ihx_use(2,nhx_seed(iters),iters)=1
127 if (avar_frag(i2,5)-avar_frag(i2,3).le.3.and.
128 & avar_frag(i2,2).gt.1.and.avar_frag(i2,4).lt.nres) then
129 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
130 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)+1
131 ihx_use(0,nhx_seed(iters),iters)=1
132 ihx_use(1,nhx_seed(iters),iters)=0
133 nhx_use(iters)=nhx_use(iters)+1
135 if (avar_frag(i2,4).gt.avar_frag(i2,5)) then
136 if (avar_frag(i2,2).gt.1.and.
137 & avar_frag(i2,4).lt.nres) then
138 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
139 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)+1
140 ihx_use(0,nhx_seed(iters),iters)=1
141 ihx_use(1,nhx_seed(iters),iters)=0
142 nhx_use(iters)=nhx_use(iters)+1
144 if (avar_frag(i2,3).lt.nres.and.
145 & avar_frag(i2,5).gt.1) then
146 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,3)+1
147 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,5)-1
148 ihx_use(0,nhx_seed(iters),iters)=
149 & ihx_use(0,nhx_seed(iters),iters)+1
150 ihx_use(2,nhx_seed(iters),iters)=0
151 nhx_use(iters)=nhx_use(iters)+1
154 if (avar_frag(i2,2).gt.1.and.
155 & avar_frag(i2,4).gt.1) then
156 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
157 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)-1
158 ihx_use(0,nhx_seed(iters),iters)=1
159 ihx_use(1,nhx_seed(iters),iters)=0
160 nhx_use(iters)=nhx_use(iters)+1
162 if (avar_frag(i2,3).lt.nres.and.
163 & avar_frag(i2,5).lt.nres) then
164 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,3)+1
165 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,5)+1
166 ihx_use(0,nhx_seed(iters),iters)=
167 & ihx_use(0,nhx_seed(iters),iters)+1
168 ihx_use(2,nhx_seed(iters),iters)=0
169 nhx_use(iters)=nhx_use(iters)+1
176 nhx_tot=nhx_tot+nhx_use(iters)
177 cd write (iout,*) "debug N17",iters,nhx_seed(iters),
178 cd & nhx_use(iters),nhx_tot
181 if (nhx_tot .ge. n17*nseed) then
183 else if (nhx_tot .ge. nseed) then
184 ntot_gen=(nhx_tot/nseed)*nseed
188 cd write (iout,*) "debug N17==",ntot_gen,nhx_tot,nseed
191 do while (ngen.lt.ntot_gen)
194 if (nhx_use(iters).gt.0) then
195 cd write (iout,*) "debug N17",nhx_use(iters),ngen,ntot_gen
196 cd write (iout,*) "debugN17^",
197 cd & (ihx_use(0,k,iters),k=1,nhx_use(iters))
199 do while (nicht_getan)
200 iih=iran_num(1,nhx_seed(iters))
201 cd write (iout,*) "debugN17^",iih
202 if (ihx_use(0,iih,iters).gt.0) then
204 cd write (iout,*) "debugN17=",iih,nhx_seed(iters)
205 cd write (iout,*) "debugN17-",iim,'##',
206 cd & (ihx_use(k,iih,iters),k=0,2)
208 do while (ihx_use(iim,iih,iters).eq.1)
210 cd write (iout,*) "debugN17-",iim,'##',
211 cd & (ihx_use(k,iih,iters),k=0,2)
215 ihx_use(iim,iih,iters)=1
216 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
217 nhx_use(iters)=nhx_use(iters)-1
223 parent(1,index)=iseed
227 nss_in(index)=bvar_nss(iseed)
228 do ij=1,nss_in(index)
229 iss_in(ij,index)=bvar_ss(1,ij,iseed)
230 jss_in(ij,index)=bvar_ss(2,ij,iseed)
237 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
243 idata(1,index)=ihx_seed(1,iih,iters)
244 idata(2,index)=ihx_seed(2,iih,iters)
246 idata(1,index)=ihx_seed(3,iih,iters)
247 idata(2,index)=ihx_seed(4,iih,iters)
250 if (ngen.eq.ntot_gen) goto 115
255 write (iout,*) "N17",n17," ngen/nseed",ngen/nseed,
260 c-----------------------------------------
261 c N16 : slide non local beta in a seed by +/- 1 or +/- 2
269 if (bvar_frag(i2,1).eq.i1) then
270 nhx_seed(iters)=nhx_seed(iters)+1
271 ihx_seed(1,nhx_seed(iters),iters)=bvar_frag(i2,3)
272 ihx_seed(2,nhx_seed(iters),iters)=bvar_frag(i2,4)
273 ihx_seed(3,nhx_seed(iters),iters)=bvar_frag(i2,5)
274 ihx_seed(4,nhx_seed(iters),iters)=bvar_frag(i2,6)
275 ihx_use(0,nhx_seed(iters),iters)=4
277 ihx_use(i3,nhx_seed(iters),iters)=0
281 nhx_use(iters)=4*nhx_seed(iters)
282 nhx_tot=nhx_tot+nhx_seed(iters)
283 cd write (iout,*) "debug N16",iters,nhx_seed(iters)
286 if (4*nhx_tot .ge. n16*nseed) then
288 else if (4*nhx_tot .ge. nseed) then
289 ntot_gen=(4*nhx_tot/nseed)*nseed
293 write (iout,*) "debug N16",ntot_gen,4*nhx_tot,nseed
296 do while (ngen.lt.ntot_gen)
299 if (nhx_use(iters).gt.0) then
301 do while (nicht_getan)
302 iih=iran_num(1,nhx_seed(iters))
303 if (ihx_use(0,iih,iters).gt.0) then
305 do while (ihx_use(iim,iih,iters).eq.1)
306 cd write (iout,*) iim,
307 cd & ihx_use(0,iih,iters),ihx_use(iim,iih,iters)
311 ihx_use(iim,iih,iters)=1
312 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
313 nhx_use(iters)=nhx_use(iters)-1
319 parent(1,index)=iseed
323 nss_in(index)=bvar_nss(iseed)
324 do ij=1,nss_in(index)
325 iss_in(ij,index)=bvar_ss(1,ij,iseed)
326 jss_in(ij,index)=bvar_ss(2,ij,iseed)
333 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
339 idata(i,index)=ihx_seed(i,iih,iters)
343 if (ngen.eq.ntot_gen) goto 116
348 write (iout,*) "N16",n16," ngen/nseed",ngen/nseed,
351 c-----------------------------------------
352 c N15 : copy two 2nd structure elements from 1 or 2 conf. in bank to a seed
367 iif=iran_num(1,n15frag)
368 do while( (ifused(iif) .or. svar_frag(iif,1).eq.iseed) .and.
370 iif=iran_num(1,n15frag)
373 if(iran.ge.mxio) goto 811
376 iig=iran_num(1,n15frag)
377 do while( (ifused(iig) .or. svar_frag(iig,1).eq.iseed .or.
378 & .not.(svar_frag(iif,3).lt.svar_frag(iig,2).or.
379 & svar_frag(iig,3).lt.svar_frag(iif,2)) ) .and.
381 iig=iran_num(1,n15frag)
384 if(iran.ge.mxio) goto 811
388 parent(1,index)=iseed
389 parent(2,index)=svar_frag(iif,1)
390 parent(3,index)=svar_frag(iig,1)
394 nss_in(index)=bvar_nss(iseed)
395 do ij=1,nss_in(index)
396 iss_in(ij,index)=bvar_ss(1,ij,iseed)
397 jss_in(ij,index)=bvar_ss(2,ij,iseed)
403 call newconf_copy(idum,dihang_in(1,1,1,index),
404 & svar_frag(iif,1),svar_frag(iif,2),svar_frag(iif,3))
406 do j=svar_frag(iig,2),svar_frag(iig,3)
408 dihang_in(i,j,1,index)=bvar(i,j,1,svar_frag(iig,1))
414 call check_old(icheck,index)
427 c-----------------------------------------
428 c N14 local_move (Maurizio) for loops in a seed
436 if (lvar_frag(i2,1).eq.i1) then
437 nlx_seed(iters)=nlx_seed(iters)+3
438 ilx_seed(1,nlx_seed(iters),iters)=lvar_frag(i2,2)
439 ilx_seed(2,nlx_seed(iters),iters)=lvar_frag(i2,3)
440 ilx_use(nlx_seed(iters),iters)=3
443 nlx_use(iters)=nlx_seed(iters)
444 nlx_tot=nlx_tot+nlx_seed(iters)
445 cd write (iout,*) "debug N14",iters,nlx_seed(iters)
448 if (nlx_tot .ge. n14*nseed) then
451 ntot_gen=(nlx_tot/nseed)*nseed
453 cd write (iout,*) "debug N14",ntot_gen,n14frag,nseed
456 do while (ngen.lt.ntot_gen)
459 if (nlx_use(iters).gt.0) then
461 do while (nicht_getan)
462 iih=iran_num(1,nlx_seed(iters))
463 if (ilx_use(iih,iters).gt.0) then
465 ilx_use(iih,iters)=ilx_use(iih,iters)-1
466 nlx_use(iters)=nlx_use(iters)-1
472 parent(1,index)=iseed
475 idata(1,index)=ilx_seed(1,iih,iters)
476 idata(2,index)=ilx_seed(2,iih,iters)
480 nss_in(index)=bvar_nss(iseed)
481 do ij=1,nss_in(index)
482 iss_in(ij,index)=bvar_ss(1,ij,iseed)
483 jss_in(ij,index)=bvar_ss(2,ij,iseed)
491 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
496 if (ngen.eq.ntot_gen) goto 131
501 cd write (iout,*) "N14",n14," ngen/nseed",ngen/nseed,
505 c-----------------------------------------
506 c N9 : shift a helix in a seed
514 if (hvar_frag(i2,1).eq.i1) then
515 nhx_seed(iters)=nhx_seed(iters)+1
516 ihx_seed(1,nhx_seed(iters),iters)=hvar_frag(i2,2)
517 ihx_seed(2,nhx_seed(iters),iters)=hvar_frag(i2,3)
518 ihx_use(0,nhx_seed(iters),iters)=4
520 ihx_use(i3,nhx_seed(iters),iters)=0
524 nhx_use(iters)=4*nhx_seed(iters)
525 nhx_tot=nhx_tot+nhx_seed(iters)
526 cd write (iout,*) "debug N9",iters,nhx_seed(iters)
529 if (4*nhx_tot .ge. n9*nseed) then
532 ntot_gen=(4*nhx_tot/nseed)*nseed
534 cd write (iout,*) "debug N9",ntot_gen,n8frag,nseed
537 do while (ngen.lt.ntot_gen)
540 if (nhx_use(iters).gt.0) then
542 do while (nicht_getan)
543 iih=iran_num(1,nhx_seed(iters))
544 if (ihx_use(0,iih,iters).gt.0) then
546 do while (ihx_use(iim,iih,iters).eq.1)
547 cd write (iout,*) iim,
548 cd & ihx_use(0,iih,iters),ihx_use(iim,iih,iters)
552 ihx_use(iim,iih,iters)=1
553 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
554 nhx_use(iters)=nhx_use(iters)-1
560 parent(1,index)=iseed
564 nss_in(index)=bvar_nss(iseed)
565 do ij=1,nss_in(index)
566 iss_in(ij,index)=bvar_ss(1,ij,iseed)
567 jss_in(ij,index)=bvar_ss(2,ij,iseed)
574 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
579 jstart=max(nnt,ihx_seed(1,iih,iters)+1)
580 jend=min(nct,ihx_seed(2,iih,iters))
581 cd write (iout,*) "debug N9",iters,iih,jstart,jend
584 else if (iim.eq.2) then
586 else if (iim.eq.3) then
588 else if (iim.eq.4) then
591 write (iout,*) 'CHUJ NASTAPIL: iim=',iim
592 call mpi_abort(mpi_comm_world,ierror,ierrcode)
595 if (itype(j).eq.10) then
601 if (j+ishift.ge.nnt.and.j+ishift.le.nct)
602 & dihang_in(i,j+ishift,1,index)=bvar(i,j,1,iseed)
605 if (ishift.gt.0) then
607 if (itype(jend+j).eq.10) then
613 if (jend+j.ge.nnt.and.jend+j.le.nct)
614 & dihang_in(i,jstart+j,1,index)=bvar(i,jend+j,1,iseed)
619 if (itype(jstart+j).eq.10) then
625 if (jend+j.ge.nnt.and.jend+j.le.nct)
626 & dihang_in(i,jend+j,1,index)=bvar(i,jstart+j,1,iseed)
630 if (ngen.eq.ntot_gen) goto 133
635 cd write (iout,*) "N9",n9," ngen/nseed",ngen/nseed,
639 c-----------------------------------------
640 c N8 : copy a helix from bank to seed
643 if (n8frag.lt.n8) then
644 write (iout,*) "N8: only ",n8frag,'helices'
661 iif=iran_num(1,n8frag)
662 do while( (ifused(iif) .or. hvar_frag(iif,1).eq.iseed) .and.
664 iif=iran_num(1,n8frag)
668 if(iran.ge.mxio) goto 911
672 parent(1,index)=iseed
673 parent(2,index)=hvar_frag(iif,1)
677 nss_in(index)=bvar_nss(iseed)
678 do ij=1,nss_in(index)
679 iss_in(ij,index)=bvar_ss(1,ij,iseed)
680 jss_in(ij,index)=bvar_ss(2,ij,iseed)
685 if (hvar_frag(iif,3)-hvar_frag(iif,2).le.6) then
686 call newconf_copy(idum,dihang_in(1,1,1,index),
687 & hvar_frag(iif,1),hvar_frag(iif,2),hvar_frag(iif,3))
689 ih_start=iran_num(hvar_frag(iif,2),hvar_frag(iif,3)-6)
690 ih_end=iran_num(ih_start,hvar_frag(iif,3))
691 call newconf_copy(idum,dihang_in(1,1,1,index),
692 & hvar_frag(iif,1),ih_start,ih_end)
696 call check_old(icheck,index)
712 c-----------------------------------------
713 c N7 : copy nonlocal beta fragment from bank to seed
716 if (n7frag.lt.n7) then
717 write (iout,*) "N7: only ",n7frag,'nonlocal fragments'
741 iif=iran_num(1,n7frag)
742 do while( (ifused(iif) .or. bvar_frag(iif,1).eq.iseed) .and.
744 iif=iran_num(1,n7frag)
748 cd write (*,'(3i5,l,4i5)'),iters,idummy,iif,ifused(iif),
749 cd & bvar_frag(iif,1),iseed,iran,index2
751 if(iran.ge.mxio) goto 999
752 if(index2.ge.mxio2) goto 999
756 parent(1,index)=iseed
757 parent(2,index)=bvar_frag(iif,1)
763 nss_in(index)=bvar_nss(iseed)
764 do ij=1,nss_in(index)
765 iss_in(ij,index)=bvar_ss(1,ij,iseed)
766 jss_in(ij,index)=bvar_ss(2,ij,iseed)
773 dihang_in2(i,j,k,index2)=bvar(i,j,k,bvar_frag(iif,1))
778 if (bvar_frag(iif,2).eq.4) then
779 do i=bvar_frag(iif,3),bvar_frag(iif,4)
782 if (bvar_frag(iif,5).lt.bvar_frag(iif,6)) then
783 cd print *,'###',bvar_frag(iif,3),bvar_frag(iif,4),
784 cd & bvar_frag(iif,5),bvar_frag(iif,6)
785 do i=bvar_frag(iif,5),bvar_frag(iif,6)
789 cd print *,'###',bvar_frag(iif,3),bvar_frag(iif,4),
790 cd & bvar_frag(iif,6),bvar_frag(iif,5)
791 do i=bvar_frag(iif,6),bvar_frag(iif,5)
800 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
812 c-----------------------------------------------
813 c N6 : copy random continues fragment from bank to seed
818 isize=(is2-is1+1)*ran1(idum)+is1
824 nss_in(index)=bvar_nss(iseed)
825 do ij=1,nss_in(index)
826 iss_in(ij,index)=bvar_ss(1,ij,iseed)
827 jss_in(ij,index)=bvar_ss(2,ij,iseed)
834 i1=nconf* ran1(idum)+1
837 i1=nbank* ran1(idum)+1
839 if(i1.eq.iseed) goto 104
841 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
842 parent(1,index)=iseed
845 call check_old(icheck,index)
846 if(icheck.eq.1) goto 104
850 c-----------------------------------------
851 if (n3.gt.0.or.n4.gt.0) call gen_hairpin
854 if (nharp_seed(iters).gt.0) nconf_harp=nconf_harp+1
856 c-----------------------------------------
857 c N3 : copy hairpin from bank to seed
868 i1=nconf* ran1(idum)+1
871 i1=nbank* ran1(idum)+1
873 if(i1.eq.iseed) goto 124
875 if (i1.eq.iisucc(k).and.nsucc.lt.nconf_harp-1) goto 124
880 call newconf_residue_hairpin(idum,dihang_in(1,1,1,index),
883 if (icycle.le.0 .and. nsucc.eq.nconf .or.
884 & icycle.gt.0 .and. nsucc.eq.nbank) then
892 call check_old(icheck,index)
893 if(icheck.eq.1) goto 124
896 parent(1,index)=iseed
901 nss_in(index)=bvar_nss(iseed)
902 do ij=1,nss_in(index)
903 iss_in(ij,index)=bvar_ss(1,ij,iseed)
904 jss_in(ij,index)=bvar_ss(2,ij,iseed)
910 c if not enough hairpins, supplement with windows
912 cdd if (n3.ne.0) write (iout,*) "N3",n3," nsucc",nsucc," nacc",nacc
914 isize=(is2-is1+1)*ran1(idum)+is1
917 parent(1,index)=iseed
922 nss_in(index)=bvar_nss(iseed)
923 do ij=1,nss_in(index)
924 iss_in(ij,index)=bvar_ss(1,ij,iseed)
925 jss_in(ij,index)=bvar_ss(2,ij,iseed)
932 i1=nconf* ran1(idum)+1
935 i1=nbank* ran1(idum)+1
937 if(i1.eq.iseed) goto 114
939 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
941 call check_old(icheck,index)
942 if(icheck.eq.1) goto 114
946 c-----------------------------------------
947 c N4 : shift a turn in hairpin in seed
950 if (4*nharp_tot .ge. n4*nseed) then
953 ntot_gen=(4*nharp_tot/nseed)*nseed
956 do while (ngen.lt.ntot_gen)
959 c write (iout,*) 'iters',iters,' iseed',iseed,' nharp_seed',
960 c & nharp_seed(iters),' nharp_use',nharp_use(iters),
961 c & ' ntot_gen',ntot_gen
962 c write (iout,*) 'iharp_use(0)',
963 c & (iharp_use(0,k,iters),k=1,nharp_seed(iters))
964 if (nharp_use(iters).gt.0) then
966 do while (nicht_getan)
967 iih=iran_num(1,nharp_seed(iters))
968 c write (iout,*) 'iih',iih,' iharp_use',
969 c & (iharp_use(k,iih,iters),k=1,4)
970 if (iharp_use(0,iih,iters).gt.0) then
972 do while (nicht_getan1)
974 nicht_getan1=iharp_use(iim,iih,iters).eq.1
977 iharp_use(iim,iih,iters)=1
978 iharp_use(0,iih,iters)=iharp_use(0,iih,iters)-1
979 nharp_use(iters)=nharp_use(iters)-1
980 cdd write (iout,'(a16,i3,a5,i2,a10,2i4)')
981 cdd & 'N4 selected hairpin',iih,' move',iim,' iharp_seed',
982 cdd & iharp_seed(1,iih,iters),iharp_seed(2,iih,iters)
988 parent(1,index)=iseed
993 nss_in(index)=bvar_nss(iseed)
994 do ij=1,nss_in(index)
995 iss_in(ij,index)=bvar_ss(1,ij,iseed)
996 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1003 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1007 jstart=iharp_seed(1,iih,iters)+1
1008 jend=iharp_seed(2,iih,iters)
1011 else if (iim.eq.2) then
1013 else if (iim.eq.3) then
1015 else if (iim.eq.4) then
1018 write (iout,*) 'CHUJ NASTAPIL: iim=',iim
1019 call mpi_abort(mpi_comm_world,ierror,ierrcode)
1021 c write (iout,*) 'jstart',jstart,' jend',jend,' ishift',ishift
1022 c write (iout,*) 'Before turn shift'
1024 c theta(j+1)=dihang_in(1,j,1,index)
1025 c phi(j+2)=dihang_in(2,j,1,index)
1026 c alph(j)=dihang_in(3,j,1,index)
1027 c omeg(j)=dihang_in(4,j,1,index)
1031 if (itype(j).eq.10) then
1037 if (j+ishift.ge.nnt.and.j+ishift.le.nct)
1038 & dihang_in(i,j+ishift,1,index)=bvar(i,j,1,iseed)
1041 c write (iout,*) 'After turn shift'
1043 c theta(j+1)=dihang_in(1,j,1,index)
1044 c phi(j+2)=dihang_in(2,j,1,index)
1045 c alph(j)=dihang_in(3,j,1,index)
1046 c omeg(j)=dihang_in(4,j,1,index)
1049 if (ngen.eq.ntot_gen) goto 135
1053 c if not enough hairpins, supplement with windows
1054 c write (iout,*) 'end of enddo'
1056 cdd write (iout,*) "N4",n4," ngen/nseed",ngen/nseed,
1060 do idummy=ngen/nseed+1,n4
1061 isize=(is2-is1+1)*ran1(idum)+is1
1066 nss_in(index)=bvar_nss(iseed)
1067 do ij=1,nss_in(index)
1068 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1069 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1076 if(icycle.le.0) then
1077 i1=nconf* ran1(idum)+1
1080 i1=nbank* ran1(idum)+1
1082 if(i1.eq.iseed) goto 134
1084 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
1085 parent(1,index)=iseed
1088 call check_old(icheck,index)
1089 if(icheck.eq.1) goto 134
1094 c-----------------------------------------
1095 c N5 : copy one residue from bank to seed (normally switched off - use N1)
1105 nss_in(index)=bvar_nss(iseed)
1106 do ij=1,nss_in(index)
1107 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1108 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1115 if(icycle.le.0) then
1116 i1=nconf* ran1(idum)+1
1119 i1=nbank* ran1(idum)+1
1121 if(i1.eq.iseed) goto 105
1123 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
1124 parent(1,index)=iseed
1127 call check_old(icheck,index)
1128 if(icheck.eq.1) goto 105
1132 c-----------------------------------------
1133 c N2 : copy backbone of one residue from bank or first bank to seed
1134 c (normally switched off - use N1)
1139 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1140 iseed=ran1(idum)*nconf+1
1141 iseed=nbank-nconf+iseed
1147 nss_in(index)=bvar_nss(iseed)
1148 do ij=1,nss_in(index)
1149 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1150 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1155 102 i1= ran1(idum)*nbank+1
1156 if(i1.eq.iseed) goto 102
1158 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1159 nran=mod(i-1,nran0)+3
1160 call newconf1arr(idum,dihang_in(1,1,1,index),nran,i1)
1161 parent(1,index)=-iseed
1163 else if(icycle.le.0.and.iters.le.iuse) then
1164 nran=mod(i-1,nran0)+1
1165 call newconf1abr(idum,dihang_in(1,1,1,index),nran,i1)
1166 parent(1,index)=iseed
1169 nran=mod(i-1,nran1)+1
1170 if(ran1(idum).lt.0.5) then
1171 call newconf1abr(idum,dihang_in(1,1,1,index),nran,i1)
1172 parent(1,index)=iseed
1175 call newconf1abb(idum,dihang_in(1,1,1,index),nran,i1)
1176 parent(1,index)=iseed
1181 call check_old(icheck,index)
1182 if(icheck.eq.1) goto 102
1186 c-----------------------------------------
1187 c N1 : copy backbone or sidechain of one residue from bank or
1188 c first bank to seed
1193 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1194 iseed=ran1(idum)*nconf+1
1195 iseed=nbank-nconf+iseed
1201 nss_in(index)=bvar_nss(iseed)
1202 do ij=1,nss_in(index)
1203 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1204 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1209 101 i1= ran1(idum)*nbank+1
1211 if(i1.eq.iseed) goto 101
1213 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1214 nran=mod(i-1,nran0)+3
1215 call newconf1rr(idum,dihang_in(1,1,1,index),nran,i1)
1216 parent(1,index)=-iseed
1218 else if(icycle.le.0.and.iters.le.iuse) then
1219 nran=mod(i-1,nran0)+1
1220 call newconf1br(idum,dihang_in(1,1,1,index),nran,i1)
1221 parent(1,index)=iseed
1224 nran=mod(i-1,nran1)+1
1225 if(ran1(idum).lt.0.5) then
1226 call newconf1br(idum,dihang_in(1,1,1,index),nran,i1)
1227 parent(1,index)=iseed
1230 call newconf1bb(idum,dihang_in(1,1,1,index),nran,i1)
1231 parent(1,index)=iseed
1236 call check_old(icheck,index)
1237 if(icheck.eq.1) goto 101
1241 c-----------------------------------------
1249 parent(1,index)=iseed
1253 nss_in(index)=bvar_nss(iseed)
1254 do ij=1,nss_in(index)
1255 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1256 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1263 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1269 c-----------------------------------------
1276 theta(j+1)=bvar(1,j,k,iseed)
1277 phi(j+2)=bvar(2,j,k,iseed)
1278 alph(j)=bvar(3,j,k,iseed)
1279 omeg(j)=bvar(4,j,k,iseed)
1284 cd write(iout,*) 'makevar DYNSS',iseed,'#',bvar_ns(iseed),
1285 cd & (bvar_s(k,iseed),k=1,bvar_ns(iseed)),
1286 cd & bvar_nss(iseed),
1287 cd & (bvar_ss(1,k,iseed)-nres,'-',
1288 cd & bvar_ss(2,k,iseed)-nres,k=1,bvar_nss(iseed))
1290 do i1=1,bvar_ns(iseed)
1292 c N10 fussion of free halfcysteines in seed
1293 c first select CYS with distance < 7A
1295 do j1=i1+1,bvar_ns(iseed)
1296 if (dist(bvar_s(i1,iseed)+nres,bvar_s(j1,iseed)+nres)
1298 & iabs(bvar_s(i1,iseed)-bvar_s(j1,iseed)).gt.3) then
1302 parent(1,index)=iseed
1304 do ij=1,bvar_nss(iseed)
1305 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1306 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1308 ij=bvar_nss(iseed)+1
1310 iss_in(ij,index)=bvar_s(i1,iseed)+nres
1311 jss_in(ij,index)=bvar_s(j1,iseed)+nres
1313 cd write(iout,*) 'makevar NSS0',index,
1314 cd & dist(bvar_s(i1,iseed)+nres,bvar_s(j1,iseed)+nres),
1315 cd & nss_in(index),iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres
1320 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1328 c N11 type I transdisulfidation
1330 do j1=1,bvar_nss(iseed)
1331 if (dist(bvar_s(i1,iseed)+nres,bvar_ss(1,j1,iseed))
1333 & iabs(bvar_s(i1,iseed)-(bvar_ss(1,j1,iseed)-nres))
1338 parent(1,index)=iseed
1340 do ij=1,bvar_nss(iseed)
1342 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1343 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1346 nss_in(index)=bvar_nss(iseed)
1347 iss_in(j1,index)=bvar_s(i1,iseed)+nres
1348 jss_in(j1,index)=bvar_ss(1,j1,iseed)
1349 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1350 iss_in(j1,index)=bvar_ss(1,j1,iseed)
1351 jss_in(j1,index)=bvar_s(i1,iseed)+nres
1354 cd write(iout,*) 'makevar NSS1 #1',index,
1355 cd & bvar_s(i1,iseed),bvar_ss(1,j1,iseed)-nres,
1356 cd & dist(bvar_s(i1,iseed)+nres,bvar_ss(1,j1,iseed)),
1357 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1358 cd & ij=1,nss_in(index))
1363 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1368 if (dist(bvar_s(i1,iseed)+nres,bvar_ss(2,j1,iseed))
1370 & iabs(bvar_s(i1,iseed)-(bvar_ss(2,j1,iseed)-nres))
1375 parent(1,index)=iseed
1377 do ij=1,bvar_nss(iseed)
1379 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1380 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1383 nss_in(index)=bvar_nss(iseed)
1384 iss_in(j1,index)=bvar_s(i1,iseed)+nres
1385 jss_in(j1,index)=bvar_ss(2,j1,iseed)
1386 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1387 iss_in(j1,index)=bvar_ss(2,j1,iseed)
1388 jss_in(j1,index)=bvar_s(i1,iseed)+nres
1392 cd write(iout,*) 'makevar NSS1 #2',index,
1393 cd & bvar_s(i1,iseed),bvar_ss(2,j1,iseed)-nres,
1394 cd & dist(bvar_s(i1,iseed)+nres,bvar_ss(2,j1,iseed)),
1395 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1396 cd & ij=1,nss_in(index))
1401 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1411 c N12 type II transdisulfidation
1413 do i1=1,bvar_nss(iseed)
1414 do j1=i1+1,bvar_nss(iseed)
1415 if (dist(bvar_ss(1,i1,iseed),bvar_ss(1,j1,iseed))
1417 & dist(bvar_ss(2,i1,iseed),bvar_ss(2,j1,iseed))
1419 & iabs(bvar_ss(1,i1,iseed)-bvar_ss(1,j1,iseed))
1421 & iabs(bvar_ss(2,i1,iseed)-bvar_ss(2,j1,iseed))
1425 parent(1,index)=iseed
1427 do ij=1,bvar_nss(iseed)
1428 if (ij.ne.i1 .and. ij.ne.j1) then
1429 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1430 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1433 nss_in(index)=bvar_nss(iseed)
1434 iss_in(i1,index)=bvar_ss(1,i1,iseed)
1435 jss_in(i1,index)=bvar_ss(1,j1,iseed)
1436 if (iss_in(i1,index).gt.jss_in(i1,index)) then
1437 iss_in(i1,index)=bvar_ss(1,j1,iseed)
1438 jss_in(i1,index)=bvar_ss(1,i1,iseed)
1440 iss_in(j1,index)=bvar_ss(2,i1,iseed)
1441 jss_in(j1,index)=bvar_ss(2,j1,iseed)
1442 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1443 iss_in(j1,index)=bvar_ss(2,j1,iseed)
1444 jss_in(j1,index)=bvar_ss(2,i1,iseed)
1448 cd write(iout,*) 'makevar NSS2 #1',index,
1449 cd & bvar_ss(1,i1,iseed)-nres,bvar_ss(1,j1,iseed)-nres,
1450 cd & dist(bvar_ss(1,i1,iseed),bvar_ss(1,j1,iseed)),
1451 cd & bvar_ss(2,i1,iseed)-nres,bvar_ss(2,j1,iseed)-nres,
1452 cd & dist(bvar_ss(2,i1,iseed),bvar_ss(2,j1,iseed)),
1453 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1454 cd & ij=1,nss_in(index))
1459 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1466 if (dist(bvar_ss(1,i1,iseed),bvar_ss(2,j1,iseed))
1468 & dist(bvar_ss(2,i1,iseed),bvar_ss(1,j1,iseed))
1470 & iabs(bvar_ss(1,i1,iseed)-bvar_ss(2,j1,iseed))
1472 & iabs(bvar_ss(2,i1,iseed)-bvar_ss(1,j1,iseed))
1476 parent(1,index)=iseed
1478 do ij=1,bvar_nss(iseed)
1479 if (ij.ne.i1 .and. ij.ne.j1) then
1480 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1481 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1484 nss_in(index)=bvar_nss(iseed)
1485 iss_in(i1,index)=bvar_ss(1,i1,iseed)
1486 jss_in(i1,index)=bvar_ss(2,j1,iseed)
1487 if (iss_in(i1,index).gt.jss_in(i1,index)) then
1488 iss_in(i1,index)=bvar_ss(2,j1,iseed)
1489 jss_in(i1,index)=bvar_ss(1,i1,iseed)
1491 iss_in(j1,index)=bvar_ss(2,i1,iseed)
1492 jss_in(j1,index)=bvar_ss(1,j1,iseed)
1493 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1494 iss_in(j1,index)=bvar_ss(1,j1,iseed)
1495 jss_in(j1,index)=bvar_ss(2,i1,iseed)
1499 cd write(iout,*) 'makevar NSS2 #2',index,
1500 cd & bvar_ss(1,i1,iseed)-nres,bvar_ss(2,j1,iseed)-nres,
1501 cd & dist(bvar_ss(1,i1,iseed),bvar_ss(2,j1,iseed)),
1502 cd & bvar_ss(2,i1,iseed)-nres,bvar_ss(1,j1,iseed)-nres,
1503 cd & dist(bvar_ss(2,i1,iseed),bvar_ss(1,j1,iseed)),
1504 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1505 cd & ij=1,nss_in(index))
1510 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1521 c N13 removal of disulfide bond
1523 if (bvar_nss(iseed).gt.0) then
1524 i1=bvar_nss(iseed)*ran1(idum)+1
1528 parent(1,index)=iseed
1531 do j1=1,bvar_nss(iseed)
1534 iss_in(ij,index)=bvar_ss(1,j1,iseed)
1535 jss_in(ij,index)=bvar_ss(2,j1,iseed)
1538 nss_in(index)=bvar_nss(iseed)-1
1540 cd write(iout,*) 'NSS3',index,i1,
1541 cd & bvar_ss(1,i1,iseed)-nres,'=',bvar_ss(2,i1,iseed)-nres,'#',
1542 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1543 cd & ij=1,nss_in(index))
1548 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1557 c-----------------------------------------
1561 if(index.ne.n) write(iout,*)'make_var : ntry=',index
1565 cd write (istat,*) "======== ii=",ii," the dihang array"
1567 cd write (istat,'(i5,4f15.5)') i,(dihang_in(k,i,1,ii)*rad2deg,k=1,4)
1572 ccccccccccccccccccccccccccccccccccccccccccccccccc
1573 ccccccccccccccccccccccccccccccccccccccccccccccccc
1574 subroutine check_old(icheck,n)
1575 implicit real*8 (a-h,o-z)
1576 include 'DIMENSIONS'
1577 include 'COMMON.CSA'
1578 include 'COMMON.BANK'
1579 include 'COMMON.CHAIN'
1580 include 'COMMON.GEO'
1590 dif=rad2deg*dabs(dihang_in(i,j,m,i1)-dihang_in(i,j,m,i2))
1591 if(dif.gt.180.0) dif=360.0-dif
1592 if(dif.gt.ctdif) goto 100
1594 if(diff.gt.ctdiff) goto 100
1607 ccccccccccccccccccccccccccccccccccccccccccccccccc
1608 ccccccccccccccccccccccccccccccccccccccccccccccccc
1609 subroutine newconf1rr(idum,vvar,nran,i1)
1610 implicit real*8 (a-h,o-z)
1611 include 'DIMENSIONS'
1612 include 'COMMON.IOUNITS'
1613 include 'COMMON.CSA'
1614 include 'COMMON.BANK'
1615 include 'COMMON.CHAIN'
1616 include 'COMMON.GEO'
1618 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1624 vvar(i,j,k)=rvar(i,j,k,iseed)
1637 10 iran= ran1(idum)*number+1
1638 if(iter.gt.number) return
1640 if(iter.eq.1) goto 11
1642 if(iran.eq.iold(ind)) goto 10
1646 do ind=1,ngroup(iran)
1647 i=igroup(1,ind,iran)
1648 j=igroup(2,ind,iran)
1649 k=igroup(3,ind,iran)
1650 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1651 if(dif.gt.180.) dif=360.-dif
1652 if(dif.gt.ctdif) goto 20
1654 if(iter.gt.number) goto 20
1657 do ind=1,ngroup(iran)
1658 i=igroup(1,ind,iran)
1659 j=igroup(2,ind,iran)
1660 k=igroup(3,ind,iran)
1661 vvar(i,j,k)=rvar(i,j,k,i1)
1668 ccccccccccccccccccccccccccccccccccccccccccccccccc
1669 ccccccccccccccccccccccccccccccccccccccccccccccccc
1670 subroutine newconf1br(idum,vvar,nran,i1)
1671 implicit real*8 (a-h,o-z)
1672 include 'DIMENSIONS'
1673 include 'COMMON.IOUNITS'
1674 include 'COMMON.CSA'
1675 include 'COMMON.BANK'
1676 include 'COMMON.CHAIN'
1677 include 'COMMON.GEO'
1678 include 'COMMON.TORCNSTR'
1679 include 'COMMON.CONTROL'
1681 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1687 vvar(i,j,k)=bvar(i,j,k,iseed)
1700 10 iran= ran1(idum)*number+1
1701 if(i2ndstr.gt.0) then
1703 if(rtmp.le.rdih_bias) then
1706 if(igroup(2,1,iran).eq.idih_nconstr(j))i=j
1711 iran= ran1(idum)*number+1
1714 if(igroup(2,1,iran).eq.idih_nconstr(j))i=j
1716 if(i.eq.0.or.juhc.lt.1000)goto 4321
1717 if(juhc.eq.1000) then
1718 print *, 'move 6 : failed to find unconstrained group'
1719 write(iout,*) 'move 6 : failed to find unconstrained group'
1724 if(iter.gt.number) return
1726 if(iter.eq.1) goto 11
1728 if(iran.eq.iold(ind)) goto 10
1732 do ind=1,ngroup(iran)
1733 i=igroup(1,ind,iran)
1734 j=igroup(2,ind,iran)
1735 k=igroup(3,ind,iran)
1736 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1737 if(dif.gt.180.) dif=360.-dif
1738 if(dif.gt.ctdif) goto 20
1740 if(iter.gt.number) goto 20
1743 do ind=1,ngroup(iran)
1744 i=igroup(1,ind,iran)
1745 j=igroup(2,ind,iran)
1746 k=igroup(3,ind,iran)
1747 vvar(i,j,k)=rvar(i,j,k,i1)
1754 ccccccccccccccccccccccccccccccccccccccccccccccccc
1755 ccccccccccccccccccccccccccccccccccccccccccccccccc
1756 subroutine newconf1bb(idum,vvar,nran,i1)
1757 implicit real*8 (a-h,o-z)
1758 include 'DIMENSIONS'
1759 include 'COMMON.IOUNITS'
1760 include 'COMMON.CSA'
1761 include 'COMMON.BANK'
1762 include 'COMMON.CHAIN'
1763 include 'COMMON.GEO'
1765 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1771 vvar(i,j,k)=bvar(i,j,k,iseed)
1784 10 iran= ran1(idum)*number+1
1785 if(iter.gt.number) return
1787 if(iter.eq.1) goto 11
1789 if(iran.eq.iold(ind)) goto 10
1793 do ind=1,ngroup(iran)
1794 i=igroup(1,ind,iran)
1795 j=igroup(2,ind,iran)
1796 k=igroup(3,ind,iran)
1797 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
1798 if(dif.gt.180.) dif=360.-dif
1799 if(dif.gt.ctdif) goto 20
1801 if(iter.gt.number) goto 20
1804 do ind=1,ngroup(iran)
1805 i=igroup(1,ind,iran)
1806 j=igroup(2,ind,iran)
1807 k=igroup(3,ind,iran)
1808 vvar(i,j,k)=bvar(i,j,k,i1)
1815 ccccccccccccccccccccccccccccccccccccccccccccccccc
1816 ccccccccccccccccccccccccccccccccccccccccccccccccc
1817 subroutine newconf1arr(idum,vvar,nran,i1)
1818 implicit real*8 (a-h,o-z)
1819 include 'DIMENSIONS'
1820 include 'COMMON.IOUNITS'
1821 include 'COMMON.CSA'
1822 include 'COMMON.BANK'
1823 include 'COMMON.CHAIN'
1824 include 'COMMON.GEO'
1826 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1832 vvar(i,j,k)=rvar(i,j,k,iseed)
1845 10 iran= ran1(idum)*number+1
1846 if(iter.gt.number) return
1848 if(iter.eq.1) goto 11
1850 if(iran.eq.iold(ind)) goto 10
1854 do ind=1,ngroup(iran)
1855 i=igroup(1,ind,iran)
1856 j=igroup(2,ind,iran)
1857 k=igroup(3,ind,iran)
1858 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1859 if(dif.gt.180.) dif=360.-dif
1860 if(dif.gt.ctdif) goto 20
1862 if(iter.gt.number) goto 20
1865 do ind=1,ngroup(iran)
1866 i=igroup(1,ind,iran)
1867 j=igroup(2,ind,iran)
1868 k=igroup(3,ind,iran)
1869 vvar(i,j,k)=rvar(i,j,k,i1)
1876 ccccccccccccccccccccccccccccccccccccccccccccccccc
1877 ccccccccccccccccccccccccccccccccccccccccccccccccc
1878 subroutine newconf1abr(idum,vvar,nran,i1)
1879 implicit real*8 (a-h,o-z)
1880 include 'DIMENSIONS'
1881 include 'COMMON.IOUNITS'
1882 include 'COMMON.CSA'
1883 include 'COMMON.BANK'
1884 include 'COMMON.CHAIN'
1885 include 'COMMON.GEO'
1886 include 'COMMON.TORCNSTR'
1887 include 'COMMON.CONTROL'
1889 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1895 vvar(i,j,k)=bvar(i,j,k,iseed)
1908 10 iran= ran1(idum)*number+1
1909 if(i2ndstr.gt.0) then
1911 if(rtmp.le.rdih_bias) then
1912 iran=ran1(idum)*ndih_nconstr+1
1913 iran=idih_nconstr(iran)
1916 if(iter.gt.number) return
1918 if(iter.eq.1) goto 11
1920 if(iran.eq.iold(ind)) goto 10
1924 do ind=1,ngroup(iran)
1925 i=igroup(1,ind,iran)
1926 j=igroup(2,ind,iran)
1927 k=igroup(3,ind,iran)
1928 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1929 if(dif.gt.180.) dif=360.-dif
1930 if(dif.gt.ctdif) goto 20
1932 if(iter.gt.number) goto 20
1935 do ind=1,ngroup(iran)
1936 i=igroup(1,ind,iran)
1937 j=igroup(2,ind,iran)
1938 k=igroup(3,ind,iran)
1939 vvar(i,j,k)=rvar(i,j,k,i1)
1946 ccccccccccccccccccccccccccccccccccccccccccccccccc
1947 ccccccccccccccccccccccccccccccccccccccccccccccccc
1948 subroutine newconf1abb(idum,vvar,nran,i1)
1949 implicit real*8 (a-h,o-z)
1950 include 'DIMENSIONS'
1951 include 'COMMON.IOUNITS'
1952 include 'COMMON.CSA'
1953 include 'COMMON.BANK'
1954 include 'COMMON.CHAIN'
1955 include 'COMMON.GEO'
1956 include 'COMMON.TORCNSTR'
1957 include 'COMMON.CONTROL'
1959 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1965 vvar(i,j,k)=bvar(i,j,k,iseed)
1978 10 iran= ran1(idum)*number+1
1979 if(i2ndstr.gt.0) then
1981 if(rtmp.le.rdih_bias) then
1982 iran=ran1(idum)*ndih_nconstr+1
1983 iran=idih_nconstr(iran)
1986 if(iter.gt.number) return
1988 if(iter.eq.1) goto 11
1990 if(iran.eq.iold(ind)) goto 10
1994 do ind=1,ngroup(iran)
1995 i=igroup(1,ind,iran)
1996 j=igroup(2,ind,iran)
1997 k=igroup(3,ind,iran)
1998 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
1999 if(dif.gt.180.) dif=360.-dif
2000 if(dif.gt.ctdif) goto 20
2002 if(iter.gt.number) goto 20
2005 do ind=1,ngroup(iran)
2006 i=igroup(1,ind,iran)
2007 j=igroup(2,ind,iran)
2008 k=igroup(3,ind,iran)
2009 vvar(i,j,k)=bvar(i,j,k,i1)
2016 ccccccccccccccccccccccccccccccccccccccccccccccccc
2017 ccccccccccccccccccccccccccccccccccccccccccccccccc
2018 subroutine newconf_residue(idum,vvar,i1,isize)
2019 implicit real*8 (a-h,o-z)
2020 include 'DIMENSIONS'
2021 include 'COMMON.IOUNITS'
2022 include 'COMMON.CSA'
2023 include 'COMMON.BANK'
2024 include 'COMMON.CHAIN'
2025 include 'COMMON.GEO'
2026 include 'COMMON.TORCNSTR'
2027 include 'COMMON.CONTROL'
2029 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2032 if (iseed.gt.mxio .or. iseed.lt.1) then
2033 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2034 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2039 vvar(i,j,k)=bvar(i,j,k,iseed)
2048 10 iran= ran1(idum)*number+1
2049 if(i2ndstr.gt.0) then
2051 if(rtmp.le.rdih_bias) then
2052 iran=ran1(idum)*ndih_nconstr+1
2053 iran=idih_nconstr(iran)
2058 if(istart.lt.2) istart=2
2059 if(iend.gt.nres-1) iend=nres-1
2061 if(iter.eq.1) goto 11
2063 if(iran.eq.iold(ind)) goto 10
2069 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
2070 if(dif.gt.180.) dif=360.-dif
2071 if(dif.gt.ctdif) goto 20
2076 if(iter.gt.number) goto 20
2082 vvar(i,j,k)=bvar(i,j,k,i1)
2089 ccccccccccccccccccccccccccccccccccccccccccccccccc
2090 ccccccccccccccccccccccccccccccccccccccccccccccccc
2091 subroutine newconf_copy(idum,vvar,i1,istart,iend)
2092 implicit real*8 (a-h,o-z)
2093 include 'DIMENSIONS'
2094 include 'COMMON.IOUNITS'
2095 include 'COMMON.CSA'
2096 include 'COMMON.BANK'
2097 include 'COMMON.CHAIN'
2098 include 'COMMON.GEO'
2099 include 'COMMON.TORCNSTR'
2100 include 'COMMON.CONTROL'
2102 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2105 if (iseed.gt.mxio .or. iseed.lt.1) then
2106 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2107 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2112 vvar(i,j,k)=bvar(i,j,k,iseed)
2120 vvar(i,j,1)=bvar(i,j,1,i1)
2126 ccccccccccccccccccccccccccccccccccccccccccccccccc
2127 ccccccccccccccccccccccccccccccccccccccccccccccccc
2128 subroutine newconf_residue_hairpin(idum,vvar,i1,fail)
2129 implicit real*8 (a-h,o-z)
2130 include 'DIMENSIONS'
2131 include 'COMMON.IOUNITS'
2132 include 'COMMON.CSA'
2133 include 'COMMON.BANK'
2134 include 'COMMON.CHAIN'
2135 include 'COMMON.GEO'
2136 include 'COMMON.VAR'
2138 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2139 integer nharp,iharp(4,maxres/3),icipa(maxres/3)
2140 logical fail,not_done
2144 if (iseed.gt.mxio .or. iseed.lt.1) then
2145 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2146 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2151 vvar(i,j,k)=bvar(i,j,k,iseed)
2157 theta(j+1)=bvar(1,j,k,i1)
2158 phi(j+2)=bvar(2,j,k,i1)
2159 alph(j)=bvar(3,j,k,i1)
2160 omeg(j)=bvar(4,j,k,i1)
2165 call hairpin(.false.,nharp,iharp)
2167 if (nharp.eq.0) then
2180 iih=iran_num(1,nharp)
2182 if (iih.eq.icipa(k)) then
2191 not_done = not_done .and. icount.le.nharp
2195 write (iout,*) "CHUJ NASTAPIL W NEWCONF_RESIDUE_HAIRPIN!!!!"
2200 istart=iharp(1,iih)+1
2203 cdd write (iout,*) "newconf_residue_hairpin: iih",iih,
2204 cdd & " istart",istart," iend",iend
2209 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
2210 if(dif.gt.180.) dif=360.-dif
2211 if(dif.gt.ctdif) goto 20
2220 vvar(i,j,k)=bvar(i,j,k,i1)
2226 c write (iout,'(4f8.3)') (rad2deg*vvar(i,l,j),i=1,4)
2237 ccccccccccccccccccccccccccccccccccccccccccccccccc
2238 ccccccccccccccccccccccccccccccccccccccccccccccccc
2239 subroutine gen_hairpin
2240 implicit real*8 (a-h,o-z)
2241 include 'DIMENSIONS'
2242 include 'COMMON.IOUNITS'
2243 include 'COMMON.CSA'
2244 include 'COMMON.BANK'
2245 include 'COMMON.CHAIN'
2246 include 'COMMON.GEO'
2247 include 'COMMON.VAR'
2248 include 'COMMON.HAIRPIN'
2250 c write (iout,*) 'Entering GEN_HAIRPIN'
2255 theta(j+1)=bvar(1,j,k,i1)
2256 phi(j+2)=bvar(2,j,k,i1)
2257 alph(j)=bvar(3,j,k,i1)
2258 omeg(j)=bvar(4,j,k,i1)
2262 call hairpin(.false.,nharp_seed(iters),iharp_seed(1,1,iters))
2267 nharp_tot=nharp_tot+nharp_seed(iters)
2268 nharp_use(iters)=4*nharp_seed(iters)
2269 do j=1,nharp_seed(iters)
2270 iharp_use(0,j,iters)=4
2272 iharp_use(k,j,iters)=0
2277 write (iout,*) 'GEN_HAIRPIN: nharp_tot',nharp_tot
2279 cdd write (iout,*) 'seed',i
2280 cdd write (iout,*) 'nharp_seed',nharp_seed(i),
2281 cdd & ' nharp_use',nharp_use(i)
2282 cd write (iout,*) 'iharp_seed, iharp_use'
2283 cd do j=1,nharp_seed(i)
2284 cd write (iout,'(7i3)') iharp_seed(1,j,i),iharp_seed(2,j,i),
2285 cd & (iharp_use(k,j,i),k=0,4)
2291 ccccccccccccccccccccccccccccccccccccccccccccccccc
2292 ccccccccccccccccccccccccccccccccccccccccccccccccc
2293 subroutine select_frag(nn,nh,nl,ns,nb,i_csa)
2294 implicit real*8 (a-h,o-z)
2295 include 'DIMENSIONS'
2296 include 'COMMON.IOUNITS'
2297 include 'COMMON.CSA'
2298 include 'COMMON.BANK'
2299 include 'COMMON.CHAIN'
2300 include 'COMMON.GEO'
2301 include 'COMMON.VAR'
2302 include 'COMMON.HAIRPIN'
2303 include 'COMMON.DISTFIT'
2305 integer isec(maxres)
2313 cd write (iout,*) 'Entering select_frag'
2320 theta(j+1)=bvar(1,j,k,i1)
2321 phi(j+2)=bvar(2,j,k,i1)
2322 alph(j)=bvar(3,j,k,i1)
2323 omeg(j)=bvar(4,j,k,i1)
2327 cd write (iout,*) ' -- ',i1,' -- '
2328 call secondary2(.false.)
2330 c bvar_frag nn==pair of nonlocal strands in beta sheet (loop>4)
2331 c strands > 4 residues; used by N7 and N16
2335 Ctest 09/12/02 bfrag(2,j)-bfrag(1,j).gt.3
2337 do i=bfrag(1,j),bfrag(2,j)
2340 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
2344 if ( (bfrag(3,j).lt.bfrag(4,j) .or.
2345 & bfrag(4,j)-bfrag(2,j).gt.4) .and.
2346 & bfrag(2,j)-bfrag(1,j).gt.4 ) then
2350 if (bfrag(3,j).lt.bfrag(4,j)) then
2351 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2352 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
2353 & ,",",bfrag(3,j)-1,"-",bfrag(4,j)-1
2355 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2356 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
2357 & ,",",bfrag(4,j)-1,"-",bfrag(3,j)-1
2360 cd call write_pdb(i_csa*1000+nn+nh,linia,0d0)
2365 bvar_frag(nn,i+2)=bfrag(i,j)
2371 c hvar_frag nh==helices; used by N8 and N9
2375 do i=hfrag(1,j),hfrag(2,j)
2379 if ( hfrag(2,j)-hfrag(1,j).gt.4 ) then
2382 cd write(linia,'(a6,i3,a1,i3)')
2383 cd & "select",hfrag(1,j)-1,"-",hfrag(2,j)-1
2384 cd call write_pdb(i_csa*1000+nn+nh,linia,0d0)
2387 hvar_frag(nh,2)=hfrag(1,j)
2388 hvar_frag(nh,3)=hfrag(2,j)
2393 cv write(iout,'(i4,1pe12.4,1x,1000i1)')
2394 cv & i1,bene(i1),(isec(i),i=1,nres)
2395 cv write(linia,'(i4,1x,1000i1)')
2396 cv & i1,(isec(i),i=1,nres)
2397 cv call write_pdb(i_csa*1000+i1,linia,bene(i1))
2399 c lvar_frag nl==loops; used by N14
2403 do while (i.lt.nres)
2404 if (isec(i).eq.0) then
2409 do while (isec(i).eq.0.and.i.le.nres)
2413 if (lvar_frag(nl,3)-lvar_frag(nl,2).lt.1) nl=nl-1
2417 cd write(iout,'(4i5)') (i,(lvar_frag(i,ii),ii=1,3),i=nl1+1,nl)
2420 c svar_frag ns==an secondary structure element; used by N15
2424 do while (i.lt.nres)
2425 if (isec(i).gt.0) then
2430 do while (isec(i).gt.0.and.isec(i-1).eq.isec(i)
2435 if (svar_frag(ns,3)-svar_frag(ns,2).lt.1) ns=ns-1
2437 if (isec(i).eq.0) i=i+1
2439 cd write(iout,'(4i5)') (i,(svar_frag(i,ii),ii=1,3),i=ns1+1,ns)
2442 c avar_frag nb==any pair of beta strands; used by N17
2448 avar_frag(nb,i+1)=bfrag(i,j)